[gimp] app: move all GimpTemplate members to private



commit 5b09e61c46dce0506c628a5b23b2fa726b89b5b0
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 2 10:16:43 2011 +0100

    app: move all GimpTemplate members to private

 app/core/gimp.c                      |    4 +-
 app/core/gimpimage-new.c             |   29 +++--
 app/core/gimpimage.c                 |    9 +-
 app/core/gimptemplate.c              |  196 ++++++++++++++++++++++++++--------
 app/core/gimptemplate.h              |   41 ++++----
 app/dialogs/image-new-dialog.c       |   14 ++-
 app/dialogs/preferences-dialog.c     |    4 +-
 app/pdb/gimprc-cmds.c                |    2 +-
 app/widgets/gimpimagecommenteditor.c |   13 ++-
 app/widgets/gimptemplateeditor.c     |   75 ++++++++-----
 app/xcf/xcf-load.c                   |    6 +-
 tools/pdbgen/pdb/gimprc.pdb          |    2 +-
 12 files changed, 273 insertions(+), 122 deletions(-)
---
diff --git a/app/core/gimp.c b/app/core/gimp.c
index b2daaf6..434d1a7 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -1117,7 +1117,9 @@ gimp_create_image (Gimp              *gimp,
 
   if (attach_comment)
     {
-      const gchar *comment = gimp->config->default_image->comment;
+      const gchar *comment;
+
+      comment = gimp_template_get_comment (gimp->config->default_image);
 
       if (comment)
         {
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index a1addfd..2a83816 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -88,45 +88,50 @@ gimp_image_new_from_template (Gimp         *gimp,
   GimpLayer     *layer;
   GimpImageType  type;
   gint           width, height;
+  const gchar   *comment;
 
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
   g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
   image = gimp_create_image (gimp,
-                             template->width, template->height,
-                             template->image_type,
+                             gimp_template_get_width (template),
+                             gimp_template_get_height (template),
+                             gimp_template_get_image_type (template),
                              FALSE);
 
   gimp_image_undo_disable (image);
 
-  if (template->comment)
+  comment = gimp_template_get_comment (template);
+
+  if (comment)
     {
       GimpParasite *parasite;
 
       parasite = gimp_parasite_new ("gimp-comment",
                                     GIMP_PARASITE_PERSISTENT,
-                                    strlen (template->comment) + 1,
-                                    template->comment);
+                                    strlen (comment) + 1,
+                                    comment);
       gimp_image_parasite_attach (image, parasite);
       gimp_parasite_free (parasite);
     }
 
   gimp_image_set_resolution (image,
-                             template->xresolution, template->yresolution);
-  gimp_image_set_unit (image, template->resolution_unit);
+                             gimp_template_get_resolution_x (template),
+                             gimp_template_get_resolution_y (template));
+  gimp_image_set_unit (image, gimp_template_get_resolution_unit (template));
 
   width  = gimp_image_get_width (image);
   height = gimp_image_get_height (image);
 
-  switch (template->fill_type)
+  switch (gimp_template_get_fill_type (template))
     {
     case GIMP_TRANSPARENT_FILL:
-      type = ((template->image_type == GIMP_RGB) ?
+      type = ((gimp_template_get_image_type (template) == GIMP_RGB) ?
               GIMP_RGBA_IMAGE : GIMP_GRAYA_IMAGE);
       break;
     default:
-      type = ((template->image_type == GIMP_RGB) ?
+      type = ((gimp_template_get_image_type (template) == GIMP_RGB) ?
               GIMP_RGB_IMAGE : GIMP_GRAY_IMAGE);
       break;
     }
@@ -136,14 +141,14 @@ gimp_image_new_from_template (Gimp         *gimp,
                           GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
 
   gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
-                              context, template->fill_type);
+                              context, gimp_template_get_fill_type (template));
 
   gimp_image_add_layer (image, layer, NULL, 0, FALSE);
 
   gimp_image_undo_enable (image);
   gimp_image_clean_all (image);
 
-  gimp_create_display (gimp, image, template->unit, 1.0);
+  gimp_create_display (gimp, image, gimp_template_get_unit (template), 1.0);
 
   g_object_unref (image);
 
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 27f6595..c0b8d52 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -739,6 +739,7 @@ gimp_image_constructed (GObject *object)
   GimpImage        *image   = GIMP_IMAGE (object);
   GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
   GimpCoreConfig   *config;
+  GimpTemplate     *template;
 
   if (G_OBJECT_CLASS (parent_class)->constructed)
     G_OBJECT_CLASS (parent_class)->constructed (object);
@@ -761,9 +762,11 @@ gimp_image_constructed (GObject *object)
                        GINT_TO_POINTER (private->ID),
                        image);
 
-  private->xresolution     = config->default_image->xresolution;
-  private->yresolution     = config->default_image->yresolution;
-  private->resolution_unit = config->default_image->resolution_unit;
+  template = config->default_image;
+
+  private->xresolution     = gimp_template_get_resolution_x (template);
+  private->yresolution     = gimp_template_get_resolution_y (template);
+  private->resolution_unit = gimp_template_get_resolution_unit (template);
 
   private->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid));
 
diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index be869c5..69208c3 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -56,6 +56,32 @@ enum
 };
 
 
+typedef struct _GimpTemplatePrivate GimpTemplatePrivate;
+
+struct _GimpTemplatePrivate
+{
+  gint               width;
+  gint               height;
+  GimpUnit           unit;
+
+  gdouble            xresolution;
+  gdouble            yresolution;
+  GimpUnit           resolution_unit;
+
+  GimpImageBaseType  image_type;
+  GimpFillType       fill_type;
+
+  gchar             *comment;
+  gchar             *filename;
+
+  guint64            initial_size;
+};
+
+#define GET_PRIVATE(template) G_TYPE_INSTANCE_GET_PRIVATE (template, \
+                                                           GIMP_TYPE_TEMPLATE, \
+                                                           GimpTemplatePrivate)
+
+
 static void      gimp_template_finalize     (GObject      *object);
 static void      gimp_template_set_property (GObject      *object,
                                              guint         property_id,
@@ -145,6 +171,8 @@ gimp_template_class_init (GimpTemplateClass *klass)
                                    NULL,
                                    NULL,
                                    GIMP_PARAM_STATIC_STRINGS);
+
+  g_type_class_add_private (klass, sizeof (GimpTemplatePrivate));
 }
 
 static void
@@ -155,18 +183,18 @@ gimp_template_init (GimpTemplate *template)
 static void
 gimp_template_finalize (GObject *object)
 {
-  GimpTemplate *template = GIMP_TEMPLATE (object);
+  GimpTemplatePrivate *private = GET_PRIVATE (object);
 
-  if (template->comment)
+  if (private->comment)
     {
-      g_free (template->comment);
-      template->comment = NULL;
+      g_free (private->comment);
+      private->comment = NULL;
     }
 
-  if (template->filename)
+  if (private->filename)
     {
-      g_free (template->filename);
-      template->filename = NULL;
+      g_free (private->filename);
+      private->filename = NULL;
     }
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -178,43 +206,43 @@ gimp_template_set_property (GObject      *object,
                             const GValue *value,
                             GParamSpec   *pspec)
 {
-  GimpTemplate *template = GIMP_TEMPLATE (object);
+  GimpTemplatePrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_WIDTH:
-      template->width = g_value_get_int (value);
+      private->width = g_value_get_int (value);
       break;
     case PROP_HEIGHT:
-      template->height = g_value_get_int (value);
+      private->height = g_value_get_int (value);
       break;
     case PROP_UNIT:
-      template->unit = g_value_get_int (value);
+      private->unit = g_value_get_int (value);
       break;
     case PROP_XRESOLUTION:
-      template->xresolution = g_value_get_double (value);
+      private->xresolution = g_value_get_double (value);
       break;
     case PROP_YRESOLUTION:
-      template->yresolution = g_value_get_double (value);
+      private->yresolution = g_value_get_double (value);
       break;
     case PROP_RESOLUTION_UNIT:
-      template->resolution_unit = g_value_get_int (value);
+      private->resolution_unit = g_value_get_int (value);
       break;
     case PROP_IMAGE_TYPE:
-      template->image_type = g_value_get_enum (value);
+      private->image_type = g_value_get_enum (value);
       break;
     case PROP_FILL_TYPE:
-      template->fill_type = g_value_get_enum (value);
+      private->fill_type = g_value_get_enum (value);
       break;
     case PROP_COMMENT:
-      if (template->comment)
-        g_free (template->comment);
-      template->comment = g_value_dup_string (value);
+      if (private->comment)
+        g_free (private->comment);
+      private->comment = g_value_dup_string (value);
       break;
     case PROP_FILENAME:
-      if (template->filename)
-        g_free (template->filename);
-      template->filename = g_value_dup_string (value);
+      if (private->filename)
+        g_free (private->filename);
+      private->filename = g_value_dup_string (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -228,39 +256,39 @@ gimp_template_get_property (GObject    *object,
                             GValue     *value,
                             GParamSpec *pspec)
 {
-  GimpTemplate *template = GIMP_TEMPLATE (object);
+  GimpTemplatePrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_WIDTH:
-      g_value_set_int (value, template->width);
+      g_value_set_int (value, private->width);
       break;
     case PROP_HEIGHT:
-      g_value_set_int (value, template->height);
+      g_value_set_int (value, private->height);
       break;
     case PROP_UNIT:
-      g_value_set_int (value, template->unit);
+      g_value_set_int (value, private->unit);
       break;
     case PROP_XRESOLUTION:
-      g_value_set_double (value, template->xresolution);
+      g_value_set_double (value, private->xresolution);
       break;
     case PROP_YRESOLUTION:
-      g_value_set_double (value, template->yresolution);
+      g_value_set_double (value, private->yresolution);
       break;
     case PROP_RESOLUTION_UNIT:
-      g_value_set_int (value, template->resolution_unit);
+      g_value_set_int (value, private->resolution_unit);
       break;
     case PROP_IMAGE_TYPE:
-      g_value_set_enum (value, template->image_type);
+      g_value_set_enum (value, private->image_type);
       break;
     case PROP_FILL_TYPE:
-      g_value_set_enum (value, template->fill_type);
+      g_value_set_enum (value, private->fill_type);
       break;
     case PROP_COMMENT:
-      g_value_set_string (value, template->comment);
+      g_value_set_string (value, private->comment);
       break;
     case PROP_FILENAME:
-      g_value_set_string (value, template->filename);
+      g_value_set_string (value, private->filename);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -272,23 +300,23 @@ static void
 gimp_template_notify (GObject    *object,
                       GParamSpec *pspec)
 {
-  GimpTemplate *template = GIMP_TEMPLATE (object);
-  gint          channels;
+  GimpTemplatePrivate *private = GET_PRIVATE (object);
+  gint                 channels;
 
   if (G_OBJECT_CLASS (parent_class)->notify)
     G_OBJECT_CLASS (parent_class)->notify (object, pspec);
 
-  channels = ((template->image_type == GIMP_RGB ? 3 : 1)     /* color      */ +
-              (template->fill_type == GIMP_TRANSPARENT_FILL) /* alpha      */ +
-              1                                              /* selection  */);
+  channels = ((private->image_type == GIMP_RGB ? 3 : 1)     /* color      */ +
+              (private->fill_type == GIMP_TRANSPARENT_FILL) /* alpha      */ +
+              1                                             /* selection  */);
 
-  template->initial_size = ((guint64) channels        *
-                            (guint64) template->width *
-                            (guint64) template->height);
+  private->initial_size = ((guint64) channels        *
+                           (guint64) private->width *
+                           (guint64) private->height);
 
-  template->initial_size +=
-    gimp_projection_estimate_memsize (template->image_type,
-                                      template->width, template->height);
+  private->initial_size +=
+    gimp_projection_estimate_memsize (private->image_type,
+                                      private->width, private->height);
 
   if (! strcmp (pspec->name, "stock-id"))
     gimp_viewable_invalidate_preview (GIMP_VIEWABLE (object));
@@ -345,3 +373,83 @@ gimp_template_set_from_image (GimpTemplate *template,
   if (comment)
     g_free (comment);
 }
+
+gint
+gimp_template_get_width (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), 0);
+
+  return GET_PRIVATE (template)->width;
+}
+
+gint
+gimp_template_get_height (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), 0);
+
+  return GET_PRIVATE (template)->height;
+}
+
+GimpUnit
+gimp_template_get_unit (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_UNIT_INCH);
+
+  return GET_PRIVATE (template)->unit;
+}
+
+gdouble
+gimp_template_get_resolution_x (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), 1.0);
+
+  return GET_PRIVATE (template)->xresolution;
+}
+
+gdouble
+gimp_template_get_resolution_y (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), 1.0);
+
+  return GET_PRIVATE (template)->yresolution;
+}
+
+GimpUnit
+gimp_template_get_resolution_unit (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_UNIT_INCH);
+
+  return GET_PRIVATE (template)->resolution_unit;
+}
+
+GimpImageBaseType
+gimp_template_get_image_type (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_RGB_IMAGE);
+
+  return GET_PRIVATE (template)->image_type;
+}
+
+GimpFillType
+gimp_template_get_fill_type (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_NO_FILL);
+
+  return GET_PRIVATE (template)->fill_type;
+}
+
+const gchar *
+gimp_template_get_comment (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
+
+  return GET_PRIVATE (template)->comment;
+}
+
+guint64
+gimp_template_get_initial_size (GimpTemplate *template)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE (template), 0);
+
+  return GET_PRIVATE (template)->initial_size;
+}
diff --git a/app/core/gimptemplate.h b/app/core/gimptemplate.h
index 1a68c38..a3f3d14 100644
--- a/app/core/gimptemplate.h
+++ b/app/core/gimptemplate.h
@@ -53,23 +53,7 @@ typedef struct _GimpTemplateClass GimpTemplateClass;
 
 struct _GimpTemplate
 {
-  GimpViewable       parent_instance;
-
-  gint               width;
-  gint               height;
-  GimpUnit           unit;
-
-  gdouble            xresolution;
-  gdouble            yresolution;
-  GimpUnit           resolution_unit;
-
-  GimpImageBaseType  image_type;
-  GimpFillType       fill_type;
-
-  gchar             *comment;
-  gchar             *filename;
-
-  guint64            initial_size;
+  GimpViewable  parent_instance;
 };
 
 struct _GimpTemplateClass
@@ -78,12 +62,27 @@ struct _GimpTemplateClass
 };
 
 
-GType          gimp_template_get_type       (void) G_GNUC_CONST;
+GType               gimp_template_get_type            (void) G_GNUC_CONST;
+
+GimpTemplate      * gimp_template_new                 (const gchar  *name);
+
+void                gimp_template_set_from_image      (GimpTemplate *template,
+                                                       GimpImage    *image);
+
+gint                gimp_template_get_width           (GimpTemplate *template);
+gint                gimp_template_get_height          (GimpTemplate *template);
+GimpUnit            gimp_template_get_unit            (GimpTemplate *template);
+
+gdouble             gimp_template_get_resolution_x    (GimpTemplate *template);
+gdouble             gimp_template_get_resolution_y    (GimpTemplate *template);
+GimpUnit            gimp_template_get_resolution_unit (GimpTemplate *template);
+
+GimpImageBaseType   gimp_template_get_image_type      (GimpTemplate *template);
+GimpFillType        gimp_template_get_fill_type       (GimpTemplate *template);
 
-GimpTemplate * gimp_template_new            (const gchar  *name);
+const gchar       * gimp_template_get_comment         (GimpTemplate *template);
 
-void           gimp_template_set_from_image (GimpTemplate *template,
-                                             GimpImage    *image);
+guint64             gimp_template_get_initial_size    (GimpTemplate *template);
 
 
 #endif /* __GIMP_TEMPLATE__ */
diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c
index 78488ca..6a0816d 100644
--- a/app/dialogs/image-new-dialog.c
+++ b/app/dialogs/image-new-dialog.c
@@ -223,7 +223,7 @@ image_new_dialog_response (GtkWidget      *widget,
       break;
 
     case GTK_RESPONSE_OK:
-      if (dialog->template->initial_size >
+      if (gimp_template_get_initial_size (dialog->template) >
           GIMP_GUI_CONFIG (dialog->context->gimp->config)->max_new_image_size)
         image_new_confirm_dialog (dialog);
       else
@@ -241,13 +241,17 @@ image_new_template_changed (GimpContext    *context,
                             GimpTemplate   *template,
                             ImageNewDialog *dialog)
 {
-  gchar *comment = NULL;
+  gchar *comment;
 
   if (!template)
     return;
 
-  if (!template->comment || !strlen (template->comment))
-    comment = g_strdup (dialog->template->comment);
+  comment = (gchar *) gimp_template_get_comment (template);
+
+  if (! comment || ! strlen (comment))
+    comment = g_strdup (gimp_template_get_comment (dialog->template));
+  else
+    comment = NULL;
 
   /*  make sure the resolution values are copied first (see bug #546924)  */
   gimp_config_sync (G_OBJECT (template), G_OBJECT (dialog->template),
@@ -316,7 +320,7 @@ image_new_confirm_dialog (ImageNewDialog *data)
                     G_CALLBACK (image_new_confirm_response),
                     data);
 
-  size = g_format_size_for_display (data->template->initial_size);
+  size = g_format_size_for_display (gimp_template_get_initial_size (data->template));
   gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                      _("You are trying to create an image "
                                        "with a size of %s."), size);
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 921f36e..57ab66d 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2039,8 +2039,8 @@ prefs_dialog_new (Gimp       *gimp,
   /*  Grid  */
   editor = gimp_grid_editor_new (core_config->default_grid,
                                  gimp_get_user_context (gimp),
-                                 core_config->default_image->xresolution,
-                                 core_config->default_image->yresolution);
+                                 gimp_template_get_resolution_x (core_config->default_image),
+                                 gimp_template_get_resolution_y (core_config->default_image));
   gtk_box_pack_start (GTK_BOX (vbox), editor, TRUE, TRUE, 0);
   gtk_widget_show (editor);
 
diff --git a/app/pdb/gimprc-cmds.c b/app/pdb/gimprc-cmds.c
index acb6800..0866989 100644
--- a/app/pdb/gimprc-cmds.c
+++ b/app/pdb/gimprc-cmds.c
@@ -119,7 +119,7 @@ get_default_comment_invoker (GimpProcedure      *procedure,
   GValueArray *return_vals;
   gchar *comment = NULL;
 
-  comment = g_strdup (gimp->config->default_image->comment);
+  comment = g_strdup (gimp_template_get_comment (gimp->config->default_image));
 
   return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
   g_value_take_string (&return_vals->values[1], comment);
diff --git a/app/widgets/gimpimagecommenteditor.c b/app/widgets/gimpimagecommenteditor.c
index 636e4ce..5388bc0 100644
--- a/app/widgets/gimpimagecommenteditor.c
+++ b/app/widgets/gimpimagecommenteditor.c
@@ -229,8 +229,17 @@ static void
 gimp_image_comment_editor_use_default_comment (GtkWidget              *button,
                                                GimpImageCommentEditor *editor)
 {
-  GimpImage   *image   = gimp_image_parasite_view_get_image (GIMP_IMAGE_PARASITE_VIEW (editor));
-  const gchar *comment = image ? image->gimp->config->default_image->comment : NULL;
+  GimpImage   *image;
+  const gchar *comment = NULL;
+
+  image = gimp_image_parasite_view_get_image (GIMP_IMAGE_PARASITE_VIEW (editor));
+
+  if (image)
+    {
+      GimpTemplate *template = image->gimp->config->default_image;
+
+      comment = gimp_template_get_comment (template);
+    }
 
   if (comment)
     gtk_text_buffer_set_text (editor->buffer, comment, -1);
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 915fde7..1bcb528 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -132,6 +132,7 @@ gimp_template_editor_constructed (GObject *object)
 {
   GimpTemplateEditor        *editor  = GIMP_TEMPLATE_EDITOR (object);
   GimpTemplateEditorPrivate *private = GET_PRIVATE (object);
+  GimpTemplate              *template;
   GtkWidget                 *aspect_box;
   GtkWidget                 *frame;
   GtkWidget                 *hbox;
@@ -156,6 +157,8 @@ gimp_template_editor_constructed (GObject *object)
 
   g_assert (private->template != NULL);
 
+  template = private->template;
+
   /*  Image size frame  */
   frame = gimp_frame_new (_("Image Size"));
   gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0);
@@ -198,7 +201,9 @@ gimp_template_editor_constructed (GObject *object)
   gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
   gtk_widget_show (hbox);
 
-  private->size_se = gimp_size_entry_new (0, private->template->unit,_("%p"),
+  private->size_se = gimp_size_entry_new (0,
+                                          gimp_template_get_unit (template),
+                                          _("%p"),
                                           TRUE, FALSE, FALSE, SB_WIDTH,
                                           GIMP_SIZE_ENTRY_UPDATE_SIZE);
 
@@ -218,11 +223,11 @@ gimp_template_editor_constructed (GObject *object)
   gtk_table_attach_defaults (GTK_TABLE (private->size_se), width, 0, 1, 0, 1);
   gtk_widget_show (width);
 
-  gimp_prop_coordinates_connect (G_OBJECT (private->template),
+  gimp_prop_coordinates_connect (G_OBJECT (template),
                                  "width", "height", "unit",
                                  private->size_se, NULL,
-                                 private->template->xresolution,
-                                 private->template->yresolution);
+                                 gimp_template_get_resolution_x (template),
+                                 gimp_template_get_resolution_y (template));
 
   hbox = gtk_hbox_new (FALSE, 12);
   gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 3, 2, 3);
@@ -326,7 +331,9 @@ gimp_template_editor_constructed (GObject *object)
   gtk_widget_show (hbox);
 
   private->resolution_se =
-    gimp_size_entry_new (0, private->template->resolution_unit, _("pixels/%s"),
+    gimp_size_entry_new (0,
+                         gimp_template_get_resolution_unit (template),
+                         _("pixels/%s"),
                          FALSE, FALSE, FALSE, SB_WIDTH,
                          GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
 
@@ -350,9 +357,11 @@ gimp_template_editor_constructed (GObject *object)
   gtk_widget_show (xres);
 
   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
-                                  private->template->xresolution, FALSE);
+                                  gimp_template_get_resolution_x (template),
+                                  FALSE);
   gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
-                                  private->template->yresolution, FALSE);
+                                  gimp_template_get_resolution_y (template),
+                                  FALSE);
 
   /*  the resolution chainbutton  */
   chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
@@ -360,7 +369,7 @@ gimp_template_editor_constructed (GObject *object)
                              1, 2, 0, 2);
   gtk_widget_show (chainbutton);
 
-  gimp_prop_coordinates_connect (G_OBJECT (private->template),
+  gimp_prop_coordinates_connect (G_OBJECT (template),
                                  "xresolution", "yresolution",
                                  "resolution-unit",
                                  private->resolution_se, chainbutton,
@@ -376,14 +385,14 @@ gimp_template_editor_constructed (GObject *object)
                                  focus_chain);
   g_list_free (focus_chain);
 
-  combo = gimp_prop_enum_combo_box_new (G_OBJECT (private->template),
+  combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
                                         "image-type",
                                         GIMP_RGB, GIMP_GRAY);
   gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
                              _("Color _space:"), 0.0, 0.5,
                              combo, 1, FALSE);
 
-  combo = gimp_prop_enum_combo_box_new (G_OBJECT (private->template),
+  combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
                                         "fill-type",
                                         GIMP_FOREGROUND_FILL,
                                         GIMP_TRANSPARENT_FILL);
@@ -401,7 +410,7 @@ gimp_template_editor_constructed (GObject *object)
                              _("Comme_nt:"), 0.0, 0.0,
                              scrolled_window, 1, FALSE);
 
-  text_buffer = gimp_prop_text_buffer_new (G_OBJECT (private->template),
+  text_buffer = gimp_prop_text_buffer_new (G_OBJECT (template),
                                            "comment", MAX_COMMENT_LENGTH);
 
   text_view = gtk_text_view_new_with_buffer (text_buffer);
@@ -411,12 +420,12 @@ gimp_template_editor_constructed (GObject *object)
   gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
   gtk_widget_show (text_view);
 
-  g_signal_connect_object (private->template, "notify",
+  g_signal_connect_object (template, "notify",
                            G_CALLBACK (gimp_template_editor_template_notify),
                            editor, 0);
 
   /*  call the notify callback once to get the labels set initially  */
-  gimp_template_editor_template_notify (private->template, NULL, editor);
+  gimp_template_editor_template_notify (template, NULL, editor);
 }
 
 static void
@@ -566,8 +575,10 @@ gimp_template_editor_set_pixels (GimpTemplateEditor *editor,
   gchar                     *text;
 
   text = g_strdup_printf (ngettext ("%d Ã? %d pixel",
-                                    "%d Ã? %d pixels", template->height),
-                          template->width, template->height);
+                                    "%d Ã? %d pixels",
+                                    gimp_template_get_height (template)),
+                          gimp_template_get_width (template),
+                          gimp_template_get_height (template));
   gtk_label_set_text (GTK_LABEL (private->pixel_label), text);
   g_free (text);
 }
@@ -582,12 +593,12 @@ gimp_template_editor_aspect_callback (GtkWidget          *widget,
       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
     {
       GimpTemplate *template    = private->template;
-      gint          width       = template->width;
-      gint          height      = template->height;
-      gdouble       xresolution = template->xresolution;
-      gdouble       yresolution = template->yresolution;
+      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);
 
-      if (template->width == template->height)
+      if (width == height)
         {
           private->block_aspect = TRUE;
           gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (private->aspect_button),
@@ -629,6 +640,8 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
   GimpAspectType             aspect;
   const gchar               *desc;
   gchar                     *text;
+  gint                       width;
+  gint                       height;
   gint                       xres;
   gint                       yres;
 
@@ -637,26 +650,31 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
       if (! strcmp (param_spec->name, "xresolution"))
         {
           gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
-                                          template->xresolution, FALSE);
+                                          gimp_template_get_resolution_x (template),
+                                          FALSE);
         }
       else if (! strcmp (param_spec->name, "yresolution"))
         {
           gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
-                                          template->yresolution, FALSE);
+                                          gimp_template_get_resolution_y (template),
+                                          FALSE);
         }
     }
 
 #ifdef ENABLE_MEMSIZE_LABEL
-  text = g_format_size_for_display (template->initial_size);
+  text = g_format_size_for_display (gimp_template_get_initial_size (template));
   gtk_label_set_text (GTK_LABEL (private->memsize_label), text);
   g_free (text);
 #endif
 
   gimp_template_editor_set_pixels (editor, template);
 
