1999-05-19 01:33:39 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-10-27 06:02:44 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gui-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimpcoreconfig.h"
|
2001-10-29 19:47:11 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-07-05 23:34:26 +08:00
|
|
|
#include "core/gimpimage-new.h"
|
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
#include "widgets/gimpenummenu.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "file-new-dialog.h"
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gimprc.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-05-10 00:38:05 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2001-08-01 07:28:56 +08:00
|
|
|
GtkWidget *dialog;
|
1999-02-25 19:25:53 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
GtkWidget *confirm_dialog;
|
1999-05-19 01:33:39 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
GtkWidget *size_se;
|
2002-01-27 23:07:41 +08:00
|
|
|
GtkWidget *memsize_label;
|
2001-08-01 07:28:56 +08:00
|
|
|
GtkWidget *resolution_se;
|
|
|
|
GtkWidget *couple_resolutions;
|
1999-02-25 19:25:53 +08:00
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
GtkWidget *type_w;
|
|
|
|
GtkWidget *fill_type_w;
|
1999-05-19 01:33:39 +08:00
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
GimpImageNewValues *values;
|
2001-08-01 07:28:56 +08:00
|
|
|
gdouble size;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
Gimp *gimp;
|
1999-08-26 12:39:21 +08:00
|
|
|
} NewImageInfo;
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
static void file_new_confirm_dialog (NewImageInfo *info);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
static void file_new_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_new_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_new_cancel_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_new_resolution_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2002-05-13 23:35:27 +08:00
|
|
|
static void file_new_image_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_new_fill_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2001-08-01 07:28:56 +08:00
|
|
|
static void file_new_image_size_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
/* public functions */
|
1998-06-10 05:21:23 +08:00
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
void
|
2001-10-29 19:47:11 +08:00
|
|
|
file_new_dialog_create (Gimp *gimp,
|
|
|
|
GimpImage *gimage)
|
1999-08-26 12:39:21 +08:00
|
|
|
{
|
2001-07-05 23:34:26 +08:00
|
|
|
NewImageInfo *info;
|
|
|
|
GtkWidget *top_vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *abox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *separator;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkObject *adjustment;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *spinbutton2;
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));
|
|
|
|
|
2001-07-05 23:34:26 +08:00
|
|
|
info = g_new0 (NewImageInfo, 1);
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
info->gimp = gimp;
|
|
|
|
|
|
|
|
info->values = gimp_image_new_values_new (gimp, gimage);
|
1999-05-31 22:11:10 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
info->confirm_dialog = NULL;
|
|
|
|
info->size = 0.0;
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
info->dialog = gimp_dialog_new (_("New Image"), "new_image",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/file_new.html",
|
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
GTK_STOCK_CANCEL, file_new_cancel_callback,
|
|
|
|
info, NULL, NULL, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2002-02-07 19:50:16 +08:00
|
|
|
GIMP_STOCK_RESET, file_new_reset_callback,
|
|
|
|
info, NULL, NULL, FALSE, FALSE,
|
|
|
|
|
2001-11-24 07:04:49 +08:00
|
|
|
GTK_STOCK_OK, file_new_ok_callback,
|
|
|
|
info, NULL, NULL, TRUE, FALSE,
|
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
NULL);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* vbox holding the rest of the dialog */
|
1999-11-24 03:11:29 +08:00
|
|
|
top_vbox = gtk_vbox_new (FALSE, 4);
|
1999-04-03 03:46:59 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 4);
|
2001-08-01 07:28:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->dialog)->vbox),
|
1999-04-03 03:46:59 +08:00
|
|
|
top_vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (top_vbox);
|
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* Image size frame */
|
2002-01-27 23:07:41 +08:00
|
|
|
frame = gtk_frame_new (_("Image Size"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
2002-01-27 23:07:41 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
1999-05-19 01:33:39 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
table = gtk_table_new (7, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 4);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 2, 4);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 4, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* the pixel size labels */
|
|
|
|
label = gtk_label_new (_("Width:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Height:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* a separator after the pixel section */
|
|
|
|
separator = gtk_hseparator_new ();
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), separator, 0, 2, 2, 3);
|
|
|
|
gtk_widget_show (separator);
|
|
|
|
|
|
|
|
/* the unit size labels */
|
|
|
|
label = gtk_label_new (_("Width:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Height:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* create the sizeentry which keeps it all together */
|
|
|
|
abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 3, 5);
|
1999-08-26 12:39:21 +08:00
|
|
|
info->size_se =
|
2001-07-05 23:34:26 +08:00
|
|
|
gimp_size_entry_new (0, info->values->unit, "%a", FALSE, FALSE, TRUE, 75,
|
1999-05-19 01:33:39 +08:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
1999-08-26 12:39:21 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (info->size_se), 1, 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), info->size_se);
|
|
|
|
gtk_widget_show (info->size_se);
|
1999-05-19 01:33:39 +08:00
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
/* height in units */
|
|
|
|
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
|
|
|
|
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (spinbutton, 75, -1);
|
1999-05-19 01:33:39 +08:00
|
|
|
/* add the "height in units" spinbutton to the sizeentry */
|
1999-08-26 12:39:21 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
|
1999-05-19 01:33:39 +08:00
|
|
|
0, 1, 2, 3);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
/* height in pixels */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 2);
|
|
|
|
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
|
|
|
|
spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (spinbutton2, 75, -1);
|
1999-05-19 01:33:39 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton2, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinbutton2);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Pixels"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2002-01-27 23:07:41 +08:00
|
|
|
info->memsize_label = gtk_label_new (NULL);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), info->memsize_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (info->memsize_label);
|
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* add the "height in pixels" spinbutton to the main table */
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
|
1999-04-03 03:46:59 +08:00
|
|
|
gtk_widget_show (hbox);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* register the height spinbuttons with the sizeentry */
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
|
1999-05-19 01:33:39 +08:00
|
|
|
GTK_SPIN_BUTTON (spinbutton),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton2));
|
|
|
|
|
|
|
|
/* width in units */
|
|
|
|
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
|
|
|
|
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (spinbutton, 75, -1);
|
1999-05-19 01:33:39 +08:00
|
|
|
/* add the "width in units" spinbutton to the sizeentry */
|
1999-08-26 12:39:21 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
|
1999-05-19 01:33:39 +08:00
|
|
|
0, 1, 1, 2);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
/* width in pixels */
|
|
|
|
abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 0, 1);
|
|
|
|
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
|
|
|
|
spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (spinbutton2, 75, -1);
|
1999-05-19 01:33:39 +08:00
|
|
|
/* add the "width in pixels" spinbutton to the main table */
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), spinbutton2);
|
|
|
|
gtk_widget_show (spinbutton2);
|
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
/* register the width spinbuttons with the sizeentry */
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
|
1999-05-19 01:33:39 +08:00
|
|
|
GTK_SPIN_BUTTON (spinbutton),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton2));
|
|
|
|
|
|
|
|
/* initialize the sizeentry */
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
2001-07-05 23:34:26 +08:00
|
|
|
info->values->xresolution, FALSE);
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
2001-07-05 23:34:26 +08:00
|
|
|
info->values->yresolution, FALSE);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->size_se), 0,
|
1999-05-19 01:33:39 +08:00
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->size_se), 1,
|
1999-05-19 01:33:39 +08:00
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
|
2001-07-05 23:34:26 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 0,
|
|
|
|
info->values->width);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1,
|
|
|
|
info->values->height);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
g_signal_connect (G_OBJECT (info->size_se), "refval_changed",
|
|
|
|
G_CALLBACK (file_new_image_size_callback),
|
|
|
|
info);
|
|
|
|
g_signal_connect (G_OBJECT (info->size_se), "value_changed",
|
|
|
|
G_CALLBACK (file_new_image_size_callback),
|
|
|
|
info);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
|
|
|
/* initialize the size label */
|
1999-08-26 12:39:21 +08:00
|
|
|
file_new_image_size_callback (info->size_se, info);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
|
|
|
/* the resolution labels */
|
|
|
|
label = gtk_label_new (_("Resolution X:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Y:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the resolution sizeentry */
|
|
|
|
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
|
|
|
|
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (spinbutton, 75, -1);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
info->resolution_se =
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_new (1, gimp->config->default_resolution_units,
|
2001-07-07 20:17:23 +08:00
|
|
|
_("pixels/%a"),
|
1999-08-26 12:39:21 +08:00
|
|
|
FALSE, FALSE, FALSE, 75,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (info->resolution_se), 1, 2);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (info->resolution_se), 2, 2);
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->resolution_se),
|
1999-05-19 01:33:39 +08:00
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
1999-08-26 12:39:21 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), spinbutton,
|
1999-05-19 01:33:39 +08:00
|
|
|
1, 2, 0, 1);
|
|
|
|
gtk_widget_show (spinbutton);
|
2002-02-07 19:50:16 +08:00
|
|
|
|
|
|
|
abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 5, 7);
|
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), info->resolution_se);
|
1999-08-26 12:39:21 +08:00
|
|
|
gtk_widget_show (info->resolution_se);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->resolution_se),
|
1999-05-19 01:33:39 +08:00
|
|
|
0, GIMP_MIN_RESOLUTION,
|
|
|
|
GIMP_MAX_RESOLUTION);
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->resolution_se),
|
1999-05-19 01:33:39 +08:00
|
|
|
1, GIMP_MIN_RESOLUTION,
|
|
|
|
GIMP_MAX_RESOLUTION);
|
|
|
|
|
2001-07-05 23:34:26 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se), 0,
|
|
|
|
info->values->xresolution);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se), 1,
|
|
|
|
info->values->yresolution);
|
1999-05-19 01:33:39 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
g_signal_connect (G_OBJECT (info->resolution_se), "value_changed",
|
|
|
|
G_CALLBACK (file_new_resolution_callback),
|
|
|
|
info);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* the resolution chainbutton */
|
1999-08-26 12:39:21 +08:00
|
|
|
info->couple_resolutions = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
1999-05-19 01:33:39 +08:00
|
|
|
gimp_chain_button_set_active
|
1999-08-26 12:39:21 +08:00
|
|
|
(GIMP_CHAIN_BUTTON (info->couple_resolutions),
|
2001-07-05 23:34:26 +08:00
|
|
|
ABS (info->values->xresolution - info->values->yresolution)
|
|
|
|
< GIMP_MIN_RESOLUTION);
|
1999-08-26 12:39:21 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (info->resolution_se),
|
|
|
|
info->couple_resolutions, 2, 3, 0, 2);
|
|
|
|
gtk_widget_show (info->couple_resolutions);
|
1999-02-25 19:25:53 +08:00
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* hbox containing the Image type and fill type frames */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 2);
|
1999-04-03 03:46:59 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (top_vbox), hbox, FALSE, FALSE, 0);
|
1999-05-19 01:33:39 +08:00
|
|
|
gtk_widget_show (hbox);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
1999-05-31 22:11:10 +08:00
|
|
|
/* frame for Image Type */
|
2002-05-13 23:35:27 +08:00
|
|
|
frame = gimp_enum_radio_frame_new (GIMP_TYPE_IMAGE_BASE_TYPE,
|
|
|
|
gtk_label_new (_("Image Type")),
|
|
|
|
2,
|
|
|
|
G_CALLBACK (file_new_image_type_callback),
|
|
|
|
info,
|
|
|
|
&info->type_w);
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->type_w),
|
|
|
|
GINT_TO_POINTER (info->values->type));
|
|
|
|
|
1998-06-09 05:53:45 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* frame for Fill Type */
|
2002-05-13 23:35:27 +08:00
|
|
|
frame = gimp_enum_radio_frame_new (GIMP_TYPE_FILL_TYPE,
|
|
|
|
gtk_label_new (_("Fill Type")),
|
|
|
|
2,
|
|
|
|
G_CALLBACK (file_new_fill_type_callback),
|
|
|
|
info,
|
|
|
|
&info->fill_type_w);
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->fill_type_w),
|
|
|
|
GINT_TO_POINTER (info->values->fill_type));
|
|
|
|
|
1998-06-09 05:53:45 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (info->size_se));
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
gtk_widget_show (info->dialog);
|
1998-06-18 13:04:01 +08:00
|
|
|
}
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_new_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
|
|
|
GimpImageNewValues *values;
|
|
|
|
|
|
|
|
info = (NewImageInfo*) data;
|
|
|
|
values = info->values;
|
|
|
|
|
|
|
|
/* get the image size in pixels */
|
|
|
|
values->width =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0));
|
|
|
|
values->height =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
|
|
|
|
|
|
|
|
/* get the resolution in dpi */
|
|
|
|
values->xresolution =
|
|
|
|
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->resolution_se), 0);
|
|
|
|
values->yresolution =
|
|
|
|
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->resolution_se), 1);
|
|
|
|
|
|
|
|
/* get the units */
|
|
|
|
values->unit =
|
|
|
|
gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (info->size_se));
|
|
|
|
values->res_unit =
|
|
|
|
gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (info->resolution_se));
|
|
|
|
|
|
|
|
if (info->size > gimprc.max_new_image_size)
|
|
|
|
{
|
|
|
|
file_new_confirm_dialog (info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (info->dialog);
|
|
|
|
gimp_image_new_create_image (info->gimp, values);
|
|
|
|
gimp_image_new_values_free (values);
|
|
|
|
g_free (info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_new_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2002-05-13 23:35:27 +08:00
|
|
|
NewImageInfo *info;
|
|
|
|
GimpCoreConfig *config;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
info = (NewImageInfo *) data;
|
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
config = info->gimp->config;
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (info->resolution_se),
|
|
|
|
file_new_resolution_callback,
|
|
|
|
info);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
gimp_chain_button_set_active
|
|
|
|
(GIMP_CHAIN_BUTTON (info->couple_resolutions),
|
2002-05-13 23:35:27 +08:00
|
|
|
ABS (config->default_xresolution -
|
|
|
|
config->default_yresolution) < GIMP_MIN_RESOLUTION);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se), 0,
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_xresolution);
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se), 1,
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_yresolution);
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (info->resolution_se),
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_resolution_units);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (info->resolution_se),
|
|
|
|
file_new_resolution_callback,
|
|
|
|
info);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_xresolution, TRUE);
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_yresolution, TRUE);
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 0,
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_width);
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1,
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_height);
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (info->size_se),
|
2002-05-13 23:35:27 +08:00
|
|
|
config->default_units);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->type_w),
|
|
|
|
GINT_TO_POINTER (config->default_type));
|
2001-11-22 21:01:26 +08:00
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->fill_type_w),
|
2002-03-18 19:07:34 +08:00
|
|
|
GINT_TO_POINTER (GIMP_BACKGROUND_FILL));
|
2001-10-29 19:47:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_new_cancel_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
|
|
|
|
|
|
|
info = (NewImageInfo*) data;
|
|
|
|
|
|
|
|
gtk_widget_destroy (info->dialog);
|
|
|
|
gimp_image_new_values_free (info->values);
|
|
|
|
g_free (info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local callback of file_new_confirm_dialog() */
|
|
|
|
static void
|
|
|
|
file_new_confirm_dialog_callback (GtkWidget *widget,
|
|
|
|
gboolean create,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
|
|
|
|
|
|
|
info = (NewImageInfo*) data;
|
|
|
|
|
|
|
|
info->confirm_dialog = NULL;
|
|
|
|
|
|
|
|
if (create)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (info->dialog);
|
|
|
|
gimp_image_new_create_image (info->gimp, info->values);
|
|
|
|
gimp_image_new_values_free (info->values);
|
|
|
|
g_free (info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (info->dialog, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_new_confirm_dialog (NewImageInfo *info)
|
|
|
|
{
|
|
|
|
gchar *size;
|
|
|
|
gchar *max_size;
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (info->dialog, FALSE);
|
|
|
|
|
2002-02-08 01:37:34 +08:00
|
|
|
size = gimp_image_new_get_memsize_string (info->size);
|
|
|
|
max_size = gimp_image_new_get_memsize_string (gimprc.max_new_image_size);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
/* xgettext:no-c-format */
|
|
|
|
|
2001-11-27 01:12:29 +08:00
|
|
|
text = g_strdup_printf (_("You are trying to create an image with\n"
|
|
|
|
"an initial size of %s.\n\n"
|
2001-10-29 19:47:11 +08:00
|
|
|
"Choose OK to create this image anyway.\n"
|
2001-11-27 01:12:29 +08:00
|
|
|
"Choose Cancel if you did not intend to\n"
|
2001-10-29 19:47:11 +08:00
|
|
|
"create such a large image.\n\n"
|
|
|
|
"To prevent this dialog from appearing,\n"
|
|
|
|
"increase the \"Maximum Image Size\"\n"
|
|
|
|
"setting (currently %s) in the\n"
|
2001-11-27 01:12:29 +08:00
|
|
|
"Preferences dialog."),
|
2001-10-29 19:47:11 +08:00
|
|
|
size, max_size);
|
|
|
|
|
|
|
|
info->confirm_dialog =
|
|
|
|
gimp_query_boolean_box (_("Confirm Image Size"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/file_new.html#confirm_size",
|
2002-01-10 04:39:49 +08:00
|
|
|
GTK_STOCK_DIALOG_INFO,
|
2001-10-29 19:47:11 +08:00
|
|
|
text,
|
|
|
|
GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
|
|
|
NULL, NULL,
|
|
|
|
file_new_confirm_dialog_callback,
|
|
|
|
info);
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
g_free (max_size);
|
|
|
|
g_free (size);
|
|
|
|
|
|
|
|
gtk_widget_show (info->confirm_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_new_resolution_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
|
|
|
|
|
|
|
static gdouble xres = 0.0;
|
|
|
|
static gdouble yres = 0.0;
|
|
|
|
gdouble new_xres;
|
|
|
|
gdouble new_yres;
|
|
|
|
|
|
|
|
info = (NewImageInfo *) data;
|
|
|
|
|
|
|
|
new_xres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
new_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
|
|
|
|
|
|
|
if (gimp_chain_button_get_active
|
|
|
|
(GIMP_CHAIN_BUTTON (info->couple_resolutions)))
|
|
|
|
{
|
2001-12-29 21:26:29 +08:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (info->resolution_se),
|
|
|
|
file_new_resolution_callback,
|
|
|
|
info);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
if (new_xres != xres)
|
|
|
|
{
|
|
|
|
yres = new_yres = xres = new_xres;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, yres);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_yres != yres)
|
|
|
|
{
|
|
|
|
xres = new_xres = yres = new_yres;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, xres);
|
|
|
|
}
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (info->resolution_se),
|
|
|
|
file_new_resolution_callback,
|
|
|
|
info);
|
2001-10-29 19:47:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (new_xres != xres)
|
|
|
|
xres = new_xres;
|
|
|
|
if (new_yres != yres)
|
|
|
|
yres = new_yres;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
|
|
|
xres, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
|
|
|
yres, FALSE);
|
|
|
|
|
|
|
|
file_new_image_size_callback (widget, data);
|
|
|
|
}
|
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
static void
|
|
|
|
file_new_image_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
|
|
|
|
|
|
|
info = (NewImageInfo*) data;
|
|
|
|
|
|
|
|
gimp_radio_button_update (widget, &info->values->type);
|
|
|
|
|
|
|
|
file_new_image_size_callback (widget, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_new_fill_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
|
|
|
|
|
|
|
info = (NewImageInfo*) data;
|
|
|
|
|
|
|
|
gimp_radio_button_update (widget, &info->values->fill_type);
|
|
|
|
|
|
|
|
file_new_image_size_callback (widget, data);
|
|
|
|
}
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
static void
|
|
|
|
file_new_image_size_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewImageInfo *info;
|
2002-01-27 23:07:41 +08:00
|
|
|
gchar *text;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
info = (NewImageInfo*) data;
|
|
|
|
|
|
|
|
info->values->width =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0));
|
|
|
|
info->values->height =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
|
|
|
|
|
2002-02-08 01:37:34 +08:00
|
|
|
info->size = gimp_image_new_calculate_memsize (info->values);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2002-02-08 01:37:34 +08:00
|
|
|
text = gimp_image_new_get_memsize_string (info->size);
|
2002-01-27 23:07:41 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (info->memsize_label), text);
|
2001-10-29 19:47:11 +08:00
|
|
|
g_free (text);
|
|
|
|
}
|