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 |
60 |
|
* Utility functions |
61 |
|
*/ |
62 |
|
|
63 |
+ |
#if ! GLIB_CHECK_VERSION(2,0,0) |
64 |
+ |
#define G_OBJECT(obj) GTK_OBJECT(obj) |
65 |
+ |
#define g_object_get_data(obj, key) gtk_object_get_data((obj), (key)) |
66 |
+ |
#define g_object_set_data(obj, key, data) gtk_object_set_data((obj), (key), (data)) |
67 |
+ |
#endif |
68 |
+ |
|
69 |
|
struct opt_desc { |
70 |
|
int label_id; |
71 |
|
GtkSignalFunc func; |
75 |
|
int label_id; |
76 |
|
}; |
77 |
|
|
78 |
+ |
struct file_req_assoc { |
79 |
+ |
file_req_assoc(GtkWidget *r, GtkWidget *e) : req(r), entry(e) {} |
80 |
+ |
GtkWidget *req; |
81 |
+ |
GtkWidget *entry; |
82 |
+ |
}; |
83 |
+ |
|
84 |
+ |
static void cb_browse_ok(GtkWidget *button, file_req_assoc *assoc) |
85 |
+ |
{ |
86 |
+ |
gchar *file = (char *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
87 |
+ |
gtk_entry_set_text(GTK_ENTRY(assoc->entry), file); |
88 |
+ |
gtk_widget_destroy(assoc->req); |
89 |
+ |
delete assoc; |
90 |
+ |
} |
91 |
+ |
|
92 |
+ |
static void cb_browse(GtkWidget *widget, void *user_data) |
93 |
+ |
{ |
94 |
+ |
GtkWidget *req = gtk_file_selection_new(GetString(STR_BROWSE_TITLE)); |
95 |
+ |
gtk_signal_connect_object(GTK_OBJECT(req), "delete_event", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(req)); |
96 |
+ |
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)); |
97 |
+ |
gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(req)->cancel_button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(req)); |
98 |
+ |
gtk_widget_show(req); |
99 |
+ |
} |
100 |
+ |
|
101 |
+ |
static GtkWidget *make_browse_button(GtkWidget *entry) |
102 |
+ |
{ |
103 |
+ |
GtkWidget *button; |
104 |
+ |
|
105 |
+ |
button = gtk_button_new_with_label(GetString(STR_BROWSE_CTRL)); |
106 |
+ |
gtk_widget_show(button); |
107 |
+ |
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)cb_browse, (void *)entry); |
108 |
+ |
return button; |
109 |
+ |
} |
110 |
+ |
|
111 |
|
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) |
112 |
|
{ |
113 |
|
GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id)); |
171 |
|
return table; |
172 |
|
} |
173 |
|
|
174 |
+ |
static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active) |
175 |
+ |
{ |
176 |
+ |
GtkWidget *label, *opt, *menu; |
177 |
+ |
|
178 |
+ |
label = gtk_label_new(GetString(label_id)); |
179 |
+ |
gtk_widget_show(label); |
180 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
181 |
+ |
|
182 |
+ |
opt = gtk_option_menu_new(); |
183 |
+ |
gtk_widget_show(opt); |
184 |
+ |
menu = gtk_menu_new(); |
185 |
+ |
|
186 |
+ |
while (options->label_id) { |
187 |
+ |
add_menu_item(menu, options->label_id, options->func); |
188 |
+ |
options++; |
189 |
+ |
} |
190 |
+ |
gtk_menu_set_active(GTK_MENU(menu), active); |
191 |
+ |
|
192 |
+ |
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); |
193 |
+ |
gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
194 |
+ |
return menu; |
195 |
+ |
} |
196 |
+ |
|
197 |
+ |
static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist) |
198 |
+ |
{ |
199 |
+ |
GtkWidget *label, *combo; |
200 |
+ |
char str[32]; |
201 |
+ |
|
202 |
+ |
label = gtk_label_new(GetString(label_id)); |
203 |
+ |
gtk_widget_show(label); |
204 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
205 |
+ |
|
206 |
+ |
combo = gtk_combo_new(); |
207 |
+ |
gtk_widget_show(combo); |
208 |
+ |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
209 |
+ |
|
210 |
+ |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value); |
211 |
+ |
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
212 |
+ |
|
213 |
+ |
return combo; |
214 |
+ |
} |
215 |
+ |
|
216 |
+ |
static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options) |
217 |
+ |
{ |
218 |
+ |
GList *glist = NULL; |
219 |
+ |
while (options->label_id) { |
220 |
+ |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
221 |
+ |
options++; |
222 |
+ |
} |
223 |
+ |
|
224 |
+ |
return table_make_combobox(table, row, label_id, default_value, glist); |
225 |
+ |
} |
226 |
+ |
|
227 |
+ |
static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false) |
228 |
+ |
{ |
229 |
+ |
GtkWidget *box, *label, *entry, *button; |
230 |
+ |
|
231 |
+ |
label = gtk_label_new(GetString(label_id)); |
232 |
+ |
gtk_widget_show(label); |
233 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
234 |
+ |
|
235 |
+ |
const char *str = PrefsFindString(prefs_item); |
236 |
+ |
if (str == NULL) |
237 |
+ |
str = ""; |
238 |
+ |
|
239 |
+ |
box = gtk_hbox_new(FALSE, 4); |
240 |
+ |
gtk_widget_show(box); |
241 |
+ |
gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
242 |
+ |
|
243 |
+ |
entry = gtk_entry_new(); |
244 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
245 |
+ |
gtk_widget_show(entry); |
246 |
+ |
gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0); |
247 |
+ |
|
248 |
+ |
button = make_browse_button(entry); |
249 |
+ |
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); |
250 |
+ |
g_object_set_data(G_OBJECT(entry), "chooser_button", button); |
251 |
+ |
return entry; |
252 |
+ |
} |
253 |
+ |
|
254 |
|
static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active) |
255 |
|
{ |
256 |
|
GtkWidget *box, *label, *opt, *menu; |
308 |
|
return entry; |
309 |
|
} |
310 |
|
|
311 |
< |
static char *get_file_entry_path(GtkWidget *entry) |
311 |
> |
static const gchar *get_file_entry_path(GtkWidget *entry) |
312 |
|
{ |
313 |
|
#ifdef HAVE_GNOMEUI |
314 |
|
return gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(entry), false); |
425 |
|
dialog = gnome_about_new( |
426 |
|
"Basilisk II", |
427 |
|
version, |
428 |
< |
"Copyright (C) 1997-2002 Christian Bauer", |
428 |
> |
"Copyright (C) 1997-2005 Christian Bauer", |
429 |
|
authors, |
430 |
|
"Basilisk II comes with ABSOLUTELY NO WARRANTY." |
431 |
|
"This is free software, and you are welcome to redistribute it" |
441 |
|
char str[512]; |
442 |
|
sprintf(str, |
443 |
|
"Basilisk II\nVersion %d.%d\n\n" |
444 |
< |
"Copyright (C) 1997-2002 Christian Bauer et al.\n" |
444 |
> |
"Copyright (C) 1997-2005 Christian Bauer et al.\n" |
445 |
|
"E-mail: Christian.Bauer@uni-mainz.de\n" |
446 |
|
"http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" |
447 |
|
"Basilisk II comes with ABSOLUTELY NO\n" |
482 |
|
// Menu item descriptions |
483 |
|
static GtkItemFactoryEntry menu_items[] = { |
484 |
|
{(gchar *)GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, "<Branch>"}, |
485 |
< |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
485 |
> |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), "<control>S", GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
486 |
|
{(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(mn_zap_pram), 0, NULL}, |
487 |
|
{(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, "<Separator>"}, |
488 |
|
{(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK), "<control>Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL}, |
506 |
|
GtkAccelGroup *accel_group = gtk_accel_group_new(); |
507 |
|
GtkItemFactory *item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); |
508 |
|
gtk_item_factory_create_items(item_factory, sizeof(menu_items) / sizeof(menu_items[0]), menu_items, NULL); |
509 |
+ |
#if GTK_CHECK_VERSION(1,3,15) |
510 |
+ |
gtk_window_add_accel_group(GTK_WINDOW(win), accel_group); |
511 |
+ |
#else |
512 |
|
gtk_accel_group_attach(accel_group, GTK_OBJECT(win)); |
513 |
+ |
#endif |
514 |
|
GtkWidget *menu_bar = gtk_item_factory_get_widget(item_factory, "<main>"); |
515 |
|
gtk_widget_show(menu_bar); |
516 |
|
gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, TRUE, 0); |
556 |
|
selected_volume = row; |
557 |
|
} |
558 |
|
|
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 |
– |
|
559 |
|
// Volume selected for addition |
560 |
|
static void add_volume_ok(GtkWidget *button, file_req_assoc *assoc) |
561 |
|
{ |
562 |
< |
char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
562 |
> |
gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
563 |
|
gtk_clist_append(GTK_CLIST(volume_list), &file); |
564 |
|
gtk_widget_destroy(assoc->req); |
565 |
|
delete assoc; |
568 |
|
// Volume selected for creation |
569 |
|
static void create_volume_ok(GtkWidget *button, file_req_assoc *assoc) |
570 |
|
{ |
571 |
< |
char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
571 |
> |
gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
572 |
|
|
573 |
< |
char *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); |
573 |
> |
const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); |
574 |
|
int size = atoi(str); |
575 |
|
|
576 |
|
char cmd[1024]; |
706 |
|
static GtkWidget *w_jit_atraps; |
707 |
|
static GtkWidget *w_jit_cache_size; |
708 |
|
static GtkWidget *w_jit_lazy_flush; |
709 |
+ |
static GtkWidget *w_jit_follow_const_jumps; |
710 |
|
|
711 |
|
// Set sensitivity of widgets |
712 |
|
static void set_jit_sensitive(void) |
715 |
|
gtk_widget_set_sensitive(w_jit_fpu, jit_enabled); |
716 |
|
gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled); |
717 |
|
gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled); |
718 |
+ |
gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled); |
719 |
|
} |
720 |
|
|
721 |
|
// "Use JIT Compiler" button toggled |
737 |
|
PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active); |
738 |
|
} |
739 |
|
|
740 |
+ |
// "Translate through constant jumps (inline blocks)" button toggled |
741 |
+ |
static void tb_jit_follow_const_jumps(GtkWidget *widget) |
742 |
+ |
{ |
743 |
+ |
PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active); |
744 |
+ |
} |
745 |
+ |
|
746 |
|
// Read settings from widgets and set preferences |
747 |
|
static void read_jit_settings(void) |
748 |
|
{ |
779 |
|
|
780 |
|
// Lazy translation cache invalidation |
781 |
|
w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush)); |
782 |
< |
|
782 |
> |
|
783 |
> |
// Follow constant jumps (inline basic blocks) |
784 |
> |
w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps)); |
785 |
> |
|
786 |
|
set_jit_sensitive(); |
787 |
|
#endif |
788 |
|
} |
1107 |
|
// Set sensitivity of widgets |
1108 |
|
static void set_input_sensitive(void) |
1109 |
|
{ |
1110 |
< |
gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes")); |
1110 |
> |
const bool use_keycodes = PrefsFindBool("keycodes"); |
1111 |
> |
gtk_widget_set_sensitive(w_keycode_file, use_keycodes); |
1112 |
> |
gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes); |
1113 |
|
gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1); |
1114 |
|
} |
1115 |
|
|
1139 |
|
// Create "Input" pane |
1140 |
|
static void create_input_pane(GtkWidget *top) |
1141 |
|
{ |
1142 |
< |
GtkWidget *box, *hbox, *menu, *label; |
1142 |
> |
GtkWidget *box, *hbox, *menu, *label, *button; |
1143 |
|
GtkObject *adj; |
1144 |
|
|
1145 |
|
box = make_pane(top, STR_INPUT_PANE_TITLE); |
1146 |
|
|
1147 |
|
make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes)); |
1148 |
< |
w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile"); |
1148 |
> |
|
1149 |
> |
hbox = gtk_hbox_new(FALSE, 4); |
1150 |
> |
gtk_widget_show(hbox); |
1151 |
> |
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); |
1152 |
> |
|
1153 |
> |
label = gtk_label_new(GetString(STR_KEYCODES_CTRL)); |
1154 |
> |
gtk_widget_show(label); |
1155 |
> |
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1156 |
> |
|
1157 |
> |
const char *str = PrefsFindString("keycodefile"); |
1158 |
> |
if (str == NULL) |
1159 |
> |
str = ""; |
1160 |
> |
|
1161 |
> |
w_keycode_file = gtk_entry_new(); |
1162 |
> |
gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str); |
1163 |
> |
gtk_widget_show(w_keycode_file); |
1164 |
> |
gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0); |
1165 |
> |
|
1166 |
> |
button = make_browse_button(w_keycode_file); |
1167 |
> |
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1168 |
> |
g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button); |
1169 |
|
|
1170 |
|
make_separator(box); |
1171 |
|
|
1313 |
|
} |
1314 |
|
close(s); |
1315 |
|
} |
1316 |
+ |
#ifdef HAVE_SLIRP |
1317 |
+ |
static char s_slirp[] = "slirp"; |
1318 |
+ |
glist = g_list_append(glist, s_slirp); |
1319 |
+ |
#endif |
1320 |
|
if (glist) |
1321 |
|
g_list_sort(glist, gl_str_cmp); |
1322 |
|
else |
1406 |
|
* "Memory/Misc" pane |
1407 |
|
*/ |
1408 |
|
|
1409 |
< |
static GtkObject *w_ramsize_adj; |
1409 |
> |
static GtkWidget *w_ramsize; |
1410 |
|
static GtkWidget *w_rom_file; |
1411 |
|
|
1412 |
|
// "Ignore SEGV" button toggled |
1431 |
|
// Read settings from widgets and set preferences |
1432 |
|
static void read_memory_settings(void) |
1433 |
|
{ |
1434 |
< |
PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20); |
1434 |
> |
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry)); |
1435 |
> |
PrefsReplaceInt32("ramsize", atoi(str) << 20); |
1436 |
|
|
1437 |
< |
const char *str = get_file_entry_path(w_rom_file); |
1437 |
> |
str = get_file_entry_path(w_rom_file); |
1438 |
|
if (str && strlen(str)) |
1439 |
|
PrefsReplaceString("rom", str); |
1440 |
|
else |
1445 |
|
// Create "Memory/Misc" pane |
1446 |
|
static void create_memory_pane(GtkWidget *top) |
1447 |
|
{ |
1448 |
< |
GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale; |
1448 |
> |
GtkWidget *box, *hbox, *table, *label, *menu; |
1449 |
|
|
1450 |
|
box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE); |
1451 |
+ |
table = make_table(box, 2, 5); |
1452 |
|
|
1453 |
< |
hbox = gtk_hbox_new(FALSE, 4); |
1454 |
< |
gtk_widget_show(hbox); |
1455 |
< |
|
1456 |
< |
label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER)); |
1457 |
< |
gtk_widget_show(label); |
1458 |
< |
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1459 |
< |
|
1460 |
< |
vbox = gtk_vbox_new(FALSE, 4); |
1461 |
< |
gtk_widget_show(vbox); |
1462 |
< |
|
1463 |
< |
gfloat min, max; |
1464 |
< |
min = 1; |
1465 |
< |
max = 1024; |
1466 |
< |
w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0); |
1467 |
< |
gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20); |
1468 |
< |
|
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); |
1453 |
> |
static const combo_desc options[] = { |
1454 |
> |
STR_RAMSIZE_2MB_LAB, |
1455 |
> |
STR_RAMSIZE_4MB_LAB, |
1456 |
> |
STR_RAMSIZE_8MB_LAB, |
1457 |
> |
STR_RAMSIZE_16MB_LAB, |
1458 |
> |
STR_RAMSIZE_32MB_LAB, |
1459 |
> |
STR_RAMSIZE_64MB_LAB, |
1460 |
> |
STR_RAMSIZE_128MB_LAB, |
1461 |
> |
STR_RAMSIZE_256MB_LAB, |
1462 |
> |
STR_RAMSIZE_512MB_LAB, |
1463 |
> |
STR_RAMSIZE_1024MB_LAB, |
1464 |
> |
0 |
1465 |
> |
}; |
1466 |
> |
char default_ramsize[10]; |
1467 |
> |
sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20); |
1468 |
> |
w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options); |
1469 |
|
|
1470 |
|
static const opt_desc model_options[] = { |
1471 |
|
{STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)}, |
1477 |
|
case 5: active = 0; break; |
1478 |
|
case 14: active = 1; break; |
1479 |
|
} |
1480 |
< |
make_option_menu(box, STR_MODELID_CTRL, model_options, active); |
1480 |
> |
table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); |
1481 |
|
|
1482 |
|
#if EMULATED_68K |
1483 |
|
static const opt_desc cpu_options[] = { |
1496 |
|
case 3: active = fpu ? 3 : 2; break; |
1497 |
|
case 4: active = 4; |
1498 |
|
} |
1499 |
< |
make_option_menu(box, STR_CPU_CTRL, cpu_options, active); |
1499 |
> |
table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active); |
1500 |
|
#endif |
1501 |
|
|
1502 |
< |
w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom"); |
1502 |
> |
w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom"); |
1503 |
|
|
1504 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1505 |
|
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1521 |
|
read_memory_settings(); |
1522 |
|
read_jit_settings(); |
1523 |
|
} |
1524 |
+ |
|
1525 |
+ |
|
1526 |
+ |
#ifdef STANDALONE_GUI |
1527 |
+ |
#include <errno.h> |
1528 |
+ |
|
1529 |
+ |
/* |
1530 |
+ |
* Fake unused data and functions |
1531 |
+ |
*/ |
1532 |
+ |
|
1533 |
+ |
uint8 XPRAM[XPRAM_SIZE]; |
1534 |
+ |
void MountVolume(void *fh) { } |
1535 |
+ |
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { } |
1536 |
+ |
void WarningAlert(const char *text) { } |
1537 |
+ |
|
1538 |
+ |
|
1539 |
+ |
/* |
1540 |
+ |
* Display alert |
1541 |
+ |
*/ |
1542 |
+ |
|
1543 |
+ |
static void dl_destroyed(void) |
1544 |
+ |
{ |
1545 |
+ |
gtk_main_quit(); |
1546 |
+ |
} |
1547 |
+ |
|
1548 |
+ |
static void display_alert(int title_id, int prefix_id, int button_id, const char *text) |
1549 |
+ |
{ |
1550 |
+ |
char str[256]; |
1551 |
+ |
sprintf(str, GetString(prefix_id), text); |
1552 |
+ |
|
1553 |
+ |
GtkWidget *dialog = gtk_dialog_new(); |
1554 |
+ |
gtk_window_set_title(GTK_WINDOW(dialog), GetString(title_id)); |
1555 |
+ |
gtk_container_border_width(GTK_CONTAINER(dialog), 5); |
1556 |
+ |
gtk_widget_set_uposition(GTK_WIDGET(dialog), 100, 150); |
1557 |
+ |
gtk_signal_connect(GTK_OBJECT(dialog), "destroy", GTK_SIGNAL_FUNC(dl_destroyed), NULL); |
1558 |
+ |
|
1559 |
+ |
GtkWidget *label = gtk_label_new(str); |
1560 |
+ |
gtk_widget_show(label); |
1561 |
+ |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); |
1562 |
+ |
|
1563 |
+ |
GtkWidget *button = gtk_button_new_with_label(GetString(button_id)); |
1564 |
+ |
gtk_widget_show(button); |
1565 |
+ |
gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(dl_quit), GTK_OBJECT(dialog)); |
1566 |
+ |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 0); |
1567 |
+ |
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
1568 |
+ |
gtk_widget_grab_default(button); |
1569 |
+ |
gtk_widget_show(dialog); |
1570 |
+ |
|
1571 |
+ |
gtk_main(); |
1572 |
+ |
} |
1573 |
+ |
|
1574 |
+ |
|
1575 |
+ |
/* |
1576 |
+ |
* Display error alert |
1577 |
+ |
*/ |
1578 |
+ |
|
1579 |
+ |
static void ErrorAlert(const char *text) |
1580 |
+ |
{ |
1581 |
+ |
display_alert(STR_ERROR_ALERT_TITLE, STR_GUI_ERROR_PREFIX, STR_QUIT_BUTTON, text); |
1582 |
+ |
} |
1583 |
+ |
|
1584 |
+ |
|
1585 |
+ |
/* |
1586 |
+ |
* Start standalone GUI |
1587 |
+ |
*/ |
1588 |
+ |
|
1589 |
+ |
int main(int argc, char *argv[]) |
1590 |
+ |
{ |
1591 |
+ |
#ifdef HAVE_GNOMEUI |
1592 |
+ |
// Init GNOME/GTK |
1593 |
+ |
char version[16]; |
1594 |
+ |
sprintf(version, "%d.%d", VERSION_MAJOR, VERSION_MINOR); |
1595 |
+ |
gnome_init("Basilisk II", version, argc, argv); |
1596 |
+ |
#else |
1597 |
+ |
// Init GTK |
1598 |
+ |
gtk_set_locale(); |
1599 |
+ |
gtk_init(&argc, &argv); |
1600 |
+ |
#endif |
1601 |
+ |
|
1602 |
+ |
// Read preferences |
1603 |
+ |
PrefsInit(argc, argv); |
1604 |
+ |
|
1605 |
+ |
// Show preferences editor |
1606 |
+ |
bool start = PrefsEditor(); |
1607 |
+ |
|
1608 |
+ |
// Exit preferences |
1609 |
+ |
PrefsExit(); |
1610 |
+ |
|
1611 |
+ |
// Transfer control to the executable |
1612 |
+ |
if (start) { |
1613 |
+ |
char b2_path[PATH_MAX]; |
1614 |
+ |
strcpy(b2_path, argv[0]); |
1615 |
+ |
char *p = strrchr(b2_path, '/'); |
1616 |
+ |
p = p ? p + 1 : b2_path; |
1617 |
+ |
*p = '\0'; |
1618 |
+ |
strcat(b2_path, "BasiliskII"); |
1619 |
+ |
argv[0] = b2_path; |
1620 |
+ |
execv(b2_path, argv); |
1621 |
+ |
|
1622 |
+ |
char str[256]; |
1623 |
+ |
sprintf(str, GetString(STR_NO_B2_EXE_FOUND), b2_path, strerror(errno)); |
1624 |
+ |
ErrorAlert(str); |
1625 |
+ |
return 1; |
1626 |
+ |
} |
1627 |
+ |
|
1628 |
+ |
return 0; |
1629 |
+ |
} |
1630 |
+ |
#endif |