20 |
|
|
21 |
|
#include "sysdeps.h" |
22 |
|
|
23 |
+ |
#include <stdlib.h> |
24 |
+ |
#include <string.h> |
25 |
|
#include <fcntl.h> |
26 |
|
#include <sys/stat.h> |
25 |
– |
#include <stdlib.h> |
27 |
|
#include <gtk/gtk.h> |
28 |
|
|
29 |
|
#include "user_strings.h" |
424 |
|
// Menu item descriptions |
425 |
|
static GtkItemFactoryEntry menu_items[] = { |
426 |
|
{(gchar *)GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, "<Branch>"}, |
427 |
< |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
427 |
> |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), "<control>S", GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
428 |
|
{(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(cb_zap_pram), 0, NULL}, |
429 |
|
{(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, "<Separator>"}, |
430 |
|
{(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK), "<control>Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL}, |
431 |
|
{(gchar *)GetString(STR_HELP_MENU_GTK), NULL, NULL, 0, "<LastBranch>"}, |
432 |
< |
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), NULL, GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
432 |
> |
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "<control>H", GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
433 |
|
}; |
434 |
|
|
435 |
|
bool PrefsEditor(void) |
464 |
|
gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); |
465 |
|
|
466 |
|
create_volumes_pane(notebook); |
467 |
< |
create_scsi_pane(notebook); |
467 |
> |
// create_scsi_pane(notebook); XXX not ready yet (merge scsi_windows.cpp from original B2/Win) |
468 |
|
create_graphics_pane(notebook); |
469 |
|
create_input_pane(notebook); |
470 |
|
create_serial_pane(notebook); |
474 |
|
|
475 |
|
static const opt_desc buttons[] = { |
476 |
|
{STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, |
476 |
– |
{STR_PREFS_ITEM_ZAP_PRAM, GTK_SIGNAL_FUNC(cb_zap_pram)}, |
477 |
– |
{STR_ABOUT_BUTTON, GTK_SIGNAL_FUNC(cb_about)}, |
477 |
|
{STR_QUIT_BUTTON, GTK_SIGNAL_FUNC(cb_quit)}, |
478 |
|
{0, NULL} |
479 |
|
}; |
1157 |
|
// Port changed in combo |
1158 |
|
static void cb_serial_port_changed(...) |
1159 |
|
{ |
1161 |
– |
printf("serial port changed\n"); |
1160 |
|
set_serial_sensitive(); |
1161 |
|
} |
1162 |
|
|
1214 |
|
* "Ethernet" pane |
1215 |
|
*/ |
1216 |
|
|
1217 |
< |
static GtkWidget *w_ether, *w_udp_port; |
1217 |
> |
static GtkWidget *w_ether; |
1218 |
> |
static GtkWidget *w_ftp_port_list, *w_tcp_port_list; |
1219 |
> |
static const char s_nat_router[] = "NAT/Router module"; |
1220 |
|
|
1221 |
|
// Set sensitivity of widgets |
1222 |
|
static void set_ethernet_sensitive(void) |
1223 |
|
{ |
1224 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1225 |
+ |
|
1226 |
+ |
bool is_nat_router = strcmp(str, s_nat_router) == 0; |
1227 |
+ |
gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router); |
1228 |
+ |
gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router); |
1229 |
|
} |
1230 |
|
|
1231 |
|
// Read settings from widgets and set preferences |
1232 |
|
static void read_ethernet_settings(void) |
1233 |
|
{ |
1234 |
|
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1235 |
< |
if (str && strlen(str)) |
1236 |
< |
PrefsReplaceString("ether", str); |
1235 |
> |
if (str && strlen(str) > 6 && strncmp(str, "NDIS: ", 6) == 0) |
1236 |
> |
PrefsReplaceString("ether", &str[6]); |
1237 |
|
else |
1238 |
|
PrefsRemoveItem("ether"); |
1239 |
+ |
|
1240 |
+ |
const bool router_enabled = str && strcmp(str, s_nat_router) == 0; |
1241 |
+ |
PrefsReplaceBool("routerenabled", router_enabled); |
1242 |
+ |
if (router_enabled) { |
1243 |
+ |
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list)); |
1244 |
+ |
PrefsReplaceString("ftp_port_list", str); |
1245 |
+ |
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list)); |
1246 |
+ |
PrefsReplaceString("tcp_port", str); |
1247 |
+ |
} |
1248 |
+ |
} |
1249 |
+ |
|
1250 |
+ |
// Ethernet emulation type changed in menulist |
1251 |
+ |
static void cb_ether_changed(...) |
1252 |
+ |
{ |
1253 |
+ |
set_ethernet_sensitive(); |
1254 |
|
} |
1255 |
|
|
1256 |
|
// Add names of ethernet interfaces |
1260 |
|
|
1261 |
|
// TODO: Get list of all Ethernet interfaces |
1262 |
|
#ifdef HAVE_SLIRP |
1263 |
< |
static char s_slirp[] = "slirp"; |
1264 |
< |
glist = g_list_append(glist, s_slirp); |
1263 |
> |
static const char s_slirp[] = "slirp"; |
1264 |
> |
glist = g_list_append(glist, (void *)s_slirp); |
1265 |
|
#endif |
1266 |
< |
#if 0 |
1267 |
< |
if (glist) |
1248 |
< |
g_list_sort(glist, gl_str_cmp); |
1249 |
< |
else |
1250 |
< |
#endif |
1251 |
< |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1266 |
> |
glist = g_list_append(glist, (void *)s_nat_router); |
1267 |
> |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1268 |
|
return glist; |
1269 |
|
} |
1270 |
|
|
1286 |
|
gtk_widget_show(combo); |
1287 |
|
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1288 |
|
const char *str = PrefsFindString("ether"); |
1289 |
< |
if (str == NULL) |
1290 |
< |
str = ""; |
1289 |
> |
if (str == NULL || str[0] == '\0') { |
1290 |
> |
if (PrefsFindBool("routerenabled")) |
1291 |
> |
str = s_nat_router; |
1292 |
> |
else |
1293 |
> |
str = GetString(STR_NONE_LAB); |
1294 |
> |
} |
1295 |
|
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1296 |
|
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1297 |
|
w_ether = GTK_COMBO(combo)->entry; |
1298 |
+ |
gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1299 |
+ |
|
1300 |
+ |
sep = gtk_hseparator_new(); |
1301 |
+ |
gtk_widget_show(sep); |
1302 |
+ |
gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1303 |
+ |
|
1304 |
+ |
label = gtk_label_new(GetString(STR_ETHER_FTP_PORT_LIST_CTRL)); |
1305 |
+ |
gtk_widget_show(label); |
1306 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1307 |
+ |
|
1308 |
+ |
entry = gtk_entry_new(); |
1309 |
+ |
str = PrefsFindString("ftp_port_list"); |
1310 |
+ |
if (str == NULL) |
1311 |
+ |
str = ""; |
1312 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1313 |
+ |
gtk_widget_show(entry); |
1314 |
+ |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1315 |
+ |
w_ftp_port_list = entry; |
1316 |
+ |
|
1317 |
+ |
label = gtk_label_new(GetString(STR_ETHER_TCP_PORT_LIST_CTRL)); |
1318 |
+ |
gtk_widget_show(label); |
1319 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1320 |
+ |
|
1321 |
+ |
entry = gtk_entry_new(); |
1322 |
+ |
str = PrefsFindString("tcp_port"); |
1323 |
+ |
if (str == NULL) |
1324 |
+ |
str = ""; |
1325 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1326 |
+ |
gtk_widget_show(entry); |
1327 |
+ |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1328 |
+ |
w_tcp_port_list = entry; |
1329 |
|
|
1330 |
|
set_ethernet_sensitive(); |
1331 |
|
} |
1475 |
|
|
1476 |
|
|
1477 |
|
/* |
1478 |
+ |
* Display alerts |
1479 |
+ |
*/ |
1480 |
+ |
|
1481 |
+ |
static void display_alert(int title_id, const char *text, int flags) |
1482 |
+ |
{ |
1483 |
+ |
MessageBox(NULL, text, GetString(title_id), MB_OK | flags); |
1484 |
+ |
} |
1485 |
+ |
|
1486 |
+ |
static void ErrorAlert(const char *text) |
1487 |
+ |
{ |
1488 |
+ |
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); |
1489 |
+ |
} |
1490 |
+ |
|
1491 |
+ |
|
1492 |
+ |
/* |
1493 |
|
* Start standalone GUI |
1494 |
|
*/ |
1495 |
|
|
1510 |
|
|
1511 |
|
// Transfer control to the Basilisk II executable |
1512 |
|
if (start) { |
1513 |
< |
printf("Start Basilisk II\n"); |
1513 |
> |
char path[_MAX_PATH]; |
1514 |
> |
bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0; |
1515 |
> |
if (ok) { |
1516 |
> |
char b2_path[_MAX_PATH]; |
1517 |
> |
char *p = strrchr(path, '\\'); |
1518 |
> |
*++p = '\0'; |
1519 |
> |
SetCurrentDirectory(path); |
1520 |
> |
strcpy(b2_path, path); |
1521 |
> |
strcat(b2_path, "BasiliskII.exe"); |
1522 |
> |
HINSTANCE h = ShellExecute(GetDesktopWindow(), "open", |
1523 |
> |
b2_path, "", path, SW_SHOWNORMAL); |
1524 |
> |
if ((int)h <= 32) |
1525 |
> |
ok = false; |
1526 |
> |
} |
1527 |
> |
if (!ok) { |
1528 |
> |
ErrorAlert("Coult not start BasiliskII executable"); |
1529 |
> |
return 1; |
1530 |
> |
} |
1531 |
|
} |
1532 |
|
|
1533 |
|
return 0; |