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

Comparing BasiliskII/src/Unix/prefs_editor_gtk.cpp (file contents):
Revision 1.24 by cebix, 2002-10-15T16:25:04Z vs.
Revision 1.29 by gbeauche, 2005-11-21T21:39:08Z

# Line 1 | Line 1
1   /*
2   *  prefs_editor_gtk.cpp - Preferences editor, Unix implementation using GTK+
3   *
4 < *  Basilisk II (C) 1997-2002 Christian Bauer
4 > *  Basilisk II (C) 1997-2005 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 69 | Line 69 | struct combo_desc {
69          int label_id;
70   };
71  
72 + struct file_req_assoc {
73 +        file_req_assoc(GtkWidget *r, GtkWidget *e) : req(r), entry(e) {}
74 +        GtkWidget *req;
75 +        GtkWidget *entry;
76 + };
77 +
78 + static void cb_browse_ok(GtkWidget *button, file_req_assoc *assoc)
79 + {
80 +        gchar *file = (char *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
81 +        gtk_entry_set_text(GTK_ENTRY(assoc->entry), file);
82 +        gtk_widget_destroy(assoc->req);
83 +        delete assoc;
84 + }
85 +
86 + static void cb_browse(GtkWidget *widget, void *user_data)
87 + {
88 +        GtkWidget *req = gtk_file_selection_new(GetString(STR_BROWSE_TITLE));
89 +        gtk_signal_connect_object(GTK_OBJECT(req), "delete_event", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(req));
90 +        gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(req)->ok_button), "clicked", GTK_SIGNAL_FUNC(cb_browse_ok), new file_req_assoc(req, (GtkWidget *)user_data));
91 +        gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(req)->cancel_button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(req));
92 +        gtk_widget_show(req);
93 + }
94 +
95 + static GtkWidget *make_browse_button(GtkWidget *entry)
96 + {
97 +        GtkWidget *button;
98 +
99 +        button = gtk_button_new_with_label(GetString(STR_BROWSE_CTRL));
100 +        gtk_widget_show(button);
101 +        gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)cb_browse, (void *)entry);
102 +        return button;
103 + }
104 +
105   static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func)
106   {
107          GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id));
# Line 132 | Line 165 | static GtkWidget *make_table(GtkWidget *
165          return table;
166   }
167  
168 + static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active)
169 + {
170 +        GtkWidget *label, *opt, *menu;
171 +
172 +        label = gtk_label_new(GetString(label_id));
173 +        gtk_widget_show(label);
174 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
175 +
176 +        opt = gtk_option_menu_new();
177 +        gtk_widget_show(opt);
178 +        menu = gtk_menu_new();
179 +
180 +        while (options->label_id) {
181 +                add_menu_item(menu, options->label_id, options->func);
182 +                options++;
183 +        }
184 +        gtk_menu_set_active(GTK_MENU(menu), active);
185 +
186 +        gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
187 +        gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
188 +        return menu;
189 + }
190 +
191 + static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist)
192 + {
193 +        GtkWidget *label, *combo;
194 +        char str[32];
195 +
196 +        label = gtk_label_new(GetString(label_id));
197 +        gtk_widget_show(label);
198 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
199 +        
200 +        combo = gtk_combo_new();
201 +        gtk_widget_show(combo);
202 +        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
203 +
204 +        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value);
205 +        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
206 +        
207 +        return combo;
208 + }
209 +
210 + static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options)
211 + {
212 +        GList *glist = NULL;
213 +        while (options->label_id) {
214 +                glist = g_list_append(glist, (void *)GetString(options->label_id));
215 +                options++;
216 +        }
217 +
218 +        return table_make_combobox(table, row, label_id, default_value, glist);
219 + }
220 +
221 + static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false)
222 + {
223 +        GtkWidget *box, *label, *entry, *button;
224 +
225 +        label = gtk_label_new(GetString(label_id));
226 +        gtk_widget_show(label);
227 +        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
228 +
229 +        const char *str = PrefsFindString(prefs_item);
230 +        if (str == NULL)
231 +                str = "";
232 +
233 +        box = gtk_hbox_new(FALSE, 4);
234 +        gtk_widget_show(box);
235 +        gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
236 +
237 +        entry = gtk_entry_new();
238 +        gtk_entry_set_text(GTK_ENTRY(entry), str);
239 +        gtk_widget_show(entry);
240 +        gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
241 +
242 +        button = make_browse_button(entry);
243 +        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
244 +        g_object_set_data(G_OBJECT(entry), "chooser_button", button);
245 +        return entry;
246 + }
247 +
248   static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active)
249   {
250          GtkWidget *box, *label, *opt, *menu;
# Line 189 | Line 302 | static GtkWidget *make_file_entry(GtkWid
302          return entry;
303   }
304  
305 < static char *get_file_entry_path(GtkWidget *entry)
305 > static const gchar *get_file_entry_path(GtkWidget *entry)
306   {
307   #ifdef HAVE_GNOMEUI
308          return gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(entry), false);
# Line 306 | Line 419 | static void mn_about(...)
419          dialog = gnome_about_new(
420                  "Basilisk II",
421                  version,
422 <                "Copyright (C) 1997-2002 Christian Bauer",
422 >                "Copyright (C) 1997-2004 Christian Bauer",
423                  authors,
424                  "Basilisk II comes with ABSOLUTELY NO WARRANTY."
425                  "This is free software, and you are welcome to redistribute it"
# Line 322 | Line 435 | static void mn_about(...)
435          char str[512];
436          sprintf(str,
437                  "Basilisk II\nVersion %d.%d\n\n"
438 <                "Copyright (C) 1997-2002 Christian Bauer et al.\n"
438 >                "Copyright (C) 1997-2004 Christian Bauer et al.\n"
439                  "E-mail: Christian.Bauer@uni-mainz.de\n"
440                  "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n"
441                  "Basilisk II comes with ABSOLUTELY NO\n"
# Line 363 | Line 476 | static void mn_zap_pram(...)
476   // Menu item descriptions
477   static GtkItemFactoryEntry menu_items[] = {
478          {(gchar *)GetString(STR_PREFS_MENU_FILE_GTK),           NULL,                   NULL,                                                   0, "<Branch>"},
479 <        {(gchar *)GetString(STR_PREFS_ITEM_START_GTK),          NULL,                   GTK_SIGNAL_FUNC(cb_start),              0, NULL},
479 >        {(gchar *)GetString(STR_PREFS_ITEM_START_GTK),          "<control>S",   GTK_SIGNAL_FUNC(cb_start),              0, NULL},
480          {(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK),       NULL,                   GTK_SIGNAL_FUNC(mn_zap_pram),   0, NULL},
481          {(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK),           NULL,                   NULL,                                                   0, "<Separator>"},
482          {(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK),           "<control>Q",   GTK_SIGNAL_FUNC(cb_quit),               0, NULL},
# Line 387 | Line 500 | bool PrefsEditor(void)
500          GtkAccelGroup *accel_group = gtk_accel_group_new();
501          GtkItemFactory *item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
502          gtk_item_factory_create_items(item_factory, sizeof(menu_items) / sizeof(menu_items[0]), menu_items, NULL);
503 + #if GTK_CHECK_VERSION(1,3,15)
504 +        gtk_window_add_accel_group(GTK_WINDOW(win), accel_group);
505 + #else
506          gtk_accel_group_attach(accel_group, GTK_OBJECT(win));
507 + #endif
508          GtkWidget *menu_bar = gtk_item_factory_get_widget(item_factory, "<main>");
509          gtk_widget_show(menu_bar);
510          gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, TRUE, 0);
# Line 433 | Line 550 | static void cl_selected(GtkWidget *list,
550          selected_volume = row;
551   }
552  
436 struct file_req_assoc {
437        file_req_assoc(GtkWidget *r, GtkWidget *e) : req(r), entry(e) {}
438        GtkWidget *req;
439        GtkWidget *entry;
440 };
441
553   // Volume selected for addition
554   static void add_volume_ok(GtkWidget *button, file_req_assoc *assoc)
555   {
556 <        char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
556 >        gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
557          gtk_clist_append(GTK_CLIST(volume_list), &file);
558          gtk_widget_destroy(assoc->req);
559          delete assoc;
# Line 451 | Line 562 | static void add_volume_ok(GtkWidget *but
562   // Volume selected for creation
563   static void create_volume_ok(GtkWidget *button, file_req_assoc *assoc)
564   {
565 <        char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
565 >        gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
566  
567 <        char *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry));
567 >        const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry));
568          int size = atoi(str);
569  
570          char cmd[1024];
# Line 589 | Line 700 | static GtkWidget *w_jit_fpu;
700   static GtkWidget *w_jit_atraps;
701   static GtkWidget *w_jit_cache_size;
702   static GtkWidget *w_jit_lazy_flush;
703 + static GtkWidget *w_jit_follow_const_jumps;
704  
705   // Set sensitivity of widgets
706   static void set_jit_sensitive(void)
# Line 597 | Line 709 | static void set_jit_sensitive(void)
709          gtk_widget_set_sensitive(w_jit_fpu, jit_enabled);
710          gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled);
711          gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled);
712 +        gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled);
713   }
714  
715   // "Use JIT Compiler" button toggled
# Line 618 | Line 731 | static void tb_jit_lazy_flush(GtkWidget
731          PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active);
732   }
733  
734 + // "Translate through constant jumps (inline blocks)" button toggled
735 + static void tb_jit_follow_const_jumps(GtkWidget *widget)
736 + {
737 +        PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active);
738 + }
739 +
740   // Read settings from widgets and set preferences
741   static void read_jit_settings(void)
742   {
# Line 654 | Line 773 | static void create_jit_pane(GtkWidget *t
773          
774          // Lazy translation cache invalidation
775          w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush));
776 <        
776 >
777 >        // Follow constant jumps (inline basic blocks)
778 >        w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps));
779 >
780          set_jit_sensitive();
781   #endif
782   }
# Line 979 | Line 1101 | static GtkWidget *w_mouse_wheel_lines;
1101   // Set sensitivity of widgets
1102   static void set_input_sensitive(void)
1103   {
1104 <        gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes"));
1104 >        const bool use_keycodes = PrefsFindBool("keycodes");
1105 >        gtk_widget_set_sensitive(w_keycode_file, use_keycodes);
1106 >        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes);
1107          gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1);
1108   }
1109  
# Line 1009 | Line 1133 | static void read_input_settings(void)
1133   // Create "Input" pane
1134   static void create_input_pane(GtkWidget *top)
1135   {
1136 <        GtkWidget *box, *hbox, *menu, *label;
1136 >        GtkWidget *box, *hbox, *menu, *label, *button;
1137          GtkObject *adj;
1138  
1139          box = make_pane(top, STR_INPUT_PANE_TITLE);
1140  
1141          make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
1142 <        w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
1142 >
1143 >        hbox = gtk_hbox_new(FALSE, 4);
1144 >        gtk_widget_show(hbox);
1145 >        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1146 >
1147 >        label = gtk_label_new(GetString(STR_KEYCODES_CTRL));
1148 >        gtk_widget_show(label);
1149 >        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1150 >
1151 >        const char *str = PrefsFindString("keycodefile");
1152 >        if (str == NULL)
1153 >                str = "";
1154 >
1155 >        w_keycode_file = gtk_entry_new();
1156 >        gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str);
1157 >        gtk_widget_show(w_keycode_file);
1158 >        gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0);
1159 >
1160 >        button = make_browse_button(w_keycode_file);
1161 >        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1162 >        g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button);
1163  
1164          make_separator(box);
1165  
# Line 1163 | Line 1307 | static GList *add_ether_names(void)
1307                  }
1308                  close(s);
1309          }
1310 + #ifdef HAVE_SLIRP
1311 +        static char s_slirp[] = "slirp";
1312 +        glist = g_list_append(glist, s_slirp);
1313 + #endif
1314          if (glist)
1315                  g_list_sort(glist, gl_str_cmp);
1316          else
# Line 1252 | Line 1400 | static void create_serial_pane(GtkWidget
1400   *  "Memory/Misc" pane
1401   */
1402  
1403 < static GtkObject *w_ramsize_adj;
1403 > static GtkWidget *w_ramsize;
1404   static GtkWidget *w_rom_file;
1405  
1406   // "Ignore SEGV" button toggled
# Line 1277 | Line 1425 | static void mn_cpu_68040(...) {PrefsRepl
1425   // Read settings from widgets and set preferences
1426   static void read_memory_settings(void)
1427   {
1428 <        PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20);
1428 >        const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry));
1429 >        PrefsReplaceInt32("ramsize", atoi(str) << 20);
1430  
1431 <        const char *str = get_file_entry_path(w_rom_file);
1431 >        str = get_file_entry_path(w_rom_file);
1432          if (str && strlen(str))
1433                  PrefsReplaceString("rom", str);
1434          else
# Line 1290 | Line 1439 | static void read_memory_settings(void)
1439   // Create "Memory/Misc" pane
1440   static void create_memory_pane(GtkWidget *top)
1441   {
1442 <        GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale;
1442 >        GtkWidget *box, *hbox, *table, *label, *menu;
1443  
1444          box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE);
1445 +        table = make_table(box, 2, 5);
1446  
1447 <        hbox = gtk_hbox_new(FALSE, 4);
1448 <        gtk_widget_show(hbox);
1449 <
1450 <        label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER));
1451 <        gtk_widget_show(label);
1452 <        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1453 <
1454 <        vbox = gtk_vbox_new(FALSE, 4);
1455 <        gtk_widget_show(vbox);
1456 <
1457 <        gfloat min, max;
1458 <        min = 1;
1459 <        max = 1024;
1460 <        w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0);
1461 <        gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20);
1462 <
1313 <        scale = gtk_hscale_new(GTK_ADJUSTMENT(w_ramsize_adj));
1314 <        gtk_widget_show(scale);
1315 <        gtk_scale_set_digits(GTK_SCALE(scale), 0);
1316 <        gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0);
1317 <
1318 <        hbox2 = gtk_hbox_new(FALSE, 4);
1319 <        gtk_widget_show(hbox2);
1320 <
1321 <        char val[32];
1322 <        sprintf(val, GetString(STR_RAMSIZE_FMT), int(min));
1323 <        label = gtk_label_new(val);
1324 <        gtk_widget_show(label);
1325 <        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1326 <
1327 <        sprintf(val, GetString(STR_RAMSIZE_FMT), int(max));
1328 <        label = gtk_label_new(val);
1329 <        gtk_widget_show(label);
1330 <        gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1331 <        gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
1332 <        gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
1333 <        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1447 >        static const combo_desc options[] = {
1448 >                STR_RAMSIZE_2MB_LAB,
1449 >                STR_RAMSIZE_4MB_LAB,
1450 >                STR_RAMSIZE_8MB_LAB,
1451 >                STR_RAMSIZE_16MB_LAB,
1452 >                STR_RAMSIZE_32MB_LAB,
1453 >                STR_RAMSIZE_64MB_LAB,
1454 >                STR_RAMSIZE_128MB_LAB,
1455 >                STR_RAMSIZE_256MB_LAB,
1456 >                STR_RAMSIZE_512MB_LAB,
1457 >                STR_RAMSIZE_1024MB_LAB,
1458 >                0
1459 >        };
1460 >        char default_ramsize[10];
1461 >        sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20);
1462 >        w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options);
1463  
1464          static const opt_desc model_options[] = {
1465                  {STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)},
# Line 1342 | Line 1471 | static void create_memory_pane(GtkWidget
1471                  case 5: active = 0; break;
1472                  case 14: active = 1; break;
1473          }
1474 <        make_option_menu(box, STR_MODELID_CTRL, model_options, active);
1474 >        table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active);
1475  
1476   #if EMULATED_68K
1477          static const opt_desc cpu_options[] = {
# Line 1361 | Line 1490 | static void create_memory_pane(GtkWidget
1490                  case 3: active = fpu ? 3 : 2; break;
1491                  case 4: active = 4;
1492          }
1493 <        make_option_menu(box, STR_CPU_CTRL, cpu_options, active);
1493 >        table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active);
1494   #endif
1495  
1496 <        w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom");
1496 >        w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom");
1497  
1498   #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1499          make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines