[gimp] Move all undo-related members to GimpImagePrivate
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Move all undo-related members to GimpImagePrivate
- Date: Thu, 4 Feb 2010 19:08:11 +0000 (UTC)
commit 09c897262eb05fc625b3035b679e5849c13f4798
Author: Michael Natterer <mitch gimp org>
Date: Thu Feb 4 20:06:49 2010 +0100
Move all undo-related members to GimpImagePrivate
Also add some new API to access them.
app/actions/edit-actions.c | 6 +-
app/actions/edit-commands.c | 23 +++--
app/core/gimpimage-private.h | 6 ++
app/core/gimpimage-scale.c | 4 +-
app/core/gimpimage-undo.c | 158 +++++++++++++++++++++++------------
app/core/gimpimage-undo.h | 42 +++++----
app/core/gimpimage.c | 24 +++---
app/core/gimpimage.h | 6 --
app/core/gimpundo.c | 6 +-
app/plug-in/gimpplugin-cleanup.c | 11 +--
app/tools/gimprectangleselecttool.c | 29 ++++---
app/tools/gimpvectortool.c | 3 +-
app/widgets/gimpimagepropview.c | 7 +-
app/widgets/gimpundoeditor.c | 41 +++++-----
14 files changed, 216 insertions(+), 150 deletions(-)
---
diff --git a/app/actions/edit-actions.c b/app/actions/edit-actions.c
index 7743401..ac89422 100644
--- a/app/actions/edit-actions.c
+++ b/app/actions/edit-actions.c
@@ -284,8 +284,10 @@ edit_actions_update (GimpActionGroup *group,
if (undo_enabled)
{
- GimpUndo *undo = gimp_undo_stack_peek (image->undo_stack);
- GimpUndo *redo = gimp_undo_stack_peek (image->redo_stack);
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
+ GimpUndo *undo = gimp_undo_stack_peek (undo_stack);
+ GimpUndo *redo = gimp_undo_stack_peek (redo_stack);
if (undo)
{
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index cc0a735..08b3560 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -122,12 +122,14 @@ void
edit_undo_clear_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpImage *image;
- GtkWidget *widget;
- GtkWidget *dialog;
- gchar *size;
- gint64 memsize;
- gint64 guisize;
+ GimpImage *image;
+ GimpUndoStack *undo_stack;
+ GimpUndoStack *redo_stack;
+ GtkWidget *widget;
+ GtkWidget *dialog;
+ gchar *size;
+ gint64 memsize;
+ gint64 guisize;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
@@ -159,11 +161,12 @@ edit_undo_clear_cmd_callback (GtkAction *action,
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("Really clear image's undo history?"));
- memsize = gimp_object_get_memsize (GIMP_OBJECT (image->undo_stack),
- &guisize);
+ undo_stack = gimp_image_get_undo_stack (image);
+ redo_stack = gimp_image_get_redo_stack (image);
+
+ memsize = gimp_object_get_memsize (GIMP_OBJECT (undo_stack), &guisize);
memsize += guisize;
- memsize += gimp_object_get_memsize (GIMP_OBJECT (image->redo_stack),
- &guisize);
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (redo_stack), &guisize);
memsize += guisize;
size = g_format_size_for_display (memsize);
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
index c08952a..cc3cea5 100644
--- a/app/core/gimpimage-private.h
+++ b/app/core/gimpimage-private.h
@@ -82,6 +82,12 @@ struct _GimpImagePrivate
gboolean quick_mask_state; /* TRUE if quick mask is on */
gboolean quick_mask_inverted; /* TRUE if quick mask is inverted */
GimpRGB quick_mask_color; /* rgba triplet of the color */
+
+ /* Undo apparatus */
+ GimpUndoStack *undo_stack; /* stack for undo operations */
+ GimpUndoStack *redo_stack; /* stack for redo operations */
+ gint group_count; /* nested undo groups */
+ GimpUndoType pushing_undo_group; /* undo group status flag */
};
#define GIMP_IMAGE_GET_PRIVATE(image) \
diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c
index cd9c347..eda5c20 100644
--- a/app/core/gimpimage-scale.c
+++ b/app/core/gimpimage-scale.c
@@ -311,8 +311,8 @@ gimp_image_scale_check (const GimpImage *image,
"scalable_size = %"G_GINT64_FORMAT" scaled_size = %"G_GINT64_FORMAT,
scalable_size, scaled_size);
- undo_size = gimp_object_get_memsize (GIMP_OBJECT (image->undo_stack), NULL);
- redo_size = gimp_object_get_memsize (GIMP_OBJECT (image->redo_stack), NULL);
+ undo_size = gimp_object_get_memsize (GIMP_OBJECT (gimp_image_get_undo_stack (image)), NULL);
+ redo_size = gimp_object_get_memsize (GIMP_OBJECT (gimp_image_get_redo_stack (image)), NULL);
/* the fixed part of the image's memsize w/o any undo information */
fixed_size = current_size - undo_size - redo_size - scalable_size;
diff --git a/app/core/gimpimage-undo.c b/app/core/gimpimage-undo.c
index c1859ad..004b516 100644
--- a/app/core/gimpimage-undo.c
+++ b/app/core/gimpimage-undo.c
@@ -51,18 +51,43 @@ static GimpDirtyMask gimp_image_undo_dirty_from_type (GimpUndoType undo_type);
gboolean
gimp_image_undo (GimpImage *image)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_val_if_fail (private->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
FALSE);
gimp_image_undo_pop_stack (image,
- image->undo_stack,
- image->redo_stack,
+ private->undo_stack,
+ private->redo_stack,
GIMP_UNDO_MODE_UNDO);
return TRUE;
}
+gboolean
+gimp_image_redo (GimpImage *image)
+{
+ GimpImagePrivate *private;
+
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_val_if_fail (private->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
+ FALSE);
+
+ gimp_image_undo_pop_stack (image,
+ private->redo_stack,
+ private->undo_stack,
+ GIMP_UNDO_MODE_REDO);
+
+ return TRUE;
+}
+
/*
* this function continues to undo as long as it only sees certain
* undo types, in particular visibility changes.
@@ -70,19 +95,23 @@ gimp_image_undo (GimpImage *image)
gboolean
gimp_image_strong_undo (GimpImage *image)
{
- GimpUndo *undo;
+ GimpImagePrivate *private;
+ GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_val_if_fail (private->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
FALSE);
- undo = gimp_undo_stack_peek (image->undo_stack);
+ undo = gimp_undo_stack_peek (private->undo_stack);
gimp_image_undo (image);
while (gimp_undo_is_weak (undo))
{
- undo = gimp_undo_stack_peek (image->undo_stack);
+ undo = gimp_undo_stack_peek (private->undo_stack);
if (gimp_undo_is_weak (undo))
gimp_image_undo (image);
}
@@ -90,21 +119,6 @@ gimp_image_strong_undo (GimpImage *image)
return TRUE;
}
-gboolean
-gimp_image_redo (GimpImage *image)
-{
- g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
- FALSE);
-
- gimp_image_undo_pop_stack (image,
- image->redo_stack,
- image->undo_stack,
- GIMP_UNDO_MODE_REDO);
-
- return TRUE;
-}
-
/*
* this function continues to redo as long as it only sees certain
* undo types, in particular visibility changes. Note that the
@@ -114,19 +128,23 @@ gimp_image_redo (GimpImage *image)
gboolean
gimp_image_strong_redo (GimpImage *image)
{
- GimpUndo *undo;
+ GimpImagePrivate *private;
+ GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ g_return_val_if_fail (private->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
FALSE);
- undo = gimp_undo_stack_peek (image->redo_stack);
+ undo = gimp_undo_stack_peek (private->redo_stack);
gimp_image_redo (image);
while (gimp_undo_is_weak (undo))
{
- undo = gimp_undo_stack_peek (image->redo_stack);
+ undo = gimp_undo_stack_peek (private->redo_stack);
if (gimp_undo_is_weak (undo))
gimp_image_redo (image);
}
@@ -134,6 +152,22 @@ gimp_image_strong_redo (GimpImage *image)
return TRUE;
}
+GimpUndoStack *
+gimp_image_get_undo_stack (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return GIMP_IMAGE_GET_PRIVATE (image)->undo_stack;
+}
+
+GimpUndoStack *
+gimp_image_get_redo_stack (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return GIMP_IMAGE_GET_PRIVATE (image)->redo_stack;
+}
+
void
gimp_image_undo_free (GimpImage *image)
{
@@ -148,8 +182,8 @@ gimp_image_undo_free (GimpImage *image)
*/
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_FREE, NULL);
- gimp_undo_free (GIMP_UNDO (image->undo_stack), GIMP_UNDO_MODE_UNDO);
- gimp_undo_free (GIMP_UNDO (image->redo_stack), GIMP_UNDO_MODE_REDO);
+ gimp_undo_free (GIMP_UNDO (private->undo_stack), GIMP_UNDO_MODE_UNDO);
+ gimp_undo_free (GIMP_UNDO (private->redo_stack), GIMP_UNDO_MODE_REDO);
/* If the image was dirty, but could become clean by redo-ing
* some actions, then it should now become 'infinitely' dirty.
@@ -165,6 +199,14 @@ gimp_image_undo_free (GimpImage *image)
*/
}
+gint
+gimp_image_get_undo_group_count (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), 0);
+
+ return GIMP_IMAGE_GET_PRIVATE (image)->group_count;
+}
+
gboolean
gimp_image_undo_group_start (GimpImage *image,
GimpUndoType undo_type,
@@ -186,16 +228,16 @@ gimp_image_undo_group_start (GimpImage *image,
dirty_mask = gimp_image_undo_dirty_from_type (undo_type);
/* Notify listeners that the image will be modified */
- if (image->group_count == 0 && dirty_mask != GIMP_DIRTY_NONE)
+ if (private->group_count == 0 && dirty_mask != GIMP_DIRTY_NONE)
gimp_image_dirty (image, dirty_mask);
if (private->undo_freeze_count > 0)
return FALSE;
- image->group_count++;
+ private->group_count++;
/* If we're already in a group...ignore */
- if (image->group_count > 1)
+ if (private->group_count > 1)
return TRUE;
/* nuke the redo stack */
@@ -207,9 +249,9 @@ gimp_image_undo_group_start (GimpImage *image,
GIMP_UNDO (undo_group)->undo_type = undo_type;
GIMP_UNDO (undo_group)->dirty_mask = dirty_mask;
- gimp_undo_stack_push_undo (image->undo_stack, GIMP_UNDO (undo_group));
+ gimp_undo_stack_push_undo (private->undo_stack, GIMP_UNDO (undo_group));
- image->pushing_undo_group = undo_type;
+ private->pushing_undo_group = undo_type;
return TRUE;
}
@@ -226,19 +268,19 @@ gimp_image_undo_group_end (GimpImage *image)
if (private->undo_freeze_count > 0)
return FALSE;
- g_return_val_if_fail (image->group_count > 0, FALSE);
+ g_return_val_if_fail (private->group_count > 0, FALSE);
- image->group_count--;
+ private->group_count--;
- if (image->group_count == 0)
+ if (private->group_count == 0)
{
- image->pushing_undo_group = GIMP_UNDO_GROUP_NONE;
+ private->pushing_undo_group = GIMP_UNDO_GROUP_NONE;
/* Do it here, since undo_push doesn't emit this event while in
* the middle of a group
*/
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_PUSHED,
- gimp_undo_stack_peek (image->undo_stack));
+ gimp_undo_stack_peek (private->undo_stack));
gimp_image_undo_free_space (image);
}
@@ -296,23 +338,23 @@ gimp_image_undo_push (GimpImage *image,
/* nuke the redo stack */
gimp_image_undo_free_redo (image);
- if (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE)
+ if (private->pushing_undo_group == GIMP_UNDO_GROUP_NONE)
{
- gimp_undo_stack_push_undo (image->undo_stack, undo);
+ gimp_undo_stack_push_undo (private->undo_stack, undo);
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_PUSHED, undo);
gimp_image_undo_free_space (image);
/* freeing undo space may have freed the newly pushed undo */
- if (gimp_undo_stack_peek (image->undo_stack) == undo)
+ if (gimp_undo_stack_peek (private->undo_stack) == undo)
return undo;
}
else
{
GimpUndoStack *undo_group;
- undo_group = GIMP_UNDO_STACK (gimp_undo_stack_peek (image->undo_stack));
+ undo_group = GIMP_UNDO_STACK (gimp_undo_stack_peek (private->undo_stack));
gimp_undo_stack_push_undo (undo_group, undo);
@@ -327,12 +369,16 @@ gimp_image_undo_can_compress (GimpImage *image,
GType object_type,
GimpUndoType undo_type)
{
+ GimpImagePrivate *private;
+
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
if (gimp_image_is_dirty (image) &&
- ! gimp_undo_stack_peek (image->redo_stack))
+ ! gimp_undo_stack_peek (private->redo_stack))
{
- GimpUndo *undo = gimp_undo_stack_peek (image->undo_stack);
+ GimpUndo *undo = gimp_undo_stack_peek (private->undo_stack);
if (undo && undo->undo_type == undo_type &&
g_type_is_a (G_TYPE_FROM_INSTANCE (undo), object_type))
@@ -347,11 +393,14 @@ gimp_image_undo_can_compress (GimpImage *image,
GimpUndo *
gimp_image_undo_get_fadeable (GimpImage *image)
{
- GimpUndo *undo;
+ GimpImagePrivate *private;
+ GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- undo = gimp_undo_stack_peek (image->undo_stack);
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ undo = gimp_undo_stack_peek (private->undo_stack);
if (GIMP_IS_UNDO_STACK (undo) && undo->undo_type == GIMP_UNDO_GROUP_PAINT)
{
@@ -421,12 +470,13 @@ gimp_image_undo_pop_stack (GimpImage *image,
static void
gimp_image_undo_free_space (GimpImage *image)
{
- GimpContainer *container;
- gint min_undo_levels;
- gint max_undo_levels;
- gint64 undo_size;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ GimpContainer *container;
+ gint min_undo_levels;
+ gint max_undo_levels;
+ gint64 undo_size;
- container = image->undo_stack->undos;
+ container = private->undo_stack->undos;
min_undo_levels = image->gimp->config->levels_of_undo;
max_undo_levels = 1024; /* FIXME */
@@ -445,7 +495,7 @@ gimp_image_undo_free_space (GimpImage *image)
while ((gimp_object_get_memsize (GIMP_OBJECT (container), NULL) > undo_size) ||
(gimp_container_get_n_children (container) > max_undo_levels))
{
- GimpUndo *freed = gimp_undo_stack_free_bottom (image->undo_stack,
+ GimpUndo *freed = gimp_undo_stack_free_bottom (private->undo_stack,
GIMP_UNDO_MODE_UNDO);
#ifdef DEBUG_IMAGE_UNDO
@@ -468,7 +518,7 @@ static void
gimp_image_undo_free_redo (GimpImage *image)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
- GimpContainer *container = image->redo_stack->undos;
+ GimpContainer *container = private->redo_stack->undos;
#ifdef DEBUG_IMAGE_UNDO
g_printerr ("redo_steps: %d redo_bytes: %ld\n",
@@ -481,7 +531,7 @@ gimp_image_undo_free_redo (GimpImage *image)
while (gimp_container_get_n_children (container) > 0)
{
- GimpUndo *freed = gimp_undo_stack_free_bottom (image->redo_stack,
+ GimpUndo *freed = gimp_undo_stack_free_bottom (private->redo_stack,
GIMP_UNDO_MODE_REDO);
#ifdef DEBUG_IMAGE_UNDO
diff --git a/app/core/gimpimage-undo.h b/app/core/gimpimage-undo.h
index 71ca705..d212da7 100644
--- a/app/core/gimpimage-undo.h
+++ b/app/core/gimpimage-undo.h
@@ -19,31 +19,35 @@
#define __GIMP_IMAGE__UNDO_H__
-gboolean gimp_image_undo (GimpImage *image);
-gboolean gimp_image_redo (GimpImage *image);
+gboolean gimp_image_undo (GimpImage *image);
+gboolean gimp_image_redo (GimpImage *image);
-gboolean gimp_image_strong_undo (GimpImage *image);
-gboolean gimp_image_strong_redo (GimpImage *image);
+gboolean gimp_image_strong_undo (GimpImage *image);
+gboolean gimp_image_strong_redo (GimpImage *image);
-void gimp_image_undo_free (GimpImage *image);
+GimpUndoStack * gimp_image_get_undo_stack (const GimpImage *image);
+GimpUndoStack * gimp_image_get_redo_stack (const GimpImage *image);
-gboolean gimp_image_undo_group_start (GimpImage *image,
- GimpUndoType undo_type,
- const gchar *name);
-gboolean gimp_image_undo_group_end (GimpImage *image);
+void gimp_image_undo_free (GimpImage *image);
-GimpUndo * gimp_image_undo_push (GimpImage *image,
- GType object_type,
- GimpUndoType undo_type,
- const gchar *name,
- GimpDirtyMask dirty_mask,
- ...) G_GNUC_NULL_TERMINATED;
+gint gimp_image_get_undo_group_count (const GimpImage *image);
+gboolean gimp_image_undo_group_start (GimpImage *image,
+ GimpUndoType undo_type,
+ const gchar *name);
+gboolean gimp_image_undo_group_end (GimpImage *image);
-GimpUndo * gimp_image_undo_can_compress (GimpImage *image,
- GType object_type,
- GimpUndoType undo_type);
+GimpUndo * gimp_image_undo_push (GimpImage *image,
+ GType object_type,
+ GimpUndoType undo_type,
+ const gchar *name,
+ GimpDirtyMask dirty_mask,
+ ...) G_GNUC_NULL_TERMINATED;
-GimpUndo * gimp_image_undo_get_fadeable (GimpImage *image);
+GimpUndo * gimp_image_undo_can_compress (GimpImage *image,
+ GType object_type,
+ GimpUndoType undo_type);
+
+GimpUndo * gimp_image_undo_get_fadeable (GimpImage *image);
#endif /* __GIMP_IMAGE__UNDO_H__ */
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index d82b1c9..4b43f34 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -671,10 +671,10 @@ gimp_image_init (GimpImage *image)
private->quick_mask_inverted = FALSE;
gimp_rgba_set (&private->quick_mask_color, 1.0, 0.0, 0.0, 0.5);
- image->undo_stack = gimp_undo_stack_new (image);
- image->redo_stack = gimp_undo_stack_new (image);
- image->group_count = 0;
- image->pushing_undo_group = GIMP_UNDO_GROUP_NONE;
+ private->undo_stack = gimp_undo_stack_new (image);
+ private->redo_stack = gimp_undo_stack_new (image);
+ private->group_count = 0;
+ private->pushing_undo_group = GIMP_UNDO_GROUP_NONE;
image->preview = NULL;
@@ -948,15 +948,15 @@ gimp_image_finalize (GObject *object)
private->sample_points = NULL;
}
- if (image->undo_stack)
+ if (private->undo_stack)
{
- g_object_unref (image->undo_stack);
- image->undo_stack = NULL;
+ g_object_unref (private->undo_stack);
+ private->undo_stack = NULL;
}
- if (image->redo_stack)
+ if (private->redo_stack)
{
- g_object_unref (image->redo_stack);
- image->redo_stack = NULL;
+ g_object_unref (private->redo_stack);
+ private->redo_stack = NULL;
}
if (image->gimp && image->gimp->image_table)
@@ -1037,9 +1037,9 @@ gimp_image_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (private->parasites),
gui_size);
- memsize += gimp_object_get_memsize (GIMP_OBJECT (image->undo_stack),
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (private->undo_stack),
gui_size);
- memsize += gimp_object_get_memsize (GIMP_OBJECT (image->redo_stack),
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (private->redo_stack),
gui_size);
*gui_size += temp_buf_get_memsize (image->preview);
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index dd2bb57..9385eb6 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -105,12 +105,6 @@ struct _GimpImage
Gimp *gimp; /* the GIMP the image belongs to*/
- /* Undo apparatus */
- GimpUndoStack *undo_stack; /* stack for undo operations */
- GimpUndoStack *redo_stack; /* stack for redo operations */
- gint group_count; /* nested undo groups */
- GimpUndoType pushing_undo_group; /* undo group status flag */
-
/* Preview */
TempBuf *preview; /* the projection preview */
diff --git a/app/core/gimpundo.c b/app/core/gimpundo.c
index cf1d312..7ccf636 100644
--- a/app/core/gimpundo.c
+++ b/app/core/gimpundo.c
@@ -32,6 +32,7 @@
#include "gimp.h"
#include "gimpcontext.h"
#include "gimpimage.h"
+#include "gimpimage-undo.h"
#include "gimpmarshal.h"
#include "gimpundo.h"
#include "gimpundostack.h"
@@ -439,9 +440,10 @@ gimp_undo_create_preview (GimpUndo *undo,
static gboolean
gimp_undo_create_preview_idle (gpointer data)
{
- GimpUndoIdle *idle = data;
+ GimpUndoIdle *idle = data;
+ GimpUndoStack *stack = gimp_image_get_undo_stack (idle->undo->image);
- if (idle->undo == gimp_undo_stack_peek (idle->undo->image->undo_stack))
+ if (idle->undo == gimp_undo_stack_peek (stack))
{
gimp_undo_create_preview_private (idle->undo, idle->context);
}
diff --git a/app/plug-in/gimpplugin-cleanup.c b/app/plug-in/gimpplugin-cleanup.c
index 528c11f..6d3c476 100644
--- a/app/plug-in/gimpplugin-cleanup.c
+++ b/app/plug-in/gimpplugin-cleanup.c
@@ -101,7 +101,7 @@ gimp_plug_in_cleanup_undo_group_start (GimpPlugIn *plug_in,
{
cleanup = gimp_plug_in_cleanup_image_new (image);
- cleanup->undo_group_count = image->group_count;
+ cleanup->undo_group_count = gimp_image_get_undo_group_count (image);
proc_frame->image_cleanups = g_list_prepend (proc_frame->image_cleanups,
cleanup);
@@ -126,7 +126,7 @@ gimp_plug_in_cleanup_undo_group_end (GimpPlugIn *plug_in,
if (! cleanup)
return FALSE;
- if (cleanup->undo_group_count == image->group_count - 1)
+ if (cleanup->undo_group_count == gimp_image_get_undo_group_count (image) - 1)
{
proc_frame->image_cleanups = g_list_remove (proc_frame->image_cleanups,
cleanup);
@@ -273,10 +273,10 @@ gimp_plug_in_cleanup_image (GimpPlugInProcFrame *proc_frame,
{
GimpImage *image = cleanup->image;
- if (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE)
+ if (gimp_image_get_undo_group_count (image) == 0)
return;
- if (cleanup->undo_group_count != image->group_count)
+ if (cleanup->undo_group_count != gimp_image_get_undo_group_count (image))
{
GimpProcedure *proc = proc_frame->procedure;
@@ -284,8 +284,7 @@ gimp_plug_in_cleanup_image (GimpPlugInProcFrame *proc_frame,
"closing open undo groups.",
gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc)));
- while (image->pushing_undo_group != GIMP_UNDO_GROUP_NONE &&
- cleanup->undo_group_count < image->group_count)
+ while (cleanup->undo_group_count < gimp_image_get_undo_group_count (image))
{
if (! gimp_image_undo_group_end (image))
break;
diff --git a/app/tools/gimprectangleselecttool.c b/app/tools/gimprectangleselecttool.c
index 8d49ec5..e2be2d5 100644
--- a/app/tools/gimprectangleselecttool.c
+++ b/app/tools/gimprectangleselecttool.c
@@ -430,11 +430,13 @@ gimp_rectangle_select_tool_button_press (GimpTool *tool,
}
else
{
- GimpImage *image = gimp_display_get_image (tool->display);
+ GimpImage *image = gimp_display_get_image (tool->display);
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
GimpUndo *undo;
GimpChannelOps operation;
- undo = gimp_undo_stack_peek (image->undo_stack);
+ undo = gimp_undo_stack_peek (undo_stack);
if (undo && priv->undo == undo)
{
@@ -446,7 +448,7 @@ gimp_rectangle_select_tool_button_press (GimpTool *tool,
gimp_tool_control_set_preserve (tool->control, FALSE);
/* we will need to redo if the user cancels or executes */
- priv->redo = gimp_undo_stack_peek (image->redo_stack);
+ priv->redo = gimp_undo_stack_peek (redo_stack);
}
/* if the operation is "Replace", turn off the marching ants,
@@ -487,7 +489,8 @@ gimp_rectangle_select_tool_button_release (GimpTool *tool,
*/
if (release_type == GIMP_BUTTON_RELEASE_CLICK)
{
- GimpUndo *redo = gimp_undo_stack_peek (image->redo_stack);
+ GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
+ GimpUndo *redo = gimp_undo_stack_peek (redo_stack);
if (redo && priv->redo == redo)
{
@@ -847,15 +850,14 @@ gimp_rectangle_select_tool_cancel (GimpRectangleTool *rectangle)
if (tool->display)
{
- GimpImage *image = gimp_display_get_image (tool->display);
- GimpUndo *undo;
+ GimpImage *image = gimp_display_get_image (tool->display);
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndo *undo = gimp_undo_stack_peek (undo_stack);
/* if we have an existing rectangle in the current display, then
* we have already "executed", and need to undo at this point,
* unless the user has done something in the meantime
*/
- undo = gimp_undo_stack_peek (image->undo_stack);
-
if (undo && priv->undo == undo)
{
/* prevent this change from halting the tool */
@@ -890,16 +892,15 @@ gimp_rectangle_select_tool_rectangle_change_complete (GimpRectangleTool *rectang
if (tool->display && ! gimp_tool_control_is_active (tool->control))
{
- GimpImage *image = gimp_display_get_image (tool->display);
- GimpUndo *undo;
- gint x1, y1, x2, y2;
+ GimpImage *image = gimp_display_get_image (tool->display);
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndo *undo = gimp_undo_stack_peek (undo_stack);
+ gint x1, y1, x2, y2;
/* if we got here via button release, we have already undone the
* previous operation. But if we got here by some other means,
* we need to undo it now.
*/
- undo = gimp_undo_stack_peek (image->undo_stack);
-
if (undo && priv->undo == undo)
{
gimp_image_undo (image);
@@ -918,7 +919,7 @@ gimp_rectangle_select_tool_rectangle_change_complete (GimpRectangleTool *rectang
/* save the undo that we got when executing, but only if
* we actually selected something
*/
- priv->undo = gimp_undo_stack_peek (image->undo_stack);
+ priv->undo = gimp_undo_stack_peek (undo_stack);
priv->redo = NULL;
}
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index 6e16318..228b17b 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -33,6 +33,7 @@
#include "core/gimpcontext.h"
#include "core/gimpchannel-select.h"
#include "core/gimpimage.h"
+#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimplist.h"
#include "core/gimpprogress.h"
@@ -662,7 +663,7 @@ gimp_vector_tool_button_release (GimpTool *tool,
GimpUndo *undo;
GimpUndoAccumulator accum = { 0, };
- undo = gimp_undo_stack_pop_undo (image->undo_stack,
+ undo = gimp_undo_stack_pop_undo (gimp_image_get_undo_stack (image),
GIMP_UNDO_MODE_UNDO, &accum);
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_EXPIRED, undo);
diff --git a/app/widgets/gimpimagepropview.c b/app/widgets/gimpimagepropview.c
index 34c1ba3..ecd9ca9 100644
--- a/app/widgets/gimpimagepropview.c
+++ b/app/widgets/gimpimagepropview.c
@@ -40,6 +40,7 @@
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
+#include "core/gimpimage-undo.h"
#include "core/gimpundostack.h"
#include "core/gimpunit.h"
#include "core/gimp-utils.h"
@@ -502,8 +503,10 @@ gimp_image_prop_view_update (GimpImagePropView *view)
GIMP_OBJECT (image));
/* undo / redo */
- gimp_image_prop_view_label_set_undo (view->undo_label, image->undo_stack);
- gimp_image_prop_view_label_set_undo (view->redo_label, image->redo_stack);
+ gimp_image_prop_view_label_set_undo (view->undo_label,
+ gimp_image_get_undo_stack (image));
+ gimp_image_prop_view_label_set_undo (view->redo_label,
+ gimp_image_get_redo_stack (image));
/* number of layers */
g_snprintf (buf, sizeof (buf), "%d",
diff --git a/app/widgets/gimpundoeditor.c b/app/widgets/gimpundoeditor.c
index e6da473..10bd21a 100644
--- a/app/widgets/gimpundoeditor.c
+++ b/app/widgets/gimpundoeditor.c
@@ -257,11 +257,11 @@ gimp_undo_editor_new (GimpCoreConfig *config,
static void
gimp_undo_editor_fill (GimpUndoEditor *editor)
{
- GimpImage *image;
- GimpUndo *top_undo_item;
- GList *list;
-
- image = GIMP_IMAGE_EDITOR (editor)->image;
+ GimpImage *image = GIMP_IMAGE_EDITOR (editor)->image;
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
+ GimpUndo *top_undo_item;
+ GList *list;
/* create a container as model for the undo history list */
editor->container = gimp_list_new (GIMP_TYPE_UNDO, FALSE);
@@ -271,7 +271,7 @@ gimp_undo_editor_fill (GimpUndoEditor *editor)
NULL);
/* the list prepends its items, so first add the redo items... */
- for (list = GIMP_LIST (image->redo_stack->undos)->list;
+ for (list = GIMP_LIST (redo_stack->undos)->list;
list;
list = g_list_next (list))
{
@@ -282,7 +282,7 @@ gimp_undo_editor_fill (GimpUndoEditor *editor)
gimp_list_reverse (GIMP_LIST (editor->container));
/* ...then add the undo items in descending order... */
- for (list = GIMP_LIST (image->undo_stack->undos)->list;
+ for (list = GIMP_LIST (undo_stack->undos)->list;
list;
list = g_list_next (list))
{
@@ -290,7 +290,7 @@ gimp_undo_editor_fill (GimpUndoEditor *editor)
* it will be added upon closing of the group.
*/
if (list->prev || ! GIMP_IS_UNDO_STACK (list->data) ||
- image->pushing_undo_group == GIMP_UNDO_GROUP_NONE)
+ gimp_image_get_undo_group_count (image) == 0)
{
gimp_container_add (editor->container, GIMP_OBJECT (list->data));
}
@@ -305,7 +305,7 @@ gimp_undo_editor_fill (GimpUndoEditor *editor)
gimp_container_view_set_container (GIMP_CONTAINER_VIEW (editor->view),
editor->container);
- top_undo_item = gimp_undo_stack_peek (image->undo_stack);
+ top_undo_item = gimp_undo_stack_peek (undo_stack);
g_signal_handlers_block_by_func (editor->view,
gimp_undo_editor_select_item,
@@ -354,7 +354,8 @@ gimp_undo_editor_undo_event (GimpImage *image,
GimpUndo *undo,
GimpUndoEditor *editor)
{
- GimpUndo *top_undo_item = gimp_undo_stack_peek (image->undo_stack);
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndo *top_undo_item = gimp_undo_stack_peek (undo_stack);
switch (event)
{
@@ -423,15 +424,15 @@ gimp_undo_editor_select_item (GimpContainerView *view,
gpointer insert_data,
GimpUndoEditor *editor)
{
- GimpImage *image;
- GimpUndo *top_undo_item;
+ GimpImage *image = GIMP_IMAGE_EDITOR (editor)->image;
+ GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
+ GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
+ GimpUndo *top_undo_item;
if (! undo)
return;
- image = GIMP_IMAGE_EDITOR (editor)->image;
-
- top_undo_item = gimp_undo_stack_peek (image->undo_stack);
+ top_undo_item = gimp_undo_stack_peek (undo_stack);
if (undo == editor->base_item)
{
@@ -441,10 +442,10 @@ gimp_undo_editor_select_item (GimpContainerView *view,
{
gimp_image_undo (image);
- top_undo_item = gimp_undo_stack_peek (image->undo_stack);
+ top_undo_item = gimp_undo_stack_peek (undo_stack);
}
}
- else if (gimp_container_have (image->undo_stack->undos, GIMP_OBJECT (undo)))
+ else if (gimp_container_have (undo_stack->undos, GIMP_OBJECT (undo)))
{
/* the selected item is on the undo stack, pop undos until it
* is on top of the undo stack
@@ -453,10 +454,10 @@ gimp_undo_editor_select_item (GimpContainerView *view,
{
gimp_image_undo (image);
- top_undo_item = gimp_undo_stack_peek (image->undo_stack);
+ top_undo_item = gimp_undo_stack_peek (undo_stack);
}
}
- else if (gimp_container_have (image->redo_stack->undos, GIMP_OBJECT (undo)))
+ else if (gimp_container_have (redo_stack->undos, GIMP_OBJECT (undo)))
{
/* the selected item is on the redo stack, pop redos until it
* is on top of the undo stack
@@ -465,7 +466,7 @@ gimp_undo_editor_select_item (GimpContainerView *view,
{
gimp_image_redo (image);
- top_undo_item = gimp_undo_stack_peek (image->undo_stack);
+ top_undo_item = gimp_undo_stack_peek (undo_stack);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]