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.19 by cebix, 2002-01-15T14:58:37Z vs.
Revision 1.24 by cebix, 2002-10-15T16:25:04Z

# 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   static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func)
73   {
74          GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id));
# Line 150 | Line 159 | static GtkWidget *make_option_menu(GtkWi
159          return menu;
160   }
161  
162 < static GtkWidget *make_entry(GtkWidget *top, int label_id, const char *prefs_item)
162 > static GtkWidget *make_file_entry(GtkWidget *top, int label_id, const char *prefs_item, bool only_dirs = false)
163   {
164          GtkWidget *box, *label, *entry;
165  
# Line 162 | Line 171 | static GtkWidget *make_entry(GtkWidget *
171          gtk_widget_show(label);
172          gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
173  
165        entry = gtk_entry_new();
166        gtk_widget_show(entry);
174          const char *str = PrefsFindString(prefs_item);
175          if (str == NULL)
176                  str = "";
177 +
178 + #ifdef HAVE_GNOMEUI
179 +        entry = gnome_file_entry_new(NULL, GetString(label_id));
180 +        if (only_dirs)
181 +                gnome_file_entry_set_directory(GNOME_FILE_ENTRY(entry), true);
182 +        gtk_entry_set_text(GTK_ENTRY(gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(entry))), str);
183 + #else
184 +        entry = gtk_entry_new();
185          gtk_entry_set_text(GTK_ENTRY(entry), str);
186 + #endif
187 +        gtk_widget_show(entry);
188          gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
189          return entry;
190   }
191  
192 + static char *get_file_entry_path(GtkWidget *entry)
193 + {
194 + #ifdef HAVE_GNOMEUI
195 +        return gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(entry), false);
196 + #else
197 +        return gtk_entry_get_text(GTK_ENTRY(entry));
198 + #endif
199 + }
200 +
201   static GtkWidget *make_checkbox(GtkWidget *top, int label_id, const char *prefs_item, GtkSignalFunc func)
202   {
203          GtkWidget *button = gtk_check_button_new_with_label(GetString(label_id));
# Line 182 | Line 208 | static GtkWidget *make_checkbox(GtkWidge
208          return button;
209   }
210  
211 + static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options)
212 + {
213 +        GtkWidget *box, *label, *combo;
214 +        char str[32];
215 +
216 +        box = gtk_hbox_new(FALSE, 4);
217 +        gtk_widget_show(box);
218 +        gtk_box_pack_start(GTK_BOX(top), box, FALSE, FALSE, 0);
219 +
220 +        label = gtk_label_new(GetString(label_id));
221 +        gtk_widget_show(label);
222 +        gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
223  
224 +        GList *glist = NULL;
225 +        while (options->label_id) {
226 +                glist = g_list_append(glist, (void *)GetString(options->label_id));
227 +                options++;
228 +        }
229 +        
230 +        combo = gtk_combo_new();
231 +        gtk_widget_show(combo);
232 +        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
233 +        
234 +        sprintf(str, "%d", PrefsFindInt32(prefs_item));
235 +        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
236 +        gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0);
237 +        
238 +        return combo;
239 + }
240 +
241 +
242   /*
243   *  Show preferences editor
244   *  Returns true when user clicked on "Start", false otherwise
# Line 225 | Line 281 | static void dl_quit(GtkWidget *dialog)
281   // "About" selected
282   static void mn_about(...)
283   {
284 <        GtkWidget *dialog, *label, *button;
284 >        GtkWidget *dialog;
285 >
286 > #ifdef HAVE_GNOMEUI
287 >
288 >        char version[32];
289 >        sprintf(version, "Version %d.%d", VERSION_MAJOR, VERSION_MINOR);
290 >        const char *authors[] = {
291 >                "Christian Bauer",
292 >                "Orlando Bassotto",
293 >                "Gwenolé Beauchesne",
294 >                "Marc Chabanas",
295 >                "Marc Hellwig",
296 >                "Biill Huey",
297 >                "Brian J. Johnson",
298 >                "Jürgen Lachmann",
299 >                "Samuel Lander",
300 >                "David Lawrence",
301 >                "Lauri Pesonen",
302 >                "Bernd Schmidt",
303 >                "and others",
304 >                NULL
305 >        };
306 >        dialog = gnome_about_new(
307 >                "Basilisk II",
308 >                version,
309 >                "Copyright (C) 1997-2002 Christian Bauer",
310 >                authors,
311 >                "Basilisk II comes with ABSOLUTELY NO WARRANTY."
312 >                "This is free software, and you are welcome to redistribute it"
313 >                "under the terms of the GNU General Public License.",
314 >                NULL
315 >        );
316 >        gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(win));
317 >
318 > #else
319 >
320 >        GtkWidget *label, *button;
321  
322          char str[512];
323          sprintf(str,
324                  "Basilisk II\nVersion %d.%d\n\n"
325 <                "Copyright (C) 1997-2001 Christian Bauer et al.\n"
325 >                "Copyright (C) 1997-2002 Christian Bauer et al.\n"
326                  "E-mail: Christian.Bauer@uni-mainz.de\n"
327                  "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n"
328                  "Basilisk II comes with ABSOLUTELY NO\n"
# Line 256 | Line 348 | static void mn_about(...)
348          gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 0);
349          GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
350          gtk_widget_grab_default(button);
351 +
352 + #endif
353 +
354          gtk_widget_show(dialog);
355   }
356  
# Line 309 | Line 404 | bool PrefsEditor(void)
404          create_input_pane(notebook);
405          create_serial_pane(notebook);
406          create_memory_pane(notebook);
407 +        create_jit_pane(notebook);
408  
409          static const opt_desc buttons[] = {
410                  {STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)},
# Line 431 | Line 527 | static void read_volumes_settings(void)
527                  PrefsAddString("disk", str);
528          }
529  
530 <        PrefsReplaceString("extfs", gtk_entry_get_text(GTK_ENTRY(w_extfs)));
530 >        PrefsReplaceString("extfs", get_file_entry_path(w_extfs));
531   }
532  
533   // Create "Volumes" pane
# Line 452 | Line 548 | static void create_volumes_pane(GtkWidge
548          gtk_signal_connect(GTK_OBJECT(volume_list), "select_row", GTK_SIGNAL_FUNC(cl_selected), NULL);
549          char *str;
550          int32 index = 0;
551 <        while ((str = (char *)PrefsFindString("disk", index++)) != NULL)
551 >        while ((str = const_cast<char *>(PrefsFindString("disk", index++))) != NULL)
552                  gtk_clist_append(GTK_CLIST(volume_list), &str);
553          gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), volume_list);
554          gtk_box_pack_start(GTK_BOX(box), scroll, TRUE, TRUE, 0);
# Line 467 | Line 563 | static void create_volumes_pane(GtkWidge
563          make_button_box(box, 0, buttons);
564          make_separator(box);
565  
566 <        w_extfs = make_entry(box, STR_EXTFS_CTRL, "extfs");
566 >        w_extfs = make_file_entry(box, STR_EXTFS_CTRL, "extfs", true);
567  
568          static const opt_desc options[] = {
569                  {STR_BOOT_ANY_LAB, GTK_SIGNAL_FUNC(mn_boot_any)},
# Line 486 | Line 582 | static void create_volumes_pane(GtkWidge
582  
583  
584   /*
585 + *  "JIT Compiler" pane
586 + */
587 +
588 + static GtkWidget *w_jit_fpu;
589 + static GtkWidget *w_jit_atraps;
590 + static GtkWidget *w_jit_cache_size;
591 + static GtkWidget *w_jit_lazy_flush;
592 +
593 + // Set sensitivity of widgets
594 + static void set_jit_sensitive(void)
595 + {
596 +        const bool jit_enabled = PrefsFindBool("jit");
597 +        gtk_widget_set_sensitive(w_jit_fpu, jit_enabled);
598 +        gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled);
599 +        gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled);
600 + }
601 +
602 + // "Use JIT Compiler" button toggled
603 + static void tb_jit(GtkWidget *widget)
604 + {
605 +        PrefsReplaceBool("jit", GTK_TOGGLE_BUTTON(widget)->active);
606 +        set_jit_sensitive();
607 + }
608 +
609 + // "Compile FPU Instructions" button toggled
610 + static void tb_jit_fpu(GtkWidget *widget)
611 + {
612 +        PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active);
613 + }
614 +
615 + // "Lazy translation cache invalidation" button toggled
616 + static void tb_jit_lazy_flush(GtkWidget *widget)
617 + {
618 +        PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active);
619 + }
620 +
621 + // Read settings from widgets and set preferences
622 + static void read_jit_settings(void)
623 + {
624 + #if USE_JIT
625 +        bool jit_enabled = PrefsFindBool("jit");
626 +        if (jit_enabled) {
627 +                const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry));
628 +                PrefsReplaceInt32("jitcachesize", atoi(str));
629 +        }
630 + #endif
631 + }
632 +
633 + // Create "JIT Compiler" pane
634 + static void create_jit_pane(GtkWidget *top)
635 + {
636 + #if USE_JIT
637 +        GtkWidget *box, *table, *label, *menu;
638 +        char str[32];
639 +        
640 +        box = make_pane(top, STR_JIT_PANE_TITLE);
641 +        make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit));
642 +        
643 +        w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu));
644 +        
645 +        // Translation cache size
646 +        static const combo_desc options[] = {
647 +                STR_JIT_CACHE_SIZE_2MB_LAB,
648 +                STR_JIT_CACHE_SIZE_4MB_LAB,
649 +                STR_JIT_CACHE_SIZE_8MB_LAB,
650 +                STR_JIT_CACHE_SIZE_16MB_LAB,
651 +                0
652 +        };
653 +        w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options);
654 +        
655 +        // Lazy translation cache invalidation
656 +        w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush));
657 +        
658 +        set_jit_sensitive();
659 + #endif
660 + }
661 +
662 + /*
663   *  "SCSI" pane
664   */
665  
# Line 497 | Line 671 | static void read_scsi_settings(void)
671          for (int id=0; id<7; id++) {
672                  char prefs_name[32];
673                  sprintf(prefs_name, "scsi%d", id);
674 <                const char *str = gtk_entry_get_text(GTK_ENTRY(w_scsi[id]));
674 >                const char *str = get_file_entry_path(w_scsi[id]);
675                  if (str && strlen(str))
676                          PrefsReplaceString(prefs_name, str);
677                  else
# Line 515 | Line 689 | static void create_scsi_pane(GtkWidget *
689          for (int id=0; id<7; id++) {
690                  char prefs_name[32];
691                  sprintf(prefs_name, "scsi%d", id);
692 <                w_scsi[id] = make_entry(box, STR_SCSI_ID_0 + id, prefs_name);
692 >                w_scsi[id] = make_file_entry(box, STR_SCSI_ID_0 + id, prefs_name);
693          }
694   }
695  
# Line 541 | Line 715 | static GtkWidget *l_fbdev_name, *l_fbdev
715   static char fbdev_name[256];
716   #endif
717  
718 + static GtkWidget *w_dspdevice_file, *w_mixerdevice_file;
719 +
720   // Hide/show graphics widgets
721   static void hide_show_graphics_widgets(void)
722   {
# Line 587 | Line 763 | static void mn_30hz(...) {PrefsReplaceIn
763   static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);}
764   static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);}
765  
766 + // Set sensitivity of widgets
767 + static void set_graphics_sensitive(void)
768 + {
769 +        const bool sound_enabled = !PrefsFindBool("nosound");
770 +        gtk_widget_set_sensitive(w_dspdevice_file, sound_enabled);
771 +        gtk_widget_set_sensitive(w_mixerdevice_file, sound_enabled);
772 + }
773 +
774   // "Disable Sound Output" button toggled
775   static void tb_nosound(GtkWidget *widget)
776   {
777          PrefsReplaceBool("nosound", GTK_TOGGLE_BUTTON(widget)->active);
778 +        set_graphics_sensitive();
779   }
780  
781   // Read graphics preferences
# Line 645 | Line 830 | static void read_graphics_settings(void)
830                          return;
831          }
832          PrefsReplaceString("screen", pref);
833 +
834 + #ifdef ENABLE_FBDEV_DGA
835 +        str = get_file_entry_path(w_fbdevice_file);
836 +        if (str && strlen(str))
837 +                PrefsReplaceString("fbdevicefile", str);
838 +        else
839 +                PrefsRemoveItem("fbdevicefile");
840 + #endif
841 +        PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file));
842 +        PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file));
843   }
844  
845   // Create "Graphics/Sound" pane
# Line 760 | Line 955 | static void create_graphics_pane(GtkWidg
955          gtk_entry_set_text(GTK_ENTRY(w_fbdev_name), fbdev_name);
956          gtk_table_attach(GTK_TABLE(table), w_fbdev_name, 1, 2, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
957  
958 <        w_fbdevice_file = make_entry(box, STR_FBDEVICE_FILE_CTRL, "fbdevicefile");
958 >        w_fbdevice_file = make_file_entry(box, STR_FBDEVICE_FILE_CTRL, "fbdevicefile");
959   #endif
960  
961          make_separator(box);
962          make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound));
963 +        w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp");
964 +        w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer");
965 +
966 +        set_graphics_sensitive();
967  
968          hide_show_graphics_widgets();
969   }
# Line 798 | Line 997 | static void mn_wheel_cursor(...) {PrefsR
997   // Read settings from widgets and set preferences
998   static void read_input_settings(void)
999   {
1000 <        const char *str = gtk_entry_get_text(GTK_ENTRY(w_keycode_file));
1000 >        const char *str = get_file_entry_path(w_keycode_file);
1001          if (str && strlen(str))
1002                  PrefsReplaceString("keycodefile", str);
1003          else
# Line 816 | Line 1015 | static void create_input_pane(GtkWidget
1015          box = make_pane(top, STR_INPUT_PANE_TITLE);
1016  
1017          make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
1018 <        w_keycode_file = make_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
1018 >        w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
1019  
1020          make_separator(box);
1021  
# Line 1056 | Line 1255 | static void create_serial_pane(GtkWidget
1255   static GtkObject *w_ramsize_adj;
1256   static GtkWidget *w_rom_file;
1257  
1258 + // "Ignore SEGV" button toggled
1259 + #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1260 + static void tb_ignoresegv(GtkWidget *widget)
1261 + {
1262 +        PrefsReplaceBool("ignoresegv", GTK_TOGGLE_BUTTON(widget)->active);
1263 + }
1264 + #endif
1265 +
1266   // Model ID selected
1267   static void mn_modelid_5(...) {PrefsReplaceInt32("modelid", 5);}
1268   static void mn_modelid_14(...) {PrefsReplaceInt32("modelid", 14);}
# Line 1072 | Line 1279 | static void read_memory_settings(void)
1279   {
1280          PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20);
1281  
1282 <        const char *str = gtk_entry_get_text(GTK_ENTRY(w_rom_file));
1282 >        const char *str = get_file_entry_path(w_rom_file);
1283          if (str && strlen(str))
1284                  PrefsReplaceString("rom", str);
1285          else
# Line 1157 | Line 1364 | static void create_memory_pane(GtkWidget
1364          make_option_menu(box, STR_CPU_CTRL, cpu_options, active);
1365   #endif
1366  
1367 <        w_rom_file = make_entry(box, STR_ROM_FILE_CTRL, "rom");
1367 >        w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom");
1368 >
1369 > #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1370 >        make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv));
1371 > #endif
1372   }
1373  
1374  
# Line 1173 | Line 1384 | static void read_settings(void)
1384          read_input_settings();
1385          read_serial_settings();
1386          read_memory_settings();
1387 +        read_jit_settings();
1388   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines