home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / file_new_dialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-17  |  22.3 KB  |  674 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. #include "config.h"
  20.  
  21. #include <gtk/gtk.h>
  22.  
  23. #include "file_new_dialog.h"
  24. #include "gimprc.h"
  25. #include "gimpui.h"
  26. #include "gdisplay.h"
  27.  
  28. #include "libgimp/gimpchainbutton.h"
  29. #include "libgimp/gimpmath.h"
  30. #include "libgimp/gimplimits.h"
  31. #include "libgimp/gimpsizeentry.h"
  32. #include "libgimp/gimpintl.h"
  33.  
  34. typedef struct
  35. {
  36.   GtkWidget *dlg;
  37.  
  38.   GtkWidget *confirm_dlg;
  39.  
  40.   GtkWidget *size_frame;
  41.   GtkWidget *size_se;
  42.   GtkWidget *resolution_se;
  43.   GtkWidget *couple_resolutions;
  44.  
  45.   /* this should be a list */
  46.   GtkWidget *type_w[2];
  47.   GtkWidget *fill_type_w[4];
  48.  
  49.   GimpImageNewValues *values;
  50.   gdouble size;
  51. } NewImageInfo;
  52.  
  53. /*  new image local functions  */
  54. static void file_new_confirm_dialog      (NewImageInfo *);
  55.  
  56. static void file_new_ok_callback         (GtkWidget *, gpointer);
  57. static void file_new_reset_callback      (GtkWidget *, gpointer);
  58. static void file_new_cancel_callback     (GtkWidget *, gpointer);
  59. static void file_new_resolution_callback (GtkWidget *, gpointer);
  60. static void file_new_image_size_callback (GtkWidget *, gpointer);
  61.  
  62. static void
  63. file_new_ok_callback (GtkWidget *widget,
  64.               gpointer   data)
  65. {
  66.   NewImageInfo *info;
  67.   GimpImageNewValues *values;
  68.  
  69.   info = (NewImageInfo*) data;
  70.   values = info->values;
  71.  
  72.   /* get the image size in pixels */
  73.   values->width = 
  74.     RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0));
  75.   values->height = 
  76.     RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
  77.  
  78.   /* get the resolution in dpi */
  79.   values->xresolution =
  80.     gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->resolution_se), 0);
  81.   values->yresolution =
  82.     gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->resolution_se), 1);
  83.  
  84.   /* get the units */
  85.   values->unit =
  86.     gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (info->size_se));
  87.   values->res_unit =
  88.     gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (info->resolution_se));
  89.  
  90.   if (info->size > max_new_image_size)
  91.     {
  92.       file_new_confirm_dialog (info);
  93.     }
  94.   else
  95.     {
  96.       gtk_widget_destroy (info->dlg);
  97.       image_new_create_image (values);
  98.       image_new_values_free (values);
  99.       g_free (info);
  100.     }
  101. }
  102.  
  103. static void
  104. file_new_reset_callback (GtkWidget *widget,
  105.              gpointer   data)
  106. {
  107.   NewImageInfo *info;
  108.  
  109.   info = (NewImageInfo*) data;
  110.  
  111.   gtk_signal_handler_block_by_data (GTK_OBJECT (info->resolution_se), info);
  112.  
  113.   gimp_chain_button_set_active
  114.     (GIMP_CHAIN_BUTTON (info->couple_resolutions),
  115.      ABS (default_xresolution - default_yresolution) < GIMP_MIN_RESOLUTION);
  116.  
  117.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
  118.                   0, default_xresolution);
  119.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
  120.                   1, default_yresolution);
  121.   gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (info->resolution_se),
  122.                 default_resolution_units);
  123.  
  124.   gtk_signal_handler_unblock_by_data (GTK_OBJECT (info->resolution_se), info);
  125.  
  126.   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se),
  127.                   0, default_xresolution, TRUE);
  128.   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se),
  129.                   1, default_yresolution, TRUE);
  130.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se),
  131.                   0, default_width);
  132.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se),
  133.                   1, default_height);
  134.   gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (info->size_se),
  135.                 default_units);
  136.  
  137.   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (info->type_w[default_type]),
  138.                 TRUE);
  139.   gtk_toggle_button_set_active
  140.     (GTK_TOGGLE_BUTTON (info->fill_type_w[BACKGROUND_FILL]), TRUE);
  141. }
  142.  
  143. static void
  144. file_new_cancel_callback (GtkWidget *widget,
  145.               gpointer   data)
  146. {
  147.   NewImageInfo *info;
  148.  
  149.   info = (NewImageInfo*) data;
  150.  
  151.   gtk_widget_destroy (info->dlg);
  152.   image_new_values_free(info->values);
  153.   g_free (info);
  154. }
  155.  
  156. /*  local callback of file_new_confirm_dialog()  */
  157. static void
  158. file_new_confirm_dialog_callback (GtkWidget *widget,
  159.                   gboolean   create,
  160.                   gpointer   data)
  161. {
  162.   NewImageInfo *info;
  163.  
  164.   info = (NewImageInfo*) data;
  165.  
  166.   info->confirm_dlg = NULL;
  167.  
  168.   if (create)
  169.     {
  170.       gtk_widget_destroy (info->dlg);
  171.       image_new_create_image (info->values);
  172.       image_new_values_free (info->values);
  173.       g_free (info);
  174.     }
  175.   else
  176.     {
  177.       gtk_widget_set_sensitive (info->dlg, TRUE);
  178.     }
  179. }
  180.  
  181. static void
  182. file_new_confirm_dialog (NewImageInfo *info)
  183. {
  184.   gchar *size;
  185.   gchar *max_size;
  186.   gchar *text;
  187.  
  188.   gtk_widget_set_sensitive (info->dlg, FALSE);
  189.  
  190.   size = image_new_get_size_string (info->size);
  191.   max_size = image_new_get_size_string (max_new_image_size);
  192.  
  193.   /* xgettext:no-c-format */
  194.         
  195.   text = g_strdup_printf (_("You are trying to create an image which\n"
  196.                 "has an initial size of %s.\n\n"
  197.                 "Choose OK to create this image anyway.\n"
  198.                 "Choose Cancel if you didn't mean to\n"
  199.                 "create such a large image.\n\n"
  200.                 "To prevent this dialog from appearing,\n"
  201.                 "increase the \"Maximum Image Size\"\n"
  202.                 "setting (currently %s) in the\n"
  203.                 "preferences dialog."),
  204.                           size, max_size);
  205.  
  206.   info->confirm_dlg =
  207.     gimp_query_boolean_box (_("Confirm Image Size"),
  208.                 gimp_standard_help_func,
  209.                 "dialogs/file_new.html#confirm_size",
  210.                 FALSE,
  211.                 text,
  212.                 _("OK"), _("Cancel"),
  213.                 NULL, NULL,
  214.                 file_new_confirm_dialog_callback,
  215.                 info);
  216.  
  217.   g_free (text);
  218.   g_free (max_size);
  219.   g_free (size);
  220.  
  221.   gtk_widget_show (info->confirm_dlg);
  222. }
  223.  
  224. static void
  225. file_new_resolution_callback (GtkWidget *widget,
  226.                   gpointer   data)
  227. {
  228.   NewImageInfo *info;
  229.  
  230.   static gdouble xres = 0.0;
  231.   static gdouble yres = 0.0;
  232.   gdouble new_xres;
  233.   gdouble new_yres;
  234.  
  235.   info = (NewImageInfo*) data;
  236.  
  237.   new_xres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
  238.   new_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
  239.  
  240.   if (gimp_chain_button_get_active
  241.       (GIMP_CHAIN_BUTTON (info->couple_resolutions)))
  242.     {
  243.       gtk_signal_handler_block_by_data
  244.     (GTK_OBJECT (info->resolution_se), info);
  245.  
  246.       if (new_xres != xres)
  247.     {
  248.       yres = new_yres = xres = new_xres;
  249.       gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, yres);
  250.     }
  251.  
  252.       if (new_yres != yres)
  253.     {
  254.       xres = new_xres = yres = new_yres;
  255.       gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, xres);
  256.     }
  257.  
  258.       gtk_signal_handler_unblock_by_data
  259.     (GTK_OBJECT (info->resolution_se), info);
  260.     }
  261.   else
  262.     {
  263.       if (new_xres != xres)
  264.     xres = new_xres;
  265.       if (new_yres != yres)
  266.     yres = new_yres;
  267.     }
  268.  
  269.   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
  270.                   xres, FALSE);
  271.   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
  272.                   yres, FALSE);
  273.  
  274.   file_new_image_size_callback (widget, data);
  275. }
  276.  
  277. static void
  278. file_new_image_size_callback (GtkWidget *widget,
  279.                   gpointer   data)
  280. {
  281.   NewImageInfo *info;
  282.   gchar *text;
  283.   gchar *label;
  284.  
  285.   info = (NewImageInfo*) data;
  286.  
  287.   info->values->width = 
  288.     RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0));
  289.   info->values->height =
  290.     RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
  291.  
  292.   info->size = image_new_calculate_size (info->values);
  293.  
  294.   label = g_strdup_printf (_("Image Size: %s"),
  295.                text = image_new_get_size_string (info->size));
  296.   gtk_frame_set_label (GTK_FRAME (info->size_frame), label);
  297.  
  298.   g_free (label);
  299.   g_free (text);
  300. }
  301.  
  302. void
  303. file_new_cmd_callback (GtkWidget *widget,
  304.                gpointer   callback_data,
  305.                guint      callback_action)
  306. {
  307.   GDisplay *gdisp;
  308.   GimpImage *image = NULL;
  309.  
  310.   /*  Before we try to determine the responsible gdisplay,
  311.    *  make sure this wasn't called from the toolbox
  312.    */
  313.   if (callback_action)
  314.     {
  315.       gdisp = gdisplay_active ();
  316.  
  317.       if (gdisp)
  318.         image = gdisp->gimage;
  319.     }
  320.  
  321.   image_new_create_window (NULL, image);
  322. }
  323.  
  324. void
  325. ui_new_image_window_create (const GimpImageNewValues *values_orig)
  326. {
  327.   NewImageInfo       *info;
  328.   GimpImageNewValues *values;
  329.  
  330.   GtkWidget *top_vbox;
  331.   GtkWidget *hbox;
  332.   GtkWidget *vbox;
  333.   GtkWidget *abox;
  334.   GtkWidget *frame;
  335.   GtkWidget *table;
  336.   GtkWidget *separator;
  337.   GtkWidget *label;
  338.   GtkWidget *button;
  339.   GtkObject *adjustment;
  340.   GtkWidget *spinbutton;
  341.   GtkWidget *spinbutton2;
  342.   GtkWidget *radio_box;
  343.   GSList *group;
  344.   GList *list;
  345.  
  346.   info = g_new (NewImageInfo, 1);
  347.   info->values = values = image_new_values_new (values_orig);
  348.  
  349.   info->confirm_dlg = NULL;
  350.   info->size = 0.0;
  351.  
  352.   info->dlg = gimp_dialog_new (_("New Image"), "new_image",
  353.                    gimp_standard_help_func,
  354.                    "dialogs/file_new.html",
  355.                    GTK_WIN_POS_MOUSE,
  356.                    FALSE, FALSE, TRUE,
  357.  
  358.                    _("OK"), file_new_ok_callback,
  359.                    info, NULL, NULL, TRUE, FALSE,
  360.                    _("Reset"), file_new_reset_callback,
  361.                    info, NULL, NULL, FALSE, FALSE,
  362.                    _("Cancel"), file_new_cancel_callback,
  363.                    info, NULL, NULL, FALSE, TRUE,
  364.  
  365.                    NULL);
  366.  
  367.   /*  vbox holding the rest of the dialog  */
  368.   top_vbox = gtk_vbox_new (FALSE, 4);
  369.   gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 4);
  370.   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->dlg)->vbox),
  371.               top_vbox, TRUE, TRUE, 0);
  372.   gtk_widget_show (top_vbox);
  373.  
  374.   /*  Image size frame  */
  375.   info->size_frame = gtk_frame_new (NULL);
  376.   gtk_box_pack_start (GTK_BOX (top_vbox), info->size_frame, FALSE, FALSE, 0);
  377.   gtk_widget_show (info->size_frame);
  378.  
  379.   vbox = gtk_vbox_new (FALSE, 0);
  380.   gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
  381.   gtk_container_add (GTK_CONTAINER (info->size_frame), vbox);
  382.   gtk_widget_show (vbox);
  383.  
  384.   table = gtk_table_new (7, 2, FALSE);
  385.   gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
  386.   gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
  387.   gtk_table_set_row_spacing (GTK_TABLE (table), 1, 4);
  388.   gtk_table_set_row_spacing (GTK_TABLE (table), 2, 4);
  389.   gtk_table_set_row_spacing (GTK_TABLE (table), 4, 4);
  390.   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
  391.   gtk_widget_show (table);
  392.  
  393.   /*  the pixel size labels  */
  394.   label = gtk_label_new (_("Width:"));
  395.   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  396.   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
  397.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  398.   gtk_widget_show (label);
  399.  
  400.   label = gtk_label_new (_("Height:"));
  401.   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  402.   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
  403.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  404.   gtk_widget_show (label);
  405.  
  406.   /*  a separator after the pixel section  */
  407.   separator = gtk_hseparator_new ();
  408.   gtk_table_attach_defaults (GTK_TABLE (table), separator, 0, 2, 2, 3);
  409.   gtk_widget_show (separator);
  410.  
  411.   /*  the unit size labels  */
  412.   label = gtk_label_new (_("Width:"));
  413.   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  414.   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
  415.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  416.   gtk_widget_show (label);
  417.  
  418.   label = gtk_label_new (_("Height:"));
  419.   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  420.   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
  421.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  422.   gtk_widget_show (label);
  423.  
  424.   /*  create the sizeentry which keeps it all together  */
  425.   abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
  426.   gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 3, 5);
  427.   info->size_se =
  428.     gimp_size_entry_new (0, values->unit, "%a", FALSE, FALSE, TRUE, 75,
  429.              GIMP_SIZE_ENTRY_UPDATE_SIZE);
  430.   gtk_table_set_col_spacing (GTK_TABLE (info->size_se), 1, 2);
  431.   gtk_container_add (GTK_CONTAINER (abox), info->size_se);
  432.   gtk_widget_show (info->size_se);
  433.   gtk_widget_show (abox);
  434.  
  435.   /*  height in units  */
  436.   adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  437.   spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
  438.   gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
  439.                                    GTK_SHADOW_NONE);
  440.   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  441.   gtk_widget_set_usize (spinbutton, 75, 0);
  442.   /*  add the "height in units" spinbutton to the sizeentry  */
  443.   gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
  444.                  0, 1, 2, 3);
  445.   gtk_widget_show (spinbutton);
  446.  
  447.   /*  height in pixels  */
  448.   hbox = gtk_hbox_new (FALSE, 2);
  449.   adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  450.   spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 0);
  451.   gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton2),
  452.                                    GTK_SHADOW_NONE);
  453.   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE);
  454.   gtk_widget_set_usize (spinbutton2, 75, 0);
  455.   gtk_box_pack_start (GTK_BOX (hbox), spinbutton2, FALSE, FALSE, 0);
  456.   gtk_widget_show (spinbutton2);
  457.  
  458.   label = gtk_label_new (_("Pixels"));
  459.   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  460.   gtk_widget_show (label);
  461.  
  462.   /*  add the "height in pixels" spinbutton to the main table  */
  463.   gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
  464.   gtk_widget_show (hbox);
  465.  
  466.   /*  register the height spinbuttons with the sizeentry  */
  467.   gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
  468.                              GTK_SPIN_BUTTON (spinbutton),
  469.                  GTK_SPIN_BUTTON (spinbutton2));
  470.  
  471.   /*  width in units  */
  472.   adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  473.   spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
  474.   gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
  475.                                    GTK_SHADOW_NONE);
  476.   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  477.   gtk_widget_set_usize (spinbutton, 75, 0);
  478.   /*  add the "width in units" spinbutton to the sizeentry  */
  479.   gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
  480.                  0, 1, 1, 2);
  481.   gtk_widget_show (spinbutton);
  482.  
  483.   /*  width in pixels  */
  484.   abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
  485.   gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 0, 1);
  486.   adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  487.   spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 0);
  488.   gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton2),
  489.                                    GTK_SHADOW_NONE);
  490.   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE);
  491.   gtk_widget_set_usize (spinbutton2, 75, 0);
  492.   /*  add the "width in pixels" spinbutton to the main table  */
  493.   gtk_container_add (GTK_CONTAINER (abox), spinbutton2);
  494.   gtk_widget_show (spinbutton2);
  495.   gtk_widget_show (abox);
  496.  
  497.   /*  register the width spinbuttons with the sizeentry  */
  498.   gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
  499.                              GTK_SPIN_BUTTON (spinbutton),
  500.                  GTK_SPIN_BUTTON (spinbutton2));
  501.  
  502.   /*  initialize the sizeentry  */
  503.   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
  504.                   values->xresolution, FALSE);
  505.   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
  506.                   values->yresolution, FALSE);
  507.  
  508.   gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->size_se), 0,
  509.                      GIMP_MIN_IMAGE_SIZE,
  510.                      GIMP_MAX_IMAGE_SIZE);
  511.   gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->size_se), 1,
  512.                      GIMP_MIN_IMAGE_SIZE,
  513.                      GIMP_MAX_IMAGE_SIZE);
  514.  
  515.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 0, values->width);
  516.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1, values->height);
  517.  
  518.   gtk_signal_connect (GTK_OBJECT (info->size_se), "refval_changed",
  519.               GTK_SIGNAL_FUNC (file_new_image_size_callback),
  520.               info);
  521.   gtk_signal_connect (GTK_OBJECT (info->size_se), "value_changed",
  522.               GTK_SIGNAL_FUNC (file_new_image_size_callback),
  523.               info);
  524.  
  525.   /*  initialize the size label  */
  526.   file_new_image_size_callback (info->size_se, info);
  527.  
  528.   /*  the resolution labels  */
  529.   label = gtk_label_new (_("Resolution X:"));
  530.   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  531.   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6,
  532.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  533.   gtk_widget_show (label);
  534.  
  535.   label = gtk_label_new (_("Y:"));
  536.   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  537.   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7,
  538.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  539.   gtk_widget_show (label);
  540.  
  541.   /*  the resolution sizeentry  */
  542.   adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  543.   spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
  544.   gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
  545.                    GTK_SHADOW_NONE);
  546.   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  547.   gtk_widget_set_usize (spinbutton, 75, 0);
  548.  
  549.   info->resolution_se =
  550.     gimp_size_entry_new (1, default_resolution_units, _("pixels/%a"),
  551.                  FALSE, FALSE, FALSE, 75,
  552.                  GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
  553.   gtk_table_set_col_spacing (GTK_TABLE (info->resolution_se), 1, 2);
  554.   gtk_table_set_col_spacing (GTK_TABLE (info->resolution_se), 2, 2);
  555.   gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->resolution_se),
  556.                  GTK_SPIN_BUTTON (spinbutton), NULL);
  557.   gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), spinbutton,
  558.                  1, 2, 0, 1);
  559.   gtk_widget_show (spinbutton);
  560.   gtk_table_attach (GTK_TABLE (table), info->resolution_se, 1, 2, 5, 7,
  561.             GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  562.   gtk_widget_show (info->resolution_se);
  563.  
  564.   gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->resolution_se),
  565.                      0, GIMP_MIN_RESOLUTION,
  566.                      GIMP_MAX_RESOLUTION);
  567.   gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->resolution_se),
  568.                      1, GIMP_MIN_RESOLUTION,
  569.                      GIMP_MAX_RESOLUTION);
  570.  
  571.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
  572.                   0, values->xresolution);
  573.   gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
  574.                   1, values->yresolution);
  575.  
  576.   gtk_signal_connect (GTK_OBJECT (info->resolution_se), "value_changed",
  577.               GTK_SIGNAL_FUNC (file_new_resolution_callback),
  578.               info);
  579.  
  580.   /*  the resolution chainbutton  */
  581.   info->couple_resolutions = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
  582.   gimp_chain_button_set_active
  583.     (GIMP_CHAIN_BUTTON (info->couple_resolutions),
  584.      ABS (values->xresolution - values->yresolution) < GIMP_MIN_RESOLUTION);
  585.   gtk_table_attach_defaults (GTK_TABLE (info->resolution_se),
  586.                  info->couple_resolutions, 2, 3, 0, 2);
  587.   gtk_widget_show (info->couple_resolutions);
  588.  
  589.   /*  hbox containing the Image type and fill type frames  */
  590.   hbox = gtk_hbox_new (FALSE, 2);
  591.   gtk_box_pack_start (GTK_BOX (top_vbox), hbox, FALSE, FALSE, 0);
  592.   gtk_widget_show (hbox);
  593.  
  594.   /*  frame for Image Type  */
  595.   frame = gtk_frame_new (_("Image Type"));
  596.   gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  597.   gtk_widget_show (frame);
  598.  
  599.   /*  radio buttons and box  */
  600.   radio_box = gtk_vbox_new (FALSE, 1);
  601.   gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2);
  602.   gtk_container_add (GTK_CONTAINER (frame), radio_box);
  603.   gtk_widget_show (radio_box);
  604.  
  605.   group = NULL;
  606.   list = g_list_first (image_new_get_image_base_type_names ());
  607.   while (list)
  608.     {
  609.       GimpImageBaseTypeName *name_info;
  610.  
  611.       name_info = (GimpImageBaseTypeName*) list->data;
  612.  
  613.       button = gtk_radio_button_new_with_label (group, name_info->name);
  614.       group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
  615.       gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, TRUE, 0);
  616.       gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type);
  617.       gtk_signal_connect (GTK_OBJECT (button), "toggled",
  618.               GTK_SIGNAL_FUNC (gimp_radio_button_update),
  619.               &values->type);
  620.       gtk_signal_connect (GTK_OBJECT (button), "toggled",
  621.               GTK_SIGNAL_FUNC (file_new_image_size_callback),
  622.               info);
  623.       if (values->type == name_info->type)
  624.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  625.       gtk_widget_show (button);
  626.  
  627.       info->type_w[name_info->type] = button;
  628.  
  629.       list = g_list_next (list);
  630.     }
  631.  
  632.   /* frame for Fill Type */
  633.   frame = gtk_frame_new (_("Fill Type"));
  634.   gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  635.   gtk_widget_show (frame);
  636.  
  637.   radio_box = gtk_vbox_new (FALSE, 1);
  638.   gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2);
  639.   gtk_container_add (GTK_CONTAINER (frame), radio_box);
  640.   gtk_widget_show (radio_box);
  641.  
  642.   group = NULL;
  643.   list = g_list_first (image_new_get_fill_type_names ());
  644.   while (list)
  645.     {
  646.       GimpFillTypeName *name_info;
  647.  
  648.       name_info = (GimpFillTypeName*) list->data;
  649.  
  650.       button =
  651.     gtk_radio_button_new_with_label (group, name_info->name);
  652.       group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
  653.       gtk_box_pack_start (GTK_BOX (radio_box), button, TRUE, TRUE, 0);
  654.       gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type);
  655.       gtk_signal_connect (GTK_OBJECT (button), "toggled",
  656.               GTK_SIGNAL_FUNC (gimp_radio_button_update),
  657.               &values->fill_type);
  658.       gtk_signal_connect (GTK_OBJECT (button), "toggled",
  659.               GTK_SIGNAL_FUNC (file_new_image_size_callback),
  660.               info);
  661.       if (values->fill_type == name_info->type)
  662.     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  663.       gtk_widget_show (button);
  664.  
  665.       info->fill_type_w[name_info->type] = button;
  666.  
  667.       list = g_list_next (list);
  668.     }
  669.  
  670.   gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (info->size_se));
  671.  
  672.   gtk_widget_show (info->dlg);
  673. }
  674.