[gimp] Move "grid", "guides" and "sample_points" to GimpImagePrivate
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Move "grid", "guides" and "sample_points" to GimpImagePrivate
- Date: Wed, 3 Feb 2010 21:16:41 +0000 (UTC)
commit c9f8399614e9eaff1a9e0691485eda67d6b38bef
Author: Michael Natterer <mitch gimp org>
Date: Wed Feb 3 22:16:02 2010 +0100
Move "grid", "guides" and "sample_points" to GimpImagePrivate
app/core/gimpguideundo.c | 7 ++++-
app/core/gimpimage-duplicate.c | 4 +-
app/core/gimpimage-grid.c | 13 +++++++---
app/core/gimpimage-guides.c | 38 ++++++++++++++++++++----------
app/core/gimpimage-private.h | 4 +++
app/core/gimpimage-sample-points.c | 22 +++++++++++++-----
app/core/gimpimage.c | 32 +++++++++++++-------------
app/core/gimpimage.h | 4 ---
app/core/gimpimageundo.c | 2 +-
app/core/gimpsamplepointundo.c | 8 ++++--
app/display/gimpdisplayshell-draw.c | 3 +-
app/display/gimpdisplayshell-handlers.c | 5 ++-
app/xcf/xcf-load.c | 12 +++++----
app/xcf/xcf-save.c | 2 +-
14 files changed, 96 insertions(+), 60 deletions(-)
---
diff --git a/app/core/gimpguideundo.c b/app/core/gimpguideundo.c
index 01002b5..da9958e 100644
--- a/app/core/gimpguideundo.c
+++ b/app/core/gimpguideundo.c
@@ -23,6 +23,7 @@
#include "gimpimage.h"
#include "gimpimage-guides.h"
+#include "gimpimage-private.h"
#include "gimpguide.h"
#include "gimpguideundo.h"
@@ -165,8 +166,10 @@ gimp_guide_undo_pop (GimpUndo *undo,
if (position == -1)
{
- undo->image->guides = g_list_prepend (undo->image->guides,
- guide_undo->guide);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (undo->image);
+
+ private->guides = g_list_prepend (private->guides,
+ guide_undo->guide);
gimp_guide_set_position (guide_undo->guide, guide_undo->position);
g_object_ref (guide_undo->guide);
gimp_image_update_guide (undo->image, guide_undo->guide);
diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c
index 69e99df..b53a9f7 100644
--- a/app/core/gimpimage-duplicate.c
+++ b/app/core/gimpimage-duplicate.c
@@ -416,8 +416,8 @@ static void
gimp_image_duplicate_grid (GimpImage *image,
GimpImage *new_image)
{
- if (image->grid)
- gimp_image_set_grid (new_image, image->grid, FALSE);
+ if (gimp_image_get_grid (image))
+ gimp_image_set_grid (new_image, gimp_image_get_grid (image), FALSE);
}
static void
diff --git a/app/core/gimpimage-grid.c b/app/core/gimpimage-grid.c
index 613b839..fdfbd57 100644
--- a/app/core/gimpimage-grid.c
+++ b/app/core/gimpimage-grid.c
@@ -29,6 +29,7 @@
#include "gimpgrid.h"
#include "gimpimage.h"
#include "gimpimage-grid.h"
+#include "gimpimage-private.h"
#include "gimpimage-undo-push.h"
#include "gimp-intl.h"
@@ -39,7 +40,7 @@ gimp_image_get_grid (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return image->grid;
+ return GIMP_IMAGE_GET_PRIVATE (image)->grid;
}
void
@@ -47,14 +48,18 @@ gimp_image_set_grid (GimpImage *image,
GimpGrid *grid,
gboolean push_undo)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_GRID (grid));
- if (gimp_config_is_equal_to (GIMP_CONFIG (image->grid), GIMP_CONFIG (grid)))
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ if (gimp_config_is_equal_to (GIMP_CONFIG (private->grid), GIMP_CONFIG (grid)))
return;
if (push_undo)
- gimp_image_undo_push_image_grid (image, _("Grid"), image->grid);
+ gimp_image_undo_push_image_grid (image, _("Grid"), private->grid);
- gimp_config_sync (G_OBJECT (grid), G_OBJECT (image->grid), 0);
+ gimp_config_sync (G_OBJECT (grid), G_OBJECT (private->grid), 0);
}
diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c
index 858c99f..3e46da3 100644
--- a/app/core/gimpimage-guides.c
+++ b/app/core/gimpimage-guides.c
@@ -25,6 +25,7 @@
#include "gimpimage.h"
#include "gimpguide.h"
#include "gimpimage-guides.h"
+#include "gimpimage-private.h"
#include "gimpimage-undo-push.h"
#include "gimp-intl.h"
@@ -83,16 +84,20 @@ gimp_image_add_guide (GimpImage *image,
GimpGuide *guide,
gint position)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_GUIDE (guide));
g_return_if_fail (position >= 0);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
if (gimp_guide_get_orientation (guide) == GIMP_ORIENTATION_HORIZONTAL)
g_return_if_fail (position <= gimp_image_get_height (image));
else
g_return_if_fail (position <= gimp_image_get_width (image));
- image->guides = g_list_prepend (image->guides, guide);
+ private->guides = g_list_prepend (private->guides, guide);
gimp_guide_set_position (guide, position);
g_object_ref (G_OBJECT (guide));
@@ -105,15 +110,19 @@ gimp_image_remove_guide (GimpImage *image,
GimpGuide *guide,
gboolean push_undo)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_GUIDE (guide));
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
gimp_image_update_guide (image, guide);
if (push_undo)
gimp_image_undo_push_guide (image, _("Remove Guide"), guide);
- image->guides = g_list_remove (image->guides, guide);
+ private->guides = g_list_remove (private->guides, guide);
gimp_guide_removed (guide);
gimp_guide_set_position (guide, -1);
@@ -148,7 +157,7 @@ gimp_image_get_guides (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return image->guides;
+ return GIMP_IMAGE_GET_PRIVATE (image)->guides;
}
GimpGuide *
@@ -159,7 +168,9 @@ gimp_image_get_guide (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- for (guides = image->guides; guides; guides = g_list_next (guides))
+ for (guides = GIMP_IMAGE_GET_PRIVATE (image)->guides;
+ guides;
+ guides = g_list_next (guides))
{
GimpGuide *guide = guides->data;
@@ -186,7 +197,9 @@ gimp_image_get_next_guide (GimpImage *image,
else
*guide_found = FALSE;
- for (guides = image->guides; guides; guides = g_list_next (guides))
+ for (guides = GIMP_IMAGE_GET_PRIVATE (image)->guides;
+ guides;
+ guides = g_list_next (guides))
{
GimpGuide *guide = guides->data;
@@ -211,20 +224,19 @@ gimp_image_find_guide (GimpImage *image,
gdouble epsilon_y)
{
GList *list;
- GimpGuide *guide;
- GimpGuide *ret = NULL;
- gdouble dist;
+ GimpGuide *ret = NULL;
gdouble mindist = G_MAXDOUBLE;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (epsilon_x > 0 && epsilon_y > 0, NULL);
- for (list = image->guides; list; list = g_list_next (list))
+ for (list = GIMP_IMAGE_GET_PRIVATE (image)->guides;
+ list;
+ list = g_list_next (list))
{
- gint position;
-
- guide = list->data;
- position = gimp_guide_get_position (guide);
+ GimpGuide *guide = list->data;
+ gint position = gimp_guide_get_position (guide);
+ gdouble dist;
if (position < 0)
continue;
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
index 6d55860..a7b1867 100644
--- a/app/core/gimpimage-private.h
+++ b/app/core/gimpimage-private.h
@@ -52,6 +52,10 @@ struct _GimpImagePrivate
GimpProjection *projection; /* projection layers & channels */
GeglNode *graph; /* GEGL projection graph */
+
+ GList *guides; /* guides */
+ GimpGrid *grid; /* grid */
+ GList *sample_points; /* color sample points */
};
#define GIMP_IMAGE_GET_PRIVATE(image) \
diff --git a/app/core/gimpimage-sample-points.c b/app/core/gimpimage-sample-points.c
index b7676b2..ee38201 100644
--- a/app/core/gimpimage-sample-points.c
+++ b/app/core/gimpimage-sample-points.c
@@ -25,6 +25,7 @@
#include "gimp.h"
#include "gimpimage.h"
+#include "gimpimage-private.h"
#include "gimpimage-sample-points.h"
#include "gimpimage-undo-push.h"
#include "gimpsamplepoint.h"
@@ -64,6 +65,8 @@ gimp_image_add_sample_point (GimpImage *image,
gint x,
gint y)
{
+ GimpImagePrivate *private;
+
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (sample_point != NULL);
g_return_if_fail (x >= 0);
@@ -71,7 +74,9 @@ gimp_image_add_sample_point (GimpImage *image,
g_return_if_fail (x < gimp_image_get_width (image));
g_return_if_fail (y < gimp_image_get_height (image));
- image->sample_points = g_list_append (image->sample_points, sample_point);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ private->sample_points = g_list_append (private->sample_points, sample_point);
sample_point->x = x;
sample_point->y = y;
@@ -86,22 +91,25 @@ gimp_image_remove_sample_point (GimpImage *image,
GimpSamplePoint *sample_point,
gboolean push_undo)
{
- GList *list;
+ GimpImagePrivate *private;
+ GList *list;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (sample_point != NULL);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
gimp_image_update_sample_point (image, sample_point);
if (push_undo)
gimp_image_undo_push_sample_point (image, _("Remove Sample Point"),
sample_point);
- list = g_list_find (image->sample_points, sample_point);
+ list = g_list_find (private->sample_points, sample_point);
if (list)
list = g_list_next (list);
- image->sample_points = g_list_remove (image->sample_points, sample_point);
+ private->sample_points = g_list_remove (private->sample_points, sample_point);
gimp_image_sample_point_removed (image, sample_point);
@@ -145,7 +153,7 @@ gimp_image_get_sample_points (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- return image->sample_points;
+ return GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
}
GimpSamplePoint *
@@ -168,7 +176,9 @@ gimp_image_find_sample_point (GimpImage *image,
return NULL;
}
- for (list = image->sample_points; list; list = g_list_next (list))
+ for (list = GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
+ list;
+ list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;
gdouble dist;
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 794b2a1..de3fc4c 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -614,9 +614,9 @@ gimp_image_init (GimpImage *image)
private->projection = gimp_projection_new (GIMP_PROJECTABLE (image));
- image->guides = NULL;
- image->grid = NULL;
- image->sample_points = NULL;
+ private->guides = NULL;
+ private->grid = NULL;
+ private->sample_points = NULL;
image->layers = gimp_drawable_stack_new (GIMP_TYPE_LAYER);
image->channels = gimp_drawable_stack_new (GIMP_TYPE_CHANNEL);
@@ -721,7 +721,7 @@ gimp_image_constructor (GType type,
private->yresolution = config->default_image->yresolution;
private->resolution_unit = config->default_image->resolution_unit;
- image->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid));
+ private->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid));
switch (private->base_type)
{
@@ -926,25 +926,25 @@ gimp_image_finalize (GObject *object)
image->parasites = NULL;
}
- if (image->guides)
+ if (private->guides)
{
- g_list_foreach (image->guides, (GFunc) g_object_unref, NULL);
- g_list_free (image->guides);
- image->guides = NULL;
+ g_list_foreach (private->guides, (GFunc) g_object_unref, NULL);
+ g_list_free (private->guides);
+ private->guides = NULL;
}
- if (image->grid)
+ if (private->grid)
{
- g_object_unref (image->grid);
- image->grid = NULL;
+ g_object_unref (private->grid);
+ private->grid = NULL;
}
- if (image->sample_points)
+ if (private->sample_points)
{
- g_list_foreach (image->sample_points,
+ g_list_foreach (private->sample_points,
(GFunc) gimp_sample_point_unref, NULL);
- g_list_free (image->sample_points);
- image->sample_points = NULL;
+ g_list_free (private->sample_points);
+ private->sample_points = NULL;
}
if (image->undo_stack)
@@ -1016,7 +1016,7 @@ gimp_image_get_memsize (GimpObject *object,
memsize += gimp_g_list_get_memsize (gimp_image_get_guides (image),
sizeof (GimpGuide));
- memsize += gimp_object_get_memsize (GIMP_OBJECT (image->grid), gui_size);
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (private->grid), gui_size);
memsize += gimp_g_list_get_memsize (gimp_image_get_sample_points (image),
sizeof (GimpSamplePoint));
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 109f68f..d31fc6f 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -105,10 +105,6 @@ struct _GimpImage
Gimp *gimp; /* the GIMP the image belongs to*/
- GList *guides; /* guides */
- GimpGrid *grid; /* grid */
- GList *sample_points; /* color sample points */
-
/* Layer/Channel attributes */
GimpContainer *layers; /* the list of layers */
GimpContainer *channels; /* the list of masks */
diff --git a/app/core/gimpimageundo.c b/app/core/gimpimageundo.c
index 1738047..612a062 100644
--- a/app/core/gimpimageundo.c
+++ b/app/core/gimpimageundo.c
@@ -404,7 +404,7 @@ gimp_image_undo_pop (GimpUndo *undo,
{
GimpGrid *grid;
- grid = gimp_config_duplicate (GIMP_CONFIG (image->grid));
+ grid = gimp_config_duplicate (GIMP_CONFIG (gimp_image_get_grid (image)));
gimp_image_set_grid (image, image_undo->grid, FALSE);
diff --git a/app/core/gimpsamplepointundo.c b/app/core/gimpsamplepointundo.c
index 5b512f1..b1d55ff 100644
--- a/app/core/gimpsamplepointundo.c
+++ b/app/core/gimpsamplepointundo.c
@@ -22,6 +22,7 @@
#include "core-types.h"
#include "gimpimage.h"
+#include "gimpimage-private.h"
#include "gimpimage-sample-points.h"
#include "gimpsamplepoint.h"
#include "gimpsamplepointundo.h"
@@ -165,9 +166,10 @@ gimp_sample_point_undo_pop (GimpUndo *undo,
if (x == -1)
{
- undo->image->sample_points =
- g_list_append (undo->image->sample_points,
- sample_point_undo->sample_point);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (undo->image);
+
+ private->sample_points = g_list_append (private->sample_points,
+ sample_point_undo->sample_point);
sample_point_undo->sample_point->x = sample_point_undo->x;
sample_point_undo->sample_point->y = sample_point_undo->y;
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index 7392ccc..86b077a 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -32,6 +32,7 @@
#include "core/gimpgrid.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
+#include "core/gimpimage-grid.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpprojection.h"
@@ -220,7 +221,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
#define CROSSHAIR 2
- grid = GIMP_GRID (image->grid);
+ grid = gimp_image_get_grid (image);
if (! grid)
return;
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 58b8cb8..35f3deb 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -32,6 +32,7 @@
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
+#include "core/gimpimage-grid.h"
#include "core/gimpitem.h"
#include "core/gimptreehandler.h"
@@ -161,7 +162,7 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
g_signal_connect (image, "undo-event",
G_CALLBACK (gimp_display_shell_undo_event_handler),
shell);
- g_signal_connect (image->grid, "notify",
+ g_signal_connect (gimp_image_get_grid (image), "notify",
G_CALLBACK (gimp_display_shell_grid_notify_handler),
shell);
g_signal_connect (image, "name-changed",
@@ -383,7 +384,7 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_name_changed_handler,
shell);
- g_signal_handlers_disconnect_by_func (image->grid,
+ g_signal_handlers_disconnect_by_func (gimp_image_get_grid (image),
gimp_display_shell_grid_notify_handler,
shell);
g_signal_handlers_disconnect_by_func (image,
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 9f61ef7..b115ac2 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -42,6 +42,7 @@
#include "core/gimpimage-colormap.h"
#include "core/gimpimage-grid.h"
#include "core/gimpimage-guides.h"
+#include "core/gimpimage-private.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpitemstack.h"
#include "core/gimplayer-floating-sel.h"
@@ -450,9 +451,10 @@ xcf_load_image_props (XcfInfo *info,
case PROP_GUIDES:
{
- gint32 position;
- gint8 orientation;
- gint i, nguides;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ gint32 position;
+ gint8 orientation;
+ gint i, nguides;
nguides = prop_size / (4 + 1);
for (i = 0; i < nguides; i++)
@@ -485,10 +487,10 @@ xcf_load_image_props (XcfInfo *info,
}
/* this is silly as the order of guides doesn't really matter,
- * but it restores the list to it's original order, which
+ * but it restores the list to its original order, which
* cannot be wrong --Mitch
*/
- image->guides = g_list_reverse (image->guides);
+ private->guides = g_list_reverse (private->guides);
}
break;
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index 9666af2..814001f 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -417,7 +417,7 @@ xcf_save_image_props (XcfInfo *info,
if (unit >= _gimp_unit_get_number_of_built_in_units (image->gimp))
xcf_check_error (xcf_save_prop (info, image, PROP_USER_UNIT, error, unit));
- if (GIMP_IS_GRID (image->grid))
+ if (gimp_image_get_grid (image))
{
GimpGrid *grid = gimp_image_get_grid (image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]