Diff for /np2/x11/gtk2/dialog_newdisk.c between versions 1.1 and 1.5

version 1.1, 2004/07/14 16:01:40 version 1.5, 2010/12/23 06:32:35
Line 12 Line 12
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    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   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES   * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Line 35 Line 33
 #include "np2.h"  #include "np2.h"
 #include "dosio.h"  #include "dosio.h"
 #include "ini.h"  #include "ini.h"
   #include "pccore.h"
   
 #include "fddfile.h"  #include "fddfile.h"
 #include "newdisk.h"  #include "newdisk.h"
Line 44 Line 43
  * create hard disk image   * create hard disk image
  */   */
   
 static int  static const OEMCHAR *str_hddsize = OEMTEXT(" HDD Size");
   
   static gint
 anex_newdisk_dialog(GtkWidget *dialog)  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 const int hddsize[] = { 5, 10, 15, 20, 30, 40 };
         static int last = 0;          static int last = 0;
   
         char buf[32];          char buf[32];
         GtkWidget *dialog_table;          GtkWidget *dialog_table;
         GtkWidget *button[NELEMENTS(hddsize)];          GtkWidget *button[NELEMENTS(hddsize)];
           GtkWidget *label;
         int i;          int i;
   
         /* dialog table */          /* 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_table_set_col_spacings(GTK_TABLE(dialog_table), 5);
         gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),dialog_table);          gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),dialog_table);
         gtk_widget_show(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) {          for (i = 0; i < NELEMENTS(hddsize); ++i) {
                 g_snprintf(buf, sizeof(buf), "%dMB", hddsize[i]);                  g_snprintf(buf, sizeof(buf), "%dMB", hddsize[i]);
                 button[i] = gtk_radio_button_new_with_label_from_widget(                  button[i] = gtk_radio_button_new_with_label_from_widget(
                     (i > 0) ? GTK_RADIO_BUTTON(button[i-1]) : NULL, buf);                      (i > 0) ? GTK_RADIO_BUTTON(button[i-1]) : NULL, buf);
                 gtk_widget_show(button[i]);                  gtk_widget_show(button[i]);
                 gtk_table_attach_defaults(GTK_TABLE(dialog_table),                  gtk_table_attach_defaults(GTK_TABLE(dialog_table),
                     button[i], i % 2, (i % 2) + 1, i / 2, (i / 2) + 1);                      button[i], i % 2, (i % 2) + 1, (i / 2) + 1, (i / 2) + 2);
                 GTK_WIDGET_UNSET_FLAGS(button[i], GTK_CAN_FOCUS);                  gtk_widget_set_can_focus(button[i], FALSE);
         }          }
         if (last >= NELEMENTS(hddsize)) {          if (last >= NELEMENTS(hddsize)) {
                 last = 0;                  last = 0;
Line 81  anex_newdisk_dialog(GtkWidget *dialog) Line 92  anex_newdisk_dialog(GtkWidget *dialog)
         if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {          if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
                 for (i = 0; i < NELEMENTS(hddsize); i++) {                  for (i = 0; i < NELEMENTS(hddsize); i++) {
                         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button[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)  t98_newdisk_dialog(GtkWidget *dialog, const int kind)
 {  {
         static const char *hddsizestr[] = {          static const char *hddsizestr[] = {
Line 128  t98_newdisk_dialog(GtkWidget *dialog, co Line 140  t98_newdisk_dialog(GtkWidget *dialog, co
         gtk_widget_show(dialog_table);          gtk_widget_show(dialog_table);
   
         /* "HDD Size" label */          /* "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_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
         gtk_table_attach_defaults(GTK_TABLE(dialog_table), label, 0, 1, 0, 1);          gtk_table_attach_defaults(GTK_TABLE(dialog_table), label, 0, 1, 0, 1);
         gtk_widget_show(label);          gtk_widget_show(label);
Line 206  create_newdisk_hd_dialog(const char *fil Line 218  create_newdisk_hd_dialog(const char *fil
         switch (kind) {          switch (kind) {
         case 1: /* HDI */          case 1: /* HDI */
                 hdsize = anex_newdisk_dialog(dialog);                  hdsize = anex_newdisk_dialog(dialog);
                 if (hdsize > 0) {                  if (hdsize >= 0) {
                         newdisk_hdi(filename, hdsize);                          newdisk_hdi(filename, hdsize);
                 }                  }
                 break;                  break;
Line 226  create_newdisk_hd_dialog(const char *fil Line 238  create_newdisk_hd_dialog(const char *fil
                 break;                  break;
         }          }
         gtk_widget_destroy(dialog);          gtk_widget_destroy(dialog);
   
 }  }
   
   
Line 255  create_newdisk_fd_dialog(const char *fil Line 266  create_newdisk_fd_dialog(const char *fil
         GtkWidget *hbox;          GtkWidget *hbox;
         GtkWidget *button[NELEMENTS(disktype)];          GtkWidget *button[NELEMENTS(disktype)];
         const gchar *p;          const gchar *p;
           int ndisktype;
         int i;          int i;
   
           ndisktype = NELEMENTS(disktype);
           if (!np2cfg.usefd144) {
                   ndisktype--;
           }
   
         dialog = gtk_dialog_new_with_buttons("Create new floppy disk image",          dialog = gtk_dialog_new_with_buttons("Create new floppy disk image",
             GTK_WINDOW(main_window),              GTK_WINDOW(main_window),
             GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL,              GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL,
Line 299  create_newdisk_fd_dialog(const char *fil Line 316  create_newdisk_fd_dialog(const char *fil
         hbox = gtk_hbox_new(FALSE, 3);          hbox = gtk_hbox_new(FALSE, 3);
         gtk_table_attach_defaults(GTK_TABLE(dialog_table), hbox, 1, 2, 1, 2);          gtk_table_attach_defaults(GTK_TABLE(dialog_table), hbox, 1, 2, 1, 2);
         gtk_widget_show(hbox);          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(                  button[i] = gtk_radio_button_new_with_label_from_widget(
                     (i > 0) ? GTK_RADIO_BUTTON(button[i-1]) : NULL,                      (i > 0) ? GTK_RADIO_BUTTON(button[i-1]) : NULL,
                     disktype[i].str);                      disktype[i].str);
                 gtk_widget_show(button[i]);                  gtk_widget_show(button[i]);
                 gtk_box_pack_start(GTK_BOX(hbox), button[i], FALSE, FALSE, 1);                  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)                  if (disktype[i].fdtype == makefdtype)
                         break;                          break;
         }          }
         if (i == NELEMENTS(disktype)) {          if (i == ndisktype) {
                 i = (i <= 1) ? 0 : 1;   /* 2HD */                  i = (i <= 1) ? 0 : 1;   /* 2HD */
         }          }
         g_signal_emit_by_name(GTK_OBJECT(button[i]), "clicked");          g_signal_emit_by_name(GTK_OBJECT(button[i]), "clicked");

Removed from v.1.1  
changed lines
  Added in v.1.5


RetroPC.NET-CVS <cvs@retropc.net>