Annotation of uae/src/gtkui.c, revision 1.1.1.19

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.