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" |
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); |
1159 |
|
// Port changed in combo |
1160 |
|
static void cb_serial_port_changed(...) |
1161 |
|
{ |
1161 |
– |
printf("serial port changed\n"); |
1162 |
|
set_serial_sensitive(); |
1163 |
|
} |
1164 |
|
|
1216 |
|
* "Ethernet" pane |
1217 |
|
*/ |
1218 |
|
|
1219 |
< |
static GtkWidget *w_ether, *w_udp_port; |
1219 |
> |
static GtkWidget *w_ether; |
1220 |
> |
static GtkWidget *w_ftp_port_list, *w_tcp_port_list; |
1221 |
> |
static const char s_nat_router[] = "NAT/Router module"; |
1222 |
|
|
1223 |
|
// Set sensitivity of widgets |
1224 |
|
static void set_ethernet_sensitive(void) |
1225 |
|
{ |
1226 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1227 |
+ |
|
1228 |
+ |
bool is_nat_router = strcmp(str, s_nat_router) == 0; |
1229 |
+ |
gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router); |
1230 |
+ |
gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router); |
1231 |
|
} |
1232 |
|
|
1233 |
|
// Read settings from widgets and set preferences |
1234 |
|
static void read_ethernet_settings(void) |
1235 |
|
{ |
1236 |
|
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1237 |
< |
if (str && strlen(str)) |
1238 |
< |
PrefsReplaceString("ether", str); |
1237 |
> |
if (str && strlen(str) > 6 && strncmp(str, "NDIS: ", 6) == 0) |
1238 |
> |
PrefsReplaceString("ether", &str[6]); |
1239 |
|
else |
1240 |
|
PrefsRemoveItem("ether"); |
1241 |
+ |
|
1242 |
+ |
const bool router_enabled = str && strcmp(str, s_nat_router) == 0; |
1243 |
+ |
PrefsReplaceBool("routerenabled", router_enabled); |
1244 |
+ |
if (router_enabled) { |
1245 |
+ |
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list)); |
1246 |
+ |
PrefsReplaceString("ftp_port_list", str); |
1247 |
+ |
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list)); |
1248 |
+ |
PrefsReplaceString("tcp_port", str); |
1249 |
+ |
} |
1250 |
+ |
} |
1251 |
+ |
|
1252 |
+ |
// Ethernet emulation type changed in menulist |
1253 |
+ |
static void cb_ether_changed(...) |
1254 |
+ |
{ |
1255 |
+ |
set_ethernet_sensitive(); |
1256 |
|
} |
1257 |
|
|
1258 |
|
// Add names of ethernet interfaces |
1262 |
|
|
1263 |
|
// TODO: Get list of all Ethernet interfaces |
1264 |
|
#ifdef HAVE_SLIRP |
1265 |
< |
static char s_slirp[] = "slirp"; |
1266 |
< |
glist = g_list_append(glist, s_slirp); |
1265 |
> |
static const char s_slirp[] = "slirp"; |
1266 |
> |
glist = g_list_append(glist, (void *)s_slirp); |
1267 |
|
#endif |
1268 |
< |
#if 0 |
1269 |
< |
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)); |
1268 |
> |
glist = g_list_append(glist, (void *)s_nat_router); |
1269 |
> |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1270 |
|
return glist; |
1271 |
|
} |
1272 |
|
|
1288 |
|
gtk_widget_show(combo); |
1289 |
|
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1290 |
|
const char *str = PrefsFindString("ether"); |
1291 |
< |
if (str == NULL) |
1292 |
< |
str = ""; |
1291 |
> |
if (str == NULL || str[0] == '\0') { |
1292 |
> |
if (PrefsFindBool("routerenabled")) |
1293 |
> |
str = s_nat_router; |
1294 |
> |
else |
1295 |
> |
str = GetString(STR_NONE_LAB); |
1296 |
> |
} |
1297 |
|
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1298 |
|
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1299 |
|
w_ether = GTK_COMBO(combo)->entry; |
1300 |
+ |
gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1301 |
+ |
|
1302 |
+ |
sep = gtk_hseparator_new(); |
1303 |
+ |
gtk_widget_show(sep); |
1304 |
+ |
gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1305 |
+ |
|
1306 |
+ |
label = gtk_label_new(GetString(STR_ETHER_FTP_PORT_LIST_CTRL)); |
1307 |
+ |
gtk_widget_show(label); |
1308 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1309 |
+ |
|
1310 |
+ |
entry = gtk_entry_new(); |
1311 |
+ |
str = PrefsFindString("ftp_port_list"); |
1312 |
+ |
if (str == NULL) |
1313 |
+ |
str = ""; |
1314 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1315 |
+ |
gtk_widget_show(entry); |
1316 |
+ |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1317 |
+ |
w_ftp_port_list = entry; |
1318 |
+ |
|
1319 |
+ |
label = gtk_label_new(GetString(STR_ETHER_TCP_PORT_LIST_CTRL)); |
1320 |
+ |
gtk_widget_show(label); |
1321 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1322 |
+ |
|
1323 |
+ |
entry = gtk_entry_new(); |
1324 |
+ |
str = PrefsFindString("tcp_port"); |
1325 |
+ |
if (str == NULL) |
1326 |
+ |
str = ""; |
1327 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1328 |
+ |
gtk_widget_show(entry); |
1329 |
+ |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1330 |
+ |
w_tcp_port_list = entry; |
1331 |
|
|
1332 |
|
set_ethernet_sensitive(); |
1333 |
|
} |
1477 |
|
|
1478 |
|
|
1479 |
|
/* |
1480 |
+ |
* Display alerts |
1481 |
+ |
*/ |
1482 |
+ |
|
1483 |
+ |
static void display_alert(int title_id, const char *text, int flags) |
1484 |
+ |
{ |
1485 |
+ |
MessageBox(NULL, text, GetString(title_id), MB_OK | flags); |
1486 |
+ |
} |
1487 |
+ |
|
1488 |
+ |
static void ErrorAlert(const char *text) |
1489 |
+ |
{ |
1490 |
+ |
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); |
1491 |
+ |
} |
1492 |
+ |
|
1493 |
+ |
|
1494 |
+ |
/* |
1495 |
|
* Start standalone GUI |
1496 |
|
*/ |
1497 |
|
|
1512 |
|
|
1513 |
|
// Transfer control to the Basilisk II executable |
1514 |
|
if (start) { |
1515 |
< |
printf("Start Basilisk II\n"); |
1515 |
> |
char path[_MAX_PATH]; |
1516 |
> |
bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0; |
1517 |
> |
if (ok) { |
1518 |
> |
char b2_path[_MAX_PATH]; |
1519 |
> |
char *p = strrchr(path, '\\'); |
1520 |
> |
*++p = '\0'; |
1521 |
> |
SetCurrentDirectory(path); |
1522 |
> |
strcpy(b2_path, path); |
1523 |
> |
strcat(b2_path, "BasiliskII.exe"); |
1524 |
> |
HINSTANCE h = ShellExecute(GetDesktopWindow(), "open", |
1525 |
> |
b2_path, "", path, SW_SHOWNORMAL); |
1526 |
> |
if ((int)h <= 32) |
1527 |
> |
ok = false; |
1528 |
> |
} |
1529 |
> |
if (!ok) { |
1530 |
> |
ErrorAlert("Coult not start BasiliskII executable"); |
1531 |
> |
return 1; |
1532 |
> |
} |
1533 |
|
} |
1534 |
|
|
1535 |
|
return 0; |