~ubuntu-branches/ubuntu/feisty/basilisk2/feisty

« back to all changes in this revision

Viewing changes to src/Windows/prefs_editor_gtk.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2006-06-01 01:11:16 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060601011116-xjhegbgyfsxag5fl
Tags: 0.9.20060529-1
* New upstream CVS snapshot.
* Update local cdbs snippet copyright-check.mk:
  + Broaden scan to also look for "(c)" by default.
  + Make egrep options configurable.
  + Ignore auto-tools files.
* Bump up standards-version to 3.7.2 (no changes needed).
* Let dh_strip do the stripping (not the make install target).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "sysdeps.h"
22
22
 
 
23
#include <stdlib.h>
 
24
#include <string.h>
 
25
#include <fcntl.h>
 
26
#include <sys/stat.h>
23
27
#include <gtk/gtk.h>
24
 
#include <stdlib.h>
25
28
 
26
29
#include "user_strings.h"
27
30
#include "version.h"
29
32
#include "xpram.h"
30
33
#include "prefs.h"
31
34
#include "prefs_editor.h"
 
35
#include "util_windows.h"
 
36
#include "b2ether/inc/b2ether_hl.h"
32
37
 
33
38
 
34
39
// Global variables
49
54
 
50
55
 
51
56
/*
 
57
 *  SheepShaver glue
 
58
 */
 
59
 
 
60
#ifdef SHEEPSHAVER
 
61
#define DISABLE_SCSI 1
 
62
#define PROGRAM_NAME "SheepShaver"
 
63
enum {
 
64
        STR_WINDOW_LAB = STR_WINDOW_CTRL,
 
65
        STR_FULLSCREEN_LAB = STR_FULLSCREEN_CTRL,
 
66
        STR_SERIALA_CTRL = STR_SERPORTA_CTRL,
 
67
        STR_SERIALB_CTRL = STR_SERPORTB_CTRL,
 
68
};
 
69
#else
 
70
#define DISABLE_SCSI 1 /* XXX merge code from original Basilisk II for Windows */
 
71
#define PROGRAM_NAME "BasiliskII"
 
72
#endif
 
73
 
 
74
 
 
75
/*
52
76
 *  Utility functions
53
77
 */
54
78
 
94
118
        return button;
95
119
}
96
120
 
97
 
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func)
 
121
static void add_menu_item(GtkWidget *menu, const char *label, GtkSignalFunc func, gpointer data = NULL)
98
122
{
99
 
        GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id));
 
123
        GtkWidget *item = gtk_menu_item_new_with_label(label);
100
124
        gtk_widget_show(item);
101
 
        gtk_signal_connect(GTK_OBJECT(item), "activate", func, NULL);
 
125
        gtk_signal_connect(GTK_OBJECT(item), "activate", func, data);
102
126
        gtk_menu_append(GTK_MENU(menu), item);
103
127
}
104
128
 
 
129
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func)
 
130
{
 
131
        add_menu_item(menu, GetString(label_id), func, NULL);
 
132
}
 
133
 
105
134
static GtkWidget *make_pane(GtkWidget *notebook, int title_id)
106
135
{
107
136
        GtkWidget *frame, *label, *box;
157
186
        return table;
158
187
}
159
188
 
 
189
static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active)
 
190
{
 
191
        GtkWidget *label, *opt, *menu;
 
192
 
 
193
        label = gtk_label_new(GetString(label_id));
 
194
        gtk_widget_show(label);
 
195
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
 
196
 
 
197
        opt = gtk_option_menu_new();
 
198
        gtk_widget_show(opt);
 
199
        menu = gtk_menu_new();
 
200
 
 
201
        while (options->label_id) {
 
202
                add_menu_item(menu, options->label_id, options->func);
 
203
                options++;
 
204
        }
 
205
        gtk_menu_set_active(GTK_MENU(menu), active);
 
206
 
 
207
        gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
 
208
        gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
209
        return menu;
 
210
}
 
211
 
 
212
static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist)
 
213
{
 
214
        GtkWidget *label, *combo;
 
215
        char str[32];
 
216
 
 
217
        label = gtk_label_new(GetString(label_id));
 
218
        gtk_widget_show(label);
 
219
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
 
220
        
 
221
        combo = gtk_combo_new();
 
222
        gtk_widget_show(combo);
 
223
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
 
224
 
 
225
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value);
 
226
        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
227
        
 
228
        return combo;
 
229
}
 
230
 
 
231
static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options)
 
232
{
 
233
        GList *glist = NULL;
 
234
        while (options->label_id) {
 
235
                glist = g_list_append(glist, (void *)GetString(options->label_id));
 
236
                options++;
 
237
        }
 
238
 
 
239
        return table_make_combobox(table, row, label_id, default_value, glist);
 
240
}
 
241
 
 
242
static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false)
 
243
{
 
244
        GtkWidget *box, *label, *entry, *button;
 
245
 
 
246
        label = gtk_label_new(GetString(label_id));
 
247
        gtk_widget_show(label);
 
248
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
 
249
 
 
250
        const char *str = PrefsFindString(prefs_item);
 
251
        if (str == NULL)
 
252
                str = "";
 
253
 
 
254
        box = gtk_hbox_new(FALSE, 4);
 
255
        gtk_widget_show(box);
 
256
        gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
257
 
 
258
        entry = gtk_entry_new();
 
259
        gtk_entry_set_text(GTK_ENTRY(entry), str); 
 
260
        gtk_widget_show(entry);
 
261
        gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
 
262
 
 
263
        button = make_browse_button(entry);
 
264
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
 
265
        g_object_set_data(G_OBJECT(entry), "chooser_button", button);
 
266
        return entry;
 
267
}
 
268
 
160
269
static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active)
161
270
{
162
271
        GtkWidget *box, *label, *opt, *menu;
222
331
        return button;
223
332
}
224
333
 
225
 
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options)
 
