ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/prefs_editor_gtk.cpp
(Generate patch)

Comparing BasiliskII/src/Windows/prefs_editor_gtk.cpp (file contents):
Revision 1.1 by gbeauche, 2005-06-20T08:40:34Z vs.
Revision 1.6 by gbeauche, 2005-11-20T23:59:18Z

# Line 20 | Line 20
20  
21   #include "sysdeps.h"
22  
23 #include <gtk/gtk.h>
23   #include <stdlib.h>
24 + #include <string.h>
25 + #include <fcntl.h>
26 + #include <sys/stat.h>
27 + #include <gtk/gtk.h>
28  
29   #include "user_strings.h"
30   #include "version.h"
# Line 157 | Line 160 | static GtkWidget *make_table(GtkWidget *
160          return table;
161   }
162  
163 + static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active)
164 + {
165 +        GtkWidget *label, *opt, *menu;
166 +
167 +        label = gtk_label_new(GetString(label_id));
168 +        gtk_widget_show(label);
169 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
170 +
171 +        opt = gtk_option_menu_new();
172 +        gtk_widget_show(opt);
173 +        menu = gtk_menu_new();
174 +
175 +        while (options->label_id) {
176 +                add_menu_item(menu, options->label_id, options->func);
177 +                options++;
178 +        }
179 +        gtk_menu_set_active(GTK_MENU(menu), active);
180 +
181 +        gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
182 +        gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
183 +        return menu;
184 + }
185 +
186 + static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist)
187 + {
188 +        GtkWidget *label, *combo;
189 +        char str[32];
190 +
191 +        label = gtk_label_new(GetString(label_id));
192 +        gtk_widget_show(label);
193 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
194 +        
195 +        combo = gtk_combo_new();
196 +        gtk_widget_show(combo);
197 +        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
198 +
199 +        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value);
200 +        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
201 +        
202 +        return combo;
203 + }
204 +
205 + static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options)
206 + {
207 +        GList *glist = NULL;
208 +        while (options->label_id) {
209 +                glist = g_list_append(glist, (void *)GetString(options->label_id));
210 +                options++;
211 +        }
212 +
213 +        return table_make_combobox(table, row, label_id, default_value, glist);
214 + }
215 +
216 + static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false)
217 + {
218 +        GtkWidget *box, *label, *entry, *button;
219 +
220 +        label = gtk_label_new(GetString(label_id));
221 +        gtk_widget_show(label);
222 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
223 +
224 +        const char *str = PrefsFindString(prefs_item);
225 +        if (str == NULL)
226 +                str = "";
227 +
228 +        box = gtk_hbox_new(FALSE, 4);
229 +        gtk_widget_show(box);
230 +        gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
231 +
232 +        entry = gtk_entry_new();
233 +        gtk_entry_set_text(GTK_ENTRY(entry), str);
234 +        gtk_widget_show(entry);
235 +        gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
236 +
237 +        button = make_browse_button(entry);
238 +        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
239 +        g_object_set_data(G_OBJECT(entry), "chooser_button", button);
240 +        return entry;
241 + }
242 +
243   static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active)
244   {
245          GtkWidget *box, *label, *opt, *menu;
# Line 341 | Line 424 | static void cb_about(...)
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)
# Line 381 | Line 464 | 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);
# Line 391 | Line 474 | bool PrefsEditor(void)
474  
475          static const opt_desc buttons[] = {
476                  {STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)},
394                {STR_PREFS_ITEM_ZAP_PRAM, GTK_SIGNAL_FUNC(cb_zap_pram)},
395                {STR_ABOUT_BUTTON, GTK_SIGNAL_FUNC(cb_about)},
477                  {STR_QUIT_BUTTON, GTK_SIGNAL_FUNC(cb_quit)},
478                  {0, NULL}
479          };
# Line 409 | Line 490 | bool PrefsEditor(void)
490   *  "Volumes" pane
491   */
492  
493 + static GtkWidget *w_enableextfs, *w_extdrives;
494   static GtkWidget *volume_list;
495   static int selected_volume;
496  
497 + // Set sensitivity of widgets
498 + static void set_volumes_sensitive(void)
499 + {
500 +        const bool enable_extfs = PrefsFindBool("enableextfs");
501 +        gtk_widget_set_sensitive(w_extdrives, enable_extfs);
502 + }
503 +
504   // Volume in list selected
505   static void cl_selected(GtkWidget *list, int row, int column)
506   {
# Line 433 | Line 522 | static void create_volume_ok(GtkWidget *
522          gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
523  
524          const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry));
525 <        int size = atoi(str);
525 >        size_t size = atoi(str) << 20;
526  
527 <        char cmd[1024];
528 <        sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", file, size);
529 <        int ret = system(cmd);
441 <        if (ret == 0)
527 >        int fd = _open(file, _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC, _S_IREAD | _S_IWRITE);
528 >        if (fd >= 0) {
529 >          if (_chsize(fd, size) == 0)
530                  gtk_clist_append(GTK_CLIST(volume_list), &file);
531 +          _close(fd);
532 +        }
533          gtk_widget_destroy(GTK_WIDGET(assoc->req));
534          delete assoc;
535   }
# Line 488 | Line 578 | static void cb_remove_volume(...)
578   static void mn_boot_any(...) {PrefsReplaceInt32("bootdriver", 0);}
579   static void mn_boot_cdrom(...) {PrefsReplaceInt32("bootdriver", CDROMRefNum);}
580  
581 + // "Enable external file system" button toggled
582 + static void tb_enableextfs(GtkWidget *widget)
583 + {
584 +        PrefsReplaceBool("enableextfs", GTK_TOGGLE_BUTTON(widget)->active);
585 +        set_volumes_sensitive();
586 + }
587 +
588   // "No CD-ROM Driver" button toggled
589   static void tb_nocdrom(GtkWidget *widget)
590   {
591          PrefsReplaceBool("nocdrom", GTK_TOGGLE_BUTTON(widget)->active);
592   }
593  
594 + // "Enable polling" button toggled
595 + static void tb_pollmedia(GtkWidget *widget)
596 + {
597 +        PrefsReplaceBool("pollmedia", GTK_TOGGLE_BUTTON(widget)->active);
598 + }
599 +
600   // Read settings from widgets and set preferences
601   static void read_volumes_settings(void)
602   {
# Line 505 | Line 608 | static void read_volumes_settings(void)
608                  gtk_clist_get_text(GTK_CLIST(volume_list), i, 0, &str);
609                  PrefsAddString("disk", str);
610          }
611 +
612 +        PrefsReplaceString("extdrives", get_file_entry_path(w_extdrives));
613   }
614  
615   // Create "Volumes" pane
# Line 553 | Line 658 | static void create_volumes_pane(GtkWidge
658          menu = make_option_menu(box, STR_BOOTDRIVER_CTRL, options, active);
659  
660          make_checkbox(box, STR_NOCDROM_CTRL, "nocdrom", GTK_SIGNAL_FUNC(tb_nocdrom));
661 +
662 +        make_checkbox(box, STR_POLLMEDIA_CTRL, "pollmedia", GTK_SIGNAL_FUNC(tb_pollmedia));
663 +
664 +        make_separator(box);
665 +        w_enableextfs = make_checkbox(box, STR_EXTFS_ENABLE_CTRL, "enableextfs", GTK_SIGNAL_FUNC(tb_enableextfs));
666 +        w_extdrives = make_file_entry(box, STR_EXTFS_DRIVES_CTRL, "extdrives", true);
667 +
668 +        set_volumes_sensitive();
669   }
670  
671  
# Line 908 | Line 1021 | static GtkWidget *w_mouse_wheel_lines;
1021   // Set sensitivity of widgets
1022   static void set_input_sensitive(void)
1023   {
1024 <        gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes"));
1024 >        const bool use_keycodes = PrefsFindBool("keycodes");
1025 >        gtk_widget_set_sensitive(w_keycode_file, use_keycodes);
1026 >        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes);
1027          gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1);
1028   }
1029  
# Line 938 | Line 1053 | static void read_input_settings(void)
1053   // Create "Input" pane
1054   static void create_input_pane(GtkWidget *top)
1055   {
1056 <        GtkWidget *box, *hbox, *menu, *label;
1056 >        GtkWidget *box, *hbox, *menu, *label, *button;
1057          GtkObject *adj;
1058  
1059          box = make_pane(top, STR_INPUT_PANE_TITLE);
1060  
1061          make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
1062 <        w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
1062 >
1063 >        hbox = gtk_hbox_new(FALSE, 4);
1064 >        gtk_widget_show(hbox);
1065 >        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1066 >
1067 >        label = gtk_label_new(GetString(STR_KEYCODES_CTRL));
1068 >        gtk_widget_show(label);
1069 >        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1070 >
1071 >        const char *str = PrefsFindString("keycodefile");
1072 >        if (str == NULL)
1073 >                str = "";
1074 >
1075 >        w_keycode_file = gtk_entry_new();
1076 >        gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str);
1077 >        gtk_widget_show(w_keycode_file);
1078 >        gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0);
1079 >
1080 >        button = make_browse_button(w_keycode_file);
1081 >        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1082 >        g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button);
1083  
1084          make_separator(box);
1085  
# Line 978 | Line 1113 | static void create_input_pane(GtkWidget
1113  
1114  
1115   /*
1116 < *  "Ports" pane
1116 > *  "Serial" pane
1117   */
1118  
1119 < static GtkWidget *w_seriala, *w_portfile0, *w_portfile0_browse;
1120 < static GtkWidget *w_serialb, *w_portfile1, *w_portfile1_browse;
1119 > static GtkWidget *w_seriala, *w_portfile0;
1120 > static GtkWidget *w_serialb, *w_portfile1;
1121  
1122   // Set sensitivity of widgets
1123   static void set_serial_sensitive(void)
# Line 993 | Line 1128 | static void set_serial_sensitive(void)
1128          str = gtk_entry_get_text(GTK_ENTRY(w_seriala));
1129          is_file = strcmp(str, "FILE") == 0;
1130          gtk_widget_set_sensitive(w_portfile0, is_file);
1131 <        gtk_widget_set_sensitive(w_portfile0_browse, is_file);
1131 >        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile0), "chooser_button")), is_file);
1132  
1133          str = gtk_entry_get_text(GTK_ENTRY(w_serialb));
1134          is_file = strcmp(str, "FILE") == 0;
1135          gtk_widget_set_sensitive(w_portfile1, is_file);
1136 <        gtk_widget_set_sensitive(w_portfile1_browse, is_file);
1136 >        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile1), "chooser_button")), is_file);
1137   }
1138  
1139   // Read settings from widgets and set preferences
# Line 1022 | Line 1157 | static void read_serial_settings(void)
1157   // Port changed in combo
1158   static void cb_serial_port_changed(...)
1159   {
1025        printf("serial port changed\n");
1160          set_serial_sensitive();
1161   }
1162  
# Line 1044 | Line 1178 | static GList *add_serial_names(void)
1178          return glist;
1179   }
1180  
1181 < // Create "Ports" pane
1181 > // Create "Serial" pane
1182   static void create_serial_pane(GtkWidget *top)
1183   {
1184          GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry;
# Line 1053 | Line 1187 | static void create_serial_pane(GtkWidget
1187          box = make_pane(top, STR_SERIAL_PANE_TITLE);
1188          table = make_table(box, 2, 5);
1189  
1056        label = gtk_label_new(GetString(STR_SERIALA_CTRL));
1057        gtk_widget_show(label);
1058        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1059
1190          GList *glist = add_serial_names();
1061        combo = gtk_combo_new();
1062        gtk_widget_show(combo);
1063        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
1191          const char *str = PrefsFindString("seriala");
1192 <        if (str == NULL)
1066 <                str = "";
1067 <        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
1068 <        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1192 >        combo = table_make_combobox(table, 0, STR_SERIALA_CTRL, str, glist);
1193          w_seriala = GTK_COMBO(combo)->entry;
1194          gtk_signal_connect(GTK_OBJECT(w_seriala), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL);
1195  
1196 <        label = gtk_label_new(GetString(STR_FILE_CTRL));
1073 <        gtk_widget_show(label);
1074 <        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1075 <
1076 <        hbox = gtk_hbox_new(FALSE, 4);
1077 <        gtk_widget_show(hbox);
1078 <        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1079 <
1080 <        w_portfile0 = gtk_entry_new();
1081 <        str = PrefsFindString("portfile0");
1082 <        if (str == NULL)
1083 <                str = "C:\\B2TEMP0.OUT";
1084 <        gtk_entry_set_text(GTK_ENTRY(w_portfile0), str);
1085 <        gtk_widget_show(w_portfile0);
1086 <        gtk_box_pack_start(GTK_BOX(hbox), w_portfile0, TRUE, TRUE, 0);
1087 <
1088 <        w_portfile0_browse = make_browse_button(w_portfile0);
1089 <        gtk_box_pack_start(GTK_BOX(hbox), w_portfile0_browse, FALSE, FALSE, 0);
1196 >        w_portfile0 = table_make_file_entry(table, 1, STR_FILE_CTRL, "portfile0");
1197  
1198          sep = gtk_hseparator_new();
1199          gtk_widget_show(sep);
1200          gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1201  
1095        label = gtk_label_new(GetString(STR_SERIALB_CTRL));
1096        gtk_widget_show(label);
1097        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1098
1099        combo = gtk_combo_new();
1100        gtk_widget_show(combo);
1101        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
1202          str = PrefsFindString("serialb");
1203 <        if (str == NULL)
1104 <                str = "";
1105 <        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
1106 <        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1203 >        combo = table_make_combobox(table, 3, STR_SERIALB_CTRL, str, glist);
1204          w_serialb = GTK_COMBO(combo)->entry;
1205          gtk_signal_connect(GTK_OBJECT(w_serialb), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL);
1206  
1207 <        label = gtk_label_new(GetString(STR_FILE_CTRL));
1111 <        gtk_widget_show(label);
1112 <        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1113 <
1114 <        hbox = gtk_hbox_new(FALSE, 4);
1115 <        gtk_widget_show(hbox);
1116 <        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1117 <
1118 <        w_portfile1 = gtk_entry_new();
1119 <        str = PrefsFindString("portfile1");
1120 <        if (str == NULL)
1121 <                str = "C:\\B2TEMP1.OUT";
1122 <        gtk_entry_set_text(GTK_ENTRY(w_portfile1), str);
1123 <        gtk_widget_show(w_portfile1);
1124 <        gtk_box_pack_start(GTK_BOX(hbox), w_portfile1, TRUE, TRUE, 0);
1125 <
1126 <        w_portfile1_browse = make_browse_button(w_portfile1);
1127 <        gtk_box_pack_start(GTK_BOX(hbox), w_portfile1_browse, FALSE, FALSE, 0);
1207 >        w_portfile1 = table_make_file_entry(table, 4, STR_FILE_CTRL, "portfile1");
1208  
1209          set_serial_sensitive();
1210   }
# Line 1134 | Line 1214 | static void create_serial_pane(GtkWidget
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
# Line 1158 | Line 1260 | static GList *add_ether_names(void)
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)
1166 <                g_list_sort(glist, gl_str_cmp);
1167 <        else
1168 < #endif
1169 <                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  
# Line 1188 | Line 1286 | static void create_ethernet_pane(GtkWidg
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   }
# Line 1202 | Line 1335 | static void create_ethernet_pane(GtkWidg
1335   *  "Memory/Misc" pane
1336   */
1337  
1338 < static GtkObject *w_ramsize_adj;
1338 > static GtkWidget *w_ramsize;
1339   static GtkWidget *w_rom_file;
1340  
1341   // "Ignore SEGV" button toggled
# Line 1227 | Line 1360 | static void mn_cpu_68040(...) {PrefsRepl
1360   // Read settings from widgets and set preferences
1361   static void read_memory_settings(void)
1362   {
1363 <        PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20);
1363 >        const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry));
1364 >        PrefsReplaceInt32("ramsize", atoi(str) << 20);
1365  
1366 <        const char *str = get_file_entry_path(w_rom_file);
1366 >        str = get_file_entry_path(w_rom_file);
1367          if (str && strlen(str))
1368                  PrefsReplaceString("rom", str);
1369          else
# Line 1240 | Line 1374 | static void read_memory_settings(void)
1374   // Create "Memory/Misc" pane
1375   static void create_memory_pane(GtkWidget *top)
1376   {
1377 <        GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale;
1377 >        GtkWidget *box, *hbox, *table, *label, *scale, *menu;
1378  
1379          box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE);
1380 +        table = make_table(box, 2, 5);
1381  
1382 <        hbox = gtk_hbox_new(FALSE, 4);
1383 <        gtk_widget_show(hbox);
1384 <
1385 <        label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER));
1386 <        gtk_widget_show(label);
1387 <        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1388 <
1389 <        vbox = gtk_vbox_new(FALSE, 4);
1390 <        gtk_widget_show(vbox);
1391 <
1392 <        gfloat min, max;
1393 <        min = 1;
1394 <        max = 1024;
1395 <        w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0);
1396 <        gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20);
1397 <
1263 <        scale = gtk_hscale_new(GTK_ADJUSTMENT(w_ramsize_adj));
1264 <        gtk_widget_show(scale);
1265 <        gtk_scale_set_digits(GTK_SCALE(scale), 0);
1266 <        gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0);
1267 <
1268 <        hbox2 = gtk_hbox_new(FALSE, 4);
1269 <        gtk_widget_show(hbox2);
1270 <
1271 <        char val[32];
1272 <        sprintf(val, GetString(STR_RAMSIZE_FMT), int(min));
1273 <        label = gtk_label_new(val);
1274 <        gtk_widget_show(label);
1275 <        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1276 <
1277 <        sprintf(val, GetString(STR_RAMSIZE_FMT), int(max));
1278 <        label = gtk_label_new(val);
1279 <        gtk_widget_show(label);
1280 <        gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1281 <        gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
1282 <        gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
1283 <        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1382 >        static const combo_desc options[] = {
1383 >                STR_RAMSIZE_2MB_LAB,
1384 >                STR_RAMSIZE_4MB_LAB,
1385 >                STR_RAMSIZE_8MB_LAB,
1386 >                STR_RAMSIZE_16MB_LAB,
1387 >                STR_RAMSIZE_32MB_LAB,
1388 >                STR_RAMSIZE_64MB_LAB,
1389 >                STR_RAMSIZE_128MB_LAB,
1390 >                STR_RAMSIZE_256MB_LAB,
1391 >                STR_RAMSIZE_512MB_LAB,
1392 >                STR_RAMSIZE_1024MB_LAB,
1393 >                0
1394 >        };
1395 >        char default_ramsize[10];
1396 >        sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20);
1397 >        w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options);
1398  
1399          static const opt_desc model_options[] = {
1400                  {STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)},
# Line 1292 | Line 1406 | static void create_memory_pane(GtkWidget
1406                  case 5: active = 0; break;
1407                  case 14: active = 1; break;
1408          }
1409 <        make_option_menu(box, STR_MODELID_CTRL, model_options, active);
1409 >        table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active);
1410  
1411   #if EMULATED_68K
1412          static const opt_desc cpu_options[] = {
# Line 1311 | Line 1425 | static void create_memory_pane(GtkWidget
1425                  case 3: active = fpu ? 3 : 2; break;
1426                  case 4: active = 4;
1427          }
1428 <        make_option_menu(box, STR_CPU_CTRL, cpu_options, active);
1428 >        table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active);
1429   #endif
1430  
1431 <        w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom");
1431 >        w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom");
1432  
1433   #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1434          make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv));
# Line 1361 | Line 1475 | void SysAddSerialPrefs(void)
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  
# Line 1381 | Line 1510 | int main(int argc, char *argv[])
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines