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.3 by gbeauche, 2005-11-20T17:26:16Z

# Line 157 | Line 157 | static GtkWidget *make_table(GtkWidget *
157          return table;
158   }
159  
160 + static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active)
161 + {
162 +        GtkWidget *label, *opt, *menu;
163 +
164 +        label = gtk_label_new(GetString(label_id));
165 +        gtk_widget_show(label);
166 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
167 +
168 +        opt = gtk_option_menu_new();
169 +        gtk_widget_show(opt);
170 +        menu = gtk_menu_new();
171 +
172 +        while (options->label_id) {
173 +                add_menu_item(menu, options->label_id, options->func);
174 +                options++;
175 +        }
176 +        gtk_menu_set_active(GTK_MENU(menu), active);
177 +
178 +        gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
179 +        gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
180 +        return menu;
181 + }
182 +
183 + static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist)
184 + {
185 +        GtkWidget *label, *combo;
186 +        char str[32];
187 +
188 +        label = gtk_label_new(GetString(label_id));
189 +        gtk_widget_show(label);
190 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
191 +        
192 +        combo = gtk_combo_new();
193 +        gtk_widget_show(combo);
194 +        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
195 +
196 +        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value);
197 +        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
198 +        
199 +        return combo;
200 + }
201 +
202 + static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options)
203 + {
204 +        GList *glist = NULL;
205 +        while (options->label_id) {
206 +                glist = g_list_append(glist, (void *)GetString(options->label_id));
207 +                options++;
208 +        }
209 +
210 +        return table_make_combobox(table, row, label_id, default_value, glist);
211 + }
212 +
213 + static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false)
214 + {
215 +        GtkWidget *box, *label, *entry, *button;
216 +
217 +        label = gtk_label_new(GetString(label_id));
218 +        gtk_widget_show(label);
219 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
220 +
221 +        const char *str = PrefsFindString(prefs_item);
222 +        if (str == NULL)
223 +                str = "";
224 +
225 +        box = gtk_hbox_new(FALSE, 4);
226 +        gtk_widget_show(box);
227 +        gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
228 +
229 +        entry = gtk_entry_new();
230 +        gtk_entry_set_text(GTK_ENTRY(entry), str);
231 +        gtk_widget_show(entry);
232 +        gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
233 +
234 +        button = make_browse_button(entry);
235 +        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
236 +        g_object_set_data(G_OBJECT(entry), "chooser_button", button);
237 +        return entry;
238 + }
239 +
240   static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active)
241   {
242          GtkWidget *box, *label, *opt, *menu;
# Line 978 | Line 1058 | static void create_input_pane(GtkWidget
1058  
1059  
1060   /*
1061 < *  "Ports" pane
1061 > *  "Serial" pane
1062   */
1063  
1064 < static GtkWidget *w_seriala, *w_portfile0, *w_portfile0_browse;
1065 < static GtkWidget *w_serialb, *w_portfile1, *w_portfile1_browse;
1064 > static GtkWidget *w_seriala, *w_portfile0;
1065 > static GtkWidget *w_serialb, *w_portfile1;
1066  
1067   // Set sensitivity of widgets
1068   static void set_serial_sensitive(void)
# Line 993 | Line 1073 | static void set_serial_sensitive(void)
1073          str = gtk_entry_get_text(GTK_ENTRY(w_seriala));
1074          is_file = strcmp(str, "FILE") == 0;
1075          gtk_widget_set_sensitive(w_portfile0, is_file);
1076 <        gtk_widget_set_sensitive(w_portfile0_browse, is_file);
1076 >        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile0), "chooser_button")), is_file);
1077  
1078          str = gtk_entry_get_text(GTK_ENTRY(w_serialb));
1079          is_file = strcmp(str, "FILE") == 0;
1080          gtk_widget_set_sensitive(w_portfile1, is_file);
1081 <        gtk_widget_set_sensitive(w_portfile1_browse, is_file);
1081 >        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile1), "chooser_button")), is_file);
1082   }
1083  
1084   // Read settings from widgets and set preferences
# Line 1044 | Line 1124 | static GList *add_serial_names(void)
1124          return glist;
1125   }
1126  
1127 < // Create "Ports" pane
1127 > // Create "Serial" pane
1128   static void create_serial_pane(GtkWidget *top)
1129   {
1130          GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry;
# Line 1053 | Line 1133 | static void create_serial_pane(GtkWidget
1133          box = make_pane(top, STR_SERIAL_PANE_TITLE);
1134          table = make_table(box, 2, 5);
1135  
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
1136          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);
1137          const char *str = PrefsFindString("seriala");
1138 <        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);
1138 >        combo = table_make_combobox(table, 0, STR_SERIALA_CTRL, str, glist);
1139          w_seriala = GTK_COMBO(combo)->entry;
1140          gtk_signal_connect(GTK_OBJECT(w_seriala), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL);
1141  
1142 <        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);
1142 >        w_portfile0 = table_make_file_entry(table, 1, STR_FILE_CTRL, "portfile0");
1143  
1144          sep = gtk_hseparator_new();
1145          gtk_widget_show(sep);
1146          gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1147  
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);
1148          str = PrefsFindString("serialb");
1149 <        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);
1149 >        combo = table_make_combobox(table, 3, STR_SERIALB_CTRL, str, glist);
1150          w_serialb = GTK_COMBO(combo)->entry;
1151          gtk_signal_connect(GTK_OBJECT(w_serialb), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL);
1152  
1153 <        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);
1153 >        w_portfile1 = table_make_file_entry(table, 4, STR_FILE_CTRL, "portfile1");
1154  
1155          set_serial_sensitive();
1156   }
# Line 1202 | Line 1228 | static void create_ethernet_pane(GtkWidg
1228   *  "Memory/Misc" pane
1229   */
1230  
1231 < static GtkObject *w_ramsize_adj;
1231 > static GtkWidget *w_ramsize;
1232   static GtkWidget *w_rom_file;
1233  
1234   // "Ignore SEGV" button toggled
# Line 1227 | Line 1253 | static void mn_cpu_68040(...) {PrefsRepl
1253   // Read settings from widgets and set preferences
1254   static void read_memory_settings(void)
1255   {
1256 <        PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20);
1256 >        const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry));
1257 >        PrefsReplaceInt32("ramsize", atoi(str) << 20);
1258  
1259 <        const char *str = get_file_entry_path(w_rom_file);
1259 >        str = get_file_entry_path(w_rom_file);
1260          if (str && strlen(str))
1261                  PrefsReplaceString("rom", str);
1262          else
# Line 1240 | Line 1267 | static void read_memory_settings(void)
1267   // Create "Memory/Misc" pane
1268   static void create_memory_pane(GtkWidget *top)
1269   {
1270 <        GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale;
1270 >        GtkWidget *box, *hbox, *table, *label, *scale, *menu;
1271  
1272          box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE);
1273 +        table = make_table(box, 2, 5);
1274  
1275 <        hbox = gtk_hbox_new(FALSE, 4);
1276 <        gtk_widget_show(hbox);
1277 <
1278 <        label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER));
1279 <        gtk_widget_show(label);
1280 <        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1281 <
1282 <        vbox = gtk_vbox_new(FALSE, 4);
1283 <        gtk_widget_show(vbox);
1284 <
1285 <        gfloat min, max;
1286 <        min = 1;
1287 <        max = 1024;
1288 <        w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0);
1289 <        gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20);
1290 <
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);
1275 >        static const combo_desc options[] = {
1276 >                STR_RAMSIZE_2MB_LAB,
1277 >                STR_RAMSIZE_4MB_LAB,
1278 >                STR_RAMSIZE_8MB_LAB,
1279 >                STR_RAMSIZE_16MB_LAB,
1280 >                STR_RAMSIZE_32MB_LAB,
1281 >                STR_RAMSIZE_64MB_LAB,
1282 >                STR_RAMSIZE_128MB_LAB,
1283 >                STR_RAMSIZE_256MB_LAB,
1284 >                STR_RAMSIZE_512MB_LAB,
1285 >                STR_RAMSIZE_1024MB_LAB,
1286 >                0
1287 >        };
1288 >        char default_ramsize[10];
1289 >        sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20);
1290 >        w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options);
1291  
1292          static const opt_desc model_options[] = {
1293                  {STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)},
# Line 1292 | Line 1299 | static void create_memory_pane(GtkWidget
1299                  case 5: active = 0; break;
1300                  case 14: active = 1; break;
1301          }
1302 <        make_option_menu(box, STR_MODELID_CTRL, model_options, active);
1302 >        table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active);
1303  
1304   #if EMULATED_68K
1305          static const opt_desc cpu_options[] = {
# Line 1311 | Line 1318 | static void create_memory_pane(GtkWidget
1318                  case 3: active = fpu ? 3 : 2; break;
1319                  case 4: active = 4;
1320          }
1321 <        make_option_menu(box, STR_CPU_CTRL, cpu_options, active);
1321 >        table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active);
1322   #endif
1323  
1324 <        w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom");
1324 >        w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom");
1325  
1326   #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1327          make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines