ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/prefs_editor_gtk.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/prefs_editor_gtk.cpp (file contents):
Revision 1.9 by cebix, 1999-10-28T15:33:15Z vs.
Revision 1.18 by cebix, 2001-07-12T19:48:27Z

# Line 1 | Line 1
1   /*
2   *  prefs_editor_gtk.cpp - Preferences editor, Unix implementation using GTK+
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 45 | Line 45 | static bool start_clicked = true;      // Ret
45   static void create_volumes_pane(GtkWidget *top);
46   static void create_scsi_pane(GtkWidget *top);
47   static void create_graphics_pane(GtkWidget *top);
48 + static void create_input_pane(GtkWidget *top);
49   static void create_serial_pane(GtkWidget *top);
50   static void create_memory_pane(GtkWidget *top);
51   static void read_settings(void);
# Line 226 | Line 227 | static void mn_about(...)
227   {
228          GtkWidget *dialog, *label, *button;
229  
230 <        char str[256];
231 <        sprintf(str, GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR);
232 <        strncat(str, "\n", 255);
233 <        strncat(str, GetString(STR_ABOUT_TEXT2), 255);
230 >        char str[512];
231 >        sprintf(str,
232 >                "Basilisk II\nVersion %d.%d\n\n"
233 >                "Copyright (C) 1997-2001 Christian Bauer et al.\n"
234 >                "E-mail: Christian.Bauer@uni-mainz.de\n"
235 >                "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n"
236 >                "Basilisk II comes with ABSOLUTELY NO\n"
237 >                "WARRANTY. This is free software, and\n"
238 >                "you are welcome to redistribute it\n"
239 >                "under the terms of the GNU General\n"
240 >                "Public License.\n",
241 >                VERSION_MAJOR, VERSION_MINOR
242 >        );
243  
244          dialog = gtk_dialog_new();
235        gtk_widget_set_usize(GTK_WIDGET(dialog), strlen(GetString(STR_ABOUT_TEXT2)) + 200, 120);
245          gtk_window_set_title(GTK_WINDOW(dialog), GetString(STR_ABOUT_TITLE));
246          gtk_container_border_width(GTK_CONTAINER(dialog), 5);
247          gtk_widget_set_uposition(GTK_WIDGET(dialog), 100, 150);
# Line 297 | Line 306 | bool PrefsEditor(void)
306          create_volumes_pane(notebook);
307          create_scsi_pane(notebook);
308          create_graphics_pane(notebook);
309 +        create_input_pane(notebook);
310          create_serial_pane(notebook);
311          create_memory_pane(notebook);
312  
# Line 400 | Line 410 | static void cb_remove_volume(...)
410   }
411  
412   // "Boot From" selected
413 < static void mn_boot_any(...) {PrefsReplaceInt16("bootdriver", 0);}
414 < static void mn_boot_cdrom(...) {PrefsReplaceInt16("bootdriver", CDROMRefNum);}
413 > static void mn_boot_any(...) {PrefsReplaceInt32("bootdriver", 0);}
414 > static void mn_boot_cdrom(...) {PrefsReplaceInt32("bootdriver", CDROMRefNum);}
415  
416   // "No CD-ROM Driver" button toggled
417   static void tb_nocdrom(GtkWidget *widget)
# Line 464 | Line 474 | static void create_volumes_pane(GtkWidge
474                  {STR_BOOT_CDROM_LAB, GTK_SIGNAL_FUNC(mn_boot_cdrom)},
475                  {0, NULL}
476          };
477 <        int bootdriver = PrefsFindInt16("bootdriver"), active = 0;
477 >        int bootdriver = PrefsFindInt32("bootdriver"), active = 0;
478          switch (bootdriver) {
479                  case 0: active = 0; break;
480                  case CDROMRefNum: active = 1; break;
# Line 525 | Line 535 | static GtkWidget *l_frameskip, *l_displa
535   static int display_type;
536   static int dis_width, dis_height;
537  
538 < #if ENABLE_FBDEV_DGA
538 > #ifdef ENABLE_FBDEV_DGA
539   static GtkWidget *w_fbdev_name, *w_fbdevice_file;
540   static GtkWidget *l_fbdev_name, *l_fbdevice_file;
541   static char fbdev_name[256];
# Line 537 | Line 547 | static void hide_show_graphics_widgets(v
547          switch (display_type) {
548                  case DISPLAY_WINDOW:
549                          gtk_widget_show(w_frameskip); gtk_widget_show(l_frameskip);
550 < #if ENABLE_FBDEV_DGA
550 > #ifdef ENABLE_FBDEV_DGA
551                          gtk_widget_show(w_display_x); gtk_widget_show(l_display_x);
552                          gtk_widget_show(w_display_y); gtk_widget_show(l_display_y);
553                          gtk_widget_hide(w_fbdev_name); gtk_widget_hide(l_fbdev_name);
# Line 545 | Line 555 | static void hide_show_graphics_widgets(v
555                          break;
556                  case DISPLAY_SCREEN:
557                          gtk_widget_hide(w_frameskip); gtk_widget_hide(l_frameskip);
558 < #if ENABLE_FBDEV_DGA
558 > #ifdef ENABLE_FBDEV_DGA
559                          gtk_widget_hide(w_display_x); gtk_widget_hide(l_display_x);
560                          gtk_widget_hide(w_display_y); gtk_widget_hide(l_display_y);
561                          gtk_widget_show(w_fbdev_name); gtk_widget_show(l_fbdev_name);
# Line 575 | Line 585 | static void mn_10hz(...) {PrefsReplaceIn
585   static void mn_15hz(...) {PrefsReplaceInt32("frameskip", 4);}
586   static void mn_30hz(...) {PrefsReplaceInt32("frameskip", 2);}
587   static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);}
588 + static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);}
589  
590   // "Disable Sound Output" button toggled
591   static void tb_nosound(GtkWidget *widget)
# Line 588 | Line 599 | static void parse_graphics_prefs(void)
599          display_type = DISPLAY_WINDOW;
600          dis_width = 512;
601          dis_height = 384;
602 < #if ENABLE_FBDEV_DGA
602 > #ifdef ENABLE_FBDEV_DGA
603          fbdev_name[0] = 0;
604   #endif
605  
# Line 596 | Line 607 | static void parse_graphics_prefs(void)
607          if (str) {
608                  if (sscanf(str, "win/%d/%d", &dis_width, &dis_height) == 2)
609                          display_type = DISPLAY_WINDOW;
610 < #if ENABLE_FBDEV_DGA
610 > #ifdef ENABLE_FBDEV_DGA
611                  else if (sscanf(str, "dga/%255s", fbdev_name) == 1)
612   #else
613                  else if (sscanf(str, "dga/%d/%d", &dis_width, &dis_height) == 2)
# Line 622 | Line 633 | static void read_graphics_settings(void)
633                          sprintf(pref, "win/%d/%d", dis_width, dis_height);
634                          break;
635                  case DISPLAY_SCREEN:
636 < #if ENABLE_FBDEV_DGA
636 > #ifdef ENABLE_FBDEV_DGA
637                          str = gtk_entry_get_text(GTK_ENTRY(w_fbdev_name));
638                          sprintf(pref, "dga/%s", str);
639   #else
# Line 680 | Line 691 | static void create_graphics_pane(GtkWidg
691          add_menu_item(menu, STR_REF_15HZ_LAB, GTK_SIGNAL_FUNC(mn_15hz));
692          add_menu_item(menu, STR_REF_30HZ_LAB, GTK_SIGNAL_FUNC(mn_30hz));
693          add_menu_item(menu, STR_REF_60HZ_LAB, GTK_SIGNAL_FUNC(mn_60hz));
694 +        add_menu_item(menu, STR_REF_DYNAMIC_LAB, GTK_SIGNAL_FUNC(mn_dynamic));
695          int frameskip = PrefsFindInt32("frameskip");
696 +        int item = -1;
697          switch (frameskip) {
698 <                case 12:
699 <                        gtk_menu_set_active(GTK_MENU(menu), 0);
700 <                        break;
701 <                case 8:
702 <                        gtk_menu_set_active(GTK_MENU(menu), 1);
703 <                        break;
704 <                case 6:
692 <                        gtk_menu_set_active(GTK_MENU(menu), 2);
693 <                        break;
694 <                case 4:
695 <                        gtk_menu_set_active(GTK_MENU(menu), 3);
696 <                        break;
697 <                case 2:
698 <                        gtk_menu_set_active(GTK_MENU(menu), 4);
699 <                        break;
700 <                case 1:
701 <                        gtk_menu_set_active(GTK_MENU(menu), 5);
702 <                        break;
698 >                case 12: item = 0; break;
699 >                case 8: item = 1; break;
700 >                case 6: item = 2; break;
701 >                case 4: item = 3; break;
702 >                case 2: item = 4; break;
703 >                case 1: item = 5; break;
704 >                case 0: item = 6; break;
705          }
706 +        if (item >= 0)
707 +                gtk_menu_set_active(GTK_MENU(menu), item);
708          gtk_option_menu_set_menu(GTK_OPTION_MENU(w_frameskip), menu);
709          gtk_table_attach(GTK_TABLE(table), w_frameskip, 1, 2, 1, 2, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4);
710  
# Line 746 | Line 750 | static void create_graphics_pane(GtkWidg
750          gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4);
751          w_display_y = GTK_COMBO(combo)->entry;
752  
753 < #if ENABLE_FBDEV_DGA
753 > #ifdef ENABLE_FBDEV_DGA
754          l_fbdev_name = gtk_label_new(GetString(STR_FBDEV_NAME_CTRL));
755          gtk_widget_show(l_fbdev_name);
756          gtk_table_attach(GTK_TABLE(table), l_fbdev_name, 0, 1, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
# Line 759 | Line 763 | static void create_graphics_pane(GtkWidg
763          w_fbdevice_file = make_entry(box, STR_FBDEVICE_FILE_CTRL, "fbdevicefile");
764   #endif
765  
766 +        make_separator(box);
767          make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound));
768  
769          hide_show_graphics_widgets();
# Line 766 | Line 771 | static void create_graphics_pane(GtkWidg
771  
772  
773   /*
774 + *  "Input" pane
775 + */
776 +
777 + static GtkWidget *w_keycode_file;
778 + static GtkWidget *w_mouse_wheel_lines;
779 +
780 + // Set sensitivity of widgets
781 + static void set_input_sensitive(void)
782 + {
783 +        gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes"));
784 +        gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1);
785 + }
786 +
787 + // "Use Raw Keycodes" button toggled
788 + static void tb_keycodes(GtkWidget *widget)
789 + {
790 +        PrefsReplaceBool("keycodes", GTK_TOGGLE_BUTTON(widget)->active);
791 +        set_input_sensitive();
792 + }
793 +
794 + // "Mouse Wheel Mode" selected
795 + static void mn_wheel_page(...) {PrefsReplaceInt32("mousewheelmode", 0); set_input_sensitive();}
796 + static void mn_wheel_cursor(...) {PrefsReplaceInt32("mousewheelmode", 1); set_input_sensitive();}
797 +
798 + // Read settings from widgets and set preferences
799 + static void read_input_settings(void)
800 + {
801 +        const char *str = gtk_entry_get_text(GTK_ENTRY(w_keycode_file));
802 +        if (str && strlen(str))
803 +                PrefsReplaceString("keycodefile", str);
804 +        else
805 +                PrefsRemoveItem("keycodefile");
806 +
807 +        PrefsReplaceInt32("mousewheellines", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w_mouse_wheel_lines)));
808 + }
809 +
810 + // Create "Input" pane
811 + static void create_input_pane(GtkWidget *top)
812 + {
813 +        GtkWidget *box, *hbox, *menu, *label;
814 +        GtkObject *adj;
815 +
816 +        box = make_pane(top, STR_INPUT_PANE_TITLE);
817 +
818 +        make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
819 +        w_keycode_file = make_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
820 +
821 +        make_separator(box);
822 +
823 +        static const opt_desc options[] = {
824 +                {STR_MOUSEWHEELMODE_PAGE_LAB, GTK_SIGNAL_FUNC(mn_wheel_page)},
825 +                {STR_MOUSEWHEELMODE_CURSOR_LAB, GTK_SIGNAL_FUNC(mn_wheel_cursor)},
826 +                {0, NULL}
827 +        };
828 +        int wheelmode = PrefsFindInt32("mousewheelmode"), active = 0;
829 +        switch (wheelmode) {
830 +                case 0: active = 0; break;
831 +                case 1: active = 1; break;
832 +        }
833 +        menu = make_option_menu(box, STR_MOUSEWHEELMODE_CTRL, options, active);
834 +
835 +        hbox = gtk_hbox_new(FALSE, 4);
836 +        gtk_widget_show(hbox);
837 +        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
838 +
839 +        label = gtk_label_new(GetString(STR_MOUSEWHEELLINES_CTRL));
840 +        gtk_widget_show(label);
841 +        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
842 +
843 +        adj = gtk_adjustment_new(PrefsFindInt32("mousewheellines"), 1, 1000, 1, 5, 0);
844 +        w_mouse_wheel_lines = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
845 +        gtk_widget_show(w_mouse_wheel_lines);
846 +        gtk_box_pack_start(GTK_BOX(hbox), w_mouse_wheel_lines, FALSE, FALSE, 0);
847 +
848 +        set_input_sensitive();
849 + }
850 +
851 +
852 + /*
853   *  "Serial/Network" pane
854   */
855  
856 < static GtkWidget *w_seriala, *w_serialb, *w_ether;
856 > static GtkWidget *w_seriala, *w_serialb, *w_ether, *w_udp_port;
857 >
858 > // Set sensitivity of widgets
859 > static void set_serial_sensitive(void)
860 > {
861 > #if SUPPORTS_UDP_TUNNEL
862 >        gtk_widget_set_sensitive(w_ether, !PrefsFindBool("udptunnel"));
863 >        gtk_widget_set_sensitive(w_udp_port, PrefsFindBool("udptunnel"));
864 > #endif
865 > }
866 >
867 > // "Tunnel AppleTalk over IP" button toggled
868 > static void tb_udptunnel(GtkWidget *widget)
869 > {
870 >        PrefsReplaceBool("udptunnel", GTK_TOGGLE_BUTTON(widget)->active);
871 >        set_serial_sensitive();
872 > }
873  
874   // Read settings from widgets and set preferences
875   static void read_serial_settings(void)
# Line 787 | Line 887 | static void read_serial_settings(void)
887                  PrefsReplaceString("ether", str);
888          else
889                  PrefsRemoveItem("ether");
890 +
891 + #if SUPPORTS_UDP_TUNNEL
892 +        PrefsReplaceInt32("udpport", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w_udp_port)));
893 + #endif
894   }
895  
896   // Add names of serial devices
# Line 870 | Line 974 | static GList *add_ether_names(void)
974   // Create "Serial/Network" pane
975   static void create_serial_pane(GtkWidget *top)
976   {
977 <        GtkWidget *box, *table, *label, *combo;
978 <        GList *glist = add_serial_names();
977 >        GtkWidget *box, *hbox, *table, *label, *combo, *sep;
978 >        GtkObject *adj;
979  
980          box = make_pane(top, STR_SERIAL_NETWORK_PANE_TITLE);
981 <        table = make_table(box, 2, 3);
981 >        table = make_table(box, 2, 4);
982  
983          label = gtk_label_new(GetString(STR_SERIALA_CTRL));
984          gtk_widget_show(label);
985          gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
986  
987 +        GList *glist = add_serial_names();
988          combo = gtk_combo_new();
989          gtk_widget_show(combo);
990          gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
# Line 904 | Line 1009 | static void create_serial_pane(GtkWidget
1009          gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1010          w_serialb = GTK_COMBO(combo)->entry;
1011  
1012 +        sep = gtk_hseparator_new();
1013 +        gtk_widget_show(sep);
1014 +        gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1015 +
1016          label = gtk_label_new(GetString(STR_ETHERNET_IF_CTRL));
1017          gtk_widget_show(label);
1018 <        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1018 >        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
1019  
1020          glist = add_ether_names();
1021          combo = gtk_combo_new();
# Line 916 | Line 1025 | static void create_serial_pane(GtkWidget
1025          if (str == NULL)
1026                  str = "";
1027          gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
1028 <        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1028 >        gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1029          w_ether = GTK_COMBO(combo)->entry;
1030 +
1031 + #if SUPPORTS_UDP_TUNNEL
1032 +        make_checkbox(box, STR_UDPTUNNEL_CTRL, "udptunnel", GTK_SIGNAL_FUNC(tb_udptunnel));
1033 +
1034 +        hbox = gtk_hbox_new(FALSE, 4);
1035 +        gtk_widget_show(hbox);
1036 +        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
1037 +
1038 +        label = gtk_label_new(GetString(STR_UDPPORT_CTRL));
1039 +        gtk_widget_show(label);
1040 +        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1041 +
1042 +        adj = gtk_adjustment_new(PrefsFindInt32("udpport"), 1, 65535, 1, 5, 0);
1043 +        w_udp_port = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
1044 +        gtk_widget_show(w_udp_port);
1045 +        gtk_box_pack_start(GTK_BOX(hbox), w_udp_port, FALSE, FALSE, 0);
1046 + #endif
1047 +
1048 +        set_serial_sensitive();
1049   }
1050  
1051  
# Line 927 | Line 1055 | static void create_serial_pane(GtkWidget
1055  
1056   static GtkObject *w_ramsize_adj;
1057   static GtkWidget *w_rom_file;
930 static GtkWidget *w_keycode_file;
1058  
1059   // Model ID selected
1060   static void mn_modelid_5(...) {PrefsReplaceInt32("modelid", 5);}
# Line 940 | Line 1067 | static void mn_cpu_68030(...) {PrefsRepl
1067   static void mn_cpu_68030_fpu(...) {PrefsReplaceInt32("cpu", 3); PrefsReplaceBool("fpu", true);}
1068   static void mn_cpu_68040(...) {PrefsReplaceInt32("cpu", 4); PrefsReplaceBool("fpu", true);}
1069  
943 // "Use Raw Keycodes" button toggled
944 static void tb_keycodes(GtkWidget *widget)
945 {
946        PrefsReplaceBool("keycodes", GTK_TOGGLE_BUTTON(widget)->active);
947 }
948
1070   // Read settings from widgets and set preferences
1071   static void read_memory_settings(void)
1072   {
# Line 957 | Line 1078 | static void read_memory_settings(void)
1078          else
1079                  PrefsRemoveItem("rom");
1080  
960        str = gtk_entry_get_text(GTK_ENTRY(w_keycode_file));
961        if (str && strlen(str))
962                PrefsReplaceString("keycodefile", str);
963        else
964                PrefsRemoveItem("keycodefile");
1081   }
1082  
1083   // Create "Memory/Misc" pane
1084   static void create_memory_pane(GtkWidget *top)
1085   {
1086 <        GtkWidget *box, *vbox, *hbox, *hbox2, *label, *scale, *menu;
1086 >        GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale;
1087  
1088          box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE);
1089  
# Line 1021 | Line 1137 | static void create_memory_pane(GtkWidget
1137          }
1138          make_option_menu(box, STR_MODELID_CTRL, model_options, active);
1139  
1140 + #if EMULATED_68K
1141          static const opt_desc cpu_options[] = {
1142                  {STR_CPU_68020_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020)},
1143                  {STR_CPU_68020_FPU_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020_fpu)},
# Line 1038 | Line 1155 | static void create_memory_pane(GtkWidget
1155                  case 4: active = 4;
1156          }
1157          make_option_menu(box, STR_CPU_CTRL, cpu_options, active);
1158 + #endif
1159  
1160          w_rom_file = make_entry(box, STR_ROM_FILE_CTRL, "rom");
1043
1044        make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
1045        w_keycode_file = make_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
1161   }
1162  
1163  
# Line 1055 | Line 1170 | static void read_settings(void)
1170          read_volumes_settings();
1171          read_scsi_settings();
1172          read_graphics_settings();
1173 +        read_input_settings();
1174          read_serial_settings();
1175          read_memory_settings();
1176   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines