[gimp] Start private struct for GimpImage and move the first members there
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Start private struct for GimpImage and move the first members there
- Date: Wed, 3 Feb 2010 19:32:40 +0000 (UTC)
commit f769284acac28e6c4020debace25c680990f3bed
Author: Michael Natterer <mitch gimp org>
Date: Wed Feb 3 20:31:25 2010 +0100
Start private struct for GimpImage and move the first members there
app/core/Makefile.am | 1 +
app/core/gimpimage-colormap.c | 74 ++++++----
app/core/gimpimage-private.h | 55 +++++++
app/core/gimpimage-undo.c | 44 ++++--
app/core/gimpimage.c | 268 +++++++++++++++++++++-------------
app/core/gimpimage.h | 24 +---
app/core/gimpimageundo.c | 12 +-
app/display/gimpdisplayshell-close.c | 7 +-
app/file/file-open.c | 3 +-
9 files changed, 315 insertions(+), 173 deletions(-)
---
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index acbe15b..a0f47f4 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -233,6 +233,7 @@ libappcore_a_sources = \
gimpimage-pick-color.h \
gimpimage-preview.c \
gimpimage-preview.h \
+ gimpimage-private.h \
gimpimage-quick-mask.c \
gimpimage-quick-mask.h \
gimpimage-resize.c \
diff --git a/app/core/gimpimage-colormap.c b/app/core/gimpimage-colormap.c
index d084100..edbc592 100644
--- a/app/core/gimpimage-colormap.c
+++ b/app/core/gimpimage-colormap.c
@@ -27,6 +27,7 @@
#include "gimpimage.h"
#include "gimpimage-colormap.h"
+#include "gimpimage-private.h"
#include "gimpimage-undo-push.h"
#include "gimp-intl.h"
@@ -37,7 +38,7 @@ gimp_image_get_colormap (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return image->colormap;
+ return GIMP_IMAGE_GET_PRIVATE (image)->colormap;
}
gint
@@ -45,7 +46,7 @@ gimp_image_get_colormap_size (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), 0);
- return image->n_colors;
+ return GIMP_IMAGE_GET_PRIVATE (image)->n_colors;
}
void
@@ -54,32 +55,36 @@ gimp_image_set_colormap (GimpImage *image,
gint n_colors,
gboolean push_undo)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (colormap != NULL || n_colors == 0);
g_return_if_fail (n_colors >= 0 && n_colors <= 256);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
if (push_undo)
gimp_image_undo_push_image_colormap (image, _("Set Colormap"));
- if (image->colormap)
- memset (image->colormap, 0, GIMP_IMAGE_COLORMAP_SIZE);
+ if (private->colormap)
+ memset (private->colormap, 0, GIMP_IMAGE_COLORMAP_SIZE);
if (colormap)
{
- if (! image->colormap)
- image->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE);
+ if (! private->colormap)
+ private->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE);
- memcpy (image->colormap, colormap, n_colors * 3);
+ memcpy (private->colormap, colormap, n_colors * 3);
}
else if (! gimp_image_base_type (image) == GIMP_INDEXED)
{
- if (image->colormap)
- g_free (image->colormap);
+ if (private->colormap)
+ g_free (private->colormap);
- image->colormap = NULL;
+ private->colormap = NULL;
}
- image->n_colors = n_colors;
+ private->n_colors = n_colors;
gimp_image_colormap_changed (image, -1);
}
@@ -89,15 +94,20 @@ gimp_image_get_colormap_entry (GimpImage *image,
gint color_index,
GimpRGB *color)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
- g_return_if_fail (image->colormap != NULL);
- g_return_if_fail (color_index >= 0 && color_index < image->n_colors);
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_if_fail (private->colormap != NULL);
+ g_return_if_fail (color_index >= 0 && color_index < private->n_colors);
g_return_if_fail (color != NULL);
gimp_rgba_set_uchar (color,
- image->colormap[color_index * 3],
- image->colormap[color_index * 3 + 1],
- image->colormap[color_index * 3 + 2],
+ private->colormap[color_index * 3],
+ private->colormap[color_index * 3 + 1],
+ private->colormap[color_index * 3 + 2],
OPAQUE_OPACITY);
}
@@ -107,9 +117,14 @@ gimp_image_set_colormap_entry (GimpImage *image,
const GimpRGB *color,
gboolean push_undo)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
- g_return_if_fail (image->colormap != NULL);
- g_return_if_fail (color_index >= 0 && color_index < image->n_colors);
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_if_fail (private->colormap != NULL);
+ g_return_if_fail (color_index >= 0 && color_index < private->n_colors);
g_return_if_fail (color != NULL);
if (push_undo)
@@ -117,9 +132,9 @@ gimp_image_set_colormap_entry (GimpImage *image,
_("Change Colormap entry"));
gimp_rgb_get_uchar (color,
- &image->colormap[color_index * 3],
- &image->colormap[color_index * 3 + 1],
- &image->colormap[color_index * 3 + 2]);
+ &private->colormap[color_index * 3],
+ &private->colormap[color_index * 3 + 1],
+ &private->colormap[color_index * 3 + 2]);
gimp_image_colormap_changed (image, color_index);
}
@@ -128,20 +143,25 @@ void
gimp_image_add_colormap_entry (GimpImage *image,
const GimpRGB *color)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
- g_return_if_fail (image->colormap != NULL);
- g_return_if_fail (image->n_colors < 256);
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_if_fail (private->colormap != NULL);
+ g_return_if_fail (private->n_colors < 256);
g_return_if_fail (color != NULL);
gimp_image_undo_push_image_colormap (image,
_("Add Color to Colormap"));
gimp_rgb_get_uchar (color,
- &image->colormap[image->n_colors * 3],
- &image->colormap[image->n_colors * 3 + 1],
- &image->colormap[image->n_colors * 3 + 2]);
+ &private->colormap[private->n_colors * 3],
+ &private->colormap[private->n_colors * 3 + 1],
+ &private->colormap[private->n_colors * 3 + 2]);
- image->n_colors++;
+ private->n_colors++;
gimp_image_colormap_changed (image, -1);
}
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
new file mode 100644
index 0000000..cf79832
--- /dev/null
+++ b/app/core/gimpimage-private.h
@@ -0,0 +1,55 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_IMAGE_PRIVATE_H__
+#define __GIMP_IMAGE_PRIVATE_H__
+
+
+typedef struct _GimpImagePrivate GimpImagePrivate;
+
+struct _GimpImagePrivate
+{
+ gint ID; /* provides a unique ID */
+
+ GimpPlugInProcedure *load_proc; /* procedure used for loading */
+ GimpPlugInProcedure *save_proc; /* last save procedure used */
+
+ gchar *display_name; /* display basename */
+ gint width; /* width in pixels */
+ gint height; /* height in pixels */
+ gdouble xresolution; /* image x-res, in dpi */
+ gdouble yresolution; /* image y-res, in dpi */
+ GimpUnit resolution_unit; /* resolution unit */
+ GimpImageBaseType base_type; /* base gimp_image type */
+
+ guchar *colormap; /* colormap (for indexed) */
+ gint n_colors; /* # of colors (for indexed) */
+
+ gint dirty; /* dirty flag -- # of ops */
+ guint dirty_time; /* time when image became dirty */
+ gint export_dirty; /* 'dirty' but for export */
+
+ gint undo_freeze_count; /* counts the _freeze's */
+};
+
+#define GIMP_IMAGE_GET_PRIVATE(image) \
+ G_TYPE_INSTANCE_GET_PRIVATE (image, \
+ GIMP_TYPE_IMAGE, \
+ GimpImagePrivate)
+
+
+#endif /* __GIMP_IMAGE_PRIVATE_H__ */
diff --git a/app/core/gimpimage-undo.c b/app/core/gimpimage-undo.c
index ca89509..c1859ad 100644
--- a/app/core/gimpimage-undo.c
+++ b/app/core/gimpimage-undo.c
@@ -27,6 +27,7 @@
#include "gimp-utils.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
+#include "gimpimage-private.h"
#include "gimpimage-undo.h"
#include "gimpitem.h"
#include "gimplist.h"
@@ -136,8 +137,12 @@ gimp_image_strong_redo (GimpImage *image)
void
gimp_image_undo_free (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
/* Emit the UNDO_FREE event before actually freeing everything
* so the views can properly detach from the undo items
*/
@@ -151,8 +156,8 @@ gimp_image_undo_free (GimpImage *image)
* This is because we've just nuked the actions that would allow
* the image to become clean again.
*/
- if (image->dirty < 0)
- image->dirty = 100000;
+ if (private->dirty < 0)
+ private->dirty = 100000;
/* The same applies to the case where the image would become clean
* due to undo actions, but since user can't undo without an undo
@@ -165,13 +170,16 @@ gimp_image_undo_group_start (GimpImage *image,
GimpUndoType undo_type,
const gchar *name)
{
- GimpUndoStack *undo_group;
- GimpDirtyMask dirty_mask;
+ GimpImagePrivate *private;
+ GimpUndoStack *undo_group;
+ GimpDirtyMask dirty_mask;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (undo_type > GIMP_UNDO_GROUP_FIRST &&
undo_type <= GIMP_UNDO_GROUP_LAST, FALSE);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
if (! name)
name = gimp_undo_type_to_name (undo_type);
@@ -181,7 +189,7 @@ gimp_image_undo_group_start (GimpImage *image,
if (image->group_count == 0 && dirty_mask != GIMP_DIRTY_NONE)
gimp_image_dirty (image, dirty_mask);
- if (image->undo_freeze_count > 0)
+ if (private->undo_freeze_count > 0)
return FALSE;
image->group_count++;
@@ -209,9 +217,13 @@ gimp_image_undo_group_start (GimpImage *image,
gboolean
gimp_image_undo_group_end (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- if (image->undo_freeze_count > 0)
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ if (private->undo_freeze_count > 0)
return FALSE;
g_return_val_if_fail (image->group_count > 0, FALSE);
@@ -242,22 +254,25 @@ gimp_image_undo_push (GimpImage *image,
GimpDirtyMask dirty_mask,
...)
{
- GParameter *params = NULL;
- gint n_params = 0;
- va_list args;
- GimpUndo *undo;
+ GimpImagePrivate *private;
+ GParameter *params = NULL;
+ gint n_params = 0;
+ va_list args;
+ GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (g_type_is_a (object_type, GIMP_TYPE_UNDO), NULL);
g_return_val_if_fail (undo_type > GIMP_UNDO_GROUP_LAST, NULL);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
/* Does this undo dirty the image? If so, we always want to mark
* image dirty, even if we can't actually push the undo.
*/
if (dirty_mask != GIMP_DIRTY_NONE)
gimp_image_dirty (image, dirty_mask);
- if (image->undo_freeze_count > 0)
+ if (private->undo_freeze_count > 0)
return NULL;
if (! name)
@@ -452,7 +467,8 @@ gimp_image_undo_free_space (GimpImage *image)
static void
gimp_image_undo_free_redo (GimpImage *image)
{
- GimpContainer *container = image->redo_stack->undos;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ GimpContainer *container = image->redo_stack->undos;
#ifdef DEBUG_IMAGE_UNDO
g_printerr ("redo_steps: %d redo_bytes: %ld\n",
@@ -483,14 +499,14 @@ gimp_image_undo_free_redo (GimpImage *image)
/* We need to use <= here because the undo counter has already been
* incremented at this point.
*/
- if (image->dirty <= 0)
+ if (private->dirty <= 0)
{
/* If the image was dirty, but could become clean by redo-ing
* some actions, then it should now become 'infinitely' dirty.
* This is because we've just nuked the actions that would allow
* the image to become clean again.
*/
- image->dirty = 100000;
+ private->dirty = 100000;
}
}
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 2b88fc9..22189c7 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -47,6 +47,7 @@
#include "gimpimage-guides.h"
#include "gimpimage-sample-points.h"
#include "gimpimage-preview.h"
+#include "gimpimage-private.h"
#include "gimpimage-quick-mask.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
@@ -556,6 +557,8 @@ gimp_image_class_init (GimpImageClass *klass)
G_PARAM_CONSTRUCT));
gimp_image_color_hash_init ();
+
+ g_type_class_add_private (klass, sizeof (GimpImagePrivate));
}
static void
@@ -580,28 +583,29 @@ gimp_projectable_iface_init (GimpProjectableInterface *iface)
static void
gimp_image_init (GimpImage *image)
{
- gint i;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ gint i;
- image->ID = 0;
+ private->ID = 0;
- image->load_proc = NULL;
- image->save_proc = NULL;
+ private->load_proc = NULL;
+ private->save_proc = NULL;
- image->width = 0;
- image->height = 0;
- image->xresolution = 1.0;
- image->yresolution = 1.0;
- image->resolution_unit = GIMP_UNIT_INCH;
- image->base_type = GIMP_RGB;
+ private->width = 0;
+ private->height = 0;
+ private->xresolution = 1.0;
+ private->yresolution = 1.0;
+ private->resolution_unit = GIMP_UNIT_INCH;
+ private->base_type = GIMP_RGB;
- image->colormap = NULL;
- image->n_colors = 0;
+ private->colormap = NULL;
+ private->n_colors = 0;
- image->dirty = 1;
- image->dirty_time = 0;
- image->undo_freeze_count = 0;
+ private->dirty = 1;
+ private->dirty_time = 0;
+ private->undo_freeze_count = 0;
- image->export_dirty = 1;
+ private->export_dirty = 1;
image->instance_count = 0;
image->disp_count = 0;
@@ -685,13 +689,15 @@ gimp_image_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
- GObject *object;
- GimpImage *image;
- GimpCoreConfig *config;
+ GObject *object;
+ GimpImage *image;
+ GimpImagePrivate *private;
+ GimpCoreConfig *config;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
- image = GIMP_IMAGE (object);
+ image = GIMP_IMAGE (object);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
g_assert (GIMP_IS_GIMP (image->gimp));
@@ -699,33 +705,33 @@ gimp_image_constructor (GType type,
do
{
- image->ID = image->gimp->next_image_ID++;
+ private->ID = image->gimp->next_image_ID++;
if (image->gimp->next_image_ID == G_MAXINT)
image->gimp->next_image_ID = 1;
}
while (g_hash_table_lookup (image->gimp->image_table,
- GINT_TO_POINTER (image->ID)));
+ GINT_TO_POINTER (private->ID)));
g_hash_table_insert (image->gimp->image_table,
- GINT_TO_POINTER (image->ID),
+ GINT_TO_POINTER (private->ID),
image);
- image->xresolution = config->default_image->xresolution;
- image->yresolution = config->default_image->yresolution;
- image->resolution_unit = config->default_image->resolution_unit;
+ private->xresolution = config->default_image->xresolution;
+ private->yresolution = config->default_image->yresolution;
+ private->resolution_unit = config->default_image->resolution_unit;
image->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid));
- switch (image->base_type)
+ switch (private->base_type)
{
case GIMP_RGB:
case GIMP_GRAY:
break;
case GIMP_INDEXED:
/* always allocate 256 colors for the colormap */
- image->n_colors = 0;
- image->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE);
+ private->n_colors = 0;
+ private->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE);
break;
default:
break;
@@ -762,7 +768,8 @@ gimp_image_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GimpImage *image = GIMP_IMAGE (object);
+ GimpImage *image = GIMP_IMAGE (object);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
switch (property_id)
{
@@ -773,13 +780,13 @@ gimp_image_set_property (GObject *object,
g_assert_not_reached ();
break;
case PROP_WIDTH:
- image->width = g_value_get_int (value);
+ private->width = g_value_get_int (value);
break;
case PROP_HEIGHT:
- image->height = g_value_get_int (value);
+ private->height = g_value_get_int (value);
break;
case PROP_BASE_TYPE:
- image->base_type = g_value_get_enum (value);
+ private->base_type = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -793,7 +800,8 @@ gimp_image_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GimpImage *image = GIMP_IMAGE (object);
+ GimpImage *image = GIMP_IMAGE (object);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
switch (property_id)
{
@@ -801,16 +809,16 @@ gimp_image_get_property (GObject *object,
g_value_set_object (value, image->gimp);
break;
case PROP_ID:
- g_value_set_int (value, image->ID);
+ g_value_set_int (value, private->ID);
break;
case PROP_WIDTH:
- g_value_set_int (value, image->width);
+ g_value_set_int (value, private->width);
break;
case PROP_HEIGHT:
- g_value_set_int (value, image->height);
+ g_value_set_int (value, private->height);
break;
case PROP_BASE_TYPE:
- g_value_set_enum (value, image->base_type);
+ g_value_set_enum (value, private->base_type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -858,7 +866,8 @@ gimp_image_dispose (GObject *object)
static void
gimp_image_finalize (GObject *object)
{
- GimpImage *image = GIMP_IMAGE (object);
+ GimpImage *image = GIMP_IMAGE (object);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
if (image->projection)
{
@@ -872,10 +881,10 @@ gimp_image_finalize (GObject *object)
image->graph = NULL;
}
- if (image->colormap)
+ if (private->colormap)
{
- g_free (image->colormap);
- image->colormap = NULL;
+ g_free (private->colormap);
+ private->colormap = NULL;
}
if (image->layers)
@@ -952,14 +961,14 @@ gimp_image_finalize (GObject *object)
if (image->gimp && image->gimp->image_table)
{
g_hash_table_remove (image->gimp->image_table,
- GINT_TO_POINTER (image->ID));
+ GINT_TO_POINTER (private->ID));
image->gimp = NULL;
}
- if (image->display_name)
+ if (private->display_name)
{
- g_free (image->display_name);
- image->display_name = NULL;
+ g_free (private->display_name);
+ private->display_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -968,16 +977,17 @@ gimp_image_finalize (GObject *object)
static void
gimp_image_name_changed (GimpObject *object)
{
- GimpImage *image = GIMP_IMAGE (object);
- const gchar *name;
+ GimpImage *image = GIMP_IMAGE (object);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
- if (image->display_name)
+ if (private->display_name)
{
- g_free (image->display_name);
- image->display_name = NULL;
+ g_free (private->display_name);
+ private->display_name = NULL;
}
/* We never want the empty string as a name, so change empty strings
@@ -1217,10 +1227,10 @@ gimp_image_get_image (GimpProjectable *projectable)
static GimpImageType
gimp_image_get_image_type (GimpProjectable *projectable)
{
- GimpImage *image = GIMP_IMAGE (projectable);
- GimpImageType type;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (projectable);
+ GimpImageType type;
- type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (image->base_type);
+ type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (private->base_type);
return GIMP_IMAGE_TYPE_WITH_ALPHA (type);
}
@@ -1360,7 +1370,7 @@ gimp_image_base_type (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
- return image->base_type;
+ return GIMP_IMAGE_GET_PRIVATE (image)->base_type;
}
GimpImageType
@@ -1368,7 +1378,7 @@ gimp_image_base_type_with_alpha (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
- switch (image->base_type)
+ switch (GIMP_IMAGE_GET_PRIVATE (image)->base_type)
{
case GIMP_RGB:
return GIMP_RGBA_IMAGE;
@@ -1393,7 +1403,7 @@ gimp_image_get_ID (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
- return image->ID;
+ return GIMP_IMAGE_GET_PRIVATE (image)->ID;
}
GimpImage *
@@ -1474,16 +1484,20 @@ gimp_image_get_filename (const GimpImage *image)
const gchar *
gimp_image_get_display_name (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- if (! image->display_name)
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ if (! private->display_name)
{
const gchar *uri = gimp_image_get_uri (image);
- image->display_name = file_utils_uri_display_basename (uri);
+ private->display_name = file_utils_uri_display_basename (uri);
}
- return image->display_name;
+ return private->display_name;
}
void
@@ -1492,7 +1506,7 @@ gimp_image_set_load_proc (GimpImage *image,
{
g_return_if_fail (GIMP_IS_IMAGE (image));
- image->load_proc = proc;
+ GIMP_IMAGE_GET_PRIVATE (image)->load_proc = proc;
}
GimpPlugInProcedure *
@@ -1500,7 +1514,7 @@ gimp_image_get_load_proc (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return image->load_proc;
+ return GIMP_IMAGE_GET_PRIVATE (image)->load_proc;
}
void
@@ -1509,7 +1523,7 @@ gimp_image_set_save_proc (GimpImage *image,
{
g_return_if_fail (GIMP_IS_IMAGE (image));
- image->save_proc = proc;
+ GIMP_IMAGE_GET_PRIVATE (image)->save_proc = proc;
}
GimpPlugInProcedure *
@@ -1517,7 +1531,7 @@ gimp_image_get_save_proc (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return image->save_proc;
+ return GIMP_IMAGE_GET_PRIVATE (image)->save_proc;
}
void
@@ -1525,21 +1539,25 @@ gimp_image_set_resolution (GimpImage *image,
gdouble xresolution,
gdouble yresolution)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
/* don't allow to set the resolution out of bounds */
if (xresolution < GIMP_MIN_RESOLUTION || xresolution > GIMP_MAX_RESOLUTION ||
yresolution < GIMP_MIN_RESOLUTION || yresolution > GIMP_MAX_RESOLUTION)
return;
- if ((ABS (image->xresolution - xresolution) >= 1e-5) ||
- (ABS (image->yresolution - yresolution) >= 1e-5))
+ if ((ABS (private->xresolution - xresolution) >= 1e-5) ||
+ (ABS (private->yresolution - yresolution) >= 1e-5))
{
gimp_image_undo_push_image_resolution (image,
_("Change Image Resolution"));
- image->xresolution = xresolution;
- image->yresolution = yresolution;
+ private->xresolution = xresolution;
+ private->yresolution = yresolution;
gimp_image_resolution_changed (image);
gimp_image_size_changed_detailed (image,
@@ -1555,11 +1573,15 @@ gimp_image_get_resolution (const GimpImage *image,
gdouble *xresolution,
gdouble *yresolution)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (xresolution != NULL && yresolution != NULL);
- *xresolution = image->xresolution;
- *yresolution = image->yresolution;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ *xresolution = private->xresolution;
+ *yresolution = private->yresolution;
}
void
@@ -1574,15 +1596,19 @@ void
gimp_image_set_unit (GimpImage *image,
GimpUnit unit)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (unit > GIMP_UNIT_PIXEL);
- if (image->resolution_unit != unit)
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ if (private->resolution_unit != unit)
{
gimp_image_undo_push_image_resolution (image,
_("Change Image Unit"));
- image->resolution_unit = unit;
+ private->resolution_unit = unit;
gimp_image_unit_changed (image);
}
}
@@ -1592,7 +1618,7 @@ gimp_image_get_unit (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), GIMP_UNIT_INCH);
- return image->resolution_unit;
+ return GIMP_IMAGE_GET_PRIVATE (image)->resolution_unit;
}
void
@@ -1608,7 +1634,7 @@ gimp_image_get_width (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), 0);
- return image->width;
+ return GIMP_IMAGE_GET_PRIVATE (image)->width;
}
gint
@@ -1616,7 +1642,7 @@ gimp_image_get_height (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), 0);
- return image->height;
+ return GIMP_IMAGE_GET_PRIVATE (image)->height;
}
gboolean
@@ -1911,7 +1937,8 @@ gimp_image_colormap_changed (GimpImage *image,
gint color_index)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
- g_return_if_fail (color_index >= -1 && color_index < image->n_colors);
+ g_return_if_fail (color_index >= -1 &&
+ color_index < GIMP_IMAGE_GET_PRIVATE (image)->n_colors);
g_signal_emit (image, gimp_image_signals[COLORMAP_CHANGED], 0,
color_index);
@@ -1942,7 +1969,7 @@ gimp_image_undo_is_enabled (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- return (image->undo_freeze_count == 0);
+ return (GIMP_IMAGE_GET_PRIVATE (image)->undo_freeze_count == 0);
}
gboolean
@@ -1967,11 +1994,15 @@ gimp_image_undo_disable (GimpImage *image)
gboolean
gimp_image_undo_freeze (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- image->undo_freeze_count++;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ private->undo_freeze_count++;
- if (image->undo_freeze_count == 1)
+ if (private->undo_freeze_count == 1)
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_FREEZE, NULL);
return TRUE;
@@ -1980,12 +2011,17 @@ gimp_image_undo_freeze (GimpImage *image)
gboolean
gimp_image_undo_thaw (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (image->undo_freeze_count > 0, FALSE);
- image->undo_freeze_count--;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_val_if_fail (private->undo_freeze_count > 0, FALSE);
- if (image->undo_freeze_count == 0)
+ private->undo_freeze_count--;
+
+ if (private->undo_freeze_count == 0)
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_THAW, NULL);
return TRUE;
@@ -2039,44 +2075,56 @@ gint
gimp_image_dirty (GimpImage *image,
GimpDirtyMask dirty_mask)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- image->dirty++;
- image->export_dirty++;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
- if (! image->dirty_time)
- image->dirty_time = time (NULL);
+ private->dirty++;
+ private->export_dirty++;
+
+ if (! private->dirty_time)
+ private->dirty_time = time (NULL);
g_signal_emit (image, gimp_image_signals[DIRTY], 0, dirty_mask);
- TRC (("dirty %d -> %d\n", image->dirty - 1, image->dirty));
+ TRC (("dirty %d -> %d\n", private->dirty - 1, private->dirty));
- return image->dirty;
+ return private->dirty;
}
gint
gimp_image_clean (GimpImage *image,
GimpDirtyMask dirty_mask)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- image->dirty--;
- image->export_dirty--;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ private->dirty--;
+ private->export_dirty--;
g_signal_emit (image, gimp_image_signals[CLEAN], 0, dirty_mask);
- TRC (("clean %d -> %d\n", image->dirty + 1, image->dirty));
+ TRC (("clean %d -> %d\n", private->dirty + 1, private->dirty));
- return image->dirty;
+ return private->dirty;
}
void
gimp_image_clean_all (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
- image->dirty = 0;
- image->dirty_time = 0;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ private->dirty = 0;
+ private->dirty_time = 0;
g_signal_emit (image, gimp_image_signals[CLEAN], 0, GIMP_DIRTY_ALL);
}
@@ -2084,9 +2132,13 @@ gimp_image_clean_all (GimpImage *image)
void
gimp_image_export_clean_all (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
- image->export_dirty = 0;
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ private->export_dirty = 0;
g_signal_emit (image, gimp_image_signals[CLEAN], 0, GIMP_DIRTY_ALL);
}
@@ -2100,7 +2152,9 @@ gimp_image_export_clean_all (GimpImage *image)
gint
gimp_image_is_dirty (const GimpImage *image)
{
- return image->dirty != 0;
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+
+ return GIMP_IMAGE_GET_PRIVATE (image)->dirty != 0;
}
/**
@@ -2112,9 +2166,20 @@ gimp_image_is_dirty (const GimpImage *image)
gboolean
gimp_image_is_export_dirty (const GimpImage *image)
{
- return image->export_dirty != 0;
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+
+ return GIMP_IMAGE_GET_PRIVATE (image)->export_dirty != 0;
}
+gint
+gimp_image_get_dirty_time (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), 0);
+
+ return GIMP_IMAGE_GET_PRIVATE (image)->dirty_time;
+}
+
+
/**
* gimp_image_saved:
* @image:
@@ -2243,11 +2308,12 @@ gimp_image_get_color (const GimpImage *src_image,
case GIMP_INDEXED_IMAGE:
/* Indexed palette lookup */
{
- gint index = *src++ * 3;
+ GimpImagePrivate *src_private = GIMP_IMAGE_GET_PRIVATE (src_image);
+ gint index = *src++ * 3;
- *rgba++ = src_image->colormap[index++];
- *rgba++ = src_image->colormap[index++];
- *rgba++ = src_image->colormap[index++];
+ *rgba++ = src_private->colormap[index++];
+ *rgba++ = src_private->colormap[index++];
+ *rgba++ = src_private->colormap[index++];
}
break;
}
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index b573730..301fbfc 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -105,27 +105,6 @@ struct _GimpImage
Gimp *gimp; /* the GIMP the image belongs to*/
- gint ID; /* provides a unique ID */
-
- GimpPlugInProcedure *load_proc; /* procedure used for loading */
- GimpPlugInProcedure *save_proc; /* last save procedure used */
-
- gchar *display_name; /* display basename */
- gint width, height; /* width and height attributes */
- gdouble xresolution; /* image x-res, in dpi */
- gdouble yresolution; /* image y-res, in dpi */
- GimpUnit resolution_unit; /* resolution unit */
- GimpImageBaseType base_type; /* base gimp_image type */
-
- guchar *colormap; /* colormap (for indexed) */
- gint n_colors; /* # of colors (for indexed) */
-
- gint dirty; /* dirty flag -- # of ops */
- guint dirty_time; /* time when image became dirty */
- gint undo_freeze_count; /* counts the _freeze's */
-
- gint export_dirty; /* 'dirty' but for export */
-
gint instance_count; /* number of instances */
gint disp_count; /* number of displays */
@@ -354,9 +333,10 @@ gint gimp_image_dirty (GimpImage *image,
gint gimp_image_clean (GimpImage *image,
GimpDirtyMask dirty_mask);
void gimp_image_clean_all (GimpImage *image);
+void gimp_image_export_clean_all (GimpImage *image);
gint gimp_image_is_dirty (const GimpImage *image);
gboolean gimp_image_is_export_dirty (const GimpImage *image);
-void gimp_image_export_clean_all (GimpImage *image);
+gint gimp_image_get_dirty_time (const GimpImage *image);
/* flush this image's displays */
diff --git a/app/core/gimpimageundo.c b/app/core/gimpimageundo.c
index a4ce929..1738047 100644
--- a/app/core/gimpimageundo.c
+++ b/app/core/gimpimageundo.c
@@ -33,6 +33,7 @@
#include "gimpimage.h"
#include "gimpimage-colormap.h"
#include "gimpimage-grid.h"
+#include "gimpimage-private.h"
#include "gimpimageundo.h"
#include "gimpparasitelist.h"
@@ -300,8 +301,9 @@ gimp_image_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
- GimpImageUndo *image_undo = GIMP_IMAGE_UNDO (undo);
- GimpImage *image = undo->image;
+ GimpImageUndo *image_undo = GIMP_IMAGE_UNDO (undo);
+ GimpImage *image = undo->image;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
@@ -376,8 +378,8 @@ gimp_image_undo_pop (GimpUndo *undo,
if (ABS (image_undo->xresolution - xres) >= 1e-5 ||
ABS (image_undo->yresolution - yres) >= 1e-5)
{
- image->xresolution = image_undo->xresolution;
- image->yresolution = image_undo->yresolution;
+ private->xresolution = image_undo->xresolution;
+ private->yresolution = image_undo->yresolution;
image_undo->xresolution = xres;
image_undo->yresolution = yres;
@@ -391,7 +393,7 @@ gimp_image_undo_pop (GimpUndo *undo,
GimpUnit unit;
unit = gimp_image_get_unit (image);
- image->resolution_unit = image_undo->resolution_unit;
+ private->resolution_unit = image_undo->resolution_unit;
image_undo->resolution_unit = unit;
accum->unit_changed = TRUE;
diff --git a/app/display/gimpdisplayshell-close.c b/app/display/gimpdisplayshell-close.c
index f5cf8ac..bc3ac50 100644
--- a/app/display/gimpdisplayshell-close.c
+++ b/app/display/gimpdisplayshell-close.c
@@ -237,14 +237,15 @@ gimp_display_shell_close_name_changed (GimpImage *image,
static gboolean
gimp_display_shell_close_time_changed (GimpMessageBox *box)
{
- GimpImage *image = g_object_get_data (G_OBJECT (box), "gimp-image");
+ GimpImage *image = g_object_get_data (G_OBJECT (box), "gimp-image");
+ gint *dirty_time = gimp_image_get_dirty_time (image);
- if (image->dirty_time)
+ if (dirty_time)
{
gint hours = 0;
gint minutes = 0;
- gimp_time_since (image->dirty_time, &hours, &minutes);
+ gimp_time_since (dirty_time, &hours, &minutes);
if (hours > 0)
{
diff --git a/app/file/file-open.c b/app/file/file-open.c
index 2ebb6e9..eb4359b 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -52,6 +52,7 @@
#include "core/gimpdocumentlist.h"
#include "core/gimpimage.h"
#include "core/gimpimage-merge.h"
+#include "core/gimpimage-private.h" /* FIXME: add api for undo freeze count */
#include "core/gimpimage-undo.h"
#include "core/gimpimagefile.h"
#include "core/gimplayer.h"
@@ -600,7 +601,7 @@ file_open_sanitize_image (GimpImage *image,
gimp_image_undo_free (image);
/* make sure that undo is enabled */
- while (image->undo_freeze_count)
+ while (GIMP_IMAGE_GET_PRIVATE (image)->undo_freeze_count)
gimp_image_undo_thaw (image);
/* Set the image to clean. Note that export dirtiness is not set to
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]