|
|
1.1 root 1: /*
2: * UAE - the Un*x Amiga Emulator
3: *
4: * Yet Another User Interface for the X11 version
5: *
6: * Copyright 1997, 1998 Bernd Schmidt
1.1.1.2 root 7: * Copyright 1998 Michael Krause
1.1 root 8: *
9: * The Tk GUI doesn't work.
10: * The X Forms Library isn't available as source, and there aren't any
11: * binaries compiled against glibc
12: *
13: * So let's try this...
14: */
15:
16: #include "sysconfig.h"
17: #include "sysdeps.h"
18:
19: #include "config.h"
20: #include "options.h"
21: #include "uae.h"
22: #include "memory.h"
23: #include "custom.h"
24: #include "gui.h"
25: #include "newcpu.h"
1.1.1.11! root 26: #include "autoconf.h"
! 27: #include "threaddep/thread.h"
1.1.1.2 root 28: #include "sounddep/sound.h"
1.1.1.10 root 29: #include "savestate.h"
1.1 root 30:
31: #include <gtk/gtk.h>
1.1.1.11! root 32: #include <gdk/gdk.h>
1.1 root 33:
1.1.1.4 root 34: /* One of the 1.1.6 "features" is a gratuitous name change */
35: #ifndef HAVE_GTK_FEATURES_1_1_6
36: #define gtk_container_set_border_width gtk_container_border_width
37: #endif
38: /* Likewise for 1.1.8. */
39: #ifndef HAVE_GTK_FEATURES_1_1_8
40: #define gtk_label_set_text gtk_label_set
41: #endif
1.1.1.5 root 42: /* This is beginning to suck... */
43: #ifndef HAVE_GTK_FEATURES_1_1_13
44: #define gtk_toggle_button_set_active gtk_toggle_button_set_state
45: #endif
1.1.1.4 root 46:
1.1 root 47: static int gui_active;
48:
1.1.1.11! root 49: static GtkWidget *gui_window;
! 50:
1.1.1.10 root 51: static GtkWidget *pause_uae_widget, *snap_save_widget, *snap_load_widget;
52:
53: static GtkWidget *chipsize_widget[5];
54: static GtkWidget *bogosize_widget[4];
55: static GtkWidget *fastsize_widget[5];
56: static GtkWidget *z3size_widget[10];
57: static GtkWidget *p96size_widget[7];
1.1.1.11! root 58: static GtkWidget *rom_text_widget, *key_text_widget;
! 59: static GtkWidget *rom_change_widget, *key_change_widget;
1.1.1.6 root 60:
1.1 root 61: static GtkWidget *disk_insert_widget[4], *disk_eject_widget[4], *disk_text_widget[4];
62: static char *new_disk_string[4];
63:
64: static GtkAdjustment *cpuspeed_adj;
1.1.1.3 root 65: static GtkWidget *cpuspeed_widgets[4], *cpuspeed_scale;
1.1.1.8 root 66: static GtkWidget *cpu_widget[5], *a24m_widget, *ccpu_widget;
1.1.1.9 root 67: static GtkWidget *sound_widget[4], *sound_bits_widget[2], *sound_freq_widget[3], *sound_ch_widget[3];
1.1 root 68:
1.1.1.10 root 69: static GtkWidget *coll_widget[4], *cslevel_widget[4];
70: static GtkWidget *fcop_widget;
71:
1.1 root 72: static GtkAdjustment *framerate_adj;
1.1.1.7 root 73: static GtkWidget *bimm_widget, *b32_widget, *afscr_widget, *pfscr_widget;
1.1 root 74:
75: static GtkWidget *joy_widget[2][6];
76:
77: static GtkWidget *led_widgets[5];
78: static GdkColor led_on[5], led_off[5];
79: static unsigned int prevledstate;
80:
1.1.1.11! root 81: static GtkWidget *hdlist_widget;
! 82: static int selected_hd_row;
! 83: static GtkWidget *hdchange_button, *hddel_button;
! 84: static GtkWidget *volname_entry, *path_entry;
! 85: static GtkWidget *dirdlg;
! 86: static char dirdlg_volname[256], dirdlg_path[256];
! 87:
1.1.1.2 root 88: static smp_comm_pipe to_gui_pipe, from_gui_pipe;
1.1.1.11! root 89: static uae_sem_t gui_sem, gui_init_sem, gui_quit_sem; /* gui_sem protects the DFx fields */
1.1.1.2 root 90:
91: static volatile int quit_gui = 0, quitted_gui = 0;
92:
1.1 root 93: static void save_config (void)
94: {
95: FILE *f;
96: char tmp[257];
97:
98: /* Backup the options file. */
99: strcpy (tmp, optionsfile);
100: strcat (tmp, "~");
101: rename (optionsfile, tmp);
102:
103: f = fopen (optionsfile, "w");
104: if (f == NULL) {
1.1.1.2 root 105: fprintf (stderr, "Error saving options file!\n");
1.1 root 106: return;
107: }
1.1.1.4 root 108: save_options (f, &currprefs);
1.1 root 109: fclose (f);
110: }
111:
112: static int nr_for_led (GtkWidget *led)
113: {
114: int i;
115: i = 0;
116: while (led_widgets[i] != led)
117: i++;
118: return i;
119: }
120:
121: static void enable_disk_buttons (int enable)
122: {
123: int i;
124: for (i = 0; i < 4; i++) {
125: gtk_widget_set_sensitive (disk_insert_widget[i], enable);
126: gtk_widget_set_sensitive (disk_eject_widget[i], enable);
127: }
128: }
129:
1.1.1.10 root 130: static void enable_snap_buttons (int enable)
131: {
132: gtk_widget_set_sensitive (snap_save_widget, enable);
133: gtk_widget_set_sensitive (snap_load_widget, enable);
134: }
135:
1.1 root 136: static void set_cpu_state (void)
137: {
1.1.1.10 root 138: int i;
139:
1.1.1.5 root 140: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (a24m_widget), changed_prefs.address_space_24 != 0);
1.1.1.8 root 141: gtk_widget_set_sensitive (a24m_widget, changed_prefs.cpu_level > 1 && changed_prefs.cpu_level < 4);
1.1.1.5 root 142: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ccpu_widget), changed_prefs.cpu_compatible != 0);
1.1 root 143: gtk_widget_set_sensitive (ccpu_widget, changed_prefs.cpu_level == 0);
1.1.1.3 root 144: gtk_widget_set_sensitive (cpuspeed_scale, changed_prefs.m68k_speed > 0);
1.1.1.10 root 145: for (i = 0; i < 10; i++)
146: gtk_widget_set_sensitive (z3size_widget[i],
147: changed_prefs.cpu_level >= 2 && ! changed_prefs.address_space_24);
1.1 root 148: }
149:
150: static void set_cpu_widget (void)
151: {
152: int nr = changed_prefs.cpu_level;
1.1.1.10 root 153:
1.1.1.5 root 154: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpu_widget[nr]), TRUE);
1.1.1.3 root 155: nr = currprefs.m68k_speed + 1 < 3 ? currprefs.m68k_speed + 1 : 2;
1.1.1.5 root 156: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpuspeed_widgets[nr]), TRUE);
1.1.1.10 root 157:
1.1 root 158: }
159:
160: static void set_gfx_state (void)
161: {
1.1.1.5 root 162: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bimm_widget), currprefs.immediate_blits != 0);
1.1.1.10 root 163: #if 0
1.1.1.5 root 164: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b32_widget), currprefs.blits_32bit_enabled != 0);
1.1.1.7 root 165: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (afscr_widget), currprefs.gfx_afullscreen != 0);
166: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pfscr_widget), currprefs.gfx_pfullscreen != 0);
1.1.1.10 root 167: #endif
168: }
169:
170: static void set_chipset_state (void)
171: {
172: int t0 = 0;
173: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (coll_widget[currprefs.collision_level]), TRUE);
174: if (currprefs.chipset_mask & CSMASK_AGA)
175: t0 = 3;
176: else if (currprefs.chipset_mask & CSMASK_ECS_DENISE)
177: t0 = 2;
178: else if (currprefs.chipset_mask & CSMASK_ECS_AGNUS)
179: t0 = 1;
180: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cslevel_widget[t0]), TRUE);
181: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fcop_widget), currprefs.fast_copper != 0);
1.1 root 182: }
183:
1.1.1.2 root 184: static void set_sound_state (void)
185: {
1.1.1.9 root 186: int stereo = currprefs.stereo + currprefs.mixed_stereo;
1.1.1.5 root 187: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_widget[currprefs.produce_sound]), 1);
1.1.1.9 root 188: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_ch_widget[stereo]), 1);
1.1.1.5 root 189: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_bits_widget[currprefs.sound_bits == 16]), 1);
1.1.1.2 root 190: }
191:
1.1.1.10 root 192: static void set_mem_state (void)
193: {
194: int t, t2;
195:
196: t = 0;
197: t2 = currprefs.chipmem_size;
198: while (t < 4 && t2 > 0x80000)
199: t++, t2 >>= 1;
200: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chipsize_widget[t]), 1);
201:
202: t = 0;
203: t2 = currprefs.bogomem_size;
204: while (t < 3 && t2 >= 0x80000)
205: t++, t2 >>= 1;
206: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bogosize_widget[t]), 1);
207:
208: t = 0;
209: t2 = currprefs.fastmem_size;
210: while (t < 4 && t2 >= 0x100000)
211: t++, t2 >>= 1;
212: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fastsize_widget[t]), 1);
213:
214: t = 0;
215: t2 = currprefs.z3fastmem_size;
216: while (t < 9 && t2 >= 0x100000)
217: t++, t2 >>= 1;
218: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (z3size_widget[t]), 1);
219:
220: t = 0;
221: t2 = currprefs.gfxmem_size;
222: while (t < 6 && t2 >= 0x100000)
223: t++, t2 >>= 1;
224: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (p96size_widget[t]), 1);
1.1.1.11! root 225:
! 226: gtk_label_set_text (GTK_LABEL (rom_text_widget), currprefs.romfile);
! 227: gtk_label_set_text (GTK_LABEL (key_text_widget), currprefs.keyfile);
1.1.1.10 root 228: }
229:
1.1 root 230: static void set_joy_state (void)
231: {
1.1.1.4 root 232: int j0t = changed_prefs.jport0;
233: int j1t = changed_prefs.jport1;
1.1 root 234: int i;
235:
236: if (j0t == j1t) {
237: /* Can't happen */
238: j0t++;
239: j0t %= 6;
240: }
241: for (i = 0; i < 6; i++) {
1.1.1.5 root 242: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (joy_widget[0][i]), j0t == i);
243: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (joy_widget[1][i]), j1t == i);
1.1 root 244: gtk_widget_set_sensitive (joy_widget[0][i], j1t != i);
245: gtk_widget_set_sensitive (joy_widget[1][i], j0t != i);
246: }
247: }
248:
1.1.1.11! root 249: static void set_hd_state (void)
! 250: {
! 251: char texts[9][256];
! 252: char *tptrs[] = { texts[0], texts[1], texts[2], texts[3], texts[4], texts[5], texts[6], texts[7], texts[8] };
! 253: int nr = nr_units (currprefs.mountinfo);
! 254: int i;
! 255:
! 256: gtk_clist_freeze (GTK_CLIST (hdlist_widget));
! 257: gtk_clist_clear (GTK_CLIST (hdlist_widget));
! 258: for (i = 0; i < nr; i++) {
! 259: int secspertrack, surfaces, reserved, blocksize, size;
! 260: int cylinders, readonly;
! 261: char *volname, *rootdir;
! 262: char *failure;
! 263:
! 264: /* We always use currprefs.mountinfo for the GUI. The filesystem
! 265: code makes a private copy which is updated every reset. */
! 266: failure = get_filesys_unit (currprefs.mountinfo, i,
! 267: &volname, &rootdir, &readonly,
! 268: &secspertrack, &surfaces, &reserved,
! 269: &cylinders, &size, &blocksize);
! 270:
! 271: if (is_hardfile (currprefs.mountinfo, i)) {
! 272: sprintf (texts[0], "DH%d", i );
! 273: sprintf (texts[3], "%d", surfaces);
! 274: sprintf (texts[4], "%d", cylinders);
! 275: sprintf (texts[5], "%d", secspertrack);
! 276: sprintf (texts[6], "%d", reserved);
! 277: sprintf (texts[7], "%d", size);
! 278: sprintf (texts[8], "%d", blocksize);
! 279: } else {
! 280: strcpy (texts[0], volname);
! 281: strcpy (texts[3], "n/a");
! 282: strcpy (texts[4], "n/a");
! 283: strcpy (texts[5], "n/a");
! 284: strcpy (texts[6], "n/a");
! 285: strcpy (texts[7], "n/a");
! 286: strcpy (texts[8], "n/a");
! 287: }
! 288: strcpy (texts[1], rootdir);
! 289: strcpy (texts[2], readonly ? "y" : "n");
! 290: gtk_clist_append (GTK_CLIST (hdlist_widget), tptrs);
! 291: }
! 292: gtk_clist_thaw (GTK_CLIST (hdlist_widget));
! 293: gtk_widget_set_sensitive (hdchange_button, FALSE);
! 294: gtk_widget_set_sensitive (hddel_button, FALSE);
! 295: }
! 296:
1.1 root 297: static void draw_led (int nr)
298: {
299: GtkWidget *thing = led_widgets[nr];
300: GdkWindow *window = thing->window;
301: GdkGC *gc = gdk_gc_new (window);
302: GdkColor *col;
303:
304: if (gui_ledstate & (1 << nr))
305: col = led_on + nr;
306: else
307: col = led_off + nr;
308: gdk_gc_set_foreground (gc, col);
309: gdk_draw_rectangle (window, gc, 1, 0, 0, -1, -1);
310: gdk_gc_destroy (gc);
311: }
312:
313: static int my_idle (void)
314: {
315: unsigned int leds = gui_ledstate;
316: int i;
317:
318: if (quit_gui) {
319: gtk_main_quit ();
320: goto out;
321: }
322: while (comm_pipe_has_data (&to_gui_pipe)) {
323: int cmd = read_comm_pipe_int_blocking (&to_gui_pipe);
324: int n;
325: switch (cmd) {
326: case 0:
327: n = read_comm_pipe_int_blocking (&to_gui_pipe);
1.1.1.4 root 328: gtk_label_set_text (GTK_LABEL (disk_text_widget[n]), currprefs.df[n]);
1.1 root 329: break;
330: case 1:
331: /* Initialization. */
332: set_cpu_widget ();
333: set_cpu_state ();
334: set_gfx_state ();
335: set_joy_state ();
1.1.1.2 root 336: set_sound_state ();
1.1.1.10 root 337: set_mem_state ();
1.1.1.11! root 338: set_hd_state ();
1.1.1.10 root 339: set_chipset_state ();
1.1.1.3 root 340:
1.1.1.11! root 341: gtk_widget_show (gui_window);
! 342: uae_sem_post (&gui_init_sem);
1.1 root 343: gui_active = 1;
344: break;
345: }
346: }
1.1.1.10 root 347:
1.1 root 348: for (i = 0; i < 5; i++) {
349: unsigned int mask = 1 << i;
1.1.1.2 root 350: unsigned int on = leds & mask;
1.1 root 351:
352: if (on == (prevledstate & mask))
353: continue;
354:
355: /* printf(": %d %d\n", i, on);*/
356: draw_led (i);
357: }
358: prevledstate = leds;
359: out:
360: return 1;
361: }
362:
1.1.1.2 root 363: static int find_current_toggle (GtkWidget **widgets, int count)
364: {
365: int i;
366: for (i = 0; i < count; i++)
367: if (GTK_TOGGLE_BUTTON (*widgets++)->active)
368: return i;
369: fprintf (stderr, "GTKUI: Can't happen!\n");
370: return -1;
371: }
372:
1.1 root 373: static void joy_changed (void)
374: {
375: if (! gui_active)
376: return;
377:
1.1.1.4 root 378: changed_prefs.jport0 = find_current_toggle (joy_widget[0], 6);
379: changed_prefs.jport1 = find_current_toggle (joy_widget[1], 6);
1.1 root 380: set_joy_state ();
381: }
382:
1.1.1.10 root 383: static void coll_changed (void)
384: {
385: changed_prefs.collision_level = find_current_toggle (coll_widget, 4);
386: }
387:
388: static void cslevel_changed (void)
389: {
390: int t = find_current_toggle (cslevel_widget, 4);
391: int t1 = 0;
392: if (t > 0)
393: t1 |= CSMASK_ECS_AGNUS;
394: if (t > 1)
395: t1 |= CSMASK_ECS_DENISE;
396: if (t > 2)
397: t1 |= CSMASK_AGA;
398: changed_prefs.chipset_mask = t1;
399: }
400:
1.1.1.2 root 401: static void custom_changed (void)
1.1 root 402: {
1.1.1.6 root 403: changed_prefs.gfx_framerate = framerate_adj->value;
1.1 root 404: changed_prefs.immediate_blits = GTK_TOGGLE_BUTTON (bimm_widget)->active;
1.1.1.10 root 405: changed_prefs.fast_copper = GTK_TOGGLE_BUTTON (fcop_widget)->active;
406: #if 0
407: changed_prefs.blits_32bit_enabled = GTK_TOGGLE_BUTTON (b32_widget)->active;
1.1.1.7 root 408: changed_prefs.gfx_afullscreen = GTK_TOGGLE_BUTTON (afscr_widget)->active;
409: changed_prefs.gfx_pfullscreen = GTK_TOGGLE_BUTTON (pfscr_widget)->active;
1.1.1.10 root 410: #endif
1.1 root 411: }
412:
413: static void cpuspeed_changed (void)
414: {
1.1.1.3 root 415: int which = find_current_toggle (cpuspeed_widgets, 3);
416: changed_prefs.m68k_speed = (which == 0 ? -1
417: : which == 1 ? 0
418: : cpuspeed_adj->value);
419: set_cpu_state ();
1.1 root 420: }
421:
422: static void cputype_changed (void)
423: {
424: int i, oldcl;
425: if (! gui_active)
426: return;
427:
428: oldcl = changed_prefs.cpu_level;
429:
1.1.1.8 root 430: changed_prefs.cpu_level = find_current_toggle (cpu_widget, 5);
1.1 root 431: changed_prefs.cpu_compatible = GTK_TOGGLE_BUTTON (ccpu_widget)->active;
432: changed_prefs.address_space_24 = GTK_TOGGLE_BUTTON (a24m_widget)->active;
433:
434: if (changed_prefs.cpu_level != 0)
435: changed_prefs.cpu_compatible = 0;
436: /* 68000/68010 always have a 24 bit address space. */
437: if (changed_prefs.cpu_level < 2)
438: changed_prefs.address_space_24 = 1;
439: /* Changing from 68000/68010 to 68020 should set a sane default. */
440: else if (oldcl < 2)
441: changed_prefs.address_space_24 = 0;
1.1.1.8 root 442:
1.1 root 443: set_cpu_state ();
444: }
445:
1.1.1.10 root 446: static void chipsize_changed (void)
447: {
448: int t = find_current_toggle (chipsize_widget, 5);
449: changed_prefs.chipmem_size = 0x80000 << t;
450: for (t = 0; t < 5; t++)
451: gtk_widget_set_sensitive (fastsize_widget[t], changed_prefs.chipmem_size <= 0x200000);
452: if (changed_prefs.chipmem_size > 0x200000) {
453: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fastsize_widget[0]), 1);
454: changed_prefs.fastmem_size = 0;
455: }
456: }
457:
458: static void bogosize_changed (void)
459: {
460: int t = find_current_toggle (bogosize_widget, 4);
461: changed_prefs.bogomem_size = (0x40000 << t) & ~0x40000;
462: }
463:
464: static void fastsize_changed (void)
465: {
466: int t = find_current_toggle (fastsize_widget, 5);
467: changed_prefs.fastmem_size = (0x80000 << t) & ~0x80000;
468: }
469:
470: static void z3size_changed (void)
471: {
472: int t = find_current_toggle (z3size_widget, 10);
473: changed_prefs.z3fastmem_size = (0x80000 << t) & ~0x80000;
474: }
475:
476: static void p96size_changed (void)
477: {
478: int t = find_current_toggle (p96size_widget, 7);
479: changed_prefs.gfxmem_size = (0x80000 << t) & ~0x80000;
480: }
481:
1.1.1.2 root 482: static void sound_changed (void)
483: {
484: changed_prefs.produce_sound = find_current_toggle (sound_widget, 4);
1.1.1.9 root 485: changed_prefs.stereo = find_current_toggle (sound_ch_widget, 3);
486: changed_prefs.mixed_stereo = 0;
487: if (changed_prefs.stereo == 2)
488: changed_prefs.mixed_stereo = changed_prefs.stereo = 1;
1.1.1.2 root 489: changed_prefs.sound_bits = (find_current_toggle (sound_bits_widget, 2) + 1) * 8;
490: }
491:
1.1 root 492: static void did_reset (void)
493: {
494: if (quit_gui)
495: return;
496:
497: write_comm_pipe_int (&from_gui_pipe, 2, 1);
498: }
499:
500: static void did_debug (void)
501: {
502: if (quit_gui)
503: return;
504:
505: write_comm_pipe_int (&from_gui_pipe, 3, 1);
506: }
507:
508: static void did_quit (void)
509: {
510: if (quit_gui)
511: return;
512:
513: write_comm_pipe_int (&from_gui_pipe, 4, 1);
514: }
515:
1.1.1.2 root 516: static void did_eject (GtkWidget *w, gpointer data)
517: {
1.1 root 518: if (quit_gui)
519: return;
520:
521: write_comm_pipe_int (&from_gui_pipe, 0, 0);
1.1.1.2 root 522: write_comm_pipe_int (&from_gui_pipe, (int)data, 1);
1.1 root 523: }
524:
1.1.1.6 root 525: static void pause_uae (GtkWidget *widget, gpointer data)
526: {
527: if (quit_gui)
528: return;
529:
530: write_comm_pipe_int (&from_gui_pipe, GTK_TOGGLE_BUTTON (widget)->active ? 5 : 6, 1);
531: }
532:
533: static void end_pause_uae (void)
534: {
535: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pause_uae_widget), FALSE);
536: }
537:
1.1 root 538: static int filesel_active = -1;
1.1.1.10 root 539: static GtkWidget *disk_selector;
540:
541: static int snapsel_active = -1;
1.1.1.11! root 542: static char *gui_snapname, *gui_romname, *gui_keyname;
1.1 root 543:
1.1.1.11! root 544: static void did_close_insert (gpointer data)
1.1 root 545: {
546: filesel_active = -1;
547: enable_disk_buttons (1);
548: }
549:
550: static void did_insert_select (GtkObject *o)
551: {
1.1.1.10 root 552: char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (disk_selector));
1.1 root 553: printf ("%s\n", s);
554: if (quit_gui)
555: return;
556:
557: uae_sem_wait (&gui_sem);
558: if (new_disk_string[filesel_active] != 0)
559: free (new_disk_string[filesel_active]);
560: new_disk_string[filesel_active] = strdup (s);
561: uae_sem_post (&gui_sem);
562: write_comm_pipe_int (&from_gui_pipe, 1, 0);
563: write_comm_pipe_int (&from_gui_pipe, filesel_active, 1);
564: filesel_active = -1;
565: enable_disk_buttons (1);
1.1.1.11! root 566: gtk_widget_destroy (disk_selector);
1.1 root 567: }
568:
569: static char fsbuffer[100];
570:
1.1.1.11! root 571: static GtkWidget *make_file_selector (const char *title,
! 572: void (*insertfunc)(GtkObject *),
! 573: void (*closefunc)(gpointer))
! 574: {
! 575: GtkWidget *p = gtk_file_selection_new (title);
! 576: gtk_signal_connect (GTK_OBJECT (p), "destroy", (GtkSignalFunc) closefunc, p);
! 577:
! 578: gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (p)->ok_button),
! 579: "clicked", (GtkSignalFunc) insertfunc,
! 580: GTK_OBJECT (p));
! 581: gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (p)->cancel_button),
! 582: "clicked", (GtkSignalFunc) gtk_widget_destroy,
! 583: GTK_OBJECT (p));
! 584:
! 585: #if 0
! 586: gtk_window_set_title (GTK_WINDOW (p), title);
! 587: #endif
! 588:
! 589: gtk_widget_show (p);
! 590: return p;
! 591: }
! 592:
! 593: static void filesel_set_path (GtkWidget *p, const char *path)
! 594: {
! 595: size_t len = strlen (path);
! 596: if (len > 0 && ! access (path, R_OK)) {
! 597: char *tmp = xmalloc (len + 2);
! 598: strcpy (tmp, path);
! 599: strcat (tmp, "/");
! 600: gtk_file_selection_set_filename (GTK_FILE_SELECTION (p),
! 601: tmp);
! 602: }
! 603: }
! 604:
1.1.1.2 root 605: static void did_insert (GtkWidget *w, gpointer data)
1.1 root 606: {
1.1.1.2 root 607: int n = (int)data;
1.1 root 608: if (filesel_active != -1)
609: return;
610: filesel_active = n;
611: enable_disk_buttons (0);
612:
613: sprintf (fsbuffer, "Select a disk image file for DF%d", n);
1.1.1.11! root 614: disk_selector = make_file_selector (fsbuffer, did_insert_select, did_close_insert);
! 615: filesel_set_path (disk_selector, currprefs.path_floppy);
1.1 root 616: }
617:
618: static gint driveled_event (GtkWidget *thing, GdkEvent *event)
619: {
620: int lednr = nr_for_led (thing);
621:
622: switch (event->type) {
623: case GDK_MAP:
624: draw_led (lednr);
625: break;
626: case GDK_EXPOSE:
627: draw_led (lednr);
628: break;
629: default:
630: break;
631: }
632:
633: return 0;
634: }
635:
1.1.1.11! root 636: static GtkWidget *snap_selector;
1.1.1.10 root 637:
1.1.1.11! root 638: static void did_close_snap (gpointer gdata)
1.1.1.10 root 639: {
640: snapsel_active = -1;
641: enable_snap_buttons (1);
642: }
643:
644: static void did_snap_select (GtkObject *o)
645: {
646: char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (snap_selector));
1.1.1.11! root 647:
1.1.1.10 root 648: if (quit_gui)
649: return;
650:
651: uae_sem_wait (&gui_sem);
652: gui_snapname = strdup (s);
653: uae_sem_post (&gui_sem);
654: write_comm_pipe_int (&from_gui_pipe, 7, 0);
655: write_comm_pipe_int (&from_gui_pipe, snapsel_active, 1);
656: snapsel_active = -1;
657: enable_snap_buttons (1);
1.1.1.11! root 658: gtk_widget_destroy (snap_selector);
1.1.1.10 root 659: }
660:
661: static void did_loadstate (void)
662: {
663: if (snapsel_active != -1)
664: return;
665: snapsel_active = STATE_DORESTORE;
666: enable_snap_buttons (0);
667:
1.1.1.11! root 668: snap_selector = make_file_selector ("Select a state file to restore",
! 669: did_snap_select, did_close_snap);
1.1.1.10 root 670: }
671:
672: static void did_savestate (void)
673: {
674: if (snapsel_active != -1)
675: return;
676: snapsel_active = STATE_DOSAVE;
677: enable_snap_buttons (0);
678:
1.1.1.11! root 679: snap_selector = make_file_selector ("Select a filename for the state file",
! 680: did_snap_select, did_close_snap);
! 681: }
! 682:
! 683: static GtkWidget *rom_selector;
! 684:
! 685: static void did_close_rom (gpointer gdata)
! 686: {
! 687: gtk_widget_set_sensitive (rom_change_widget, 1);
! 688: }
! 689:
! 690: static void did_rom_select (GtkObject *o)
! 691: {
! 692: char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (rom_selector));
! 693:
! 694: if (quit_gui)
! 695: return;
! 696:
! 697: gtk_widget_set_sensitive (rom_change_widget, 1);
! 698:
! 699: uae_sem_wait (&gui_sem);
! 700: gui_romname = strdup (s);
! 701: uae_sem_post (&gui_sem);
! 702: write_comm_pipe_int (&from_gui_pipe, 8, 0);
! 703: gtk_label_set_text (GTK_LABEL (rom_text_widget), gui_romname);
! 704: gtk_widget_destroy (rom_selector);
! 705: }
! 706:
! 707: static void did_romchange (GtkWidget *w, gpointer data)
! 708: {
! 709: gtk_widget_set_sensitive (rom_change_widget, 0);
! 710:
! 711: rom_selector = make_file_selector ("Select a ROM file",
! 712: did_rom_select, did_close_rom);
! 713: filesel_set_path (rom_selector, currprefs.path_rom);
! 714: }
! 715:
! 716: static GtkWidget *key_selector;
1.1.1.10 root 717:
1.1.1.11! root 718: static void did_close_key (gpointer gdata)
! 719: {
! 720: gtk_widget_set_sensitive (key_change_widget, 1);
! 721: }
! 722:
! 723: static void did_key_select (GtkObject *o)
! 724: {
! 725: char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (key_selector));
! 726:
! 727: if (quit_gui)
! 728: return;
! 729:
! 730: gtk_widget_set_sensitive (key_change_widget, 1);
! 731:
! 732: uae_sem_wait (&gui_sem);
! 733: gui_keyname = strdup (s);
! 734: uae_sem_post (&gui_sem);
! 735: write_comm_pipe_int (&from_gui_pipe, 9, 0);
! 736: gtk_label_set_text (GTK_LABEL (key_text_widget), gui_keyname);
! 737: gtk_widget_destroy (key_selector);
! 738: }
! 739:
! 740: static void did_keychange (GtkWidget *w, gpointer data)
! 741: {
! 742: gtk_widget_set_sensitive (key_change_widget, 0);
! 743:
! 744: key_selector = make_file_selector ("Select a Kickstart key file",
! 745: did_key_select, did_close_key);
! 746: filesel_set_path (key_selector, currprefs.path_rom);
1.1.1.10 root 747: }
748:
1.1.1.2 root 749: static void add_empty_vbox (GtkWidget *tobox)
750: {
751: GtkWidget *thing = gtk_vbox_new (FALSE, 0);
752: gtk_widget_show (thing);
753: gtk_box_pack_start (GTK_BOX (tobox), thing, TRUE, TRUE, 0);
754: }
755:
1.1.1.3 root 756: static void add_empty_hbox (GtkWidget *tobox)
757: {
758: GtkWidget *thing = gtk_hbox_new (FALSE, 0);
759: gtk_widget_show (thing);
760: gtk_box_pack_start (GTK_BOX (tobox), thing, TRUE, TRUE, 0);
761: }
762:
1.1.1.2 root 763: static void add_centered_to_vbox (GtkWidget *vbox, GtkWidget *w)
764: {
765: GtkWidget *hbox = gtk_hbox_new (TRUE, 0);
766: gtk_widget_show (hbox);
767: gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, FALSE, 0);
768: gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
769: }
770:
771: static GtkWidget *make_labelled_widget (const char *str, GtkWidget *thing)
772: {
773: GtkWidget *label = gtk_label_new (str);
774: GtkWidget *hbox2 = gtk_hbox_new (FALSE, 4);
775:
776: gtk_widget_show (label);
777: gtk_widget_show (thing);
778:
779: gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
780: gtk_box_pack_start (GTK_BOX (hbox2), thing, FALSE, TRUE, 0);
781:
782: return hbox2;
783: }
784:
1.1.1.3 root 785: static GtkWidget *add_labelled_widget_centered (const char *str, GtkWidget *thing, GtkWidget *vbox)
1.1.1.2 root 786: {
787: GtkWidget *w = make_labelled_widget (str, thing);
788: gtk_widget_show (w);
789: add_centered_to_vbox (vbox, w);
1.1.1.3 root 790: return w;
1.1.1.2 root 791: }
792:
1.1.1.10 root 793: static int make_radio_group (const char **labels, GtkWidget *tobox,
1.1.1.2 root 794: GtkWidget **saveptr, gint t1, gint t2,
1.1.1.10 root 795: void (*sigfunc) (void), int count, GSList *group)
1.1.1.2 root 796: {
1.1.1.10 root 797: int t = 0;
798:
799: while (*labels && (count == -1 || count-- > 0)) {
800: GtkWidget *thing = gtk_radio_button_new_with_label (group, *labels++);
801: group = gtk_radio_button_group (GTK_RADIO_BUTTON (thing));
1.1.1.2 root 802:
803: *saveptr++ = thing;
804: gtk_widget_show (thing);
805: gtk_box_pack_start (GTK_BOX (tobox), thing, t1, t2, 0);
806: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) sigfunc, NULL);
1.1.1.10 root 807: t++;
1.1.1.2 root 808: }
1.1.1.10 root 809: return t;
1.1.1.2 root 810: }
811:
812: static GtkWidget *make_radio_group_box (const char *title, const char **labels,
813: GtkWidget **saveptr, int horiz,
814: void (*sigfunc) (void))
815: {
816: GtkWidget *frame, *newbox;
817:
818: frame = gtk_frame_new (title);
819: newbox = (horiz ? gtk_hbox_new : gtk_vbox_new) (FALSE, 4);
820: gtk_widget_show (newbox);
1.1.1.4 root 821: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1.1.1.2 root 822: gtk_container_add (GTK_CONTAINER (frame), newbox);
1.1.1.10 root 823: make_radio_group (labels, newbox, saveptr, horiz, !horiz, sigfunc, -1, NULL);
824: return frame;
825: }
826:
827: static GtkWidget *make_radio_group_box_1 (const char *title, const char **labels,
828: GtkWidget **saveptr, int horiz,
829: void (*sigfunc) (void), int elts_per_column)
830: {
831: GtkWidget *frame, *newbox;
832: GtkWidget *column;
833: GSList *group = 0;
834:
835: frame = gtk_frame_new (title);
836: column = (horiz ? gtk_vbox_new : gtk_hbox_new) (FALSE, 4);
837: gtk_container_add (GTK_CONTAINER (frame), column);
838: gtk_widget_show (column);
839:
840: while (*labels) {
841: int count;
842: newbox = (horiz ? gtk_hbox_new : gtk_vbox_new) (FALSE, 4);
843: gtk_widget_show (newbox);
844: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
845: gtk_container_add (GTK_CONTAINER (column), newbox);
846: count = make_radio_group (labels, newbox, saveptr, horiz, !horiz, sigfunc, elts_per_column, group);
847: labels += count;
848: saveptr += count;
849: group = gtk_radio_button_group (GTK_RADIO_BUTTON (saveptr[-1]));
850: }
1.1.1.2 root 851: return frame;
852: }
853:
1.1 root 854: static GtkWidget *make_led (int nr)
855: {
856: GtkWidget *subframe, *the_led, *thing;
857: GdkColormap *colormap;
858:
859: the_led = gtk_vbox_new (FALSE, 0);
860: gtk_widget_show (the_led);
861:
862: thing = gtk_preview_new (GTK_PREVIEW_COLOR);
863: gtk_box_pack_start (GTK_BOX (the_led), thing, TRUE, TRUE, 0);
864: gtk_widget_show (thing);
865:
866: subframe = gtk_frame_new (NULL);
867: gtk_box_pack_start (GTK_BOX (the_led), subframe, TRUE, TRUE, 0);
868: gtk_widget_show (subframe);
869:
870: thing = gtk_drawing_area_new ();
871: gtk_drawing_area_size (GTK_DRAWING_AREA (thing), 20, 5);
872: gtk_widget_set_events (thing, GDK_EXPOSURE_MASK);
873: gtk_container_add (GTK_CONTAINER (subframe), thing);
874: colormap = gtk_widget_get_colormap (thing);
875: led_on[nr].red = nr == 0 ? 0xEEEE : 0xCCCC;
876: led_on[nr].green = nr == 0 ? 0: 0xFFFF;
877: led_on[nr].blue = 0;
878: led_on[nr].pixel = 0;
879: led_off[nr].red = 0;
880: led_off[nr].green = 0;
881: led_off[nr].blue = 0;
882: led_off[nr].pixel = 0;
883: gdk_color_alloc (colormap, led_on + nr);
884: gdk_color_alloc (colormap, led_off + nr);
885: led_widgets[nr] = thing;
886: gtk_signal_connect (GTK_OBJECT (thing), "event",
887: (GtkSignalFunc) driveled_event, (gpointer) thing);
888: gtk_widget_show (thing);
889:
890: thing = gtk_preview_new (GTK_PREVIEW_COLOR);
891: gtk_box_pack_start (GTK_BOX (the_led), thing, TRUE, TRUE, 0);
892: gtk_widget_show (thing);
893:
894: return the_led;
895: }
896:
1.1.1.11! root 897: static GtkWidget *make_file_container (const char *title, GtkWidget *vbox)
! 898: {
! 899: GtkWidget *thing = gtk_frame_new (title);
! 900: GtkWidget *buttonbox = gtk_hbox_new (FALSE, 4);
! 901:
! 902: gtk_container_set_border_width (GTK_CONTAINER (buttonbox), 4);
! 903: gtk_container_add (GTK_CONTAINER (thing), buttonbox);
! 904: gtk_box_pack_start (GTK_BOX (vbox), thing, FALSE, TRUE, 0);
! 905: gtk_widget_show (buttonbox);
! 906: gtk_widget_show (thing);
! 907:
! 908: return buttonbox;
! 909: }
! 910:
! 911: static GtkWidget *make_file_widget (GtkWidget *buttonbox)
! 912: {
! 913: GtkWidget *thing, *subthing;
! 914: GtkWidget *subframe = gtk_frame_new (NULL);
! 915:
! 916: gtk_frame_set_shadow_type (GTK_FRAME (subframe), GTK_SHADOW_ETCHED_OUT);
! 917: gtk_box_pack_start (GTK_BOX (buttonbox), subframe, TRUE, TRUE, 0);
! 918: gtk_widget_show (subframe);
! 919: subthing = gtk_vbox_new (FALSE, 0);
! 920: gtk_widget_show (subthing);
! 921: gtk_container_add (GTK_CONTAINER (subframe), subthing);
! 922: thing = gtk_label_new ("");
! 923: gtk_widget_show (thing);
! 924: gtk_box_pack_start (GTK_BOX (subthing), thing, TRUE, TRUE, 0);
! 925:
! 926: return thing;
! 927: }
! 928:
1.1 root 929: static void make_floppy_disks (GtkWidget *vbox)
930: {
1.1.1.2 root 931: GtkWidget *thing, *subthing, *subframe, *buttonbox;
932: char buf[5];
1.1 root 933: int i;
1.1.1.2 root 934:
935: add_empty_vbox (vbox);
936:
1.1 root 937: for (i = 0; i < 4; i++) {
1.1.1.2 root 938: /* Frame with an hbox and the "DFx:" title */
1.1 root 939: sprintf (buf, "DF%d:", i);
1.1.1.11! root 940: buttonbox = make_file_container (buf, vbox);
! 941:
1.1.1.2 root 942: /* LED */
1.1 root 943: subthing = make_led (i + 1);
944: gtk_box_pack_start (GTK_BOX (buttonbox), subthing, FALSE, TRUE, 0);
945:
1.1.1.2 root 946: /* Current file display */
1.1.1.11! root 947: disk_text_widget[i] = make_file_widget (buttonbox);
1.1 root 948:
949: /* Now, the buttons. */
950: thing = gtk_button_new_with_label ("Eject");
951: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
952: gtk_widget_show (thing);
953: disk_eject_widget[i] = thing;
1.1.1.2 root 954: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_eject, (gpointer) i);
1.1 root 955:
956: thing = gtk_button_new_with_label ("Insert");
957: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
958: gtk_widget_show (thing);
959: disk_insert_widget[i] = thing;
1.1.1.2 root 960: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_insert, (gpointer) i);
1.1 root 961: }
1.1.1.2 root 962:
963: add_empty_vbox (vbox);
1.1 root 964: }
965:
1.1.1.3 root 966: static GtkWidget *make_cpu_speed_sel (void)
967: {
1.1.1.10 root 968: int t;
1.1.1.3 root 969: static const char *labels[] = {
970: "Optimize for host CPU speed","Approximate 68000/7MHz speed", "Adjustable",
971: NULL
972: };
973: GtkWidget *frame, *newbox;
974:
975: frame = gtk_frame_new ("CPU speed");
976: newbox = gtk_vbox_new (FALSE, 4);
977: gtk_widget_show (newbox);
1.1.1.4 root 978: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1.1.1.3 root 979: gtk_container_add (GTK_CONTAINER (frame), newbox);
1.1.1.10 root 980: make_radio_group (labels, newbox, cpuspeed_widgets, 0, 1, cpuspeed_changed, -1, NULL);
1.1.1.3 root 981:
1.1.1.10 root 982: t = currprefs.m68k_speed > 0 ? currprefs.m68k_speed : 4 * CYCLE_UNIT;
983: cpuspeed_adj = GTK_ADJUSTMENT (gtk_adjustment_new (t, 1.0, 5120.0, 1.0, 1.0, 1.0));
1.1.1.3 root 984: gtk_signal_connect (GTK_OBJECT (cpuspeed_adj), "value_changed",
985: GTK_SIGNAL_FUNC (cpuspeed_changed), NULL);
986:
987: cpuspeed_scale = gtk_hscale_new (cpuspeed_adj);
988: gtk_range_set_update_policy (GTK_RANGE (cpuspeed_scale), GTK_UPDATE_DELAYED);
989: gtk_scale_set_digits (GTK_SCALE (cpuspeed_scale), 0);
990: gtk_scale_set_value_pos (GTK_SCALE (cpuspeed_scale), GTK_POS_RIGHT);
991: cpuspeed_scale = add_labelled_widget_centered ("Cycles per instruction:", cpuspeed_scale, newbox);
992:
993: return frame;
994: }
995:
1.1.1.2 root 996: static void make_cpu_widgets (GtkWidget *vbox)
1.1 root 997: {
998: int i;
1.1.1.3 root 999: GtkWidget *newbox, *hbox, *frame;
1.1 root 1000: GtkWidget *thing;
1.1.1.2 root 1001: static const char *radiolabels[] = {
1.1.1.8 root 1002: "68000", "68010", "68020", "68020+68881", "68040",
1.1.1.2 root 1003: NULL
1004: };
1005:
1006: add_empty_vbox (vbox);
1007:
1.1.1.3 root 1008: hbox = gtk_hbox_new (FALSE, 0);
1009: add_empty_vbox (hbox);
1010:
1011: newbox = make_radio_group_box ("CPU type", radiolabels, cpu_widget, 0, cputype_changed);
1.1.1.2 root 1012: gtk_widget_show (newbox);
1.1.1.3 root 1013: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, FALSE, 0);
1014:
1015: newbox = make_cpu_speed_sel ();
1016: gtk_widget_show (newbox);
1017: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, FALSE, 0);
1018:
1019: add_empty_vbox (hbox);
1020: gtk_widget_show (hbox);
1021: gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
1.1 root 1022:
1023: frame = gtk_frame_new ("CPU flags");
1.1.1.2 root 1024: add_centered_to_vbox (vbox, frame);
1.1 root 1025: gtk_widget_show (frame);
1.1.1.2 root 1026: newbox = gtk_vbox_new (FALSE, 4);
1027: gtk_widget_show (newbox);
1.1.1.4 root 1028: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1.1.1.2 root 1029: gtk_container_add (GTK_CONTAINER (frame), newbox);
1.1 root 1030:
1031: a24m_widget = gtk_check_button_new_with_label ("24 bit address space");
1.1.1.2 root 1032: add_centered_to_vbox (newbox, a24m_widget);
1.1 root 1033: gtk_widget_show (a24m_widget);
1034: ccpu_widget = gtk_check_button_new_with_label ("Slow but compatible");
1.1.1.2 root 1035: add_centered_to_vbox (newbox, ccpu_widget);
1.1 root 1036: gtk_widget_show (ccpu_widget);
1.1.1.8 root 1037:
1.1.1.2 root 1038: add_empty_vbox (vbox);
1039:
1.1 root 1040: gtk_signal_connect (GTK_OBJECT (ccpu_widget), "clicked",
1041: (GtkSignalFunc) cputype_changed, NULL);
1042: gtk_signal_connect (GTK_OBJECT (a24m_widget), "clicked",
1043: (GtkSignalFunc) cputype_changed, NULL);
1044: }
1045:
1.1.1.2 root 1046: static void make_gfx_widgets (GtkWidget *vbox)
1.1 root 1047: {
1.1.1.10 root 1048: GtkWidget *thing, *frame, *newbox, *hbox;
1049: static const char *p96labels[] = {
1050: "None", "1 MB", "2 MB", "4 MB", "8 MB", "16 MB", "32 MB", NULL
1051: };
1.1 root 1052:
1.1.1.2 root 1053: add_empty_vbox (vbox);
1.1 root 1054:
1.1.1.10 root 1055: hbox = gtk_hbox_new (FALSE, 10);
1056: gtk_widget_show (hbox);
1057: add_centered_to_vbox (vbox, hbox);
1058:
1059: frame = make_radio_group_box_1 ("P96 RAM", p96labels, p96size_widget, 0, p96size_changed, 4);
1060: gtk_widget_show (frame);
1061: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1062:
1063: frame = gtk_frame_new ("Miscellaneous");
1064: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
1065:
1066: gtk_widget_show (frame);
1067: newbox = gtk_vbox_new (FALSE, 4);
1068: gtk_widget_show (newbox);
1069: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1070: gtk_container_add (GTK_CONTAINER (frame), newbox);
1071:
1.1.1.6 root 1072: framerate_adj = GTK_ADJUSTMENT (gtk_adjustment_new (currprefs.gfx_framerate, 1.0, 21.0, 1.0, 1.0, 1.0));
1.1 root 1073: gtk_signal_connect (GTK_OBJECT (framerate_adj), "value_changed",
1.1.1.2 root 1074: GTK_SIGNAL_FUNC (custom_changed), NULL);
1.1 root 1075:
1076: thing = gtk_hscale_new (framerate_adj);
1077: gtk_range_set_update_policy (GTK_RANGE (thing), GTK_UPDATE_DELAYED);
1078: gtk_scale_set_digits (GTK_SCALE (thing), 0);
1079: gtk_scale_set_value_pos (GTK_SCALE (thing), GTK_POS_RIGHT);
1.1.1.10 root 1080: add_labelled_widget_centered ("Framerate:", thing, newbox);
1.1 root 1081:
1082: b32_widget = gtk_check_button_new_with_label ("32 bit blitter");
1.1.1.10 root 1083: add_centered_to_vbox (newbox, b32_widget);
1.1.1.7 root 1084: #if 0
1.1 root 1085: gtk_widget_show (b32_widget);
1.1.1.7 root 1086: #endif
1.1 root 1087: bimm_widget = gtk_check_button_new_with_label ("Immediate blits");
1.1.1.10 root 1088: add_centered_to_vbox (newbox, bimm_widget);
1.1 root 1089: gtk_widget_show (bimm_widget);
1090:
1.1.1.7 root 1091: afscr_widget = gtk_check_button_new_with_label ("Amiga modes fullscreen");
1.1.1.10 root 1092: add_centered_to_vbox (newbox, afscr_widget);
1.1.1.7 root 1093: #if 0
1094: gtk_widget_show (afscr_widget);
1095: #endif
1096: pfscr_widget = gtk_check_button_new_with_label ("Picasso modes fullscreen");
1.1.1.10 root 1097: add_centered_to_vbox (newbox, pfscr_widget);
1.1.1.7 root 1098: #if 0
1099: gtk_widget_show (pfscr_widget);
1100: #endif
1.1.1.2 root 1101: add_empty_vbox (vbox);
1102:
1.1 root 1103: gtk_signal_connect (GTK_OBJECT (bimm_widget), "clicked",
1.1.1.2 root 1104: (GtkSignalFunc) custom_changed, NULL);
1.1.1.10 root 1105: #if 0
1.1 root 1106: gtk_signal_connect (GTK_OBJECT (b32_widget), "clicked",
1.1.1.2 root 1107: (GtkSignalFunc) custom_changed, NULL);
1.1.1.7 root 1108: gtk_signal_connect (GTK_OBJECT (afscr_widget), "clicked",
1109: (GtkSignalFunc) custom_changed, NULL);
1110: gtk_signal_connect (GTK_OBJECT (pfscr_widget), "clicked",
1111: (GtkSignalFunc) custom_changed, NULL);
1.1.1.10 root 1112: #endif
1113: }
1114:
1115: static void make_chipset_widgets (GtkWidget *vbox)
1116: {
1117: GtkWidget *frame, *newbox, *hbox;
1118: static const char *colllabels[] = {
1119: "None (fastest)", "Sprites only", "Sprites & playfields", "Full (very slow)",
1120: NULL
1121: };
1122: static const char *cslevellabels[] = {
1123: "OCS", "ECS Agnus", "Full ECS", "AGA", NULL
1124: };
1125:
1126: add_empty_vbox (vbox);
1127:
1128: hbox = gtk_hbox_new (FALSE, 10);
1129: gtk_widget_show (hbox);
1130: add_centered_to_vbox (vbox, hbox);
1131:
1132: newbox = make_radio_group_box ("Sprite collisions", colllabels, coll_widget, 0, coll_changed);
1133: gtk_widget_show (newbox);
1134: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1135:
1136: newbox = make_radio_group_box ("Chipset", cslevellabels, cslevel_widget, 0, cslevel_changed);
1137: gtk_widget_show (newbox);
1138: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1139:
1140: fcop_widget = gtk_check_button_new_with_label ("Enable copper speedup code");
1141: add_centered_to_vbox (vbox, fcop_widget);
1142: gtk_widget_show (fcop_widget);
1143:
1144: gtk_signal_connect (GTK_OBJECT (fcop_widget), "clicked",
1145: (GtkSignalFunc) custom_changed, NULL);
1146:
1147: add_empty_vbox (vbox);
1.1.1.2 root 1148: }
1149:
1150: static void make_sound_widgets (GtkWidget *vbox)
1151: {
1152: GtkWidget *frame, *newbox;
1153: int i;
1154: GtkWidget *hbox;
1155: static const char *soundlabels1[] = {
1156: "None", "No output", "Normal", "Accurate",
1157: NULL
1158: }, *soundlabels2[] = {
1159: "8 bit", "16 bit",
1160: NULL
1161: }, *soundlabels3[] = {
1.1.1.9 root 1162: "Mono", "Stereo", "Mixed",
1.1.1.2 root 1163: NULL
1164: };
1165:
1166: add_empty_vbox (vbox);
1167:
1168: newbox = make_radio_group_box ("Mode", soundlabels1, sound_widget, 1, sound_changed);
1169: gtk_widget_show (newbox);
1170: add_centered_to_vbox (vbox, newbox);
1171:
1172: hbox = gtk_hbox_new (FALSE, 10);
1173: gtk_widget_show (hbox);
1174: add_centered_to_vbox (vbox, hbox);
1175: newbox = make_radio_group_box ("Channels", soundlabels3, sound_ch_widget, 1, sound_changed);
1176: gtk_widget_show (newbox);
1177: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1178: newbox = make_radio_group_box ("Resolution", soundlabels2, sound_bits_widget, 1, sound_changed);
1179: gtk_widget_show (newbox);
1180: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1.1.1.3 root 1181:
1.1.1.2 root 1182: add_empty_vbox (vbox);
1.1 root 1183: }
1184:
1.1.1.10 root 1185: static void make_mem_widgets (GtkWidget *vbox)
1186: {
1187: GtkWidget *hbox = gtk_hbox_new (FALSE, 10);
1188: GtkWidget *label, *frame;
1189:
1190: static const char *chiplabels[] = {
1191: "512 KB", "1 MB", "2 MB", "4 MB", "8 MB", NULL
1192: };
1193: static const char *bogolabels[] = {
1194: "None", "512 KB", "1 MB", "1.8 MB", NULL
1195: };
1196: static const char *fastlabels[] = {
1197: "None", "1 MB", "2 MB", "4 MB", "8 MB", NULL
1198: };
1199: static const char *z3labels[] = {
1200: "None", "1 MB", "2 MB", "4 MB", "8 MB",
1201: "16 MB", "32 MB", "64 MB", "128 MB", "256 MB",
1202: NULL
1203: };
1204:
1205: add_empty_vbox (vbox);
1.1.1.11! root 1206:
! 1207: {
! 1208: GtkWidget *buttonbox = make_file_container ("Kickstart ROM file:", vbox);
! 1209: GtkWidget *thing = gtk_button_new_with_label ("Change");
! 1210:
! 1211: /* Current file display */
! 1212: rom_text_widget = make_file_widget (buttonbox);
! 1213:
! 1214: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
! 1215: gtk_widget_show (thing);
! 1216: rom_change_widget = thing;
! 1217: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_romchange, 0);
! 1218: }
! 1219:
! 1220: {
! 1221: GtkWidget *buttonbox = make_file_container ("ROM key file for Cloanto Amiga Forever:", vbox);
! 1222: GtkWidget *thing = gtk_button_new_with_label ("Change");
! 1223:
! 1224: /* Current file display */
! 1225: key_text_widget = make_file_widget (buttonbox);
! 1226:
! 1227: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
! 1228: gtk_widget_show (thing);
! 1229: key_change_widget = thing;
! 1230: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_keychange, 0);
! 1231: }
! 1232:
1.1.1.10 root 1233: gtk_widget_show (hbox);
1234: add_centered_to_vbox (vbox, hbox);
1235:
1236: add_empty_vbox (vbox);
1237:
1238: label = gtk_label_new ("These settings take effect after the next reset.");
1239: gtk_widget_show (label);
1240: add_centered_to_vbox (vbox, label);
1241:
1242: frame = make_radio_group_box ("Chip Mem", chiplabels, chipsize_widget, 0, chipsize_changed);
1243: gtk_widget_show (frame);
1244: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1245:
1246: frame = make_radio_group_box ("Slow Mem", bogolabels, bogosize_widget, 0, bogosize_changed);
1247: gtk_widget_show (frame);
1248: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1249:
1250: frame = make_radio_group_box ("Fast Mem", fastlabels, fastsize_widget, 0, fastsize_changed);
1251: gtk_widget_show (frame);
1252: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1253:
1254: frame = make_radio_group_box_1 ("Z3 Mem", z3labels, z3size_widget, 0, z3size_changed, 5);
1255: gtk_widget_show (frame);
1256: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1257: }
1258:
1.1.1.2 root 1259: static void make_joy_widgets (GtkWidget *dvbox)
1.1 root 1260: {
1261: int i;
1.1.1.2 root 1262: GtkWidget *hbox = gtk_hbox_new (FALSE, 10);
1263: static const char *joylabels[] = {
1264: "Joystick 0", "Joystick 1", "Mouse", "Numeric pad",
1265: "Cursor keys/Right Ctrl", "T/F/H/B/Left Alt",
1266: NULL
1267: };
1268:
1269: add_empty_vbox (dvbox);
1270: gtk_widget_show (hbox);
1271: add_centered_to_vbox (dvbox, hbox);
1.1 root 1272:
1273: for (i = 0; i < 2; i++) {
1274: GtkWidget *vbox, *frame;
1275: GtkWidget *thing;
1276: char buffer[20];
1277: int j;
1278:
1279: sprintf (buffer, "Port %d", i);
1.1.1.2 root 1280: frame = make_radio_group_box (buffer, joylabels, joy_widget[i], 0, joy_changed);
1.1 root 1281: gtk_widget_show (frame);
1.1.1.2 root 1282: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1.1 root 1283: }
1.1.1.2 root 1284:
1285: add_empty_vbox (dvbox);
1286: }
1287:
1.1.1.11! root 1288: static void newdir_ok (void)
! 1289: {
! 1290: int n;
! 1291: strcpy (dirdlg_volname, gtk_entry_get_text (GTK_ENTRY (volname_entry)));
! 1292: strcpy (dirdlg_path, gtk_entry_get_text (GTK_ENTRY (path_entry)));
! 1293:
! 1294: n = strlen (dirdlg_volname);
! 1295: /* Strip colons from the end. */
! 1296: if (n > 0) {
! 1297: if (dirdlg_volname[n - 1] == ':')
! 1298: dirdlg_volname[n - 1] = '\0';
! 1299: }
! 1300: if (strlen (dirdlg_volname) == 0 || strlen (dirdlg_path) == 0) {
! 1301: /* Uh, no messageboxes in gtk? */
! 1302: } else {
! 1303: add_filesys_unit (currprefs.mountinfo, dirdlg_volname, dirdlg_path,
! 1304: 0, 0, 0, 0, 0);
! 1305: set_hd_state ();
! 1306: }
! 1307: gtk_widget_destroy (dirdlg);
! 1308: }
! 1309:
! 1310: static GtkWidget *create_dirdlg (const char *title)
! 1311: {
! 1312: GtkWidget *vbox, *hbox, *thing, *label1, *button;
! 1313:
! 1314: dirdlg = gtk_dialog_new ();
! 1315:
! 1316: gtk_window_set_title (GTK_WINDOW (dirdlg), title);
! 1317: gtk_window_set_position (GTK_WINDOW (dirdlg), GTK_WIN_POS_MOUSE);
! 1318: gtk_window_set_modal (GTK_WINDOW (dirdlg), TRUE);
! 1319: gtk_widget_show (dirdlg);
! 1320:
! 1321: vbox = GTK_DIALOG (dirdlg)->vbox;
! 1322: hbox = gtk_hbox_new (FALSE, 10);
! 1323: gtk_widget_show (hbox);
! 1324: gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10);
! 1325: label1 = gtk_label_new ("Path:");
! 1326: gtk_box_pack_start (GTK_BOX (hbox), label1, FALSE, TRUE, 10);
! 1327: gtk_widget_show (label1);
! 1328: thing = gtk_entry_new_with_max_length (255);
! 1329: gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10);
! 1330: gtk_widget_show (thing);
! 1331: path_entry = thing;
! 1332:
! 1333: hbox = gtk_hbox_new (FALSE, 10);
! 1334: gtk_widget_show (hbox);
! 1335: gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10);
! 1336: thing = gtk_label_new ("Volume name:");
! 1337: gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, TRUE, 10);
! 1338: gtk_widget_show (thing);
! 1339: thing = gtk_entry_new_with_max_length (255);
! 1340: gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10);
! 1341: gtk_widget_show (thing);
! 1342: gtk_widget_set_usize (thing, 200, -1);
! 1343: volname_entry = thing;
! 1344:
! 1345: hbox = GTK_DIALOG (dirdlg)->action_area;
! 1346: button = gtk_button_new_with_label ("OK");
! 1347: gtk_signal_connect (GTK_OBJECT (button), "clicked",
! 1348: GTK_SIGNAL_FUNC(newdir_ok), NULL);
! 1349: GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
! 1350: gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
! 1351: gtk_widget_grab_default (button);
! 1352: gtk_widget_show (button);
! 1353:
! 1354: button = gtk_button_new_with_label ("Cancel");
! 1355: gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
! 1356: GTK_SIGNAL_FUNC (gtk_widget_destroy),
! 1357: GTK_OBJECT (dirdlg));
! 1358: gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
! 1359: gtk_widget_show (button);
! 1360: }
! 1361:
! 1362: static void did_newdir (void)
! 1363: {
! 1364: create_dirdlg ("Add a new mounted directory");
! 1365: }
! 1366: static void did_newhdf (void)
! 1367: {
! 1368: }
! 1369:
! 1370: static void did_hdchange (void)
! 1371: {
! 1372: int secspertrack, surfaces, reserved, blocksize, size;
! 1373: int cylinders, readonly;
! 1374: char *volname, *rootdir;
! 1375: char *failure;
! 1376:
! 1377: failure = get_filesys_unit (currprefs.mountinfo, selected_hd_row,
! 1378: &volname, &rootdir, &readonly,
! 1379: &secspertrack, &surfaces, &reserved,
! 1380: &cylinders, &size, &blocksize);
! 1381:
! 1382: if (is_hardfile (currprefs.mountinfo, selected_hd_row)) {
! 1383: } else {
! 1384: create_dirdlg ("Change a mounted directory");
! 1385: gtk_entry_set_text (GTK_ENTRY (volname_entry), volname);
! 1386: gtk_entry_set_text (GTK_ENTRY (path_entry), rootdir);
! 1387: }
! 1388: }
! 1389: static void did_hddel (void)
! 1390: {
! 1391: kill_filesys_unit (currprefs.mountinfo, selected_hd_row);
! 1392: set_hd_state ();
! 1393: }
! 1394:
! 1395: static void hdselect (GtkWidget *widget, gint row, gint column, GdkEventButton *bevent,
! 1396: gpointer user_data)
! 1397: {
! 1398: selected_hd_row = row;
! 1399: gtk_widget_set_sensitive (hdchange_button, TRUE);
! 1400: gtk_widget_set_sensitive (hddel_button, TRUE);
! 1401: }
! 1402:
! 1403: static void hdunselect (GtkWidget *widget, gint row, gint column, GdkEventButton *bevent,
! 1404: gpointer user_data)
! 1405: {
! 1406: gtk_widget_set_sensitive (hdchange_button, FALSE);
! 1407: gtk_widget_set_sensitive (hddel_button, FALSE);
! 1408: }
! 1409:
! 1410:
1.1.1.6 root 1411: static GtkWidget *make_buttons (const char *label, GtkWidget *box, void (*sigfunc) (void), GtkWidget *(*create)(const char *label))
1.1.1.2 root 1412: {
1.1.1.6 root 1413: GtkWidget *thing = create (label);
1.1.1.2 root 1414: gtk_widget_show (thing);
1415: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) sigfunc, NULL);
1416: gtk_box_pack_start (GTK_BOX (box), thing, TRUE, TRUE, 0);
1.1.1.6 root 1417:
1418: return thing;
1.1 root 1419: }
1.1.1.6 root 1420: #define make_button(label, box, sigfunc) make_buttons(label, box, sigfunc, gtk_button_new_with_label)
1.1 root 1421:
1.1.1.11! root 1422: static void make_hd_widgets (GtkWidget *dvbox)
! 1423: {
! 1424: GtkWidget *thing, *buttonbox, *hbox;
! 1425: char *titles [] = {
! 1426: "Volume", "File/Directory", "R/O", "Heads", "Cyl.", "Sec.", "Rsrvd", "Size", "Blksize"
! 1427: };
! 1428:
! 1429: thing = gtk_clist_new_with_titles (9, titles);
! 1430: gtk_clist_set_selection_mode (GTK_CLIST (thing), GTK_SELECTION_SINGLE);
! 1431: gtk_signal_connect (GTK_OBJECT (thing), "select_row", (GtkSignalFunc) hdselect, NULL);
! 1432: gtk_signal_connect (GTK_OBJECT (thing), "unselect_row", (GtkSignalFunc) hdunselect, NULL);
! 1433: hdlist_widget = thing;
! 1434: gtk_widget_set_usize (thing, -1, 200);
! 1435:
! 1436: gtk_widget_show (thing);
! 1437: add_centered_to_vbox (dvbox, thing);
! 1438:
! 1439: hbox = gtk_hbox_new (FALSE, 10);
! 1440: gtk_widget_show (hbox);
! 1441: gtk_box_pack_start (GTK_BOX (dvbox), hbox, FALSE, TRUE, 0);
! 1442:
! 1443: /* The buttons */
! 1444: buttonbox = gtk_hbox_new (TRUE, 4);
! 1445: gtk_widget_show (buttonbox);
! 1446: gtk_box_pack_start (GTK_BOX (hbox), buttonbox, TRUE, TRUE, 0);
! 1447: make_button ("New filesystem...", buttonbox, did_newdir);
! 1448: #if 0 /* later... */
! 1449: make_button ("New hardfile...", buttonbox, did_newhdf);
! 1450: #endif
! 1451: hdchange_button = make_button ("Change...", buttonbox, did_hdchange);
! 1452: hddel_button = make_button ("Delete", buttonbox, did_hddel);
! 1453:
! 1454: thing = gtk_label_new ("These settings take effect after the next reset.");
! 1455: gtk_widget_show (thing);
! 1456: add_centered_to_vbox (dvbox, thing);
! 1457: }
! 1458:
! 1459: static void make_about_widgets (GtkWidget *dvbox)
! 1460: {
! 1461: GtkWidget *thing;
! 1462: GtkStyle *style;
! 1463: GdkFont *font;
! 1464: char t[20];
! 1465:
! 1466: add_empty_vbox (dvbox);
! 1467:
! 1468: sprintf (t, "UAE %d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
! 1469: thing = gtk_label_new (t);
! 1470: gtk_widget_show (thing);
! 1471: add_centered_to_vbox (dvbox, thing);
! 1472:
! 1473: font = gdk_font_load ("-*-helvetica-medium-r-normal--*-240-*-*-*-*-*-*");
! 1474: if (font) {
! 1475: style = gtk_style_copy (GTK_WIDGET (thing)->style);
! 1476: gdk_font_unref (style->font);
! 1477: style->font = font;
! 1478: gdk_font_ref (style->font);
! 1479: gtk_widget_push_style (style);
! 1480: gtk_widget_set_style (thing, style);
! 1481: }
! 1482: thing = gtk_label_new ("Choose your settings, then deselect the Pause button to start!");
! 1483: gtk_widget_show (thing);
! 1484: add_centered_to_vbox (dvbox, thing);
! 1485:
! 1486: add_empty_vbox (dvbox);
! 1487: }
! 1488:
! 1489:
! 1490: static void create_guidlg (void)
1.1 root 1491: {
1492: GtkWidget *window, *notebook;
1.1.1.2 root 1493: GtkWidget *buttonbox, *vbox, *hbox;
1.1 root 1494: GtkWidget *thing;
1495: int i;
1496: int argc = 1;
1497: char *a[] = {"UAE"};
1498: char **argv = a;
1.1.1.2 root 1499: static const struct _pages {
1500: const char *title;
1501: void (*createfunc)(GtkWidget *);
1502: } pages[] = {
1.1.1.10 root 1503: /* ??? If this isn't the first page, there are errors in draw_led. */
1.1.1.2 root 1504: { "Floppy disks", make_floppy_disks },
1.1.1.10 root 1505: { "Memory", make_mem_widgets },
1.1.1.2 root 1506: { "CPU emulation", make_cpu_widgets },
1507: { "Graphics", make_gfx_widgets },
1.1.1.10 root 1508: { "Chipset", make_chipset_widgets },
1.1.1.2 root 1509: { "Sound", make_sound_widgets },
1.1.1.11! root 1510: { "Game ports", make_joy_widgets },
! 1511: { "Harddisks", make_hd_widgets },
! 1512: { "About", make_about_widgets }
1.1.1.2 root 1513: };
1.1 root 1514:
1515: gtk_init (&argc, &argv);
1516: gtk_rc_parse ("uaegtkrc");
1517:
1.1.1.11! root 1518: gui_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
! 1519: gtk_window_set_title (GTK_WINDOW (gui_window), "UAE control");
1.1 root 1520:
1521: vbox = gtk_vbox_new (FALSE, 4);
1.1.1.11! root 1522: gtk_container_add (GTK_CONTAINER (gui_window), vbox);
! 1523: gtk_container_set_border_width (GTK_CONTAINER (gui_window), 10);
1.1 root 1524:
1.1.1.2 root 1525: /* First line - buttons and power LED */
1526: hbox = gtk_hbox_new (FALSE, 10);
1527: gtk_widget_show (hbox);
1528: gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
1.1 root 1529:
1.1.1.2 root 1530: /* The buttons */
1531: buttonbox = gtk_hbox_new (TRUE, 4);
1.1 root 1532: gtk_widget_show (buttonbox);
1.1.1.2 root 1533: gtk_box_pack_start (GTK_BOX (hbox), buttonbox, TRUE, TRUE, 0);
1534: make_button ("Reset", buttonbox, did_reset);
1535: make_button ("Debug", buttonbox, did_debug);
1536: make_button ("Quit", buttonbox, did_quit);
1537: make_button ("Save config", buttonbox, save_config);
1.1.1.6 root 1538: pause_uae_widget = make_buttons ("Pause", buttonbox, pause_uae, gtk_toggle_button_new_with_label);
1.1 root 1539:
1.1.1.2 root 1540: /* The LED */
1541: thing = make_led (0);
1542: thing = make_labelled_widget ("Power:", thing);
1.1 root 1543: gtk_widget_show (thing);
1.1.1.2 root 1544: gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, TRUE, 0);
1.1 root 1545:
1.1.1.10 root 1546: /* More buttons */
1547: buttonbox = gtk_hbox_new (TRUE, 4);
1548: gtk_widget_show (buttonbox);
1549: gtk_box_pack_start (GTK_BOX (vbox), buttonbox, TRUE, TRUE, 0);
1550: snap_save_widget = make_button ("Save state", buttonbox, did_savestate);
1551: snap_load_widget = make_button ("Load state", buttonbox, did_loadstate);
1552:
1.1.1.2 root 1553: /* Place a separator below those buttons. */
1.1 root 1554: thing = gtk_hseparator_new ();
1555: gtk_box_pack_start (GTK_BOX (vbox), thing, FALSE, TRUE, 0);
1556: gtk_widget_show (thing);
1557:
1.1.1.2 root 1558: /* Now the notebook */
1.1 root 1559: notebook = gtk_notebook_new ();
1.1.1.2 root 1560: gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
1.1 root 1561: gtk_widget_show (notebook);
1562:
1.1.1.2 root 1563: for (i = 0; i < sizeof pages / sizeof (struct _pages); i++) {
1564: thing = gtk_vbox_new (FALSE, 4);
1565: gtk_widget_show (thing);
1.1.1.4 root 1566: gtk_container_set_border_width (GTK_CONTAINER (thing), 10);
1.1.1.2 root 1567: pages[i].createfunc (thing);
1568: gtk_notebook_append_page (GTK_NOTEBOOK (notebook), thing, gtk_label_new (pages[i].title));
1569: }
1.1 root 1570:
1.1.1.11! root 1571: /* Put "about" screen first. */
! 1572: gtk_notebook_set_page (GTK_NOTEBOOK (notebook), i - 1);
1.1 root 1573: enable_disk_buttons (1);
1.1.1.11! root 1574: enable_snap_buttons (1);
1.1 root 1575:
1576: gtk_widget_show (vbox);
1577:
1578: filesel_active = -1;
1.1.1.10 root 1579: snapsel_active = -1;
1580:
1.1 root 1581: gtk_timeout_add (1000, (GtkFunction)my_idle, 0);
1.1.1.11! root 1582: }
! 1583:
! 1584: static void *gtk_gui_thread (void *dummy)
! 1585: {
1.1 root 1586: gtk_main ();
1.1.1.11! root 1587:
1.1 root 1588: quitted_gui = 1;
1589: uae_sem_post (&gui_quit_sem);
1590: return 0;
1591: }
1592:
1593: void gui_changesettings(void)
1594: {
1595:
1596: }
1597:
1.1.1.4 root 1598: void gui_fps (int x)
1599: {
1600: }
1601:
1602: void gui_led (int num, int on)
1.1 root 1603: {
1604: if (no_gui)
1605: return;
1606:
1607: /* if (num == 0)
1608: return;
1609: printf("LED %d %d\n", num, on);
1610: write_comm_pipe_int (&to_gui_pipe, 1, 0);
1611: write_comm_pipe_int (&to_gui_pipe, num == 0 ? 4 : num - 1, 0);
1612: write_comm_pipe_int (&to_gui_pipe, on, 1);
1613: printf("#LED %d %d\n", num, on);*/
1614: }
1615:
1.1.1.11! root 1616: void gui_filename (int num, const char *name)
1.1 root 1617: {
1618: if (no_gui)
1619: return;
1620:
1621: write_comm_pipe_int (&to_gui_pipe, 0, 0);
1622: write_comm_pipe_int (&to_gui_pipe, num, 1);
1623:
1624: /* gui_update ();*/
1625: }
1626:
1.1.1.10 root 1627: void gui_handle_events (void)
1.1 root 1628: {
1.1.1.6 root 1629: int pause_uae = FALSE;
1630:
1.1 root 1631: if (no_gui)
1632: return;
1633:
1.1.1.6 root 1634: do {
1635: while (pause_uae || comm_pipe_has_data (&from_gui_pipe)) {
1636: int cmd = read_comm_pipe_int_blocking (&from_gui_pipe);
1637: int n;
1638: switch (cmd) {
1.1.1.11! root 1639: case 0:
! 1640: n = read_comm_pipe_int_blocking (&from_gui_pipe);
! 1641: changed_prefs.df[n][0] = '\0';
! 1642: break;
! 1643: case 1:
! 1644: n = read_comm_pipe_int_blocking (&from_gui_pipe);
! 1645: uae_sem_wait (&gui_sem);
! 1646: strncpy (changed_prefs.df[n], new_disk_string[n], 255);
! 1647: free (new_disk_string[n]);
! 1648: new_disk_string[n][0] = '\0';
! 1649: changed_prefs.df[n][255] = '\0';
! 1650: uae_sem_post (&gui_sem);
! 1651: break;
! 1652: case 2:
! 1653: uae_reset ();
! 1654: end_pause_uae ();
! 1655: break;
! 1656: case 3:
! 1657: activate_debugger ();
! 1658: end_pause_uae ();
! 1659: break;
! 1660: case 4:
! 1661: uae_quit ();
! 1662: end_pause_uae ();
! 1663: break;
! 1664: case 5:
! 1665: pause_uae = TRUE;
! 1666: break;
! 1667: case 6:
! 1668: pause_uae = FALSE;
! 1669: break;
1.1.1.10 root 1670: case 7:
1671: printf ("STATESAVE\n");
1.1.1.11! root 1672: savestate_state = read_comm_pipe_int_blocking (&from_gui_pipe);
! 1673: uae_sem_wait (&gui_sem);
! 1674: savestate_filename = gui_snapname;
! 1675: uae_sem_post (&gui_sem);
! 1676: break;
! 1677: case 8:
! 1678: uae_sem_wait (&gui_sem);
! 1679: strncpy (changed_prefs.romfile, gui_romname, 255);
! 1680: changed_prefs.romfile[255] = '\0';
! 1681: free (gui_romname);
! 1682: uae_sem_post (&gui_sem);
! 1683: break;
! 1684: case 9:
! 1685: uae_sem_wait (&gui_sem);
! 1686: strncpy (changed_prefs.keyfile, gui_keyname, 255);
! 1687: changed_prefs.keyfile[255] = '\0';
! 1688: free (gui_keyname);
! 1689: uae_sem_post (&gui_sem);
1.1.1.10 root 1690: break;
1.1.1.6 root 1691: }
1692: }
1693: } while (pause_uae);
1.1 root 1694: }
1.1.1.7 root 1695:
1696: void gui_update_gfx (void)
1697: {
1698: #if 0 /* This doesn't work... */
1699: set_gfx_state ();
1700: #endif
1701: }
1.1.1.11! root 1702:
! 1703: int gui_init (void)
! 1704: {
! 1705: uae_thread_id tid;
! 1706:
! 1707: gui_active = 0;
! 1708:
! 1709: init_comm_pipe (&to_gui_pipe, 20, 1);
! 1710: init_comm_pipe (&from_gui_pipe, 20, 1);
! 1711: uae_sem_init (&gui_sem, 0, 1);
! 1712: uae_sem_init (&gui_init_sem, 0, 0);
! 1713: uae_sem_init (&gui_quit_sem, 0, 0);
! 1714:
! 1715: create_guidlg ();
! 1716: uae_start_thread (gtk_gui_thread, NULL, &tid);
! 1717: gui_update ();
! 1718:
! 1719: if (currprefs.start_gui == 1) {
! 1720: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pause_uae_widget), TRUE);
! 1721: write_comm_pipe_int (&from_gui_pipe, 5, 1);
! 1722: /* Handle events until Pause is unchecked. */
! 1723: gui_handle_events ();
! 1724: /* Quit requested? */
! 1725: if (quit_program == -1) {
! 1726: gui_exit ();
! 1727: return -2;
! 1728: }
! 1729: }
! 1730:
! 1731: return 1;
! 1732: }
! 1733:
! 1734: int gui_update (void)
! 1735: {
! 1736: if (no_gui)
! 1737: return 0;
! 1738:
! 1739: write_comm_pipe_int (&to_gui_pipe, 1, 1);
! 1740: uae_sem_wait (&gui_init_sem);
! 1741: return 0;
! 1742: }
! 1743:
! 1744: void gui_exit (void)
! 1745: {
! 1746: if (no_gui)
! 1747: return;
! 1748:
! 1749: quit_gui = 1;
! 1750: uae_sem_wait (&gui_quit_sem);
! 1751: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.