--- np2/x11/gtk2/dialog_newdisk.c 2004/07/14 16:01:40 1.1 +++ np2/x11/gtk2/dialog_newdisk.c 2010/12/23 06:32:35 1.5 @@ -1,4 +1,4 @@ -/* $Id: dialog_newdisk.c,v 1.1 2004/07/14 16:01:40 monaka Exp $ */ +/* $Id: dialog_newdisk.c,v 1.5 2010/12/23 06:32:35 monaka Exp $ */ /* * Copyright (c) 2004 NONAKA Kimihiro @@ -12,8 +12,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -35,6 +33,7 @@ #include "np2.h" #include "dosio.h" #include "ini.h" +#include "pccore.h" #include "fddfile.h" #include "newdisk.h" @@ -44,32 +43,44 @@ * create hard disk image */ -static int +static const OEMCHAR *str_hddsize = OEMTEXT(" HDD Size"); + +static gint anex_newdisk_dialog(GtkWidget *dialog) { + static const int cnv[] = { 0, 1, 2, 3, 5, 6 }; static const int hddsize[] = { 5, 10, 15, 20, 30, 40 }; static int last = 0; char buf[32]; GtkWidget *dialog_table; GtkWidget *button[NELEMENTS(hddsize)]; + GtkWidget *label; int i; /* dialog table */ - dialog_table = gtk_table_new(3, 2, FALSE); + dialog_table = gtk_table_new(4, 2, FALSE); gtk_table_set_col_spacings(GTK_TABLE(dialog_table), 5); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),dialog_table); gtk_widget_show(dialog_table); - /* HD size radio button */ + /* "HDD Size" label */ + label = gtk_label_new(str_hddsize); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_table_attach(GTK_TABLE(dialog_table), label, 0, 1, 0, 1, + GTK_FILL|GTK_SHRINK, GTK_FILL|GTK_SHRINK, + 0, 5); + gtk_widget_show(label); + + /* HDD Size radio button */ for (i = 0; i < NELEMENTS(hddsize); ++i) { g_snprintf(buf, sizeof(buf), "%dMB", hddsize[i]); button[i] = gtk_radio_button_new_with_label_from_widget( (i > 0) ? GTK_RADIO_BUTTON(button[i-1]) : NULL, buf); gtk_widget_show(button[i]); gtk_table_attach_defaults(GTK_TABLE(dialog_table), - button[i], i % 2, (i % 2) + 1, i / 2, (i / 2) + 1); - GTK_WIDGET_UNSET_FLAGS(button[i], GTK_CAN_FOCUS); + button[i], i % 2, (i % 2) + 1, (i / 2) + 1, (i / 2) + 2); + gtk_widget_set_can_focus(button[i], FALSE); } if (last >= NELEMENTS(hddsize)) { last = 0; @@ -81,14 +92,15 @@ anex_newdisk_dialog(GtkWidget *dialog) if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { for (i = 0; i < NELEMENTS(hddsize); i++) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button[i]))) { - return i; + last = i; + return cnv[i]; } } } - return 0; + return -1; } -static int +static gint t98_newdisk_dialog(GtkWidget *dialog, const int kind) { static const char *hddsizestr[] = { @@ -128,7 +140,7 @@ t98_newdisk_dialog(GtkWidget *dialog, co gtk_widget_show(dialog_table); /* "HDD Size" label */ - label = gtk_label_new(" HDD Size"); + label = gtk_label_new(str_hddsize); gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); gtk_table_attach_defaults(GTK_TABLE(dialog_table), label, 0, 1, 0, 1); gtk_widget_show(label); @@ -206,7 +218,7 @@ create_newdisk_hd_dialog(const char *fil switch (kind) { case 1: /* HDI */ hdsize = anex_newdisk_dialog(dialog); - if (hdsize > 0) { + if (hdsize >= 0) { newdisk_hdi(filename, hdsize); } break; @@ -226,7 +238,6 @@ create_newdisk_hd_dialog(const char *fil break; } gtk_widget_destroy(dialog); - } @@ -255,8 +266,14 @@ create_newdisk_fd_dialog(const char *fil GtkWidget *hbox; GtkWidget *button[NELEMENTS(disktype)]; const gchar *p; + int ndisktype; int i; + ndisktype = NELEMENTS(disktype); + if (!np2cfg.usefd144) { + ndisktype--; + } + dialog = gtk_dialog_new_with_buttons("Create new floppy disk image", GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, @@ -299,19 +316,19 @@ create_newdisk_fd_dialog(const char *fil hbox = gtk_hbox_new(FALSE, 3); gtk_table_attach_defaults(GTK_TABLE(dialog_table), hbox, 1, 2, 1, 2); gtk_widget_show(hbox); - for (i = 0; i < NELEMENTS(disktype); ++i) { + for (i = 0; i < ndisktype; ++i) { button[i] = gtk_radio_button_new_with_label_from_widget( (i > 0) ? GTK_RADIO_BUTTON(button[i-1]) : NULL, disktype[i].str); gtk_widget_show(button[i]); gtk_box_pack_start(GTK_BOX(hbox), button[i], FALSE, FALSE, 1); - GTK_WIDGET_UNSET_FLAGS(button[i], GTK_CAN_FOCUS); + gtk_widget_set_can_focus(button[i], FALSE); } - for (i = 0; i < NELEMENTS(disktype); ++i) { + for (i = 0; i < ndisktype; ++i) { if (disktype[i].fdtype == makefdtype) break; } - if (i == NELEMENTS(disktype)) { + if (i == ndisktype) { i = (i <= 1) ? 0 : 1; /* 2HD */ } g_signal_emit_by_name(GTK_OBJECT(button[i]), "clicked");