--- np2/x11/gtk/Attic/dialog_config.c 2003/11/18 14:34:30 1.2 +++ np2/x11/gtk/Attic/dialog_config.c 2004/06/17 14:36:34 1.7 @@ -33,7 +33,7 @@ #include "sysmng.h" #include "gtk/xnp2.h" -#include "gtk/gtkmenu.h" +#include "gtk/gtk_menu.h" static const char *baseclock_str[] = { "1.9968MHz", "2.4576MHz" @@ -45,6 +45,15 @@ static const char *clockmult_str[] = { static const struct { const char* label; + const char* arch; +} architecture[] = { + { "PC-9801VM", "VM" }, + { "PC-9801VX", "VX" }, + { "PC-286", "EPSON" }, +}; + +static const struct { + const char* label; const int rate; } samplingrate[] = { { "11KHz", 11025 }, @@ -56,23 +65,27 @@ static GtkWidget *baseclock_entry; static GtkWidget *clockmult_entry; static GtkWidget *buffer_entry; static GtkWidget *resume_checkbutton; -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) +#if defined(GCC_CPU_ARCH_IA32) static GtkWidget *disablemmx_checkbutton; #endif +static const char *arch; static int rate; static void ok_button_clicked(GtkButton *b, gpointer d) { - gchar *bufp = gtk_entry_get_text(GTK_ENTRY(buffer_entry)); - gchar *base = gtk_entry_get_text(GTK_ENTRY(baseclock_entry)); - gchar *multp = gtk_entry_get_text(GTK_ENTRY(clockmult_entry)); + const gchar *bufp = gtk_entry_get_text(GTK_ENTRY(buffer_entry)); + const gchar *base = gtk_entry_get_text(GTK_ENTRY(baseclock_entry)); + const gchar *multp = gtk_entry_get_text(GTK_ENTRY(clockmult_entry)); gint resume = GTK_TOGGLE_BUTTON(resume_checkbutton)->active; +#if defined(GCC_CPU_ARCH_IA32) gint disablemmx = GTK_TOGGLE_BUTTON(disablemmx_checkbutton)->active; +#endif guint bufsize; guint mult; UINT renewal = 0; + int i; UNUSED(b); @@ -99,6 +112,18 @@ ok_button_clicked(GtkButton *b, gpointer break; } + for (i = 0; i < NELEMENTS(architecture); i++) { + if (strcmp(arch, architecture[i].arch) == 0) { + milstr_ncpy(np2cfg.model, arch, sizeof(np2cfg.model)); + renewal |= SYS_UPDATECFG; + break; + } + } + if (i == NELEMENTS(architecture)) { + milstr_ncpy(np2cfg.model, "VX", sizeof(np2cfg.model)); + renewal |= SYS_UPDATECFG; + } + switch (rate) { case 11025: case 22050: @@ -122,7 +147,7 @@ ok_button_clicked(GtkButton *b, gpointer soundrenewal = 1; } -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) +#if defined(GCC_CPU_ARCH_IA32) if (!(mmxflag & MMXFLAG_NOTSUPPORT)) { disablemmx = disablemmx ? MMXFLAG_DISABLE : 0; if (np2oscfg.disablemmx != disablemmx) { @@ -157,19 +182,28 @@ dialog_destroy(GtkWidget *w, GtkWidget * } static void +arch_radiobutton_clicked(GtkButton *b, gpointer d) +{ + + UNUSED(b); + + arch = (char *)d; +} + +static void rate_radiobutton_clicked(GtkButton *b, gpointer d) { UNUSED(b); - rate = (gint)d; + rate = GPOINTER_TO_INT(d); } static void clock_changed(GtkEditable *e, gpointer d) { - gchar *base = gtk_entry_get_text(GTK_ENTRY(baseclock_entry)); - gchar *multp = gtk_entry_get_text(GTK_ENTRY(clockmult_entry)); + const gchar *base = gtk_entry_get_text(GTK_ENTRY(baseclock_entry)); + const gchar *multp = gtk_entry_get_text(GTK_ENTRY(clockmult_entry)); guint mult = milstr_solveINT(multp); gchar buf[80]; gint clock; @@ -202,6 +236,9 @@ create_configure_dialog(void) GtkWidget *confirm_widget; GtkWidget *ok_button; GtkWidget *cancel_button; + GtkWidget *arch_frame; + GtkWidget *arch_hbox; + GtkWidget *arch_radiobutton[NELEMENTS(architecture)]; GtkWidget *sound_frame; GtkWidget *soundframe_vbox; GtkWidget *soundrate_hbox; @@ -212,13 +249,14 @@ create_configure_dialog(void) GtkWidget *ms_label; GList *baseclock_combo_items = NULL; GList *rate_combo_items = NULL; + GSList *arch_group = NULL; GSList *rate_group = NULL; gchar buf[8]; int i; uninstall_idle_process(); - config_dialog = gtk_window_new(GTK_WINDOW_DIALOG); + config_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(config_dialog), "Configure"); gtk_window_set_position(GTK_WINDOW(config_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(config_dialog), TRUE); @@ -336,6 +374,39 @@ create_configure_dialog(void) gtk_button_box_set_spacing(GTK_BUTTON_BOX(confirm_widget), 0); /* + * Architecture frame + */ + arch_frame = gtk_frame_new("Architecture"); + gtk_widget_show(arch_frame); + gtk_box_pack_start(GTK_BOX(main_widget), arch_frame, TRUE, TRUE, 0); + + /* architecture */ + arch_hbox = gtk_hbox_new(TRUE, 2); + gtk_widget_show(arch_hbox); + gtk_container_add(GTK_CONTAINER(arch_frame), arch_hbox); + + for (i = 0; i < NELEMENTS(architecture); i++) { + arch_radiobutton[i] = gtk_radio_button_new_with_label(arch_group, architecture[i].label); + arch_group = gtk_radio_button_group(GTK_RADIO_BUTTON(arch_radiobutton[i])); + gtk_widget_show(arch_radiobutton[i]); + gtk_box_pack_start(GTK_BOX(arch_hbox), arch_radiobutton[i], FALSE, FALSE, 0); + GTK_WIDGET_UNSET_FLAGS(arch_radiobutton[i], GTK_CAN_FOCUS); + gtk_signal_connect(GTK_OBJECT(arch_radiobutton[i]), "clicked", + GTK_SIGNAL_FUNC(arch_radiobutton_clicked), (gpointer)architecture[i].arch); + } + for (i = 0; i < NELEMENTS(architecture); i++) { + if (strcmp(np2cfg.model, architecture[i].arch) == 0) { + break; + } + } + if (i == NELEMENTS(architecture)) { + i = 1; + milstr_ncpy(np2cfg.model, "VX", sizeof(np2cfg.model)); + sysmng_update(SYS_UPDATECFG); + } + gtk_signal_emit_by_name(GTK_OBJECT(arch_radiobutton[i]), "clicked"); + + /* * Sound frame */ sound_frame = gtk_frame_new("Sound"); @@ -364,7 +435,7 @@ create_configure_dialog(void) gtk_box_pack_start(GTK_BOX(soundrate_hbox), rate_radiobutton[i], FALSE, FALSE, 0); GTK_WIDGET_UNSET_FLAGS(rate_radiobutton[i], GTK_CAN_FOCUS); gtk_signal_connect(GTK_OBJECT(rate_radiobutton[i]), "clicked", - GTK_SIGNAL_FUNC(rate_radiobutton_clicked), (gpointer)samplingrate[i].rate); + GTK_SIGNAL_FUNC(rate_radiobutton_clicked), GINT_TO_POINTER(samplingrate[i].rate)); } if (np2cfg.samplingrate == 11025) { i = 0; @@ -416,7 +487,7 @@ create_configure_dialog(void) gtk_signal_emit_by_name(GTK_OBJECT(resume_checkbutton), "clicked"); } -#if defined(__GNUC__) && (defined(i386) || defined(__i386__)) +#if defined(GCC_CPU_ARCH_IA32) /* Disable MMX */ disablemmx_checkbutton = gtk_check_button_new_with_label("Disable MMX"); gtk_widget_show(disablemmx_checkbutton);