334
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, GList *glist)
226
335
{
227
336
        GtkWidget *box, *label, *combo;
228
 
        char str[32];
229
337
 
230
338
        box = gtk_hbox_new(FALSE, 4);
231
339
        gtk_widget_show(box);
234
342
        label = gtk_label_new(GetString(label_id));
235
343
        gtk_widget_show(label);
236
344
        gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
237
 
 
238
 
        GList *glist = NULL;
239
 
        while (options->label_id) {
240
 
                glist = g_list_append(glist, (void *)GetString(options->label_id));
241
 
                options++;
242
 
        }
243
345
        
244
346
        combo = gtk_combo_new();
245
347
        gtk_widget_show(combo);
246
348
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
247
349
        
248
 
        sprintf(str, "%d", PrefsFindInt32(prefs_item));
249
 
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
 
350
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value);
250
351
        gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0);
251
352
        
252
353
        return combo;
253
354
}
254
355
 
 
356
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, const combo_desc *options)
 
357
{
 
358
        GList *glist = NULL;
 
359
        while (options->label_id) {
 
360
                glist = g_list_append(glist, (void *)GetString(options->label_id));
 
361
                options++;
 
362
        }
 
363
 
 
364
        return make_combobox(top, label_id, default_value, glist);
 
365
}
 
366
 
255
367
 
256
368
/*
257
369
 *  Show preferences editor
307
419
 
308
420
        char str[512];
309
421
        sprintf(str,
310
 
                "Basilisk II\nVersion %d.%d\n\n"
 
422
                PROGRAM_NAME "\nVersion %d.%d\n\n"
311
423
                "Copyright (C) 1997-2005 Christian Bauer et al.\n"
312
 
                "E-mail: Christian.Bauer@uni-mainz.de\n"
313
 
                "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n"
314
 
                "Basilisk II comes with ABSOLUTELY NO\n"
 
424
                "E-mail: cb@cebix.net\n"
 
425
#ifdef SHEEPSHAVER
 
426
                "http://sheepshaver.cebix.net/\n\n"
 
427
#else
 
428
                "http://basilisk.cebix.net/\n\n"
 
429
#endif
 
430
                PROGRAM_NAME " comes with ABSOLUTELY NO\n"
315
431
                "WARRANTY. This is free software, and\n"
316
432
                "you are welcome to redistribute it\n"
317
433
                "under the terms of the GNU General\n"
341
457
// Menu item descriptions
342
458
static GtkItemFactoryEntry menu_items[] = {
343
459
        {(gchar *)GetString(STR_PREFS_MENU_FILE_GTK),           NULL,                   NULL,                                                   0, "<Branch>"},
344
 
        {(gchar *)GetString(STR_PREFS_ITEM_START_GTK),          NULL,                   GTK_SIGNAL_FUNC(cb_start),              0, NULL},
 
460
        {(gchar *)GetString(STR_PREFS_ITEM_START_GTK),          "<control>S",   GTK_SIGNAL_FUNC(cb_start),              0, NULL},
345
461
        {(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK),       NULL,                   GTK_SIGNAL_FUNC(cb_zap_pram),   0, NULL},
346
462
        {(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK),           NULL,                   NULL,                                                   0, "<Separator>"},
347
463
        {(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK),           "<control>Q",   GTK_SIGNAL_FUNC(cb_quit),               0, NULL},
348
464
        {(gchar *)GetString(STR_HELP_MENU_GTK),                         NULL,                   NULL,                                                   0, "<LastBranch>"},
349
 
        {(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK),           NULL,                   GTK_SIGNAL_FUNC(cb_about),              0, NULL}
 
465
        {(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK),           "<control>H",   GTK_SIGNAL_FUNC(cb_about),              0, NULL}
350
466
};
351
467
 
 
468
void PrefsMigrate(void)
 
469
{
 
470
        // Ethernet
 
471
        const char *ether = PrefsFindString("ether");
 
472
        if (ether && ether[0] == '{') {
 
473
                PrefsReplaceString("etherguid", ether);
 
474
                PrefsReplaceString("ether", "b2ether");
 
475
        }
 
476
        if (PrefsFindBool("routerenabled")) {
 
477
                PrefsRemoveItem("etherguid");
 
478
                PrefsReplaceString("ether", "router");
 
479
        }
 
480
}
 
481
 
352
482
bool PrefsEditor(void)
353
483
{
354
484
        // Create window
381
511
        gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0);
382
512
 
383
513
        create_volumes_pane(notebook);
 
514
#ifndef DISABLE_SCSI
384
515
        create_scsi_pane(notebook);
 
516
#endif
385
517
        create_graphics_pane(notebook);
386
518
        create_input_pane(notebook);
387
519
        create_serial_pane(notebook);
391
523
 
392
524
        static const opt_desc buttons[] = {
393
525
                {STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)},
394
 
                {STR_PREFS_ITEM_ZAP_PRAM, GTK_SIGNAL_FUNC(cb_zap_pram)},
395
 
                {STR_ABOUT_BUTTON, GTK_SIGNAL_FUNC(cb_about)},
396
526
                {STR_QUIT_BUTTON, GTK_SIGNAL_FUNC(cb_quit)},
397
527
                {0, NULL}
398
528
        };
409
539
 *  "Volumes" pane
410
540
 */
411
541
 
 
542
static GtkWidget *w_enableextfs, *w_extdrives, *w_cdrom_drive;
412
543
static GtkWidget *volume_list;
413
544
static int selected_volume;
414
545
 
 
546
// Set sensitivity of widgets
 
547
static void set_volumes_sensitive(void)
 
548
{
 
549
        const bool enable_extfs = PrefsFindBool("enableextfs");
 
550
        gtk_widget_set_sensitive(w_extdrives, enable_extfs);
 
551
        const bool no_cdrom = PrefsFindBool("nocdrom");
 
552
        gtk_widget_set_sensitive(w_cdrom_drive, !no_cdrom);
 
553
}
 
554
 
415
555
// Volume in list selected
416
556
static void cl_selected(GtkWidget *list, int row, int column)
417
557
{
433
573
        gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req));
434
574
 
435
575
        const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry));
436
 
        int size = atoi(str);
 
576
        size_t size = atoi(str) << 20;
437
577
 
438
 
        char cmd[1024];
439
 
        sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", file, size);
440
 
        int ret = system(cmd);
441
 
        if (ret == 0)
 
578
        int fd = _open(file, _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC, _S_IREAD | _S_IWRITE);
 
579
        if (fd >= 0) {
 
580
          if (_chsize(fd, size) == 0)
442
581
                gtk_clist_append(GTK_CLIST(volume_list), &file);
 
582
          _close(fd);
 
583
        }
443
584
        gtk_widget_destroy(GTK_WIDGET(assoc->req));
444
585
        delete assoc;
445
586
}
488
629
static void mn_boot_any(...) {PrefsReplaceInt32("bootdriver", 0);}
489
630
static void mn_boot_cdrom(...) {PrefsReplaceInt32("bootdriver", CDROMRefNum);}
490
631
 
 
632
// "Enable external file system" button toggled
 
633
static void tb_enableextfs(GtkWidget *widget)
 
634
{
 
635
        PrefsReplaceBool("enableextfs", GTK_TOGGLE_BUTTON(widget)->active);
 
636
        set_volumes_sensitive();
 
637
}
 
638
 
491
639
// "No CD-ROM Driver" button toggled
492
640
static void tb_nocdrom(GtkWidget *widget)
493
641
{
494
642
        PrefsReplaceBool("nocdrom", GTK_TOGGLE_BUTTON(widget)->active);
 
643
        set_volumes_sensitive();
 
644
}
 
645
 
 
646
// Add names of CD-ROM devices
 
647
static GList *add_cdrom_names(void)
 
648
{
 
649
        GList *glist = NULL;
 
650
 
 
651
        char rootdir[4] = "X:\\";
 
652
        for (char letter = 'C'; letter <= 'Z'; letter++) {
 
653
                rootdir[0] = letter;
 
654
                if (GetDriveType(rootdir) == DRIVE_CDROM)
 
655
                        glist = g_list_append(glist, strdup(rootdir));
 
656
        }
 
657
 
 
658
        return glist;
 
659
}
 
660
 
 
661
// "Enable polling" button toggled
 
662
static void tb_pollmedia(GtkWidget *widget)
 
663
{
 
664
        PrefsReplaceBool("pollmedia", GTK_TOGGLE_BUTTON(widget)->active);
495
665
}
496
666
 
497
667
// Read settings from widgets and set preferences
505
675
                gtk_clist_get_text(GTK_CLIST(volume_list), i, 0, &str);
506
676
                PrefsAddString("disk", str);
507
677
        }
 
678
 
 
679
        const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_cdrom_drive)->entry));
 
680
        if (str && strlen(str))
 
681
                PrefsReplaceString("cdrom", str);
 
682
        else
 
683
                PrefsRemoveItem("cdrom");
 
684
 
 
685
        PrefsReplaceString("extdrives", get_file_entry_path(w_extdrives));
508
686
}
509
687
 
510
688
// Create "Volumes" pane
553
731
        menu = make_option_menu(box, STR_BOOTDRIVER_CTRL, options, active);
554
732
 
555
733
        make_checkbox(box, STR_NOCDROM_CTRL, "nocdrom", GTK_SIGNAL_FUNC(tb_nocdrom));
 
734
 
 
735
        GList *glist = add_cdrom_names();
 
736
        str = const_cast<char *>(PrefsFindString("cdrom"));
 
737
        if (str == NULL)
 
738
                str = "";
 
739
        w_cdrom_drive = make_combobox(box, STR_CDROM_DRIVE_CTRL, str, glist);
 
740
 
 
741
        make_checkbox(box, STR_POLLMEDIA_CTRL, "pollmedia", GTK_SIGNAL_FUNC(tb_pollmedia));
 
742
 
 
743
        make_separator(box);
 
744
        w_enableextfs = make_checkbox(box, STR_EXTFS_ENABLE_CTRL, "enableextfs", GTK_SIGNAL_FUNC(tb_enableextfs));
 
745
        w_extdrives = make_file_entry(box, STR_EXTFS_DRIVES_CTRL, "extdrives", true);
 
746
 
 
747
        set_volumes_sensitive();
556
748
}
557
749
 
558
750
 
560
752
 *  "JIT Compiler" pane
561
753
 */
562
754
 
 
755
#ifndef SHEEPSHAVER
563
756
static GtkWidget *w_jit_fpu;
564
757
static GtkWidget *w_jit_atraps;
565
758
static GtkWidget *w_jit_cache_size;
566
759
static GtkWidget *w_jit_lazy_flush;
567
760
static GtkWidget *w_jit_follow_const_jumps;
 
761
#endif
568
762
 
569
763
// Set sensitivity of widgets
570
764
static void set_jit_sensitive(void)
571
765
{
 
766
#ifndef SHEEPSHAVER
572
767
        const bool jit_enabled = PrefsFindBool("jit");
573
768
        gtk_widget_set_sensitive(w_jit_fpu, jit_enabled);
574
769
        gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled);
575
770
        gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled);
576
771
        gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled);
 
772
#endif
577
773
}
578
774
 
579
775
// "Use JIT Compiler" button toggled
584
780
}
585
781
 
586
782
// "Compile FPU Instructions" button toggled
 
783
#ifndef SHEEPSHAVER
587
784
static void tb_jit_fpu(GtkWidget *widget)
588
785
{
589
786
        PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active);
590
787
}
 
788
#endif
591
789
 
592
790
// "Lazy translation cache invalidation" button toggled
 
791
#ifndef SHEEPSHAVER
593
792
static void tb_jit_lazy_flush(GtkWidget *widget)
594
793
{
595
794
        PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active);
596
795
}
 
796
#endif
597
797
 
598
798
// "Translate through constant jumps (inline blocks)" button toggled
 
799
#ifndef SHEEPSHAVER
599
800
static void tb_jit_follow_const_jumps(GtkWidget *widget)
600
801
{
601
802
        PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active);
602
803
}
 
804
#endif
603
805
 
604
806
// Read settings from widgets and set preferences
605
807
static void read_jit_settings(void)
607
809
#if USE_JIT
608
810
        bool jit_enabled = PrefsFindBool("jit");
609
811
        if (jit_enabled) {
 
812
#ifndef SHEEPSHAVER
610
813
                const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry));
611
814
                PrefsReplaceInt32("jitcachesize", atoi(str));
 
815
#endif
612
816
        }
613
817
#endif
614
818
}
615
819
 
 
820
// "Use built-in 68k DR emulator" button toggled
 
821
#ifdef SHEEPSHAVER
 
822
static void tb_jit_68k(GtkWidget *widget)
 
823
{
 
824
        PrefsReplaceBool("jit68k", GTK_TOGGLE_BUTTON(widget)->active);
 
825
}
 
826
#endif
 
827
 
616
828
// Create "JIT Compiler" pane
617
829
static void create_jit_pane(GtkWidget *top)
618
830
{
623
835
        box = make_pane(top, STR_JIT_PANE_TITLE);
624
836
        make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit));
625
837
        
 
838
#ifndef SHEEPSHAVER
626
839
        w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu));
627
840
        
628
841
        // Translation cache size
633
846
                STR_JIT_CACHE_SIZE_16MB_LAB,
634
847
                0
635
848
        };
636
 
        w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options);
 
849
        sprintf(str, "%d", PrefsFindInt32("jitcachesize"));
 
850
        w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, str, options);
637
851
        
638
852
        // Lazy translation cache invalidation
639
853
        w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush));
640
854
 
641
855
        // Follow constant jumps (inline basic blocks)
642
856
        w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps));
 
857
#endif
643
858
 
644
859
        set_jit_sensitive();
645
860
#endif
 
861
 
 
862
#ifdef SHEEPSHAVER
 
863
        make_checkbox(box, STR_JIT_68K_CTRL, "jit68k", GTK_SIGNAL_FUNC(tb_jit_68k));
 
864
#endif
646
865
}
647
866
 
648
867
/*
654
873
// Read settings from widgets and set preferences
655
874
static void read_scsi_settings(void)
656
875
{
 
876
#ifndef DISABLE_SCSI
657
877
        for (int id=0; id<7; id++) {
658
878
                char prefs_name[32];
659
879
                sprintf(prefs_name, "scsi%d", id);
663
883
                else
664
884
                        PrefsRemoveItem(prefs_name);
665
885
        }
 
886
#endif
666
887
}
667
888
 
668
889
// Create "SCSI" pane
669
890
static void create_scsi_pane(GtkWidget *top)
670
891
{
 
892
#ifndef DISABLE_SCSI
671
893
        GtkWidget *box;
672
894
 
673
895
        box = make_pane(top, STR_SCSI_PANE_TITLE);
677
899
                sprintf(prefs_name, "scsi%d", id);
678
900
                w_scsi[id] = make_file_entry(box, STR_SCSI_ID_0 + id, prefs_name);
679
901
        }
 
902
#endif
680
903
}
681
904
 
682
905
 
720
943
{
721
944
        display_type = DISPLAY_SCREEN;
722
945
        hide_show_graphics_widgets();
 
946
        PrefsReplaceInt32("frameskip", 1);
723
947
}
724
948
 
725
949
// "5 Hz".."60Hz" selected
731
955
static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);}
732
956
static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);}
733
957
 
 
958
// QuickDraw acceleration
 
959
#ifdef SHEEPSHAVER
 
960
static void tb_gfxaccel(GtkWidget *widget)
 
961
{
 
962
        PrefsReplaceBool("gfxaccel", GTK_TOGGLE_BUTTON(widget)->active);
 
963
}
 
964
#endif
 
965
 
734
966
// Set sensitivity of widgets
735
967
static void set_graphics_sensitive(void)
736
968
{
748
980
static void parse_graphics_prefs(void)
749
981
{
750
982
        display_type = DISPLAY_WINDOW;
 
983
#ifdef SHEEPSHAVER
 
984
        dis_width = 640;
 
985
        dis_height = 480;
 
986
#else
751
987
        dis_width = 512;
752
988
        dis_height = 384;
 
989
#endif
753
990
 
754
991
        const char *str = PrefsFindString("screen");
755
992
        if (str) {
889
1126
        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4);
890
1127
        w_display_y = GTK_COMBO(combo)->entry;
891
1128
 
 
1129
#ifdef SHEEPSHAVER
 
1130
        make_checkbox(box, STR_GFXACCEL_CTRL, "gfxaccel", GTK_SIGNAL_FUNC(tb_gfxaccel));
 
1131
#endif
 
1132
 
892
1133
        make_separator(box);
893
1134
        make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound));
894
1135
 
908
1149
// Set sensitivity of widgets
909
1150
static void set_input_sensitive(void)
910
1151
{
911
 
        gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes"));
 
1152
        const bool use_keycodes = PrefsFindBool("keycodes");
 
1153
        gtk_widget_set_sensitive(w_keycode_file, use_keycodes);
 
1154
        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes);
912
1155
        gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1);
913
1156
}
914
1157
 
938
1181
// Create "Input" pane
939
1182
static void create_input_pane(GtkWidget *top)
940
1183
{
941
 
        GtkWidget *box, *hbox, *menu, *label;
 
1184
        GtkWidget *box, *hbox, *menu, *label, *button;
942
1185
        GtkObject *adj;
943
1186
 
944
1187
        box = make_pane(top, STR_INPUT_PANE_TITLE);
945
1188
 
946
1189
        make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
947
 
        w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
 
1190
 
 
1191
        hbox = gtk_hbox_new(FALSE, 4);
 
1192
        gtk_widget_show(hbox);
 
1193
        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
 
1194
 
 
1195
        label = gtk_label_new(GetString(STR_KEYCODES_CTRL));
 
1196
        gtk_widget_show(label);
 
1197
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 
1198
 
 
1199
        const char *str = PrefsFindString("keycodefile");
 
1200
        if (str == NULL)
 
1201
                str = "";
 
1202
 
 
1203
        w_keycode_file = gtk_entry_new();
 
1204
        gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str); 
 
1205
        gtk_widget_show(w_keycode_file);
 
1206
        gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0);
 
1207
 
 
1208
        button = make_browse_button(w_keycode_file);
 
1209
        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
 
1210
        g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button);
948
1211
 
949
1212
        make_separator(box);
950
1213
 
981
1244
 *  "Serial" pane
982
1245
 */
983
1246
 
984
 
static GtkWidget *w_seriala, *w_portfile0, *w_portfile0_browse;
985
 
static GtkWidget *w_serialb, *w_portfile1, *w_portfile1_browse;
 
1247
static GtkWidget *w_seriala, *w_portfile0;
 
1248
static GtkWidget *w_serialb, *w_portfile1;
986
1249
 
987
1250
// Set sensitivity of widgets
988
1251
static void set_serial_sensitive(void)
993
1256
        str = gtk_entry_get_text(GTK_ENTRY(w_seriala));
994
1257
        is_file = strcmp(str, "FILE") == 0;
995
1258
        gtk_widget_set_sensitive(w_portfile0, is_file);
996
 
        gtk_widget_set_sensitive(w_portfile0_browse, is_file);
 
1259
        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile0), "chooser_button")), is_file);
997
1260
 
998
1261
        str = gtk_entry_get_text(GTK_ENTRY(w_serialb));
999
1262
        is_file = strcmp(str, "FILE") == 0;
1000
1263
        gtk_widget_set_sensitive(w_portfile1, is_file);
1001
 
        gtk_widget_set_sensitive(w_portfile1_browse, is_file);
 
1264
        gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile1), "chooser_button")), is_file);
1002
1265
}
1003
1266
 
1004
1267
// Read settings from widgets and set preferences
1022
1285
// Port changed in combo
1023
1286
static void cb_serial_port_changed(...)
1024
1287
{
1025
 
        printf("serial port changed\n");
1026
1288
        set_serial_sensitive();
1027
1289
}
1028
1290
 
1053
1315
        box = make_pane(top, STR_SERIAL_PANE_TITLE);
1054
1316
        table = make_table(box, 2, 5);
1055
1317
 
1056
 
        label = gtk_label_new(GetString(STR_SERIALA_CTRL));
1057
 
        gtk_widget_show(label);
1058
 
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1059
 
 
1060
1318
        GList *glist = add_serial_names();
1061
 
        combo = gtk_combo_new();
1062
 
        gtk_widget_show(combo);
1063
 
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
1064
1319
        const char *str = PrefsFindString("seriala");
1065
 
        if (str == NULL)
1066
 
                str = "";
1067
 
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); 
1068
 
        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
1320
        combo = table_make_combobox(table, 0, STR_SERIALA_CTRL, str, glist);
1069
1321
        w_seriala = GTK_COMBO(combo)->entry;
1070
1322
        gtk_signal_connect(GTK_OBJECT(w_seriala), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL);
1071
1323
 
1072
 
        label = gtk_label_new(GetString(STR_FILE_CTRL));
1073
 
        gtk_widget_show(label);
1074
 
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1075
 
 
1076
 
        hbox = gtk_hbox_new(FALSE, 4);
1077
 
        gtk_widget_show(hbox);
1078
 
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1079
 
 
1080
 
        w_portfile0 = gtk_entry_new();
1081
 
        str = PrefsFindString("portfile0");
1082
 
        if (str == NULL)
1083
 
                str = "C:\\B2TEMP0.OUT";
1084
 
        gtk_entry_set_text(GTK_ENTRY(w_portfile0), str);
1085
 
        gtk_widget_show(w_portfile0);
1086
 
        gtk_box_pack_start(GTK_BOX(hbox), w_portfile0, TRUE, TRUE, 0);
1087
 
 
1088
 
        w_portfile0_browse = make_browse_button(w_portfile0);
1089
 
        gtk_box_pack_start(GTK_BOX(hbox), w_portfile0_browse, FALSE, FALSE, 0);
 
1324
        w_portfile0 = table_make_file_entry(table, 1, STR_FILE_CTRL, "portfile0");
1090
1325
 
1091
1326
        sep = gtk_hseparator_new();
1092
1327
        gtk_widget_show(sep);
1093
1328
        gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1094
1329
 
1095
 
        label = gtk_label_new(GetString(STR_SERIALB_CTRL));
1096
 
        gtk_widget_show(label);
1097
 
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1098
 
 
1099
 
        combo = gtk_combo_new();
1100
 
        gtk_widget_show(combo);
1101
 
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
1102
1330
        str = PrefsFindString("serialb");
1103
 
        if (str == NULL)
1104
 
                str = "";
1105
 
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); 
1106
 
        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
1331
        combo = table_make_combobox(table, 3, STR_SERIALB_CTRL, str, glist);
1107
1332
        w_serialb = GTK_COMBO(combo)->entry;
1108
1333
        gtk_signal_connect(GTK_OBJECT(w_serialb), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL);
1109
1334
 
1110
 
        label = gtk_label_new(GetString(STR_FILE_CTRL));
1111
 
        gtk_widget_show(label);
1112
 
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1113
 
 
1114
 
        hbox = gtk_hbox_new(FALSE, 4);
1115
 
        gtk_widget_show(hbox);
1116
 
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1117
 
 
1118
 
        w_portfile1 = gtk_entry_new();
1119
 
        str = PrefsFindString("portfile1");
1120
 
        if (str == NULL)
1121
 
                str = "C:\\B2TEMP1.OUT";
1122
 
        gtk_entry_set_text(GTK_ENTRY(w_portfile1), str);
1123
 
        gtk_widget_show(w_portfile1);
1124
 
        gtk_box_pack_start(GTK_BOX(hbox), w_portfile1, TRUE, TRUE, 0);
1125
 
 
1126
 
        w_portfile1_browse = make_browse_button(w_portfile1);
1127
 
        gtk_box_pack_start(GTK_BOX(hbox), w_portfile1_browse, FALSE, FALSE, 0);
 
1335
        w_portfile1 = table_make_file_entry(table, 4, STR_FILE_CTRL, "portfile1");
1128
1336
 
