2006-12-10 05:33:38 +08:00
|
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-04-11 21:17:23 +08:00
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-04-11 21:17:23 +08:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-04-11 21:17:23 +08:00
|
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-04-11 21:17:23 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-04-11 21:17:23 +08:00
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
|
#include "core/gimptemplate.h"
|
|
|
|
|
|
2011-03-22 22:20:03 +08:00
|
|
|
|
#include "gimppropwidgets.h"
|
2003-04-11 21:17:23 +08:00
|
|
|
|
#include "gimptemplateeditor.h"
|
|
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
2004-05-07 23:45:56 +08:00
|
|
|
|
#define SB_WIDTH 8
|
2003-10-15 23:30:11 +08:00
|
|
|
|
#define MAX_COMMENT_LENGTH 512 /* arbitrary */
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
|
2003-10-14 23:20:59 +08:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_TEMPLATE
|
|
|
|
|
};
|
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
typedef struct _GimpTemplateEditorPrivate GimpTemplateEditorPrivate;
|
|
|
|
|
|
|
|
|
|
struct _GimpTemplateEditorPrivate
|
|
|
|
|
{
|
|
|
|
|
GimpTemplate *template;
|
|
|
|
|
|
|
|
|
|
GtkWidget *aspect_button;
|
|
|
|
|
gboolean block_aspect;
|
|
|
|
|
|
|
|
|
|
GtkWidget *expander;
|
|
|
|
|
GtkWidget *size_se;
|
|
|
|
|
GtkWidget *memsize_label;
|
|
|
|
|
GtkWidget *pixel_label;
|
|
|
|
|
GtkWidget *more_label;
|
|
|
|
|
GtkWidget *resolution_se;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define GET_PRIVATE(editor) \
|
|
|
|
|
G_TYPE_INSTANCE_GET_PRIVATE (editor, \
|
|
|
|
|
GIMP_TYPE_TEMPLATE_EDITOR, \
|
|
|
|
|
GimpTemplateEditorPrivate)
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
static void gimp_template_editor_constructed (GObject *object);
|
2005-12-20 06:37:49 +08:00
|
|
|
|
static void gimp_template_editor_finalize (GObject *object);
|
|
|
|
|
static void gimp_template_editor_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gimp_template_editor_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
2010-10-30 21:44:46 +08:00
|
|
|
|
G_DEFINE_TYPE (GimpTemplateEditor, gimp_template_editor, GTK_TYPE_BOX)
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
|
#define parent_class gimp_template_editor_parent_class
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_class_init (GimpTemplateEditorClass *klass)
|
|
|
|
|
{
|
2005-12-20 06:37:49 +08:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
object_class->constructed = gimp_template_editor_constructed;
|
2005-12-20 06:37:49 +08:00
|
|
|
|
object_class->finalize = gimp_template_editor_finalize;
|
2003-10-14 23:20:59 +08:00
|
|
|
|
object_class->set_property = gimp_template_editor_set_property;
|
|
|
|
|
object_class->get_property = gimp_template_editor_get_property;
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_TEMPLATE,
|
|
|
|
|
g_param_spec_object ("template", NULL, NULL,
|
|
|
|
|
GIMP_TYPE_TEMPLATE,
|
2006-01-19 04:29:40 +08:00
|
|
|
|
GIMP_PARAM_READWRITE |
|
2003-10-14 23:20:59 +08:00
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2011-03-01 18:50:16 +08:00
|
|
|
|
|
|
|
|
|
g_type_class_add_private (object_class, sizeof (GimpTemplateEditorPrivate));
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_init (GimpTemplateEditor *editor)
|
|
|
|
|
{
|
2010-10-30 21:44:46 +08:00
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
|
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
|
|
|
|
|
gtk_box_set_spacing (GTK_BOX (editor), 12);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_constructed (GObject *object)
|
2003-10-14 23:20:59 +08:00
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditor *editor = GIMP_TEMPLATE_EDITOR (object);
|
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (object);
|
2011-03-02 17:16:43 +08:00
|
|
|
|
GimpTemplate *template;
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GtkWidget *aspect_box;
|
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
GtkWidget *table;
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
GtkObject *adjustment;
|
|
|
|
|
GtkWidget *width;
|
|
|
|
|
GtkWidget *height;
|
|
|
|
|
GtkWidget *xres;
|
|
|
|
|
GtkWidget *yres;
|
|
|
|
|
GtkWidget *chainbutton;
|
|
|
|
|
GtkWidget *combo;
|
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
|
GtkWidget *text_view;
|
|
|
|
|
GtkTextBuffer *text_buffer;
|
|
|
|
|
GList *focus_chain = NULL;
|
|
|
|
|
gchar *text;
|
2003-10-14 23:20:59 +08:00
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
if (G_OBJECT_CLASS (parent_class)->constructed)
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
g_assert (private->template != NULL);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
template = private->template;
|
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
/* Image size frame */
|
2004-05-03 05:13:51 +08:00
|
|
|
|
frame = gimp_frame_new (_("Image Size"));
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
2004-05-07 23:45:56 +08:00
|
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
2004-05-21 22:17:27 +08:00
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
2004-10-12 22:14:16 +08:00
|
|
|
|
width = gimp_spin_button_new (&adjustment,
|
|
|
|
|
1, 1, 1, 1, 10, 0,
|
|
|
|
|
1, 2);
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (width), SB_WIDTH);
|
|
|
|
|
|
|
|
|
|
height = gimp_spin_button_new (&adjustment,
|
|
|
|
|
1, 1, 1, 1, 10, 0,
|
|
|
|
|
1, 2);
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (height), SB_WIDTH);
|
|
|
|
|
|
2004-05-07 23:45:56 +08:00
|
|
|
|
/* the image size labels */
|
2004-10-12 22:14:16 +08:00
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Width:"));
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2004-10-12 22:14:16 +08:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), width);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
2004-10-12 22:14:16 +08:00
|
|
|
|
label = gtk_label_new_with_mnemonic (_("H_eight:"));
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2004-10-12 22:14:16 +08:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), height);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
|
|
/* create the sizeentry which keeps it all together */
|
2011-09-30 17:29:11 +08:00
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
|
2003-09-24 05:51:08 +08:00
|
|
|
|
gtk_widget_show (hbox);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
private->size_se = gimp_size_entry_new (0,
|
|
|
|
|
gimp_template_get_unit (template),
|
|
|
|
|
_("%p"),
|
2011-03-01 18:50:16 +08:00
|
|
|
|
TRUE, FALSE, FALSE, SB_WIDTH,
|
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2004-10-12 08:12:31 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (private->size_se), 0, 2);
|
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (private->size_se), 1, 6);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), private->size_se, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (private->size_se);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->size_se),
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SPIN_BUTTON (height), NULL);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (private->size_se), height, 0, 1, 1, 2);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_widget_show (height);
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->size_se),
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SPIN_BUTTON (width), NULL);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (private->size_se), width, 0, 1, 0, 1);
|
2004-05-29 06:35:54 +08:00
|
|
|
|
gtk_widget_show (width);
|
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_prop_coordinates_connect (G_OBJECT (template),
|
2004-05-07 23:45:56 +08:00
|
|
|
|
"width", "height", "unit",
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->size_se, NULL,
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_template_get_resolution_x (template),
|
|
|
|
|
gimp_template_get_resolution_y (template));
|
2004-05-07 23:45:56 +08:00
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 3, 2, 3);
|
|
|
|
|
gtk_widget_show (hbox);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2004-09-25 09:47:01 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
2003-04-16 20:59:36 +08:00
|
|
|
|
aspect_box = gimp_enum_stock_box_new (GIMP_TYPE_ASPECT_TYPE,
|
|
|
|
|
"gimp", GTK_ICON_SIZE_MENU,
|
|
|
|
|
G_CALLBACK (gimp_template_editor_aspect_callback),
|
|
|
|
|
editor,
|
2011-03-01 18:50:16 +08:00
|
|
|
|
&private->aspect_button);
|
|
|
|
|
gtk_widget_hide (private->aspect_button); /* hide "square" */
|
2003-10-15 09:06:30 +08:00
|
|
|
|
|
2004-09-25 09:47:01 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), aspect_box, FALSE, FALSE, 0);
|
2003-04-16 20:59:36 +08:00
|
|
|
|
gtk_widget_show (aspect_box);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2004-09-24 22:43:32 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->pixel_label = gtk_label_new (NULL);
|
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (private->pixel_label),
|
2004-09-24 22:43:32 +08:00
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
|
-1);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (private->pixel_label), 0.0, 0.0);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), private->pixel_label, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (private->pixel_label);
|
2004-09-24 22:43:32 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->more_label = gtk_label_new (NULL);
|
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (private->more_label),
|
2004-09-25 09:47:01 +08:00
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
|
-1);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (private->more_label), 0.0, 0.0);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), private->more_label, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (private->more_label);
|
2004-09-25 09:47:01 +08:00
|
|
|
|
|
2004-10-27 05:18:20 +08:00
|
|
|
|
#ifdef ENABLE_MEMSIZE_LABEL
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->memsize_label = gtk_label_new (NULL);
|
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (private->memsize_label),
|
2004-09-24 22:43:32 +08:00
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
|
-1);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (private->memsize_label), 0.0, 0.0);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), private->memsize_label, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (private->memsize_label);
|
2004-10-27 05:18:20 +08:00
|
|
|
|
#endif
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2004-05-07 23:45:56 +08:00
|
|
|
|
text = g_strdup_printf ("<b>%s</b>", _("_Advanced Options"));
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->expander = g_object_new (GTK_TYPE_EXPANDER,
|
|
|
|
|
"label", text,
|
|
|
|
|
"use-markup", TRUE,
|
|
|
|
|
"use-underline", TRUE,
|
|
|
|
|
NULL);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
g_free (text);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), private->expander, TRUE, TRUE, 0);
|
|
|
|
|
gtk_widget_show (private->expander);
|
2003-04-16 20:59:36 +08:00
|
|
|
|
|
2004-05-07 23:45:56 +08:00
|
|
|
|
frame = gimp_frame_new ("<expander>");
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (private->expander), frame);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
|
|
table = gtk_table_new (5, 2, FALSE);
|
2004-05-21 22:17:27 +08:00
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
|
gtk_widget_show (table);
|
2003-04-16 20:59:36 +08:00
|
|
|
|
|
2004-10-12 22:14:16 +08:00
|
|
|
|
xres = gimp_spin_button_new (&adjustment,
|
|
|
|
|
1, 1, 1, 1, 10, 0,
|
|
|
|
|
1, 2);
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (xres), SB_WIDTH);
|
|
|
|
|
|
|
|
|
|
yres = gimp_spin_button_new (&adjustment,
|
|
|
|
|
1, 1, 1, 1, 10, 0,
|
|
|
|
|
1, 2);
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (yres), SB_WIDTH);
|
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
/* the resolution labels */
|
2004-10-12 22:14:16 +08:00
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_X resolution:"));
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2004-10-12 22:14:16 +08:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), xres);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
2004-10-12 22:14:16 +08:00
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Y resolution:"));
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2004-10-12 22:14:16 +08:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), yres);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
|
|
/* the resolution sizeentry */
|
2011-09-30 17:29:11 +08:00
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
|
2003-09-24 05:51:08 +08:00
|
|
|
|
gtk_widget_show (hbox);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->resolution_se =
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_size_entry_new (0,
|
|
|
|
|
gimp_template_get_resolution_unit (template),
|
|
|
|
|
_("pixels/%s"),
|
2003-04-16 20:59:36 +08:00
|
|
|
|
FALSE, FALSE, FALSE, SB_WIDTH,
|
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
2004-10-12 08:12:31 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (private->resolution_se), 0, 2);
|
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (private->resolution_se), 1, 2);
|
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (private->resolution_se), 2, 2);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), private->resolution_se, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (private->resolution_se);
|
2003-09-24 05:51:08 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->resolution_se),
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SPIN_BUTTON (yres), NULL);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), yres,
|
2004-10-12 08:12:31 +08:00
|
|
|
|
0, 1, 1, 2);
|
2003-04-16 20:59:36 +08:00
|
|
|
|
gtk_widget_show (yres);
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->resolution_se),
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_SPIN_BUTTON (xres), NULL);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), xres,
|
2006-04-12 20:49:29 +08:00
|
|
|
|
0, 1, 0, 1);
|
2003-04-16 20:59:36 +08:00
|
|
|
|
gtk_widget_show (xres);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_template_get_resolution_x (template),
|
|
|
|
|
FALSE);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_template_get_resolution_y (template),
|
|
|
|
|
FALSE);
|
2003-10-15 23:30:11 +08:00
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
/* the resolution chainbutton */
|
|
|
|
|
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), chainbutton,
|
2003-04-16 20:59:36 +08:00
|
|
|
|
1, 2, 0, 2);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gtk_widget_show (chainbutton);
|
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_prop_coordinates_connect (G_OBJECT (template),
|
2003-10-02 03:55:13 +08:00
|
|
|
|
"xresolution", "yresolution",
|
|
|
|
|
"resolution-unit",
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->resolution_se, chainbutton,
|
2003-10-02 03:55:13 +08:00
|
|
|
|
1.0, 1.0);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2004-12-10 00:22:25 +08:00
|
|
|
|
focus_chain = g_list_prepend (focus_chain,
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GIMP_SIZE_ENTRY (private->resolution_se)->unitmenu);
|
2004-12-10 00:22:25 +08:00
|
|
|
|
focus_chain = g_list_prepend (focus_chain, chainbutton);
|
|
|
|
|
focus_chain = g_list_prepend (focus_chain, yres);
|
|
|
|
|
focus_chain = g_list_prepend (focus_chain, xres);
|
2003-04-16 20:59:36 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_container_set_focus_chain (GTK_CONTAINER (private->resolution_se),
|
2003-04-16 20:59:36 +08:00
|
|
|
|
focus_chain);
|
|
|
|
|
g_list_free (focus_chain);
|
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
|
2004-05-07 23:45:56 +08:00
|
|
|
|
"image-type",
|
|
|
|
|
GIMP_RGB, GIMP_GRAY);
|
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
2005-04-05 17:12:29 +08:00
|
|
|
|
_("Color _space:"), 0.0, 0.5,
|
2004-05-07 23:45:56 +08:00
|
|
|
|
combo, 1, FALSE);
|
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
|
2004-05-07 23:45:56 +08:00
|
|
|
|
"fill-type",
|
|
|
|
|
GIMP_FOREGROUND_FILL,
|
2012-03-16 09:21:26 +08:00
|
|
|
|
GIMP_PATTERN_FILL);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
|
|
|
|
_("_Fill with:"), 0.0, 0.5,
|
|
|
|
|
combo, 1, FALSE);
|
2003-10-15 23:30:11 +08:00
|
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
2004-07-22 00:29:29 +08:00
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
|
GTK_SHADOW_IN);
|
2003-10-15 23:30:11 +08:00
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
2006-04-12 20:49:29 +08:00
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2004-05-07 23:45:56 +08:00
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
2004-09-25 09:47:01 +08:00
|
|
|
|
_("Comme_nt:"), 0.0, 0.0,
|
2004-05-07 23:45:56 +08:00
|
|
|
|
scrolled_window, 1, FALSE);
|
2003-10-15 23:30:11 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
text_buffer = gimp_prop_text_buffer_new (G_OBJECT (template),
|
2003-10-15 23:30:11 +08:00
|
|
|
|
"comment", MAX_COMMENT_LENGTH);
|
|
|
|
|
|
|
|
|
|
text_view = gtk_text_view_new_with_buffer (text_buffer);
|
|
|
|
|
g_object_unref (text_buffer);
|
|
|
|
|
|
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
|
|
|
|
gtk_widget_show (text_view);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
g_signal_connect_object (template, "notify",
|
2004-04-19 04:46:46 +08:00
|
|
|
|
G_CALLBACK (gimp_template_editor_template_notify),
|
|
|
|
|
editor, 0);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
|
2004-09-24 22:43:32 +08:00
|
|
|
|
/* call the notify callback once to get the labels set initially */
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_template_editor_template_notify (template, NULL, editor);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_finalize (GObject *object)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (object);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
if (private->template)
|
2003-04-11 21:17:23 +08:00
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
g_object_unref (private->template);
|
|
|
|
|
private->template = NULL;
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (object);
|
2005-12-20 06:37:49 +08:00
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_TEMPLATE:
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->template = g_value_dup_object (value);
|
2005-12-20 06:37:49 +08:00
|
|
|
|
break;
|
2008-07-23 15:47:10 +08:00
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (object);
|
2005-12-20 06:37:49 +08:00
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_TEMPLATE:
|
2011-03-01 18:50:16 +08:00
|
|
|
|
g_value_set_object (value, private->template);
|
2005-12-20 06:37:49 +08:00
|
|
|
|
break;
|
2008-07-23 15:47:10 +08:00
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
GtkWidget *
|
2003-10-14 23:20:59 +08:00
|
|
|
|
gimp_template_editor_new (GimpTemplate *template,
|
|
|
|
|
Gimp *gimp,
|
|
|
|
|
gboolean edit_template)
|
2003-04-11 21:17:23 +08:00
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditor *editor;
|
|
|
|
|
GimpTemplateEditorPrivate *private;
|
2003-04-13 03:06:25 +08:00
|
|
|
|
|
2003-10-14 23:20:59 +08:00
|
|
|
|
g_return_val_if_fail (!edit_template || GIMP_IS_GIMP (gimp), NULL);
|
2003-04-13 03:06:25 +08:00
|
|
|
|
|
2003-10-14 23:20:59 +08:00
|
|
|
|
editor = g_object_new (GIMP_TYPE_TEMPLATE_EDITOR,
|
|
|
|
|
"template", template,
|
|
|
|
|
NULL);
|
2003-04-13 03:06:25 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private = GET_PRIVATE (editor);
|
|
|
|
|
|
2003-04-14 00:25:14 +08:00
|
|
|
|
if (edit_template)
|
2003-04-13 03:06:25 +08:00
|
|
|
|
{
|
2003-10-15 00:29:33 +08:00
|
|
|
|
GtkWidget *table;
|
|
|
|
|
GtkWidget *entry;
|
2011-03-22 22:20:03 +08:00
|
|
|
|
GtkWidget *icon_picker;
|
2003-10-15 00:29:33 +08:00
|
|
|
|
|
2003-04-14 00:25:14 +08:00
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
2004-05-21 22:17:27 +08:00
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
2003-04-13 03:06:25 +08:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (editor), table, 0);
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
entry = gimp_prop_entry_new (G_OBJECT (private->template), "name", 128);
|
2003-04-14 00:25:14 +08:00
|
|
|
|
|
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
|
|
|
_("_Name:"), 1.0, 0.5,
|
|
|
|
|
entry, 1, FALSE);
|
|
|
|
|
|
2011-03-22 22:20:03 +08:00
|
|
|
|
icon_picker = gimp_prop_icon_picker_new (G_OBJECT (private->template),
|
|
|
|
|
"stock-id",
|
|
|
|
|
gimp);
|
2003-04-14 00:25:14 +08:00
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2003-04-13 03:06:25 +08:00
|
|
|
|
_("_Icon:"), 1.0, 0.5,
|
2011-03-22 22:20:03 +08:00
|
|
|
|
icon_picker, 1, TRUE);
|
2003-04-13 03:06:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return GTK_WIDGET (editor);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplate *
|
|
|
|
|
gimp_template_editor_get_template (GimpTemplateEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor), NULL);
|
|
|
|
|
|
|
|
|
|
return GET_PRIVATE (editor)->template;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-10 06:37:49 +08:00
|
|
|
|
void
|
|
|
|
|
gimp_template_editor_show_advanced (GimpTemplateEditor *editor,
|
|
|
|
|
gboolean expanded)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private;
|
|
|
|
|
|
2004-06-10 06:37:49 +08:00
|
|
|
|
g_return_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor));
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private = GET_PRIVATE (editor);
|
|
|
|
|
|
|
|
|
|
gtk_expander_set_expanded (GTK_EXPANDER (private->expander), expanded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gimp_template_editor_get_size_se (GimpTemplateEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor), NULL);
|
|
|
|
|
|
|
|
|
|
return GET_PRIVATE (editor)->size_se;
|
2004-06-10 06:37:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
2005-11-03 00:07:07 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_set_pixels (GimpTemplateEditor *editor,
|
|
|
|
|
GimpTemplate *template)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (editor);
|
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
|
|
text = g_strdup_printf (ngettext ("%d × %d pixel",
|
2011-03-02 17:16:43 +08:00
|
|
|
|
"%d × %d pixels",
|
|
|
|
|
gimp_template_get_height (template)),
|
|
|
|
|
gimp_template_get_width (template),
|
|
|
|
|
gimp_template_get_height (template));
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (private->pixel_label), text);
|
2005-11-03 00:07:07 +08:00
|
|
|
|
g_free (text);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_aspect_callback (GtkWidget *widget,
|
|
|
|
|
GimpTemplateEditor *editor)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (editor);
|
|
|
|
|
|
|
|
|
|
if (! private->block_aspect &&
|
2008-06-28 23:50:27 +08:00
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
2003-04-11 21:17:23 +08:00
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplate *template = private->template;
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gint width = gimp_template_get_width (template);
|
|
|
|
|
gint height = gimp_template_get_height (template);
|
|
|
|
|
gdouble xresolution = gimp_template_get_resolution_x (template);
|
|
|
|
|
gdouble yresolution = gimp_template_get_resolution_y (template);
|
2004-10-15 06:55:18 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
if (width == height)
|
2003-04-11 21:17:23 +08:00
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->block_aspect = TRUE;
|
|
|
|
|
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (private->aspect_button),
|
2003-11-15 07:17:38 +08:00
|
|
|
|
GIMP_ASPECT_SQUARE);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->block_aspect = FALSE;
|
2003-04-11 21:17:23 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-15 06:55:18 +08:00
|
|
|
|
g_signal_handlers_block_by_func (template,
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gimp_template_editor_template_notify,
|
|
|
|
|
editor);
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2003-04-11 21:17:23 +08:00
|
|
|
|
yresolution, FALSE);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2003-04-11 21:17:23 +08:00
|
|
|
|
xresolution, FALSE);
|
|
|
|
|
|
2004-10-15 06:55:18 +08:00
|
|
|
|
g_object_set (template,
|
2003-04-11 21:17:23 +08:00
|
|
|
|
"width", height,
|
|
|
|
|
"height", width,
|
|
|
|
|
"xresolution", yresolution,
|
|
|
|
|
"yresolution", xresolution,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2004-10-15 06:55:18 +08:00
|
|
|
|
g_signal_handlers_unblock_by_func (template,
|
2003-04-11 21:17:23 +08:00
|
|
|
|
gimp_template_editor_template_notify,
|
|
|
|
|
editor);
|
2004-10-15 06:55:18 +08:00
|
|
|
|
|
2005-11-03 00:07:07 +08:00
|
|
|
|
gimp_template_editor_set_pixels (editor, template);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_template_editor_template_notify (GimpTemplate *template,
|
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
|
GimpTemplateEditor *editor)
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
GimpTemplateEditorPrivate *private = GET_PRIVATE (editor);
|
|
|
|
|
GimpAspectType aspect;
|
|
|
|
|
const gchar *desc;
|
|
|
|
|
gchar *text;
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gint xres;
|
|
|
|
|
gint yres;
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
|
|
|
|
if (param_spec)
|
|
|
|
|
{
|
|
|
|
|
if (! strcmp (param_spec->name, "xresolution"))
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_template_get_resolution_x (template),
|
|
|
|
|
FALSE);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
else if (! strcmp (param_spec->name, "yresolution"))
|
|
|
|
|
{
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_template_get_resolution_y (template),
|
|
|
|
|
FALSE);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-27 05:18:20 +08:00
|
|
|
|
#ifdef ENABLE_MEMSIZE_LABEL
|
2011-09-13 17:39:24 +08:00
|
|
|
|
text = g_format_size (gimp_template_get_initial_size (template));
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (private->memsize_label), text);
|
2003-11-14 20:05:13 +08:00
|
|
|
|
g_free (text);
|
2004-10-27 05:18:20 +08:00
|
|
|
|
#endif
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
2005-11-03 00:07:07 +08:00
|
|
|
|
gimp_template_editor_set_pixels (editor, template);
|
2004-09-24 22:43:32 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
width = gimp_template_get_width (template);
|
|
|
|
|
height = gimp_template_get_height (template);
|
|
|
|
|
|
|
|
|
|
if (width > height)
|
2003-04-11 21:17:23 +08:00
|
|
|
|
aspect = GIMP_ASPECT_LANDSCAPE;
|
2011-03-02 17:16:43 +08:00
|
|
|
|
else if (height > width)
|
2003-04-11 21:17:23 +08:00
|
|
|
|
aspect = GIMP_ASPECT_PORTRAIT;
|
|
|
|
|
else
|
|
|
|
|
aspect = GIMP_ASPECT_SQUARE;
|
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->block_aspect = TRUE;
|
|
|
|
|
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (private->aspect_button),
|
2003-11-15 07:17:38 +08:00
|
|
|
|
aspect);
|
2011-03-01 18:50:16 +08:00
|
|
|
|
private->block_aspect = FALSE;
|
2003-04-13 03:06:25 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_IMAGE_BASE_TYPE,
|
|
|
|
|
gimp_template_get_image_type (template),
|
2004-10-26 01:55:25 +08:00
|
|
|
|
NULL, NULL, &desc, NULL);
|
2004-09-25 09:47:01 +08:00
|
|
|
|
|
2011-03-02 17:16:43 +08:00
|
|
|
|
xres = ROUND (gimp_template_get_resolution_x (template));
|
|
|
|
|
yres = ROUND (gimp_template_get_resolution_y (template));
|
2005-01-03 00:55:50 +08:00
|
|
|
|
|
|
|
|
|
if (xres != yres)
|
2006-04-06 00:45:27 +08:00
|
|
|
|
text = g_strdup_printf (_("%d × %d ppi, %s"), xres, yres, desc);
|
2004-09-25 09:47:01 +08:00
|
|
|
|
else
|
2006-04-06 00:45:27 +08:00
|
|
|
|
text = g_strdup_printf (_("%d ppi, %s"), yres, desc);
|
2004-09-25 09:47:01 +08:00
|
|
|
|
|
2011-03-01 18:50:16 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (private->more_label), text);
|
2004-09-25 09:47:01 +08:00
|
|
|
|
g_free (text);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
}
|