-  if (template->width > template->height)
+  width  = gimp_template_get_width (template);
+  height = gimp_template_get_height (template);
+
+  if (width > height)
     aspect = GIMP_ASPECT_LANDSCAPE;
-  else if (template->height > template->width)
+  else if (height > width)
     aspect = GIMP_ASPECT_PORTRAIT;
   else
     aspect = GIMP_ASPECT_SQUARE;
@@ -666,11 +684,12 @@ gimp_template_editor_template_notify (GimpTemplate       *template,
                                    aspect);
   private->block_aspect = FALSE;
 
-  gimp_enum_get_value (GIMP_TYPE_IMAGE_BASE_TYPE, template->image_type,
+  gimp_enum_get_value (GIMP_TYPE_IMAGE_BASE_TYPE,
+                       gimp_template_get_image_type (template),
                        NULL, NULL, &desc, NULL);
 
-  xres = ROUND (template->xresolution);
-  yres = ROUND (template->yresolution);
+  xres = ROUND (gimp_template_get_resolution_x (template));
+  yres = ROUND (gimp_template_get_resolution_y (template));
 
   if (xres != yres)
     text = g_strdup_printf (_("%d Ã? %d ppi, %s"), xres, yres, desc);
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index e9f2f47..3b14e56 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -534,11 +534,13 @@ xcf_load_image_props (XcfInfo   *info,
             if (xres < GIMP_MIN_RESOLUTION || xres > GIMP_MAX_RESOLUTION ||
                 yres < GIMP_MIN_RESOLUTION || yres > GIMP_MAX_RESOLUTION)
               {
+                GimpTemplate *template = image->gimp->config->default_image;
+
                 gimp_message_literal (info->gimp, G_OBJECT (info->progress),
 				      GIMP_MESSAGE_WARNING,
 				      "Warning, resolution out of range in XCF file");
-                xres = image->gimp->config->default_image->xresolution;
-                yres = image->gimp->config->default_image->yresolution;
+                xres = gimp_template_get_resolution_x (template);
+                yres = gimp_template_get_resolution_y (template);
               }
 
             gimp_image_set_resolution (image, xres, yres);
diff --git a/tools/pdbgen/pdb/gimprc.pdb b/tools/pdbgen/pdb/gimprc.pdb
index b8863f6..585bb4b 100644
--- a/tools/pdbgen/pdb/gimprc.pdb
+++ b/tools/pdbgen/pdb/gimprc.pdb
@@ -141,7 +141,7 @@ sub get_default_comment {
 	headers => [ qw("core/gimptemplate.h") ],
 	code => <<'CODE'
 {
-  comment = g_strdup (gimp->config->default_image->comment);
+  comment = g_strdup (gimp_template_get_comment (gimp->config->default_image));
 }
 CODE
     );



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]