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 |
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 |
|
|
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)); |
189 |
|
return entry; |
190 |
|
} |
191 |
|
|
192 |
< |
static char *get_file_entry_path(GtkWidget *entry) |
192 |
> |
static const gchar *get_file_entry_path(GtkWidget *entry) |
193 |
|
{ |
194 |
|
#ifdef HAVE_GNOMEUI |
195 |
|
return gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(entry), false); |
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 |
306 |
|
dialog = gnome_about_new( |
307 |
|
"Basilisk II", |
308 |
|
version, |
309 |
< |
"Copyright (C) 1997-2002 Christian Bauer", |
309 |
> |
"Copyright (C) 1997-2004 Christian Bauer", |
310 |
|
authors, |
311 |
|
"Basilisk II comes with ABSOLUTELY NO WARRANTY." |
312 |
|
"This is free software, and you are welcome to redistribute it" |
322 |
|
char str[512]; |
323 |
|
sprintf(str, |
324 |
|
"Basilisk II\nVersion %d.%d\n\n" |
325 |
< |
"Copyright (C) 1997-2002 Christian Bauer et al.\n" |
325 |
> |
"Copyright (C) 1997-2004 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" |
387 |
|
GtkAccelGroup *accel_group = gtk_accel_group_new(); |
388 |
|
GtkItemFactory *item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); |
389 |
|
gtk_item_factory_create_items(item_factory, sizeof(menu_items) / sizeof(menu_items[0]), menu_items, NULL); |
390 |
+ |
#if GTK_CHECK_VERSION(1,3,15) |
391 |
+ |
gtk_window_add_accel_group(GTK_WINDOW(win), accel_group); |
392 |
+ |
#else |
393 |
|
gtk_accel_group_attach(accel_group, GTK_OBJECT(win)); |
394 |
+ |
#endif |
395 |
|
GtkWidget *menu_bar = gtk_item_factory_get_widget(item_factory, "<main>"); |
396 |
|
gtk_widget_show(menu_bar); |
397 |
|
gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, TRUE, 0); |
408 |
|
create_input_pane(notebook); |
409 |
|
create_serial_pane(notebook); |
410 |
|
create_memory_pane(notebook); |
411 |
+ |
create_jit_pane(notebook); |
412 |
|
|
413 |
|
static const opt_desc buttons[] = { |
414 |
|
{STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, |
446 |
|
// Volume selected for addition |
447 |
|
static void add_volume_ok(GtkWidget *button, file_req_assoc *assoc) |
448 |
|
{ |
449 |
< |
char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
449 |
> |
gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
450 |
|
gtk_clist_append(GTK_CLIST(volume_list), &file); |
451 |
|
gtk_widget_destroy(assoc->req); |
452 |
|
delete assoc; |
455 |
|
// Volume selected for creation |
456 |
|
static void create_volume_ok(GtkWidget *button, file_req_assoc *assoc) |
457 |
|
{ |
458 |
< |
char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
458 |
> |
gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
459 |
|
|
460 |
< |
char *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); |
460 |
> |
const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); |
461 |
|
int size = atoi(str); |
462 |
|
|
463 |
|
char cmd[1024]; |
586 |
|
|
587 |
|
|
588 |
|
/* |
589 |
+ |
* "JIT Compiler" pane |
590 |
+ |
*/ |
591 |
+ |
|
592 |
+ |
static GtkWidget *w_jit_fpu; |
593 |
+ |
static GtkWidget *w_jit_atraps; |
594 |
+ |
static GtkWidget *w_jit_cache_size; |
595 |
+ |
static GtkWidget *w_jit_lazy_flush; |
596 |
+ |
static GtkWidget *w_jit_follow_const_jumps; |
597 |
+ |
|
598 |
+ |
// Set sensitivity of widgets |
599 |
+ |
static void set_jit_sensitive(void) |
600 |
+ |
{ |
601 |
+ |
const bool jit_enabled = PrefsFindBool("jit"); |
602 |
+ |
gtk_widget_set_sensitive(w_jit_fpu, jit_enabled); |
603 |
+ |
gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled); |
604 |
+ |
gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled); |
605 |
+ |
gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled); |
606 |
+ |
} |
607 |
+ |
|
608 |
+ |
// "Use JIT Compiler" button toggled |
609 |
+ |
static void tb_jit(GtkWidget *widget) |
610 |
+ |
{ |
611 |
+ |
PrefsReplaceBool("jit", GTK_TOGGLE_BUTTON(widget)->active); |
612 |
+ |
set_jit_sensitive(); |
613 |
+ |
} |
614 |
+ |
|
615 |
+ |
// "Compile FPU Instructions" button toggled |
616 |
+ |
static void tb_jit_fpu(GtkWidget *widget) |
617 |
+ |
{ |
618 |
+ |
PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active); |
619 |
+ |
} |
620 |
+ |
|
621 |
+ |
// "Lazy translation cache invalidation" button toggled |
622 |
+ |
static void tb_jit_lazy_flush(GtkWidget *widget) |
623 |
+ |
{ |
624 |
+ |
PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active); |
625 |
+ |
} |
626 |
+ |
|
627 |
+ |
// "Translate through constant jumps (inline blocks)" button toggled |
628 |
+ |
static void tb_jit_follow_const_jumps(GtkWidget *widget) |
629 |
+ |
{ |
630 |
+ |
PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active); |
631 |
+ |
} |
632 |
+ |
|
633 |
+ |
// Read settings from widgets and set preferences |
634 |
+ |
static void read_jit_settings(void) |
635 |
+ |
{ |
636 |
+ |
#if USE_JIT |
637 |
+ |
bool jit_enabled = PrefsFindBool("jit"); |
638 |
+ |
if (jit_enabled) { |
639 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry)); |
640 |
+ |
PrefsReplaceInt32("jitcachesize", atoi(str)); |
641 |
+ |
} |
642 |
+ |
#endif |
643 |
+ |
} |
644 |
+ |
|
645 |
+ |
// Create "JIT Compiler" pane |
646 |
+ |
static void create_jit_pane(GtkWidget *top) |
647 |
+ |
{ |
648 |
+ |
#if USE_JIT |
649 |
+ |
GtkWidget *box, *table, *label, *menu; |
650 |
+ |
char str[32]; |
651 |
+ |
|
652 |
+ |
box = make_pane(top, STR_JIT_PANE_TITLE); |
653 |
+ |
make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit)); |
654 |
+ |
|
655 |
+ |
w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu)); |
656 |
+ |
|
657 |
+ |
// Translation cache size |
658 |
+ |
static const combo_desc options[] = { |
659 |
+ |
STR_JIT_CACHE_SIZE_2MB_LAB, |
660 |
+ |
STR_JIT_CACHE_SIZE_4MB_LAB, |
661 |
+ |
STR_JIT_CACHE_SIZE_8MB_LAB, |
662 |
+ |
STR_JIT_CACHE_SIZE_16MB_LAB, |
663 |
+ |
0 |
664 |
+ |
}; |
665 |
+ |
w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options); |
666 |
+ |
|
667 |
+ |
// Lazy translation cache invalidation |
668 |
+ |
w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush)); |
669 |
+ |
|
670 |
+ |
// Follow constant jumps (inline basic blocks) |
671 |
+ |
w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps)); |
672 |
+ |
|
673 |
+ |
set_jit_sensitive(); |
674 |
+ |
#endif |
675 |
+ |
} |
676 |
+ |
|
677 |
+ |
/* |
678 |
|
* "SCSI" pane |
679 |
|
*/ |
680 |
|
|
730 |
|
static char fbdev_name[256]; |
731 |
|
#endif |
732 |
|
|
733 |
+ |
static GtkWidget *w_dspdevice_file, *w_mixerdevice_file; |
734 |
+ |
|
735 |
|
// Hide/show graphics widgets |
736 |
|
static void hide_show_graphics_widgets(void) |
737 |
|
{ |
778 |
|
static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);} |
779 |
|
static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);} |
780 |
|
|
781 |
+ |
// Set sensitivity of widgets |
782 |
+ |
static void set_graphics_sensitive(void) |
783 |
+ |
{ |
784 |
+ |
const bool sound_enabled = !PrefsFindBool("nosound"); |
785 |
+ |
gtk_widget_set_sensitive(w_dspdevice_file, sound_enabled); |
786 |
+ |
gtk_widget_set_sensitive(w_mixerdevice_file, sound_enabled); |
787 |
+ |
} |
788 |
+ |
|
789 |
|
// "Disable Sound Output" button toggled |
790 |
|
static void tb_nosound(GtkWidget *widget) |
791 |
|
{ |
792 |
|
PrefsReplaceBool("nosound", GTK_TOGGLE_BUTTON(widget)->active); |
793 |
+ |
set_graphics_sensitive(); |
794 |
|
} |
795 |
|
|
796 |
|
// Read graphics preferences |
853 |
|
else |
854 |
|
PrefsRemoveItem("fbdevicefile"); |
855 |
|
#endif |
856 |
+ |
PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file)); |
857 |
+ |
PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file)); |
858 |
|
} |
859 |
|
|
860 |
|
// Create "Graphics/Sound" pane |
975 |
|
|
976 |
|
make_separator(box); |
977 |
|
make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound)); |
978 |
+ |
w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp"); |
979 |
+ |
w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer"); |
980 |
+ |
|
981 |
+ |
set_graphics_sensitive(); |
982 |
|
|
983 |
|
hide_show_graphics_widgets(); |
984 |
|
} |
1178 |
|
} |
1179 |
|
close(s); |
1180 |
|
} |
1181 |
+ |
#ifdef HAVE_SLIRP |
1182 |
+ |
static char s_slirp[] = "slirp"; |
1183 |
+ |
glist = g_list_append(glist, s_slirp); |
1184 |
+ |
#endif |
1185 |
|
if (glist) |
1186 |
|
g_list_sort(glist, gl_str_cmp); |
1187 |
|
else |
1274 |
|
static GtkObject *w_ramsize_adj; |
1275 |
|
static GtkWidget *w_rom_file; |
1276 |
|
|
1277 |
+ |
// "Ignore SEGV" button toggled |
1278 |
+ |
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1279 |
+ |
static void tb_ignoresegv(GtkWidget *widget) |
1280 |
+ |
{ |
1281 |
+ |
PrefsReplaceBool("ignoresegv", GTK_TOGGLE_BUTTON(widget)->active); |
1282 |
+ |
} |
1283 |
+ |
#endif |
1284 |
+ |
|
1285 |
|
// Model ID selected |
1286 |
|
static void mn_modelid_5(...) {PrefsReplaceInt32("modelid", 5);} |
1287 |
|
static void mn_modelid_14(...) {PrefsReplaceInt32("modelid", 14);} |
1384 |
|
#endif |
1385 |
|
|
1386 |
|
w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom"); |
1387 |
+ |
|
1388 |
+ |
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1389 |
+ |
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1390 |
+ |
#endif |
1391 |
|
} |
1392 |
|
|
1393 |
|
|
1403 |
|
read_input_settings(); |
1404 |
|
read_serial_settings(); |
1405 |
|
read_memory_settings(); |
1406 |
+ |
read_jit_settings(); |
1407 |
|
} |