1129
1337
        set_serial_sensitive();
1130
1338
}
1134
1342
 *  "Ethernet" pane
1135
1343
 */
1136
1344
 
1137
 
static GtkWidget *w_ether, *w_udp_port;
 
1345
static GtkWidget *w_ftp_port_list, *w_tcp_port_list;
1138
1346
 
1139
1347
// Set sensitivity of widgets
1140
1348
static void set_ethernet_sensitive(void)
1141
1349
{
 
1350
        const char *str = PrefsFindString("ether");
 
1351
 
 
1352
        bool is_router = str && strcmp(str, "router") == 0;
 
1353
        gtk_widget_set_sensitive(w_ftp_port_list, is_router);
 
1354
        gtk_widget_set_sensitive(w_tcp_port_list, is_router);
1142
1355
}
1143
1356
 
1144
1357
// Read settings from widgets and set preferences
1145
1358
static void read_ethernet_settings(void)
1146
1359
{
1147
 
        const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether));
1148
 
        if (str && strlen(str))
1149
 
                PrefsReplaceString("ether", str);
1150
 
        else
1151
 
                PrefsRemoveItem("ether");
1152
 
}
1153
 
 
1154
 
// Add names of ethernet interfaces
1155
 
static GList *add_ether_names(void)
1156
 
{
1157
 
        GList *glist = NULL;
1158
 
 
1159
 
        // TODO: Get list of all Ethernet interfaces
1160
 
#ifdef HAVE_SLIRP
1161
 
        static char s_slirp[] = "slirp";
1162
 
        glist = g_list_append(glist, s_slirp);
1163
 
#endif
1164
 
#if 0
1165
 
        if (glist)
1166
 
                g_list_sort(glist, gl_str_cmp);
1167
 
        else
1168
 
#endif
1169
 
                glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB));
1170
 
        return glist;
1171
 
}
1172
 
 
 
1360
        const char *str = PrefsFindString("ether");
 
1361
 
 
1362
        bool is_router = str && strcmp(str, "router") == 0;
 
1363
        if (is_router) {
 
1364
                str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list));
 
1365
                PrefsReplaceString("ftp_port_list", str);
 
1366
                str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list));
 
1367
                PrefsReplaceString("tcp_port", str);
 
1368
        }
 
1369
}
 
1370
 
 
1371
// Ethernet emulation type changed in menulist
 
1372
static void cb_ether_changed(...)
 
1373
{
 
1374
        set_ethernet_sensitive();
 
1375
}
 
1376
 
 
1377
// Ethernet option "None" selected
 
1378
static void mn_ether_none(void)
 
1379
{
 
1380
        PrefsRemoveItem("ether");
 
1381
        PrefsRemoveItem("etherguid");
 
1382
}
 
1383
 
 
1384
// Ethernet option "Basilisk II Router" selected
 
1385
static void mn_ether_router(void)
 
1386
{
 
1387
        PrefsReplaceString("ether", "router");
 
1388
        PrefsRemoveItem("etherguid");
 
1389
}
 
1390
 
 
1391
// Ethernet option "Basilisk II Slirp" selected
 
1392
static void mn_ether_slirp(void)
 
1393
{
 
1394
        PrefsReplaceString("ether", "slirp");
 
1395
        PrefsRemoveItem("etherguid");
 
1396
}
 
1397
 
 
1398
// Ethernet option for Basilisk II driver selected
 
1399
static void mn_ether_b2ether(GtkWidget *, const char *guid)
 
1400
{
 
1401
        PrefsReplaceString("ether", "b2ether");
 
1402
        PrefsReplaceString("etherguid", guid);
 
1403
}
 
1404
 
 
1405
// Ethernet option for Basilisk II driver selected
 
1406
static void mn_ether_tap(GtkWidget *, const char *guid)
 
1407
{
 
1408
        PrefsReplaceString("ether", "tap");
 
1409
        PrefsReplaceString("etherguid", guid);
 
1410
}
 
1411
 
 
1412
// Create ethernet interfaces menu
 
1413
static int create_ether_menu(GtkWidget *menu)
 
1414
{
 
1415
        int active = -1;
 
1416
        int n_items = 0;
 
1417
        const char *ether = PrefsFindString("ether");
 
1418
        const char *etherguid = PrefsFindString("etherguid");
 
1419
 
 
1420
        // No Ethernet
 
1421
        add_menu_item(menu, STR_NONE_LAB, (GtkSignalFunc)mn_ether_none);
 
1422
        if (ether == NULL)
 
1423
                active = n_items;
 
1424
        n_items++;
 
1425
 
 
1426
        // Basilisk II Router
 
1427
        add_menu_item(menu, "Basilisk II Router", (GtkSignalFunc)mn_ether_router);
 
1428
        if (ether && strcmp(ether, "router") == 0)
 
1429
                active = n_items;
 
1430
        n_items++;
 
1431
 
 
1432
        // Basilisk II Slirp
 
1433
        add_menu_item(menu, "Basilisk II Slirp", (GtkSignalFunc)mn_ether_slirp);
 
1434
        if (ether && strcmp(ether, "slirp") == 0)
 
1435
                active = n_items;
 
1436
        n_items++;
 
1437
 
 
1438
        // Basilisk II Ethernet Adapter
 
1439
        PacketOpenAdapter("", 0);
 
1440
        {
 
1441
                ULONG sz;
 
1442
                char names[1024];
 
1443
                sz = sizeof(names);
 
1444
                if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) {
 
1445
                        char *p = names;
 
1446
                        while (*p) {
 
1447
                                const char DEVICE_HEADER[] = "\\Device\\B2ether_";
 
1448
                                if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) {
 
1449
                                        LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0);
 
1450
                                        if (fd) {
 
1451
                                                char guid[256];
 
1452
                                                sprintf(guid, "%s", p + sizeof(DEVICE_HEADER) - 1);
 
1453
                                                const char *name = ether_guid_to_name(guid);
 
1454
                                                if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) {
 
1455
                                                        add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(guid));
 
1456
                                                        if (etherguid && strcmp(guid, etherguid) == 0 &&
 
1457
                                                                ether && strcmp(ether, "b2ether") == 0)
 
1458
                                                                active = n_items;
 
1459
                                                        n_items++;
 
1460
                                                }
 
1461
                                                PacketCloseAdapter(fd);
 
1462
                                        }
 
1463
                                }
 
1464
                                p += strlen(p) + 1;
 
1465
                        }
 
1466
                }
 
1467
        }
 
1468
        PacketCloseAdapter(NULL);
 
1469
 
 
1470
        // TAP-Win32
 
1471
        const char *tap_devices;
 
1472
        if ((tap_devices = ether_tap_devices()) != NULL) {
 
1473
                const char *guid = tap_devices;
 
1474
                while (*guid) {
 
1475
                        const char *name = ether_guid_to_name(guid);
 
1476
                        if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) {
 
1477
                                add_menu_item(menu, name, (GtkSignalFunc)mn_ether_tap, strdup(guid));
 
1478
                                if (etherguid && strcmp(guid, etherguid) == 0 &&
 
1479
                                        ether && strcmp(ether, "tap") == 0)
 
1480
                                        active = n_items;
 
1481
                                n_items++;
 
1482
                        }
 
1483
                        guid += strlen(guid) + 1;
 
1484
                }
 
1485
                free((char *)tap_devices);
 
1486
        }
 
1487
 
 
1488
        return active;
 
1489
}
1173
1490
 
1174
1491
// Create "Ethernet" pane
1175
1492
static void create_ethernet_pane(GtkWidget *top)
1176
1493
{
1177
 
        GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry;
 
1494
        GtkWidget *box, *hbox, *table, *label, *sep, *entry, *opt, *menu, *item;
1178
1495
 
1179
1496
        box = make_pane(top, STR_NETWORK_PANE_TITLE);
1180
1497
        table = make_table(box, 2, 5);
1183
1500
        gtk_widget_show(label);
1184
1501
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1185
1502
 
1186
 
        GList *glist = add_ether_names();
1187
 
        combo = gtk_combo_new();
1188
 
        gtk_widget_show(combo);
1189
 
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
1190
 
        const char *str = PrefsFindString("ether");
1191
 
        if (str == NULL)
1192
 
                str = "";
1193
 
        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); 
1194
 
        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1195
 
        w_ether = GTK_COMBO(combo)->entry;
 
1503
        opt = gtk_option_menu_new();
 
1504
        gtk_widget_show(opt);
 
1505
        menu = gtk_menu_new();
 
1506
        int active = create_ether_menu(menu);
 
1507
        if (active >= 0)
 
1508
                gtk_menu_set_active(GTK_MENU(menu), active);
 
1509
        gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
 
1510
        gtk_table_attach(GTK_TABLE(table), opt, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
1511
        gtk_signal_connect(GTK_OBJECT(opt), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL);
 
1512
 
 
1513
        sep = gtk_hseparator_new();
 
1514
        gtk_widget_show(sep);
 
1515
        gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
 
1516
 
 
1517
        label = gtk_label_new(GetString(STR_ETHER_FTP_PORT_LIST_CTRL));
 
1518
        gtk_widget_show(label);
 
1519
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
 
1520
 
 
1521
        entry = gtk_entry_new();
 
1522
        const char *str = PrefsFindString("ftp_port_list");
 
1523
        if (str == NULL)
 
1524
                str = "";
 
1525
        gtk_entry_set_text(GTK_ENTRY(entry), str);
 
1526
        gtk_widget_show(entry);
 
1527
        gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
1528
        w_ftp_port_list = entry;
 
1529
 
 
1530
        label = gtk_label_new(GetString(STR_ETHER_TCP_PORT_LIST_CTRL));
 
1531
        gtk_widget_show(label);
 
1532
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
 
1533
 
 
1534
        entry = gtk_entry_new();
 
1535
        str = PrefsFindString("tcp_port");
 
1536
        if (str == NULL)
 
1537
                str = "";
 
1538
        gtk_entry_set_text(GTK_ENTRY(entry), str);
 
1539
        gtk_widget_show(entry);
 
1540
        gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
 
1541
        w_tcp_port_list = entry;
1196
1542
 
1197
1543
        set_ethernet_sensitive();
1198
1544
}
1202
1548
 *  "Memory/Misc" pane
1203
1549
 */
1204
1550
 
1205
 
static GtkObject *w_ramsize_adj;
 
1551
static GtkWidget *w_ramsize;
1206
1552
static GtkWidget *w_rom_file;
1207
1553
 
 
1554
// Don't use CPU when idle?
 
1555
static void tb_idlewait(GtkWidget *widget)
 
1556
{
 
1557
        PrefsReplaceBool("idlewait", GTK_TOGGLE_BUTTON(widget)->active);
 
1558
}
 
1559
 
1208
1560
// "Ignore SEGV" button toggled
1209
1561
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1210
1562
static void tb_ignoresegv(GtkWidget *widget)
1227
1579
// Read settings from widgets and set preferences
1228
1580
static void read_memory_settings(void)
1229
1581
{
1230
 
        PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20);
 
1582
        const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry));
 
1583
        PrefsReplaceInt32("ramsize", atoi(str) << 20);
1231
1584
 
1232
 
        const char *str = get_file_entry_path(w_rom_file);
 
1585
        str = get_file_entry_path(w_rom_file);
1233
1586
        if (str && strlen(str))
1234
1587
                PrefsReplaceString("rom", str);
1235
1588
        else
1240
1593
// Create "Memory/Misc" pane
1241
1594
static void create_memory_pane(GtkWidget *top)
1242
1595
{
1243
 
        GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale;
 
1596
        GtkWidget *box, *hbox, *table, *label, *scale, *menu;
1244
1597
 
1245
1598
        box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE);
1246
 
 
1247
 
        hbox = gtk_hbox_new(FALSE, 4);
1248
 
        gtk_widget_show(hbox);
1249
 
 
1250
 
        label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER));
1251
 
        gtk_widget_show(label);
1252
 
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1253
 
 
1254
 
        vbox = gtk_vbox_new(FALSE, 4);
1255
 
        gtk_widget_show(vbox);
1256
 
 
1257
 
        gfloat min, max;
1258
 
        min = 1;
1259
 
        max = 1024;
1260
 
        w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0);
1261
 
        gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20);
1262
 
 
1263
 
        scale = gtk_hscale_new(GTK_ADJUSTMENT(w_ramsize_adj));
1264
 
        gtk_widget_show(scale);
1265
 
        gtk_scale_set_digits(GTK_SCALE(scale), 0);
1266
 
        gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0);
1267
 
 
1268
 
        hbox2 = gtk_hbox_new(FALSE, 4);
1269
 
        gtk_widget_show(hbox2);
1270
 
 
1271
 
        char val[32];
1272
 
        sprintf(val, GetString(STR_RAMSIZE_FMT), int(min));
1273
 
        label = gtk_label_new(val);
1274
 
        gtk_widget_show(label);
1275
 
        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1276
 
 
1277
 
        sprintf(val, GetString(STR_RAMSIZE_FMT), int(max));
1278
 
        label = gtk_label_new(val);
1279
 
        gtk_widget_show(label);
1280
 
        gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1281
 
        gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0);
1282
 
        gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
1283
 
        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1284
 
 
 
1599
        table = make_table(box, 2, 5);
 
1600
 
 
1601
        static const combo_desc options[] = {
 
1602
#ifndef SHEEPSHAVER
 
1603
                STR_RAMSIZE_2MB_LAB,
 
1604
#endif
 
1605
                STR_RAMSIZE_4MB_LAB,
 
1606
                STR_RAMSIZE_8MB_LAB,
 
1607
                STR_RAMSIZE_16MB_LAB,
 
1608
                STR_RAMSIZE_32MB_LAB,
 
1609
                STR_RAMSIZE_64MB_LAB,
 
1610
                STR_RAMSIZE_128MB_LAB,
 
1611
                STR_RAMSIZE_256MB_LAB,
 
1612
                STR_RAMSIZE_512MB_LAB,
 
1613
                STR_RAMSIZE_1024MB_LAB,
 
1614
                0
 
1615
        };
 
1616
        char default_ramsize[16];
 
1617
        sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20);
 
1618
        w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options);
 
1619
 
 
1620
#ifndef SHEEPSHAVER
1285
1621
        static const opt_desc model_options[] = {
1286
1622
                {STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)},
1287
1623
                {STR_MODELID_14_LAB, GTK_SIGNAL_FUNC(mn_modelid_14)},
1292
1628
                case 5: active = 0; break;
1293
1629
                case 14: active = 1; break;
1294
1630
        }
1295
 
        make_option_menu(box, STR_MODELID_CTRL, model_options, active);
 
1631
        table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active);
 
1632
#endif
1296
1633
 
1297
1634
#if EMULATED_68K
1298
1635
        static const opt_desc cpu_options[] = {
1311
1648
                case 3: active = fpu ? 3 : 2; break;
1312
1649
                case 4: active = 4;
1313
1650
        }
1314
 
        make_option_menu(box, STR_CPU_CTRL, cpu_options, active);
 
1651
        table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active);
1315
1652
#endif
1316
1653
 
1317
 
        w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom");
 
1654
        w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom");
 
1655
 
 
1656
        make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait));
1318
1657
 
1319
1658
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1320
1659
        make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv));
1346
1685
uint8 XPRAM[XPRAM_SIZE];
1347
1686
void MountVolume(void *fh) { }
1348
1687
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { }
1349
 
void WarningAlert(const char *text) { }
 
1688
void recycle_write_packet(LPPACKET) { }
 
1689
VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { }
1350
1690
 
1351
1691
 
1352
1692
/*
1361
1701
 
1362
1702
 
1363
1703
/*
 
1704
 *  Display alerts
 
1705
 */
 
1706
 
 
1707
static void display_alert(int title_id, const char *text, int flags)
 
1708
{
 
1709
        MessageBox(NULL, text, GetString(title_id), MB_OK | flags);
 
1710
}
 
1711
 
 
1712
void ErrorAlert(const char *text)
 
1713
{
 
1714
        display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
 
1715
}
 
1716
 
 
1717
void WarningAlert(const char *text)
 
1718
{
 
1719
        display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP);
 
1720
}
 
1721
 
 
1722
 
 
1723
/*
1364
1724
 *  Start standalone GUI
1365
1725
 */
1366
1726
 
1373
1733
        // Read preferences
1374
1734
        PrefsInit(argc, argv);
1375
1735
 
 
1736
        // Migrate preferences
 
1737
        PrefsMigrate();
 
1738
 
1376
1739
        // Show preferences editor
1377
1740
        bool start = PrefsEditor();
1378
1741
 
1379
1742
        // Exit preferences
1380
1743
        PrefsExit();
1381
1744
 
1382
 
        // Transfer control to the Basilisk II executable
 
1745
        // Transfer control to the executable
1383
1746
        if (start) {
1384
 
                printf("Start Basilisk II\n");
 
1747
                char path[_MAX_PATH];
 
1748
                bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0;
 
1749
                if (ok) {
 
1750
                        char b2_path[_MAX_PATH];
 
1751
                        char *p = strrchr(path, '\\');
 
1752
                        *++p = '\0';
 
1753
                        SetCurrentDirectory(path);
 
1754
                        strcpy(b2_path, path);
 
1755
                        strcat(b2_path, PROGRAM_NAME);
 
1756
                        strcat(b2_path, ".exe");
 
1757
                        HINSTANCE h = ShellExecute(GetDesktopWindow(), "open",
 
1758
                                                                           b2_path, "", path, SW_SHOWNORMAL);
 
1759
                        if ((int)h <= 32)
 
1760
                                ok = false;
 
1761
                }
 
1762
                if (!ok) {
 
1763
                        ErrorAlert("Coult not start " PROGRAM_NAME " executable");
 
1764
                        return 1;
 
1765
                }
1385
1766
        }
1386
1767
 
1387
1768
        return 0;