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.14 by cebix, 2001-01-04T19:50:22Z 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-2000 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 28 | Line 28
28   #include <net/if.h>
29   #include <net/if_arp.h>
30  
31 + #ifdef HAVE_GNOMEUI
32 + #include <gnome.h>
33 + #endif
34 +
35   #include "user_strings.h"
36   #include "version.h"
37   #include "cdrom.h"
# Line 48 | Line 52 | static void create_graphics_pane(GtkWidg
52   static void create_input_pane(GtkWidget *top);
53   static void create_serial_pane(GtkWidget *top);
54   static void create_memory_pane(GtkWidget *top);
55 + static void create_jit_pane(GtkWidget *top);
56   static void read_settings(void);
57  
58  
# Line 60 | Line 65 | struct opt_desc {
65          GtkSignalFunc func;
66   };
67  
68 + 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 123 | 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 150 | Line 272 | static GtkWidget *make_option_menu(GtkWi
272          return menu;
273   }
274  
275 < static GtkWidget *make_entry(GtkWidget *top, int label_id, const char *prefs_item)
275 > static GtkWidget *make_file_entry(GtkWidget *top, int label_id, const char *prefs_item, bool only_dirs = false)
276   {
277          GtkWidget *box, *label, *entry;
278  
# Line 162 | Line 284 | static GtkWidget *make_entry(GtkWidget *
284          gtk_widget_show(label);
285          gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
286  
165        entry = gtk_entry_new();
166        gtk_widget_show(entry);
287          const char *str = PrefsFindString(prefs_item);
288          if (str == NULL)
289                  str = "";
290 +
291 + #ifdef HAVE_GNOMEUI
292 +        entry = gnome_file_entry_new(NULL, GetString(label_id));
293 +        if (only_dirs)
294 +                gnome_file_entry_set_directory(GNOME_FILE_ENTRY(entry), true);
295 +        gtk_entry_set_text(GTK_ENTRY(gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(entry))), str);
296 + #else
297 +        entry = gtk_entry_new();
298          gtk_entry_set_text(GTK_ENTRY(entry), str);
299 + #endif
300 +        gtk_widget_show(entry);
301          gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
302          return entry;
303   }
304  
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);
309 + #else
310 +        return gtk_entry_get_text(GTK_ENTRY(entry));
311 + #endif
312 + }
313 +
314   static GtkWidget *make_checkbox(GtkWidget *top, int label_id, const char *prefs_item, GtkSignalFunc func)
315   {
316          GtkWidget *button = gtk_check_button_new_with_label(GetString(label_id));
# Line 182 | Line 321 | static GtkWidget *make_checkbox(GtkWidge
321          return button;
322   }
323  
324 + static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options)
325 + {
326 +        GtkWidget *box, *label, *combo;
327 +        char str[32];
328 +
329 +        box = gtk_hbox_new(FALSE, 4);
330 +        gtk_widget_show(box);
331 +        gtk_box_pack_start(GTK_BOX(top), box, FALSE, FALSE, 0);
332 +
333 +        label = gtk_label_new(GetString(label_id));
334 +        gtk_widget_show(label);
335 +        gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
336 +
337 +        GList *glist = NULL;
338 +        while (options->label_id) {
339 +                glist = g_list_append(glist, (void *)GetString(options->label_id));
340 +                options++;
341 +        }
342 +        
343 +        combo = gtk_combo_new();
344 +        gtk_widget_show(combo);
345 +        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
346 +        
347 +        sprintf(str, "%d", PrefsFindInt32(prefs_item));
348 +        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
349 +        gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0);
350 +        
351 +        return combo;
352 + }
353  
354 +
355   /*
356   *  Show preferences editor
357   *  Returns true when user clicked on "Start", false otherwise
# Line 225 | Line 394 | static void dl_quit(GtkWidget *dialog)
394   // "About" selected
395   static void mn_about(...)
396   {
397 <        GtkWidget *dialog, *label, *button;
397 >        GtkWidget *dialog;
398  
399 <        char str[256];
400 <        sprintf(str, GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR);
401 <        strncat(str, "\n", 255);
402 <        strncat(str, GetString(STR_ABOUT_TEXT2), 255);
399 > #ifdef HAVE_GNOMEUI
400 >
401 >        char version[32];
402 >        sprintf(version, "Version %d.%d", VERSION_MAJOR, VERSION_MINOR);
403 >        const char *authors[] = {
404 >                "Christian Bauer",
405 >                "Orlando Bassotto",
406 >                "Gwenolé Beauchesne",
407 >                "Marc Chabanas",
408 >                "Marc Hellwig",
409 >                "Biill Huey",
410 >                "Brian J. Johnson",
411 >                "Jürgen Lachmann",
412 >                "Samuel Lander",
413 >                "David Lawrence",
414 >                "Lauri Pesonen",
415 >                "Bernd Schmidt",
416 >                "and others",
417 >                NULL
418 >        };
419 >        dialog = gnome_about_new(
420 >                "Basilisk II",
421 >                version,
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"
426 >                "under the terms of the GNU General Public License.",
427 >                NULL
428 >        );
429 >        gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(win));
430 >
431 > #else
432 >
433 >        GtkWidget *label, *button;
434 >
435 >        char str[512];
436 >        sprintf(str,
437 >                "Basilisk II\nVersion %d.%d\n\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"
442 >                "WARRANTY. This is free software, and\n"
443 >                "you are welcome to redistribute it\n"
444 >                "under the terms of the GNU General\n"
445 >                "Public License.\n",
446 >                VERSION_MAJOR, VERSION_MINOR
447 >        );
448  
449          dialog = gtk_dialog_new();
236        gtk_widget_set_usize(GTK_WIDGET(dialog), strlen(GetString(STR_ABOUT_TEXT2)) + 200, 120);
450          gtk_window_set_title(GTK_WINDOW(dialog), GetString(STR_ABOUT_TITLE));
451          gtk_container_border_width(GTK_CONTAINER(dialog), 5);
452          gtk_widget_set_uposition(GTK_WIDGET(dialog), 100, 150);
# Line 248 | Line 461 | static void mn_about(...)
461          gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 0);
462          GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
463          gtk_widget_grab_default(button);
464 +
465 + #endif
466 +
467          gtk_widget_show(dialog);
468   }
469  
# Line 260 | 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 284 | 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 301 | Line 521 | bool PrefsEditor(void)
521          create_input_pane(notebook);
522          create_serial_pane(notebook);
523          create_memory_pane(notebook);
524 +        create_jit_pane(notebook);
525  
526          static const opt_desc buttons[] = {
527                  {STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)},
# Line 329 | Line 550 | static void cl_selected(GtkWidget *list,
550          selected_volume = row;
551   }
552  
332 struct file_req_assoc {
333        file_req_assoc(GtkWidget *r, GtkWidget *e) : req(r), entry(e) {}
334        GtkWidget *req;
335        GtkWidget *entry;
336 };
337
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 347 | 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 423 | Line 638 | static void read_volumes_settings(void)
638                  PrefsAddString("disk", str);
639          }
640  
641 <        PrefsReplaceString("extfs", gtk_entry_get_text(GTK_ENTRY(w_extfs)));
641 >        PrefsReplaceString("extfs", get_file_entry_path(w_extfs));
642   }
643  
644   // Create "Volumes" pane
# Line 444 | Line 659 | static void create_volumes_pane(GtkWidge
659          gtk_signal_connect(GTK_OBJECT(volume_list), "select_row", GTK_SIGNAL_FUNC(cl_selected), NULL);
660          char *str;
661          int32 index = 0;
662 <        while ((str = (char *)PrefsFindString("disk", index++)) != NULL)
662 >        while ((str = const_cast<char *>(PrefsFindString("disk", index++))) != NULL)
663                  gtk_clist_append(GTK_CLIST(volume_list), &str);
664          gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), volume_list);
665          gtk_box_pack_start(GTK_BOX(box), scroll, TRUE, TRUE, 0);
# Line 459 | Line 674 | static void create_volumes_pane(GtkWidge
674          make_button_box(box, 0, buttons);
675          make_separator(box);
676  
677 <        w_extfs = make_entry(box, STR_EXTFS_CTRL, "extfs");
677 >        w_extfs = make_file_entry(box, STR_EXTFS_CTRL, "extfs", true);
678  
679          static const opt_desc options[] = {
680                  {STR_BOOT_ANY_LAB, GTK_SIGNAL_FUNC(mn_boot_any)},
# Line 478 | Line 693 | static void create_volumes_pane(GtkWidge
693  
694  
695   /*
696 + *  "JIT Compiler" pane
697 + */
698 +
699 + 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)
707 + {
708 +        const bool jit_enabled = PrefsFindBool("jit");
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
716 + static void tb_jit(GtkWidget *widget)
717 + {
718 +        PrefsReplaceBool("jit", GTK_TOGGLE_BUTTON(widget)->active);
719 +        set_jit_sensitive();
720 + }
721 +
722 + // "Compile FPU Instructions" button toggled
723 + static void tb_jit_fpu(GtkWidget *widget)
724 + {
725 +        PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active);
726 + }
727 +
728 + // "Lazy translation cache invalidation" button toggled
729 + static void tb_jit_lazy_flush(GtkWidget *widget)
730 + {
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 + {
743 + #if USE_JIT
744 +        bool jit_enabled = PrefsFindBool("jit");
745 +        if (jit_enabled) {
746 +                const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry));
747 +                PrefsReplaceInt32("jitcachesize", atoi(str));
748 +        }
749 + #endif
750 + }
751 +
752 + // Create "JIT Compiler" pane
753 + static void create_jit_pane(GtkWidget *top)
754 + {
755 + #if USE_JIT
756 +        GtkWidget *box, *table, *label, *menu;
757 +        char str[32];
758 +        
759 +        box = make_pane(top, STR_JIT_PANE_TITLE);
760 +        make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit));
761 +        
762 +        w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu));
763 +        
764 +        // Translation cache size
765 +        static const combo_desc options[] = {
766 +                STR_JIT_CACHE_SIZE_2MB_LAB,
767 +                STR_JIT_CACHE_SIZE_4MB_LAB,
768 +                STR_JIT_CACHE_SIZE_8MB_LAB,
769 +                STR_JIT_CACHE_SIZE_16MB_LAB,
770 +                0
771 +        };
772 +        w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options);
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 +
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 + }
783 +
784 + /*
785   *  "SCSI" pane
786   */
787  
# Line 489 | Line 793 | static void read_scsi_settings(void)
793          for (int id=0; id<7; id++) {
794                  char prefs_name[32];
795                  sprintf(prefs_name, "scsi%d", id);
796 <                const char *str = gtk_entry_get_text(GTK_ENTRY(w_scsi[id]));
796 >                const char *str = get_file_entry_path(w_scsi[id]);
797                  if (str && strlen(str))
798                          PrefsReplaceString(prefs_name, str);
799                  else
# Line 507 | Line 811 | static void create_scsi_pane(GtkWidget *
811          for (int id=0; id<7; id++) {
812                  char prefs_name[32];
813                  sprintf(prefs_name, "scsi%d", id);
814 <                w_scsi[id] = make_entry(box, STR_SCSI_ID_0 + id, prefs_name);
814 >                w_scsi[id] = make_file_entry(box, STR_SCSI_ID_0 + id, prefs_name);
815          }
816   }
817  
# Line 533 | Line 837 | static GtkWidget *l_fbdev_name, *l_fbdev
837   static char fbdev_name[256];
838   #endif
839  
840 + static GtkWidget *w_dspdevice_file, *w_mixerdevice_file;
841 +
842   // Hide/show graphics widgets
843   static void hide_show_graphics_widgets(void)
844   {
# Line 579 | Line 885 | static void mn_30hz(...) {PrefsReplaceIn
885   static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);}
886   static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);}
887  
888 + // Set sensitivity of widgets
889 + static void set_graphics_sensitive(void)
890 + {
891 +        const bool sound_enabled = !PrefsFindBool("nosound");
892 +        gtk_widget_set_sensitive(w_dspdevice_file, sound_enabled);
893 +        gtk_widget_set_sensitive(w_mixerdevice_file, sound_enabled);
894 + }
895 +
896   // "Disable Sound Output" button toggled
897   static void tb_nosound(GtkWidget *widget)
898   {
899          PrefsReplaceBool("nosound", GTK_TOGGLE_BUTTON(widget)->active);
900 +        set_graphics_sensitive();
901   }
902  
903   // Read graphics preferences
# Line 637 | Line 952 | static void read_graphics_settings(void)
952                          return;
953          }
954          PrefsReplaceString("screen", pref);
955 +
956 + #ifdef ENABLE_FBDEV_DGA
957 +        str = get_file_entry_path(w_fbdevice_file);
958 +        if (str && strlen(str))
959 +                PrefsReplaceString("fbdevicefile", str);
960 +        else
961 +                PrefsRemoveItem("fbdevicefile");
962 + #endif
963 +        PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file));
964 +        PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file));
965   }
966  
967   // Create "Graphics/Sound" pane
# Line 752 | Line 1077 | static void create_graphics_pane(GtkWidg
1077          gtk_entry_set_text(GTK_ENTRY(w_fbdev_name), fbdev_name);
1078          gtk_table_attach(GTK_TABLE(table), w_fbdev_name, 1, 2, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1079  
1080 <        w_fbdevice_file = make_entry(box, STR_FBDEVICE_FILE_CTRL, "fbdevicefile");
1080 >        w_fbdevice_file = make_file_entry(box, STR_FBDEVICE_FILE_CTRL, "fbdevicefile");
1081   #endif
1082  
1083          make_separator(box);
1084          make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound));
1085 +        w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp");
1086 +        w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer");
1087 +
1088 +        set_graphics_sensitive();
1089  
1090          hide_show_graphics_widgets();
1091   }
# Line 772 | 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 790 | Line 1121 | static void mn_wheel_cursor(...) {PrefsR
1121   // Read settings from widgets and set preferences
1122   static void read_input_settings(void)
1123   {
1124 <        const char *str = gtk_entry_get_text(GTK_ENTRY(w_keycode_file));
1124 >        const char *str = get_file_entry_path(w_keycode_file);
1125          if (str && strlen(str))
1126                  PrefsReplaceString("keycodefile", str);
1127          else
# Line 802 | 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_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 845 | Line 1196 | static void create_input_pane(GtkWidget
1196   *  "Serial/Network" pane
1197   */
1198  
1199 < static GtkWidget *w_seriala, *w_serialb, *w_ether;
1199 > static GtkWidget *w_seriala, *w_serialb, *w_ether, *w_udp_port;
1200 >
1201 > // Set sensitivity of widgets
1202 > static void set_serial_sensitive(void)
1203 > {
1204 > #if SUPPORTS_UDP_TUNNEL
1205 >        gtk_widget_set_sensitive(w_ether, !PrefsFindBool("udptunnel"));
1206 >        gtk_widget_set_sensitive(w_udp_port, PrefsFindBool("udptunnel"));
1207 > #endif
1208 > }
1209 >
1210 > // "Tunnel AppleTalk over IP" button toggled
1211 > static void tb_udptunnel(GtkWidget *widget)
1212 > {
1213 >        PrefsReplaceBool("udptunnel", GTK_TOGGLE_BUTTON(widget)->active);
1214 >        set_serial_sensitive();
1215 > }
1216  
1217   // Read settings from widgets and set preferences
1218   static void read_serial_settings(void)
# Line 863 | Line 1230 | static void read_serial_settings(void)
1230                  PrefsReplaceString("ether", str);
1231          else
1232                  PrefsRemoveItem("ether");
1233 +
1234 + #if SUPPORTS_UDP_TUNNEL
1235 +        PrefsReplaceInt32("udpport", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w_udp_port)));
1236 + #endif
1237   }
1238  
1239   // Add names of serial devices
# Line 936 | 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 946 | Line 1321 | static GList *add_ether_names(void)
1321   // Create "Serial/Network" pane
1322   static void create_serial_pane(GtkWidget *top)
1323   {
1324 <        GtkWidget *box, *table, *label, *combo, *sep;
1325 <        GList *glist = add_serial_names();
1324 >        GtkWidget *box, *hbox, *table, *label, *combo, *sep;
1325 >        GtkObject *adj;
1326  
1327          box = make_pane(top, STR_SERIAL_NETWORK_PANE_TITLE);
1328          table = make_table(box, 2, 4);
# Line 956 | Line 1331 | static void create_serial_pane(GtkWidget
1331          gtk_widget_show(label);
1332          gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1333  
1334 +        GList *glist = add_serial_names();
1335          combo = gtk_combo_new();
1336          gtk_widget_show(combo);
1337          gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
# Line 998 | Line 1374 | static void create_serial_pane(GtkWidget
1374          gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
1375          gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1376          w_ether = GTK_COMBO(combo)->entry;
1377 +
1378 + #if SUPPORTS_UDP_TUNNEL
1379 +        make_checkbox(box, STR_UDPTUNNEL_CTRL, "udptunnel", GTK_SIGNAL_FUNC(tb_udptunnel));
1380 +
1381 +        hbox = gtk_hbox_new(FALSE, 4);
1382 +        gtk_widget_show(hbox);
1383 +        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1384 +
1385 +        label = gtk_label_new(GetString(STR_UDPPORT_CTRL));
1386 +        gtk_widget_show(label);
1387 +        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1388 +
1389 +        adj = gtk_adjustment_new(PrefsFindInt32("udpport"), 1, 65535, 1, 5, 0);
1390 +        w_udp_port = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
1391 +        gtk_widget_show(w_udp_port);
1392 +        gtk_box_pack_start(GTK_BOX(hbox), w_udp_port, FALSE, FALSE, 0);
1393 + #endif
1394 +
1395 +        set_serial_sensitive();
1396   }
1397  
1398  
# Line 1005 | 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
1407 + #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1408 + static void tb_ignoresegv(GtkWidget *widget)
1409 + {
1410 +        PrefsReplaceBool("ignoresegv", GTK_TOGGLE_BUTTON(widget)->active);
1411 + }
1412 + #endif
1413 +
1414   // Model ID selected
1415   static void mn_modelid_5(...) {PrefsReplaceInt32("modelid", 5);}
1416   static void mn_modelid_14(...) {PrefsReplaceInt32("modelid", 14);}
# Line 1022 | 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 = gtk_entry_get_text(GTK_ENTRY(w_rom_file));
1431 >        str = get_file_entry_path(w_rom_file);
1432          if (str && strlen(str))
1433                  PrefsReplaceString("rom", str);
1434          else
# Line 1035 | 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, *menu;
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 <
1058 <        scale = gtk_hscale_new(GTK_ADJUSTMENT(w_ramsize_adj));
1059 <        gtk_widget_show(scale);
1060 <        gtk_scale_set_digits(GTK_SCALE(scale), 0);
1061 <        gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0);
1062 <
1063 <        hbox2 = gtk_hbox_new(FALSE, 4);
1064 <        gtk_widget_show(hbox2);
1065 <
1066 <        char val[32];
1067 <        sprintf(val, GetString(STR_RAMSIZE_FMT), int(min));
1068 <        label = gtk_label_new(val);
1069 <        gtk_widget_show(label);
1070 <        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1071 <
1072 <        sprintf(val, GetString(STR_RAMSIZE_FMT), int(max));
1073 <        label = gtk_label_new(val);
1074 <        gtk_widget_show(label);
1075 <        gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1076 <        gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
1077 <        gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
1078 <        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 1087 | 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 1106 | 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_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));
1500 > #endif
1501   }
1502  
1503  
# Line 1125 | Line 1513 | static void read_settings(void)
1513          read_input_settings();
1514          read_serial_settings();
1515          read_memory_settings();
1516 +        read_jit_settings();
1517   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines