mirror of https://github.com/GNOME/gimp.git
app/widgets/Makefile.am app/widgets/widgets-types.h new widget chopped out
2003-04-11 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimptemplateeditor.[ch]: new widget chopped out of file-new-dialog.c * app/gui/file-new-dialog.c: use it.
This commit is contained in:
parent
5408dfc8ad
commit
d47eedc279
|
@ -1,3 +1,12 @@
|
|||
2003-04-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimptemplateeditor.[ch]: new widget chopped out
|
||||
of file-new-dialog.c
|
||||
|
||||
* app/gui/file-new-dialog.c: use it.
|
||||
|
||||
2003-04-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimppreviewrenderer.c (gimp_preview_renderer_create_gc):
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "widgets/gimpcontainermenuimpl.h"
|
||||
#include "widgets/gimpenummenu.h"
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
#include "widgets/gimptemplateeditor.h"
|
||||
#include "widgets/gimpviewabledialog.h"
|
||||
|
||||
#include "file-new-dialog.h"
|
||||
|
@ -46,27 +47,16 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define SB_WIDTH 10
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *confirm_dialog;
|
||||
|
||||
GtkWidget *template_menu;
|
||||
|
||||
GtkWidget *aspect_button;
|
||||
gboolean block_aspect;
|
||||
|
||||
GtkWidget *size_se;
|
||||
GtkWidget *memsize_label;
|
||||
GtkWidget *resolution_se;
|
||||
|
||||
GtkWidget *editor;
|
||||
GtkWidget *ok_button;
|
||||
|
||||
Gimp *gimp;
|
||||
GimpTemplate *template;
|
||||
gulong memsize;
|
||||
} NewImageInfo;
|
||||
|
||||
|
@ -79,8 +69,6 @@ static void file_new_cancel_callback (GtkWidget *widget,
|
|||
NewImageInfo *info);
|
||||
static void file_new_reset_callback (GtkWidget *widget,
|
||||
NewImageInfo *info);
|
||||
static void file_new_aspect_callback (GtkWidget *widget,
|
||||
NewImageInfo *info);
|
||||
static void file_new_template_notify (GimpTemplate *template,
|
||||
GParamSpec *param_spec,
|
||||
NewImageInfo *info);
|
||||
|
@ -89,6 +77,7 @@ static void file_new_template_select (GimpContainerMenu *menu,
|
|||
gpointer insert_data,
|
||||
NewImageInfo *info);
|
||||
static void file_new_confirm_dialog (NewImageInfo *info);
|
||||
static void file_new_create_image (NewImageInfo *info);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -98,19 +87,9 @@ file_new_dialog_create (Gimp *gimp,
|
|||
GimpImage *gimage)
|
||||
{
|
||||
NewImageInfo *info;
|
||||
GimpTemplate *template;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *abox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *spinbutton2;
|
||||
GtkWidget *chainbutton;
|
||||
GtkWidget *optionmenu;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
@ -118,13 +97,8 @@ file_new_dialog_create (Gimp *gimp,
|
|||
|
||||
info = g_new0 (NewImageInfo, 1);
|
||||
|
||||
info->gimp = gimp;
|
||||
info->template = gimp_image_new_get_last_template (gimp, gimage);
|
||||
info->memsize = 0;
|
||||
|
||||
g_signal_connect (info->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
info->gimp = gimp;
|
||||
info->memsize = 0;
|
||||
|
||||
info->dialog =
|
||||
gimp_viewable_dialog_new (NULL,
|
||||
|
@ -176,227 +150,21 @@ file_new_dialog_create (Gimp *gimp,
|
|||
G_CALLBACK (file_new_template_select),
|
||||
info);
|
||||
|
||||
/* Image size frame */
|
||||
frame = gtk_frame_new (_("Image Size"));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
/* Template editor */
|
||||
info->editor = gimp_template_editor_new ();
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), info->editor, FALSE, FALSE, 0);
|
||||
gtk_widget_show (info->editor);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
g_signal_connect (GIMP_TEMPLATE_EDITOR (info->editor)->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
|
||||
table = gtk_table_new (7, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 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);
|
||||
template = gimp_image_new_get_last_template (gimp, gimage);
|
||||
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (info->editor),
|
||||
template);
|
||||
g_object_unref (template);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (abox);
|
||||
|
||||
info->size_se = gimp_size_entry_new (0, info->template->unit, "%a",
|
||||
FALSE, FALSE, TRUE, SB_WIDTH,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (info->size_se), 1, 4);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (info->size_se), 1, 2);
|
||||
gtk_container_add (GTK_CONTAINER (abox), info->size_se);
|
||||
gtk_widget_show (info->size_se);
|
||||
|
||||
/* height in units */
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
/* add the "height in units" spinbutton to the sizeentry */
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
|
||||
0, 1, 2, 3);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
/* height in pixels */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
||||
spinbutton2 = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton2), SB_WIDTH);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/* add the "height in pixels" spinbutton to the main table */
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* register the height spinbuttons with the sizeentry */
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
|
||||
GTK_SPIN_BUTTON (spinbutton),
|
||||
GTK_SPIN_BUTTON (spinbutton2));
|
||||
|
||||
/* width in units */
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
/* add the "width in units" spinbutton to the sizeentry */
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
|
||||
0, 1, 1, 2);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
/* width in pixels */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 1);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
spinbutton2 = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton2), SB_WIDTH);
|
||||
/* add the "width in pixels" spinbutton to the main table */
|
||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton2);
|
||||
|
||||
hbox2 = gimp_enum_stock_box_new (GIMP_TYPE_ASPECT_TYPE,
|
||||
"gimp", GTK_ICON_SIZE_MENU,
|
||||
G_CALLBACK (file_new_aspect_callback),
|
||||
info,
|
||||
&info->aspect_button);
|
||||
gtk_widget_hide (info->aspect_button); /* hide "square" */
|
||||
gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
/* register the width spinbuttons with the sizeentry */
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
|
||||
GTK_SPIN_BUTTON (spinbutton),
|
||||
GTK_SPIN_BUTTON (spinbutton2));
|
||||
|
||||
/* initialize the sizeentry */
|
||||
gimp_prop_size_entry_connect (G_OBJECT (info->template),
|
||||
"width", "height", "unit",
|
||||
info->size_se, NULL,
|
||||
info->template->xresolution,
|
||||
info->template->yresolution);
|
||||
|
||||
/* 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 */
|
||||
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);
|
||||
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
|
||||
info->resolution_se = gimp_size_entry_new (1, info->template->resolution_unit,
|
||||
_("pixels/%a"),
|
||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||
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);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (info->resolution_se), 0, 2);
|
||||
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->resolution_se),
|
||||
GTK_SPIN_BUTTON (spinbutton), NULL);
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), spinbutton,
|
||||
1, 2, 0, 1);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (abox), info->resolution_se);
|
||||
gtk_widget_show (info->resolution_se);
|
||||
|
||||
/* the resolution chainbutton */
|
||||
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), chainbutton,
|
||||
2, 3, 0, 2);
|
||||
gtk_widget_show (chainbutton);
|
||||
|
||||
gimp_prop_size_entry_connect (G_OBJECT (info->template),
|
||||
"xresolution", "yresolution",
|
||||
"resolution-unit",
|
||||
info->resolution_se, chainbutton,
|
||||
1.0, 1.0);
|
||||
|
||||
/* hbox containing the Image type and fill type frames */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* frame for Image Type */
|
||||
frame = gimp_prop_enum_radio_frame_new (G_OBJECT (info->template),
|
||||
"image-type",
|
||||
_("Image Type"),
|
||||
GIMP_RGB, GIMP_GRAY);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* frame for Fill Type */
|
||||
frame = gimp_prop_enum_radio_frame_new (G_OBJECT (info->template),
|
||||
"fill-type",
|
||||
_("Fill Type"),
|
||||
-1, -1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (info->size_se));
|
||||
|
||||
/* update the size label */
|
||||
file_new_template_notify (info->template, NULL, info);
|
||||
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (GIMP_TEMPLATE_EDITOR (info->editor)->size_se));
|
||||
|
||||
gtk_widget_show (info->dialog);
|
||||
}
|
||||
|
@ -409,17 +177,9 @@ file_new_ok_callback (GtkWidget *widget,
|
|||
NewImageInfo *info)
|
||||
{
|
||||
if (info->memsize > GIMP_GUI_CONFIG (info->gimp->config)->max_new_image_size)
|
||||
{
|
||||
file_new_confirm_dialog (info);
|
||||
}
|
||||
file_new_confirm_dialog (info);
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (info->dialog);
|
||||
gimp_template_create_image (info->gimp, info->template);
|
||||
gimp_image_new_set_last_template (info->gimp, info->template);
|
||||
g_object_unref (info->template);
|
||||
g_free (info);
|
||||
}
|
||||
file_new_create_image (info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -427,7 +187,6 @@ file_new_cancel_callback (GtkWidget *widget,
|
|||
NewImageInfo *info)
|
||||
{
|
||||
gtk_widget_destroy (info->dialog);
|
||||
g_object_unref (info->template);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
|
@ -435,76 +194,13 @@ static void
|
|||
file_new_reset_callback (GtkWidget *widget,
|
||||
NewImageInfo *info)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
GimpTemplate *template;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
info->gimp->config->default_xresolution,
|
||||
FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
info->gimp->config->default_yresolution,
|
||||
FALSE);
|
||||
|
||||
gimp_template_set_from_config (info->template, info->gimp->config);
|
||||
|
||||
g_object_set (info->template,
|
||||
"fill-type", GIMP_BACKGROUND_FILL,
|
||||
NULL);
|
||||
gimp_container_menu_select_item (GIMP_CONTAINER_MENU (info->template_menu),
|
||||
NULL);
|
||||
|
||||
g_signal_connect (info->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
file_new_template_notify (info->template, NULL, info);
|
||||
}
|
||||
|
||||
static void
|
||||
file_new_aspect_callback (GtkWidget *widget,
|
||||
NewImageInfo *info)
|
||||
{
|
||||
if (! info->block_aspect && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
|
||||
width = info->template->width;
|
||||
height = info->template->height;
|
||||
xresolution = info->template->xresolution;
|
||||
yresolution = info->template->yresolution;
|
||||
|
||||
if (info->template->width == info->template->height)
|
||||
{
|
||||
info->block_aspect = TRUE;
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->aspect_button),
|
||||
GINT_TO_POINTER (GIMP_ASPECT_SQUARE));
|
||||
info->block_aspect = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
yresolution, FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
xresolution, FALSE);
|
||||
|
||||
g_object_set (info->template,
|
||||
"width", height,
|
||||
"height", width,
|
||||
"xresolution", yresolution,
|
||||
"yresolution", xresolution,
|
||||
NULL);
|
||||
|
||||
g_signal_handlers_unblock_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
}
|
||||
template = gimp_template_new ("foo");
|
||||
gimp_template_set_from_config (template, info->gimp->config);
|
||||
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (info->editor),
|
||||
template);
|
||||
g_object_unref (template);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -512,51 +208,13 @@ file_new_template_notify (GimpTemplate *template,
|
|||
GParamSpec *param_spec,
|
||||
NewImageInfo *info)
|
||||
{
|
||||
GimpAspectType aspect;
|
||||
|
||||
if (param_spec)
|
||||
{
|
||||
if (! strcmp (param_spec->name, "xresolution"))
|
||||
{
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
template->xresolution, FALSE);
|
||||
}
|
||||
else if (! strcmp (param_spec->name, "yresolution"))
|
||||
{
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
template->yresolution, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (info->memsize != template->initial_size)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
info->memsize = template->initial_size;
|
||||
|
||||
if (template->initial_size_too_large)
|
||||
text = g_strdup (_("Too large!"));
|
||||
else
|
||||
text = gimp_memsize_to_string (info->memsize);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (info->memsize_label), text);
|
||||
g_free (text);
|
||||
|
||||
gtk_widget_set_sensitive (info->ok_button,
|
||||
! template->initial_size_too_large);
|
||||
}
|
||||
|
||||
if (info->template->width > info->template->height)
|
||||
aspect = GIMP_ASPECT_LANDSCAPE;
|
||||
else if (info->template->height > info->template->width)
|
||||
aspect = GIMP_ASPECT_PORTRAIT;
|
||||
else
|
||||
aspect = GIMP_ASPECT_SQUARE;
|
||||
|
||||
info->block_aspect = TRUE;
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->aspect_button),
|
||||
GINT_TO_POINTER (aspect));
|
||||
info->block_aspect = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -566,24 +224,8 @@ file_new_template_select (GimpContainerMenu *menu,
|
|||
NewImageInfo *info)
|
||||
{
|
||||
if (template)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
template->xresolution, FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
template->yresolution, FALSE);
|
||||
|
||||
gimp_config_copy_properties (G_OBJECT (template),
|
||||
G_OBJECT (info->template));
|
||||
|
||||
g_signal_connect (info->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
file_new_template_notify (info->template, NULL, info);
|
||||
}
|
||||
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (info->editor),
|
||||
template);
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,17 +241,9 @@ file_new_confirm_dialog_callback (GtkWidget *widget,
|
|||
info->confirm_dialog = NULL;
|
||||
|
||||
if (create)
|
||||
{
|
||||
gtk_widget_destroy (info->dialog);
|
||||
gimp_template_create_image (info->gimp, info->template);
|
||||
gimp_image_new_set_last_template (info->gimp, info->template);
|
||||
g_object_unref (info->template);
|
||||
g_free (info);
|
||||
}
|
||||
file_new_create_image (info);
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (info->dialog, TRUE);
|
||||
}
|
||||
gtk_widget_set_sensitive (info->dialog, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -656,3 +290,20 @@ file_new_confirm_dialog (NewImageInfo *info)
|
|||
|
||||
gtk_widget_show (info->confirm_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
file_new_create_image (NewImageInfo *info)
|
||||
{
|
||||
GimpTemplate *template;
|
||||
|
||||
template =
|
||||
gimp_template_editor_get_template (GIMP_TEMPLATE_EDITOR (info->editor));
|
||||
|
||||
gtk_widget_destroy (info->dialog);
|
||||
|
||||
gimp_template_create_image (info->gimp, template);
|
||||
gimp_image_new_set_last_template (info->gimp, template);
|
||||
g_object_unref (template);
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "widgets/gimpcontainermenuimpl.h"
|
||||
#include "widgets/gimpenummenu.h"
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
#include "widgets/gimptemplateeditor.h"
|
||||
#include "widgets/gimpviewabledialog.h"
|
||||
|
||||
#include "file-new-dialog.h"
|
||||
|
@ -46,27 +47,16 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define SB_WIDTH 10
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *confirm_dialog;
|
||||
|
||||
GtkWidget *template_menu;
|
||||
|
||||
GtkWidget *aspect_button;
|
||||
gboolean block_aspect;
|
||||
|
||||
GtkWidget *size_se;
|
||||
GtkWidget *memsize_label;
|
||||
GtkWidget *resolution_se;
|
||||
|
||||
GtkWidget *editor;
|
||||
GtkWidget *ok_button;
|
||||
|
||||
Gimp *gimp;
|
||||
GimpTemplate *template;
|
||||
gulong memsize;
|
||||
} NewImageInfo;
|
||||
|
||||
|
@ -79,8 +69,6 @@ static void file_new_cancel_callback (GtkWidget *widget,
|
|||
NewImageInfo *info);
|
||||
static void file_new_reset_callback (GtkWidget *widget,
|
||||
NewImageInfo *info);
|
||||
static void file_new_aspect_callback (GtkWidget *widget,
|
||||
NewImageInfo *info);
|
||||
static void file_new_template_notify (GimpTemplate *template,
|
||||
GParamSpec *param_spec,
|
||||
NewImageInfo *info);
|
||||
|
@ -89,6 +77,7 @@ static void file_new_template_select (GimpContainerMenu *menu,
|
|||
gpointer insert_data,
|
||||
NewImageInfo *info);
|
||||
static void file_new_confirm_dialog (NewImageInfo *info);
|
||||
static void file_new_create_image (NewImageInfo *info);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -98,19 +87,9 @@ file_new_dialog_create (Gimp *gimp,
|
|||
GimpImage *gimage)
|
||||
{
|
||||
NewImageInfo *info;
|
||||
GimpTemplate *template;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *abox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *spinbutton2;
|
||||
GtkWidget *chainbutton;
|
||||
GtkWidget *optionmenu;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
@ -118,13 +97,8 @@ file_new_dialog_create (Gimp *gimp,
|
|||
|
||||
info = g_new0 (NewImageInfo, 1);
|
||||
|
||||
info->gimp = gimp;
|
||||
info->template = gimp_image_new_get_last_template (gimp, gimage);
|
||||
info->memsize = 0;
|
||||
|
||||
g_signal_connect (info->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
info->gimp = gimp;
|
||||
info->memsize = 0;
|
||||
|
||||
info->dialog =
|
||||
gimp_viewable_dialog_new (NULL,
|
||||
|
@ -176,227 +150,21 @@ file_new_dialog_create (Gimp *gimp,
|
|||
G_CALLBACK (file_new_template_select),
|
||||
info);
|
||||
|
||||
/* Image size frame */
|
||||
frame = gtk_frame_new (_("Image Size"));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
/* Template editor */
|
||||
info->editor = gimp_template_editor_new ();
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), info->editor, FALSE, FALSE, 0);
|
||||
gtk_widget_show (info->editor);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
g_signal_connect (GIMP_TEMPLATE_EDITOR (info->editor)->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
|
||||
table = gtk_table_new (7, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 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);
|
||||
template = gimp_image_new_get_last_template (gimp, gimage);
|
||||
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (info->editor),
|
||||
template);
|
||||
g_object_unref (template);
|
||||
|
||||
/* 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);
|
||||
gtk_widget_show (abox);
|
||||
|
||||
info->size_se = gimp_size_entry_new (0, info->template->unit, "%a",
|
||||
FALSE, FALSE, TRUE, SB_WIDTH,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (info->size_se), 1, 4);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (info->size_se), 1, 2);
|
||||
gtk_container_add (GTK_CONTAINER (abox), info->size_se);
|
||||
gtk_widget_show (info->size_se);
|
||||
|
||||
/* height in units */
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
/* add the "height in units" spinbutton to the sizeentry */
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
|
||||
0, 1, 2, 3);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
/* height in pixels */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
||||
spinbutton2 = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton2), SB_WIDTH);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/* add the "height in pixels" spinbutton to the main table */
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* register the height spinbuttons with the sizeentry */
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
|
||||
GTK_SPIN_BUTTON (spinbutton),
|
||||
GTK_SPIN_BUTTON (spinbutton2));
|
||||
|
||||
/* width in units */
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
/* add the "width in units" spinbutton to the sizeentry */
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
|
||||
0, 1, 1, 2);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
/* width in pixels */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 1);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
spinbutton2 = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton2), SB_WIDTH);
|
||||
/* add the "width in pixels" spinbutton to the main table */
|
||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton2);
|
||||
|
||||
hbox2 = gimp_enum_stock_box_new (GIMP_TYPE_ASPECT_TYPE,
|
||||
"gimp", GTK_ICON_SIZE_MENU,
|
||||
G_CALLBACK (file_new_aspect_callback),
|
||||
info,
|
||||
&info->aspect_button);
|
||||
gtk_widget_hide (info->aspect_button); /* hide "square" */
|
||||
gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
/* register the width spinbuttons with the sizeentry */
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
|
||||
GTK_SPIN_BUTTON (spinbutton),
|
||||
GTK_SPIN_BUTTON (spinbutton2));
|
||||
|
||||
/* initialize the sizeentry */
|
||||
gimp_prop_size_entry_connect (G_OBJECT (info->template),
|
||||
"width", "height", "unit",
|
||||
info->size_se, NULL,
|
||||
info->template->xresolution,
|
||||
info->template->yresolution);
|
||||
|
||||
/* 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 */
|
||||
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);
|
||||
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
|
||||
info->resolution_se = gimp_size_entry_new (1, info->template->resolution_unit,
|
||||
_("pixels/%a"),
|
||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||
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);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (info->resolution_se), 0, 2);
|
||||
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->resolution_se),
|
||||
GTK_SPIN_BUTTON (spinbutton), NULL);
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), spinbutton,
|
||||
1, 2, 0, 1);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (abox), info->resolution_se);
|
||||
gtk_widget_show (info->resolution_se);
|
||||
|
||||
/* the resolution chainbutton */
|
||||
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
||||
gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), chainbutton,
|
||||
2, 3, 0, 2);
|
||||
gtk_widget_show (chainbutton);
|
||||
|
||||
gimp_prop_size_entry_connect (G_OBJECT (info->template),
|
||||
"xresolution", "yresolution",
|
||||
"resolution-unit",
|
||||
info->resolution_se, chainbutton,
|
||||
1.0, 1.0);
|
||||
|
||||
/* hbox containing the Image type and fill type frames */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* frame for Image Type */
|
||||
frame = gimp_prop_enum_radio_frame_new (G_OBJECT (info->template),
|
||||
"image-type",
|
||||
_("Image Type"),
|
||||
GIMP_RGB, GIMP_GRAY);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* frame for Fill Type */
|
||||
frame = gimp_prop_enum_radio_frame_new (G_OBJECT (info->template),
|
||||
"fill-type",
|
||||
_("Fill Type"),
|
||||
-1, -1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (info->size_se));
|
||||
|
||||
/* update the size label */
|
||||
file_new_template_notify (info->template, NULL, info);
|
||||
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (GIMP_TEMPLATE_EDITOR (info->editor)->size_se));
|
||||
|
||||
gtk_widget_show (info->dialog);
|
||||
}
|
||||
|
@ -409,17 +177,9 @@ file_new_ok_callback (GtkWidget *widget,
|
|||
NewImageInfo *info)
|
||||
{
|
||||
if (info->memsize > GIMP_GUI_CONFIG (info->gimp->config)->max_new_image_size)
|
||||
{
|
||||
file_new_confirm_dialog (info);
|
||||
}
|
||||
file_new_confirm_dialog (info);
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (info->dialog);
|
||||
gimp_template_create_image (info->gimp, info->template);
|
||||
gimp_image_new_set_last_template (info->gimp, info->template);
|
||||
g_object_unref (info->template);
|
||||
g_free (info);
|
||||
}
|
||||
file_new_create_image (info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -427,7 +187,6 @@ file_new_cancel_callback (GtkWidget *widget,
|
|||
NewImageInfo *info)
|
||||
{
|
||||
gtk_widget_destroy (info->dialog);
|
||||
g_object_unref (info->template);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
|
@ -435,76 +194,13 @@ static void
|
|||
file_new_reset_callback (GtkWidget *widget,
|
||||
NewImageInfo *info)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
GimpTemplate *template;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
info->gimp->config->default_xresolution,
|
||||
FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
info->gimp->config->default_yresolution,
|
||||
FALSE);
|
||||
|
||||
gimp_template_set_from_config (info->template, info->gimp->config);
|
||||
|
||||
g_object_set (info->template,
|
||||
"fill-type", GIMP_BACKGROUND_FILL,
|
||||
NULL);
|
||||
gimp_container_menu_select_item (GIMP_CONTAINER_MENU (info->template_menu),
|
||||
NULL);
|
||||
|
||||
g_signal_connect (info->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
file_new_template_notify (info->template, NULL, info);
|
||||
}
|
||||
|
||||
static void
|
||||
file_new_aspect_callback (GtkWidget *widget,
|
||||
NewImageInfo *info)
|
||||
{
|
||||
if (! info->block_aspect && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
|
||||
width = info->template->width;
|
||||
height = info->template->height;
|
||||
xresolution = info->template->xresolution;
|
||||
yresolution = info->template->yresolution;
|
||||
|
||||
if (info->template->width == info->template->height)
|
||||
{
|
||||
info->block_aspect = TRUE;
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->aspect_button),
|
||||
GINT_TO_POINTER (GIMP_ASPECT_SQUARE));
|
||||
info->block_aspect = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
yresolution, FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
xresolution, FALSE);
|
||||
|
||||
g_object_set (info->template,
|
||||
"width", height,
|
||||
"height", width,
|
||||
"xresolution", yresolution,
|
||||
"yresolution", xresolution,
|
||||
NULL);
|
||||
|
||||
g_signal_handlers_unblock_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
}
|
||||
template = gimp_template_new ("foo");
|
||||
gimp_template_set_from_config (template, info->gimp->config);
|
||||
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (info->editor),
|
||||
template);
|
||||
g_object_unref (template);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -512,51 +208,13 @@ file_new_template_notify (GimpTemplate *template,
|
|||
GParamSpec *param_spec,
|
||||
NewImageInfo *info)
|
||||
{
|
||||
GimpAspectType aspect;
|
||||
|
||||
if (param_spec)
|
||||
{
|
||||
if (! strcmp (param_spec->name, "xresolution"))
|
||||
{
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
template->xresolution, FALSE);
|
||||
}
|
||||
else if (! strcmp (param_spec->name, "yresolution"))
|
||||
{
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
template->yresolution, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (info->memsize != template->initial_size)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
info->memsize = template->initial_size;
|
||||
|
||||
if (template->initial_size_too_large)
|
||||
text = g_strdup (_("Too large!"));
|
||||
else
|
||||
text = gimp_memsize_to_string (info->memsize);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (info->memsize_label), text);
|
||||
g_free (text);
|
||||
|
||||
gtk_widget_set_sensitive (info->ok_button,
|
||||
! template->initial_size_too_large);
|
||||
}
|
||||
|
||||
if (info->template->width > info->template->height)
|
||||
aspect = GIMP_ASPECT_LANDSCAPE;
|
||||
else if (info->template->height > info->template->width)
|
||||
aspect = GIMP_ASPECT_PORTRAIT;
|
||||
else
|
||||
aspect = GIMP_ASPECT_SQUARE;
|
||||
|
||||
info->block_aspect = TRUE;
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->aspect_button),
|
||||
GINT_TO_POINTER (aspect));
|
||||
info->block_aspect = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -566,24 +224,8 @@ file_new_template_select (GimpContainerMenu *menu,
|
|||
NewImageInfo *info)
|
||||
{
|
||||
if (template)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (info->template,
|
||||
file_new_template_notify,
|
||||
info);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
|
||||
template->xresolution, FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
|
||||
template->yresolution, FALSE);
|
||||
|
||||
gimp_config_copy_properties (G_OBJECT (template),
|
||||
G_OBJECT (info->template));
|
||||
|
||||
g_signal_connect (info->template, "notify",
|
||||
G_CALLBACK (file_new_template_notify),
|
||||
info);
|
||||
file_new_template_notify (info->template, NULL, info);
|
||||
}
|
||||
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (info->editor),
|
||||
template);
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,17 +241,9 @@ file_new_confirm_dialog_callback (GtkWidget *widget,
|
|||
info->confirm_dialog = NULL;
|
||||
|
||||
if (create)
|
||||
{
|
||||
gtk_widget_destroy (info->dialog);
|
||||
gimp_template_create_image (info->gimp, info->template);
|
||||
gimp_image_new_set_last_template (info->gimp, info->template);
|
||||
g_object_unref (info->template);
|
||||
g_free (info);
|
||||
}
|
||||
file_new_create_image (info);
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (info->dialog, TRUE);
|
||||
}
|
||||
gtk_widget_set_sensitive (info->dialog, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -656,3 +290,20 @@ file_new_confirm_dialog (NewImageInfo *info)
|
|||
|
||||
gtk_widget_show (info->confirm_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
file_new_create_image (NewImageInfo *info)
|
||||
{
|
||||
GimpTemplate *template;
|
||||
|
||||
template =
|
||||
gimp_template_editor_get_template (GIMP_TEMPLATE_EDITOR (info->editor));
|
||||
|
||||
gtk_widget_destroy (info->dialog);
|
||||
|
||||
gimp_template_create_image (info->gimp, template);
|
||||
gimp_image_new_set_last_template (info->gimp, template);
|
||||
g_object_unref (template);
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,8 @@ libappwidgets_a_sources = \
|
|||
gimppropwidgets.h \
|
||||
gimpselectioneditor.c \
|
||||
gimpselectioneditor.h \
|
||||
gimptemplateeditor.c \
|
||||
gimptemplateeditor.h \
|
||||
gimptemplateview.c \
|
||||
gimptemplateview.h \
|
||||
gimptexteditor.c \
|
||||
|
|
|
@ -0,0 +1,492 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpconfig-utils.h"
|
||||
#include "config/gimpconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimptemplate.h"
|
||||
|
||||
#include "gimptemplateeditor.h"
|
||||
#include "widgets/gimpenummenu.h"
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define SB_WIDTH 10
|
||||
|
||||
|
||||
static void gimp_template_editor_class_init (GimpTemplateEditorClass *klass);
|
||||
static void gimp_template_editor_init (GimpTemplateEditor *editor);
|
||||
|
||||
static void gimp_template_editor_finalize (GObject *object);
|
||||
|
||||
static void gimp_template_editor_aspect_callback (GtkWidget *widget,
|
||||
GimpTemplateEditor *editor);
|
||||
static void gimp_template_editor_template_notify (GimpTemplate *template,
|
||||
GParamSpec *param_spec,
|
||||
GimpTemplateEditor *editor);
|
||||
|
||||
|
||||
static GimpEditorClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_template_editor_get_type (void)
|
||||
{
|
||||
static GType view_type = 0;
|
||||
|
||||
if (! view_type)
|
||||
{
|
||||
static const GTypeInfo view_info =
|
||||
{
|
||||
sizeof (GimpTemplateEditorClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_template_editor_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpTemplateEditor),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_template_editor_init,
|
||||
};
|
||||
|
||||
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
|
||||
"GimpTemplateEditor",
|
||||
&view_info, 0);
|
||||
}
|
||||
|
||||
return view_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_template_editor_class_init (GimpTemplateEditorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_template_editor_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_template_editor_init (GimpTemplateEditor *editor)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *abox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *label;
|
||||
GtkObject *adjustment;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *spinbutton2;
|
||||
GtkWidget *chainbutton;
|
||||
|
||||
editor->template = gimp_template_new ("GimpTemplateEditor");
|
||||
editor->memsize = 0;
|
||||
|
||||
/* Image size frame */
|
||||
frame = gtk_frame_new (_("Image Size"));
|
||||
gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
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_spacings (GTK_TABLE (table), 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);
|
||||
gtk_widget_show (abox);
|
||||
|
||||
editor->size_se = gimp_size_entry_new (0, editor->template->unit, "%a",
|
||||
FALSE, FALSE, TRUE, SB_WIDTH,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (editor->size_se), 1, 4);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (editor->size_se), 1, 2);
|
||||
gtk_container_add (GTK_CONTAINER (abox), editor->size_se);
|
||||
gtk_widget_show (editor->size_se);
|
||||
|
||||
/* height in units */
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
/* add the "height in units" spinbutton to the sizeentry */
|
||||
gtk_table_attach_defaults (GTK_TABLE (editor->size_se), spinbutton,
|
||||
0, 1, 2, 3);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
/* height in pixels */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
||||
spinbutton2 = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton2), SB_WIDTH);
|
||||
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);
|
||||
|
||||
editor->memsize_label = gtk_label_new (NULL);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), editor->memsize_label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (editor->memsize_label);
|
||||
|
||||
/* add the "height in pixels" spinbutton to the main table */
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* register the height spinbuttons with the sizeentry */
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (editor->size_se),
|
||||
GTK_SPIN_BUTTON (spinbutton),
|
||||
GTK_SPIN_BUTTON (spinbutton2));
|
||||
|
||||
/* width in units */
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
/* add the "width in units" spinbutton to the sizeentry */
|
||||
gtk_table_attach_defaults (GTK_TABLE (editor->size_se), spinbutton,
|
||||
0, 1, 1, 2);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
/* width in pixels */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 1);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
spinbutton2 = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton2), SB_WIDTH);
|
||||
/* add the "width in pixels" spinbutton to the main table */
|
||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton2);
|
||||
|
||||
hbox2 = gimp_enum_stock_box_new (GIMP_TYPE_ASPECT_TYPE,
|
||||
"gimp", GTK_ICON_SIZE_MENU,
|
||||
G_CALLBACK (gimp_template_editor_aspect_callback),
|
||||
editor,
|
||||
&editor->aspect_button);
|
||||
gtk_widget_hide (editor->aspect_button); /* hide "square" */
|
||||
gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
/* register the width spinbuttons with the sizeentry */
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (editor->size_se),
|
||||
GTK_SPIN_BUTTON (spinbutton),
|
||||
GTK_SPIN_BUTTON (spinbutton2));
|
||||
|
||||
/* initialize the sizeentry */
|
||||
gimp_prop_size_entry_connect (G_OBJECT (editor->template),
|
||||
"width", "height", "unit",
|
||||
editor->size_se, NULL,
|
||||
editor->template->xresolution,
|
||||
editor->template->yresolution);
|
||||
|
||||
/* 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 */
|
||||
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);
|
||||
|
||||
spinbutton = gimp_spin_button_new (&adjustment,
|
||||
1, 1, 1, 1, 10, 0,
|
||||
1, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||
|
||||
editor->resolution_se = gimp_size_entry_new (1, editor->template->resolution_unit,
|
||||
_("pixels/%a"),
|
||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (editor->resolution_se), 1, 2);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (editor->resolution_se), 2, 2);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (editor->resolution_se), 0, 2);
|
||||
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (editor->resolution_se),
|
||||
GTK_SPIN_BUTTON (spinbutton), NULL);
|
||||
gtk_table_attach_defaults (GTK_TABLE (editor->resolution_se), spinbutton,
|
||||
1, 2, 0, 1);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (abox), editor->resolution_se);
|
||||
gtk_widget_show (editor->resolution_se);
|
||||
|
||||
/* the resolution chainbutton */
|
||||
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
||||
gtk_table_attach_defaults (GTK_TABLE (editor->resolution_se), chainbutton,
|
||||
2, 3, 0, 2);
|
||||
gtk_widget_show (chainbutton);
|
||||
|
||||
gimp_prop_size_entry_connect (G_OBJECT (editor->template),
|
||||
"xresolution", "yresolution",
|
||||
"resolution-unit",
|
||||
editor->resolution_se, chainbutton,
|
||||
1.0, 1.0);
|
||||
|
||||
/* hbox containing the Image type and fill type frames */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* frame for Image Type */
|
||||
frame = gimp_prop_enum_radio_frame_new (G_OBJECT (editor->template),
|
||||
"image-type",
|
||||
_("Image Type"),
|
||||
GIMP_RGB, GIMP_GRAY);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* frame for Fill Type */
|
||||
frame = gimp_prop_enum_radio_frame_new (G_OBJECT (editor->template),
|
||||
"fill-type",
|
||||
_("Fill Type"),
|
||||
-1, -1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_template_editor_finalize (GObject *object)
|
||||
{
|
||||
GimpTemplateEditor *editor;
|
||||
|
||||
editor = GIMP_TEMPLATE_EDITOR (object);
|
||||
|
||||
if (editor->template)
|
||||
{
|
||||
g_object_unref (editor->template);
|
||||
editor->template = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_template_editor_new (void)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_TEMPLATE_EDITOR, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_template_editor_set_template (GimpTemplateEditor *editor,
|
||||
GimpTemplate *template)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor));
|
||||
g_return_if_fail (GIMP_IS_TEMPLATE (template));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (editor->template,
|
||||
gimp_template_editor_template_notify,
|
||||
editor);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 0,
|
||||
template->xresolution, FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 1,
|
||||
template->yresolution, FALSE);
|
||||
|
||||
gimp_config_copy_properties (G_OBJECT (template),
|
||||
G_OBJECT (editor->template));
|
||||
|
||||
g_signal_connect (editor->template, "notify",
|
||||
G_CALLBACK (gimp_template_editor_template_notify),
|
||||
editor);
|
||||
gimp_template_editor_template_notify (editor->template, NULL, editor);
|
||||
}
|
||||
|
||||
GimpTemplate *
|
||||
gimp_template_editor_get_template (GimpTemplateEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor), NULL);
|
||||
|
||||
return GIMP_TEMPLATE (gimp_config_duplicate (G_OBJECT (editor->template)));
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_template_editor_aspect_callback (GtkWidget *widget,
|
||||
GimpTemplateEditor *editor)
|
||||
{
|
||||
if (! editor->block_aspect && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
|
||||
width = editor->template->width;
|
||||
height = editor->template->height;
|
||||
xresolution = editor->template->xresolution;
|
||||
yresolution = editor->template->yresolution;
|
||||
|
||||
if (editor->template->width == editor->template->height)
|
||||
{
|
||||
editor->block_aspect = TRUE;
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (editor->aspect_button),
|
||||
GINT_TO_POINTER (GIMP_ASPECT_SQUARE));
|
||||
editor->block_aspect = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (editor->template,
|
||||
gimp_template_editor_template_notify,
|
||||
editor);
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 0,
|
||||
yresolution, FALSE);
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 1,
|
||||
xresolution, FALSE);
|
||||
|
||||
g_object_set (editor->template,
|
||||
"width", height,
|
||||
"height", width,
|
||||
"xresolution", yresolution,
|
||||
"yresolution", xresolution,
|
||||
NULL);
|
||||
|
||||
g_signal_handlers_unblock_by_func (editor->template,
|
||||
gimp_template_editor_template_notify,
|
||||
editor);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_template_editor_template_notify (GimpTemplate *template,
|
||||
GParamSpec *param_spec,
|
||||
GimpTemplateEditor *editor)
|
||||
{
|
||||
GimpAspectType aspect;
|
||||
|
||||
if (param_spec)
|
||||
{
|
||||
if (! strcmp (param_spec->name, "xresolution"))
|
||||
{
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 0,
|
||||
template->xresolution, FALSE);
|
||||
}
|
||||
else if (! strcmp (param_spec->name, "yresolution"))
|
||||
{
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 1,
|
||||
template->yresolution, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (editor->memsize != template->initial_size)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
editor->memsize = template->initial_size;
|
||||
|
||||
if (template->initial_size_too_large)
|
||||
text = g_strdup (_("Too large!"));
|
||||
else
|
||||
text = gimp_memsize_to_string (editor->memsize);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (editor->memsize_label), text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
if (editor->template->width > editor->template->height)
|
||||
aspect = GIMP_ASPECT_LANDSCAPE;
|
||||
else if (editor->template->height > editor->template->width)
|
||||
aspect = GIMP_ASPECT_PORTRAIT;
|
||||
else
|
||||
aspect = GIMP_ASPECT_SQUARE;
|
||||
|
||||
editor->block_aspect = TRUE;
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (editor->aspect_button),
|
||||
GINT_TO_POINTER (aspect));
|
||||
editor->block_aspect = FALSE;
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimptemplateeditor.h
|
||||
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TEMPLATE_EDITOR_H__
|
||||
#define __GIMP_TEMPLATE_EDITOR_H__
|
||||
|
||||
|
||||
#include "gimpeditor.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_TEMPLATE_EDITOR (gimp_template_editor_get_type ())
|
||||
#define GIMP_TEMPLATE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TEMPLATE_EDITOR, GimpTemplateEditor))
|
||||
#define GIMP_TEMPLATE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TEMPLATE_EDITOR, GimpTemplateEditorClass))
|
||||
#define GIMP_IS_TEMPLATE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TEMPLATE_EDITOR))
|
||||
#define GIMP_IS_TEMPLATE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TEMPLATE_EDITOR))
|
||||
#define GIMP_TEMPLATE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TEMPLATE_EDITOR, GimpTemplateEditorClass))
|
||||
|
||||
|
||||
typedef struct _GimpTemplateEditorClass GimpTemplateEditorClass;
|
||||
|
||||
struct _GimpTemplateEditor
|
||||
{
|
||||
GimpEditor parent_instance;
|
||||
|
||||
GimpTemplate *template;
|
||||
gulong memsize;
|
||||
|
||||
GtkWidget *aspect_button;
|
||||
gboolean block_aspect;
|
||||
|
||||
GtkWidget *size_se;
|
||||
GtkWidget *memsize_label;
|
||||
GtkWidget *resolution_se;
|
||||
};
|
||||
|
||||
struct _GimpTemplateEditorClass
|
||||
{
|
||||
GimpEditorClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_template_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_template_editor_new (void);
|
||||
|
||||
void gimp_template_editor_set_template (GimpTemplateEditor *editor,
|
||||
GimpTemplate *template);
|
||||
GimpTemplate * gimp_template_editor_get_template (GimpTemplateEditor *editor);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEMPLATE_EDITOR_H__ */
|
|
@ -69,6 +69,7 @@ typedef struct _GimpBrushEditor GimpBrushEditor;
|
|||
typedef struct _GimpGradientEditor GimpGradientEditor;
|
||||
typedef struct _GimpPaletteEditor GimpPaletteEditor;
|
||||
typedef struct _GimpSelectionEditor GimpSelectionEditor;
|
||||
typedef struct _GimpTemplateEditor GimpTemplateEditor;
|
||||
typedef struct _GimpUndoEditor GimpUndoEditor;
|
||||
|
||||
typedef struct _GimpContainerView GimpContainerView;
|
||||
|
|
Loading…
Reference in New Issue