--- BasiliskII/src/Windows/prefs_editor_gtk.cpp 2005/06/20 08:40:34 1.1 +++ BasiliskII/src/Windows/prefs_editor_gtk.cpp 2005/11/20 23:59:18 1.6 @@ -20,8 +20,11 @@ #include "sysdeps.h" -#include #include +#include +#include +#include +#include #include "user_strings.h" #include "version.h" @@ -157,6 +160,86 @@ static GtkWidget *make_table(GtkWidget * return table; } +static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active) +{ + GtkWidget *label, *opt, *menu; + + label = gtk_label_new(GetString(label_id)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + opt = gtk_option_menu_new(); + gtk_widget_show(opt); + menu = gtk_menu_new(); + + while (options->label_id) { + add_menu_item(menu, options->label_id, options->func); + options++; + } + gtk_menu_set_active(GTK_MENU(menu), active); + + gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); + gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + return menu; +} + +static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist) +{ + GtkWidget *label, *combo; + char str[32]; + + label = gtk_label_new(GetString(label_id)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + combo = gtk_combo_new(); + gtk_widget_show(combo); + gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); + + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value); + gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + + return combo; +} + +static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options) +{ + GList *glist = NULL; + while (options->label_id) { + glist = g_list_append(glist, (void *)GetString(options->label_id)); + options++; + } + + return table_make_combobox(table, row, label_id, default_value, glist); +} + +static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false) +{ + GtkWidget *box, *label, *entry, *button; + + label = gtk_label_new(GetString(label_id)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + const char *str = PrefsFindString(prefs_item); + if (str == NULL) + str = ""; + + box = gtk_hbox_new(FALSE, 4); + gtk_widget_show(box); + gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + + entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(entry), str); + gtk_widget_show(entry); + gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0); + + button = make_browse_button(entry); + gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); + g_object_set_data(G_OBJECT(entry), "chooser_button", button); + return entry; +} + static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active) { GtkWidget *box, *label, *opt, *menu; @@ -341,12 +424,12 @@ static void cb_about(...) // Menu item descriptions static GtkItemFactoryEntry menu_items[] = { {(gchar *)GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, ""}, - {(gchar *)GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL}, + {(gchar *)GetString(STR_PREFS_ITEM_START_GTK), "S", GTK_SIGNAL_FUNC(cb_start), 0, NULL}, {(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(cb_zap_pram), 0, NULL}, {(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, ""}, {(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK), "Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL}, {(gchar *)GetString(STR_HELP_MENU_GTK), NULL, NULL, 0, ""}, - {(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), NULL, GTK_SIGNAL_FUNC(cb_about), 0, NULL} + {(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "H", GTK_SIGNAL_FUNC(cb_about), 0, NULL} }; bool PrefsEditor(void) @@ -381,7 +464,7 @@ bool PrefsEditor(void) gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); create_volumes_pane(notebook); - create_scsi_pane(notebook); +// create_scsi_pane(notebook); XXX not ready yet (merge scsi_windows.cpp from original B2/Win) create_graphics_pane(notebook); create_input_pane(notebook); create_serial_pane(notebook); @@ -391,8 +474,6 @@ bool PrefsEditor(void) static const opt_desc buttons[] = { {STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, - {STR_PREFS_ITEM_ZAP_PRAM, GTK_SIGNAL_FUNC(cb_zap_pram)}, - {STR_ABOUT_BUTTON, GTK_SIGNAL_FUNC(cb_about)}, {STR_QUIT_BUTTON, GTK_SIGNAL_FUNC(cb_quit)}, {0, NULL} }; @@ -409,9 +490,17 @@ bool PrefsEditor(void) * "Volumes" pane */ +static GtkWidget *w_enableextfs, *w_extdrives; static GtkWidget *volume_list; static int selected_volume; +// Set sensitivity of widgets +static void set_volumes_sensitive(void) +{ + const bool enable_extfs = PrefsFindBool("enableextfs"); + gtk_widget_set_sensitive(w_extdrives, enable_extfs); +} + // Volume in list selected static void cl_selected(GtkWidget *list, int row, int column) { @@ -433,13 +522,14 @@ static void create_volume_ok(GtkWidget * gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); - int size = atoi(str); + size_t size = atoi(str) << 20; - char cmd[1024]; - sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", file, size); - int ret = system(cmd); - if (ret == 0) + int fd = _open(file, _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC, _S_IREAD | _S_IWRITE); + if (fd >= 0) { + if (_chsize(fd, size) == 0) gtk_clist_append(GTK_CLIST(volume_list), &file); + _close(fd); + } gtk_widget_destroy(GTK_WIDGET(assoc->req)); delete assoc; } @@ -488,12 +578,25 @@ static void cb_remove_volume(...) static void mn_boot_any(...) {PrefsReplaceInt32("bootdriver", 0);} static void mn_boot_cdrom(...) {PrefsReplaceInt32("bootdriver", CDROMRefNum);} +// "Enable external file system" button toggled +static void tb_enableextfs(GtkWidget *widget) +{ + PrefsReplaceBool("enableextfs", GTK_TOGGLE_BUTTON(widget)->active); + set_volumes_sensitive(); +} + // "No CD-ROM Driver" button toggled static void tb_nocdrom(GtkWidget *widget) { PrefsReplaceBool("nocdrom", GTK_TOGGLE_BUTTON(widget)->active); } +// "Enable polling" button toggled +static void tb_pollmedia(GtkWidget *widget) +{ + PrefsReplaceBool("pollmedia", GTK_TOGGLE_BUTTON(widget)->active); +} + // Read settings from widgets and set preferences static void read_volumes_settings(void) { @@ -505,6 +608,8 @@ static void read_volumes_settings(void) gtk_clist_get_text(GTK_CLIST(volume_list), i, 0, &str); PrefsAddString("disk", str); } + + PrefsReplaceString("extdrives", get_file_entry_path(w_extdrives)); } // Create "Volumes" pane @@ -553,6 +658,14 @@ static void create_volumes_pane(GtkWidge menu = make_option_menu(box, STR_BOOTDRIVER_CTRL, options, active); make_checkbox(box, STR_NOCDROM_CTRL, "nocdrom", GTK_SIGNAL_FUNC(tb_nocdrom)); + + make_checkbox(box, STR_POLLMEDIA_CTRL, "pollmedia", GTK_SIGNAL_FUNC(tb_pollmedia)); + + make_separator(box); + w_enableextfs = make_checkbox(box, STR_EXTFS_ENABLE_CTRL, "enableextfs", GTK_SIGNAL_FUNC(tb_enableextfs)); + w_extdrives = make_file_entry(box, STR_EXTFS_DRIVES_CTRL, "extdrives", true); + + set_volumes_sensitive(); } @@ -908,7 +1021,9 @@ static GtkWidget *w_mouse_wheel_lines; // Set sensitivity of widgets static void set_input_sensitive(void) { - gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes")); + const bool use_keycodes = PrefsFindBool("keycodes"); + gtk_widget_set_sensitive(w_keycode_file, use_keycodes); + gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes); gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1); } @@ -938,13 +1053,33 @@ static void read_input_settings(void) // Create "Input" pane static void create_input_pane(GtkWidget *top) { - GtkWidget *box, *hbox, *menu, *label; + GtkWidget *box, *hbox, *menu, *label, *button; GtkObject *adj; box = make_pane(top, STR_INPUT_PANE_TITLE); make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes)); - w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile"); + + hbox = gtk_hbox_new(FALSE, 4); + gtk_widget_show(hbox); + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(GetString(STR_KEYCODES_CTRL)); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + const char *str = PrefsFindString("keycodefile"); + if (str == NULL) + str = ""; + + w_keycode_file = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str); + gtk_widget_show(w_keycode_file); + gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0); + + button = make_browse_button(w_keycode_file); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button); make_separator(box); @@ -978,11 +1113,11 @@ static void create_input_pane(GtkWidget /* - * "Ports" pane + * "Serial" pane */ -static GtkWidget *w_seriala, *w_portfile0, *w_portfile0_browse; -static GtkWidget *w_serialb, *w_portfile1, *w_portfile1_browse; +static GtkWidget *w_seriala, *w_portfile0; +static GtkWidget *w_serialb, *w_portfile1; // Set sensitivity of widgets static void set_serial_sensitive(void) @@ -993,12 +1128,12 @@ static void set_serial_sensitive(void) str = gtk_entry_get_text(GTK_ENTRY(w_seriala)); is_file = strcmp(str, "FILE") == 0; gtk_widget_set_sensitive(w_portfile0, is_file); - gtk_widget_set_sensitive(w_portfile0_browse, is_file); + gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile0), "chooser_button")), is_file); str = gtk_entry_get_text(GTK_ENTRY(w_serialb)); is_file = strcmp(str, "FILE") == 0; gtk_widget_set_sensitive(w_portfile1, is_file); - gtk_widget_set_sensitive(w_portfile1_browse, is_file); + gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile1), "chooser_button")), is_file); } // Read settings from widgets and set preferences @@ -1022,7 +1157,6 @@ static void read_serial_settings(void) // Port changed in combo static void cb_serial_port_changed(...) { - printf("serial port changed\n"); set_serial_sensitive(); } @@ -1044,7 +1178,7 @@ static GList *add_serial_names(void) return glist; } -// Create "Ports" pane +// Create "Serial" pane static void create_serial_pane(GtkWidget *top) { GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry; @@ -1053,78 +1187,24 @@ static void create_serial_pane(GtkWidget box = make_pane(top, STR_SERIAL_PANE_TITLE); table = make_table(box, 2, 5); - label = gtk_label_new(GetString(STR_SERIALA_CTRL)); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); - GList *glist = add_serial_names(); - combo = gtk_combo_new(); - gtk_widget_show(combo); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); const char *str = PrefsFindString("seriala"); - if (str == NULL) - str = ""; - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); - gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + combo = table_make_combobox(table, 0, STR_SERIALA_CTRL, str, glist); w_seriala = GTK_COMBO(combo)->entry; gtk_signal_connect(GTK_OBJECT(w_seriala), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL); - label = gtk_label_new(GetString(STR_FILE_CTRL)); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); - - hbox = gtk_hbox_new(FALSE, 4); - gtk_widget_show(hbox); - gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); - - w_portfile0 = gtk_entry_new(); - str = PrefsFindString("portfile0"); - if (str == NULL) - str = "C:\\B2TEMP0.OUT"; - gtk_entry_set_text(GTK_ENTRY(w_portfile0), str); - gtk_widget_show(w_portfile0); - gtk_box_pack_start(GTK_BOX(hbox), w_portfile0, TRUE, TRUE, 0); - - w_portfile0_browse = make_browse_button(w_portfile0); - gtk_box_pack_start(GTK_BOX(hbox), w_portfile0_browse, FALSE, FALSE, 0); + w_portfile0 = table_make_file_entry(table, 1, STR_FILE_CTRL, "portfile0"); sep = gtk_hseparator_new(); gtk_widget_show(sep); gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); - label = gtk_label_new(GetString(STR_SERIALB_CTRL)); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); - - combo = gtk_combo_new(); - gtk_widget_show(combo); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); str = PrefsFindString("serialb"); - if (str == NULL) - str = ""; - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); - gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + combo = table_make_combobox(table, 3, STR_SERIALB_CTRL, str, glist); w_serialb = GTK_COMBO(combo)->entry; gtk_signal_connect(GTK_OBJECT(w_serialb), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL); - label = gtk_label_new(GetString(STR_FILE_CTRL)); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); - - hbox = gtk_hbox_new(FALSE, 4); - gtk_widget_show(hbox); - gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); - - w_portfile1 = gtk_entry_new(); - str = PrefsFindString("portfile1"); - if (str == NULL) - str = "C:\\B2TEMP1.OUT"; - gtk_entry_set_text(GTK_ENTRY(w_portfile1), str); - gtk_widget_show(w_portfile1); - gtk_box_pack_start(GTK_BOX(hbox), w_portfile1, TRUE, TRUE, 0); - - w_portfile1_browse = make_browse_button(w_portfile1); - gtk_box_pack_start(GTK_BOX(hbox), w_portfile1_browse, FALSE, FALSE, 0); + w_portfile1 = table_make_file_entry(table, 4, STR_FILE_CTRL, "portfile1"); set_serial_sensitive(); } @@ -1134,21 +1214,43 @@ static void create_serial_pane(GtkWidget * "Ethernet" pane */ -static GtkWidget *w_ether, *w_udp_port; +static GtkWidget *w_ether; +static GtkWidget *w_ftp_port_list, *w_tcp_port_list; +static const char s_nat_router[] = "NAT/Router module"; // Set sensitivity of widgets static void set_ethernet_sensitive(void) { + const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); + + bool is_nat_router = strcmp(str, s_nat_router) == 0; + gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router); + gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router); } // Read settings from widgets and set preferences static void read_ethernet_settings(void) { const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); - if (str && strlen(str)) - PrefsReplaceString("ether", str); + if (str && strlen(str) > 6 && strncmp(str, "NDIS: ", 6) == 0) + PrefsReplaceString("ether", &str[6]); else PrefsRemoveItem("ether"); + + const bool router_enabled = str && strcmp(str, s_nat_router) == 0; + PrefsReplaceBool("routerenabled", router_enabled); + if (router_enabled) { + str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list)); + PrefsReplaceString("ftp_port_list", str); + str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list)); + PrefsReplaceString("tcp_port", str); + } +} + +// Ethernet emulation type changed in menulist +static void cb_ether_changed(...) +{ + set_ethernet_sensitive(); } // Add names of ethernet interfaces @@ -1158,15 +1260,11 @@ static GList *add_ether_names(void) // TODO: Get list of all Ethernet interfaces #ifdef HAVE_SLIRP - static char s_slirp[] = "slirp"; - glist = g_list_append(glist, s_slirp); + static const char s_slirp[] = "slirp"; + glist = g_list_append(glist, (void *)s_slirp); #endif -#if 0 - if (glist) - g_list_sort(glist, gl_str_cmp); - else -#endif - glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); + glist = g_list_append(glist, (void *)s_nat_router); + glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); return glist; } @@ -1188,11 +1286,46 @@ static void create_ethernet_pane(GtkWidg gtk_widget_show(combo); gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); const char *str = PrefsFindString("ether"); - if (str == NULL) - str = ""; + if (str == NULL || str[0] == '\0') { + if (PrefsFindBool("routerenabled")) + str = s_nat_router; + else + str = GetString(STR_NONE_LAB); + } gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); w_ether = GTK_COMBO(combo)->entry; + gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); + + sep = gtk_hseparator_new(); + gtk_widget_show(sep); + gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + label = gtk_label_new(GetString(STR_ETHER_FTP_PORT_LIST_CTRL)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + entry = gtk_entry_new(); + str = PrefsFindString("ftp_port_list"); + if (str == NULL) + str = ""; + gtk_entry_set_text(GTK_ENTRY(entry), str); + gtk_widget_show(entry); + gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + w_ftp_port_list = entry; + + label = gtk_label_new(GetString(STR_ETHER_TCP_PORT_LIST_CTRL)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + entry = gtk_entry_new(); + str = PrefsFindString("tcp_port"); + if (str == NULL) + str = ""; + gtk_entry_set_text(GTK_ENTRY(entry), str); + gtk_widget_show(entry); + gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); + w_tcp_port_list = entry; set_ethernet_sensitive(); } @@ -1202,7 +1335,7 @@ static void create_ethernet_pane(GtkWidg * "Memory/Misc" pane */ -static GtkObject *w_ramsize_adj; +static GtkWidget *w_ramsize; static GtkWidget *w_rom_file; // "Ignore SEGV" button toggled @@ -1227,9 +1360,10 @@ static void mn_cpu_68040(...) {PrefsRepl // Read settings from widgets and set preferences static void read_memory_settings(void) { - PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20); + const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry)); + PrefsReplaceInt32("ramsize", atoi(str) << 20); - const char *str = get_file_entry_path(w_rom_file); + str = get_file_entry_path(w_rom_file); if (str && strlen(str)) PrefsReplaceString("rom", str); else @@ -1240,47 +1374,27 @@ static void read_memory_settings(void) // Create "Memory/Misc" pane static void create_memory_pane(GtkWidget *top) { - GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale; + GtkWidget *box, *hbox, *table, *label, *scale, *menu; box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE); + table = make_table(box, 2, 5); - hbox = gtk_hbox_new(FALSE, 4); - gtk_widget_show(hbox); - - label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER)); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - vbox = gtk_vbox_new(FALSE, 4); - gtk_widget_show(vbox); - - gfloat min, max; - min = 1; - max = 1024; - w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0); - gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(w_ramsize_adj)); - gtk_widget_show(scale); - gtk_scale_set_digits(GTK_SCALE(scale), 0); - gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0); - - hbox2 = gtk_hbox_new(FALSE, 4); - gtk_widget_show(hbox2); - - char val[32]; - sprintf(val, GetString(STR_RAMSIZE_FMT), int(min)); - label = gtk_label_new(val); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - - sprintf(val, GetString(STR_RAMSIZE_FMT), int(max)); - label = gtk_label_new(val); - gtk_widget_show(label); - gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); + static const combo_desc options[] = { + STR_RAMSIZE_2MB_LAB, + STR_RAMSIZE_4MB_LAB, + STR_RAMSIZE_8MB_LAB, + STR_RAMSIZE_16MB_LAB, + STR_RAMSIZE_32MB_LAB, + STR_RAMSIZE_64MB_LAB, + STR_RAMSIZE_128MB_LAB, + STR_RAMSIZE_256MB_LAB, + STR_RAMSIZE_512MB_LAB, + STR_RAMSIZE_1024MB_LAB, + 0 + }; + char default_ramsize[10]; + sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20); + w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options); static const opt_desc model_options[] = { {STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)}, @@ -1292,7 +1406,7 @@ static void create_memory_pane(GtkWidget case 5: active = 0; break; case 14: active = 1; break; } - make_option_menu(box, STR_MODELID_CTRL, model_options, active); + table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); #if EMULATED_68K static const opt_desc cpu_options[] = { @@ -1311,10 +1425,10 @@ static void create_memory_pane(GtkWidget case 3: active = fpu ? 3 : 2; break; case 4: active = 4; } - make_option_menu(box, STR_CPU_CTRL, cpu_options, active); + table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active); #endif - w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom"); + w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom"); #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); @@ -1361,6 +1475,21 @@ void SysAddSerialPrefs(void) /* + * Display alerts + */ + +static void display_alert(int title_id, const char *text, int flags) +{ + MessageBox(NULL, text, GetString(title_id), MB_OK | flags); +} + +static void ErrorAlert(const char *text) +{ + display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); +} + + +/* * Start standalone GUI */ @@ -1381,7 +1510,24 @@ int main(int argc, char *argv[]) // Transfer control to the Basilisk II executable if (start) { - printf("Start Basilisk II\n"); + char path[_MAX_PATH]; + bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0; + if (ok) { + char b2_path[_MAX_PATH]; + char *p = strrchr(path, '\\'); + *++p = '\0'; + SetCurrentDirectory(path); + strcpy(b2_path, path); + strcat(b2_path, "BasiliskII.exe"); + HINSTANCE h = ShellExecute(GetDesktopWindow(), "open", + b2_path, "", path, SW_SHOWNORMAL); + if ((int)h <= 32) + ok = false; + } + if (!ok) { + ErrorAlert("Coult not start BasiliskII executable"); + return 1; + } } return 0;