Move the undo disable/freeze APIs to gimpimage-undo.[ch]

This commit is contained in:
Michael Natterer
2010-02-08 11:11:33 +01:00
parent 052dcd0164
commit 9a561646c2
8 changed files with 80 additions and 76 deletions

View File

@ -34,6 +34,7 @@
#include "gimpimage-grid.h"
#include "gimpimage-guides.h"
#include "gimpimage-private.h"
#include "gimpimage-undo.h"
#include "gimpimage-sample-points.h"
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"

View File

@ -48,6 +48,69 @@ static GimpDirtyMask gimp_image_undo_dirty_from_type (GimpUndoType undo_type);
/* public functions */
gboolean
gimp_image_undo_is_enabled (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
return (GIMP_IMAGE_GET_PRIVATE (image)->undo_freeze_count == 0);
}
gboolean
gimp_image_undo_enable (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
/* Free all undo steps as they are now invalidated */
gimp_image_undo_free (image);
return gimp_image_undo_thaw (image);
}
gboolean
gimp_image_undo_disable (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
return gimp_image_undo_freeze (image);
}
gboolean
gimp_image_undo_freeze (GimpImage *image)
{
GimpImagePrivate *private;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
private = GIMP_IMAGE_GET_PRIVATE (image);
private->undo_freeze_count++;
if (private->undo_freeze_count == 1)
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_FREEZE, NULL);
return TRUE;
}
gboolean
gimp_image_undo_thaw (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->undo_freeze_count > 0, FALSE);
private->undo_freeze_count--;
if (private->undo_freeze_count == 0)
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_THAW, NULL);
return TRUE;
}
gboolean
gimp_image_undo (GimpImage *image)
{

View File

@ -19,6 +19,12 @@
#define __GIMP_IMAGE__UNDO_H__
gboolean gimp_image_undo_is_enabled (const GimpImage *image);
gboolean gimp_image_undo_enable (GimpImage *image);
gboolean gimp_image_undo_disable (GimpImage *image);
gboolean gimp_image_undo_freeze (GimpImage *image);
gboolean gimp_image_undo_thaw (GimpImage *image);
gboolean gimp_image_undo (GimpImage *image);
gboolean gimp_image_redo (GimpImage *image);

View File

@ -2087,72 +2087,6 @@ gimp_image_quick_mask_changed (GimpImage *image)
g_signal_emit (image, gimp_image_signals[QUICK_MASK_CHANGED], 0);
}
/* undo */
gboolean
gimp_image_undo_is_enabled (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
return (GIMP_IMAGE_GET_PRIVATE (image)->undo_freeze_count == 0);
}
gboolean
gimp_image_undo_enable (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
/* Free all undo steps as they are now invalidated */
gimp_image_undo_free (image);
return gimp_image_undo_thaw (image);
}
gboolean
gimp_image_undo_disable (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
return gimp_image_undo_freeze (image);
}
gboolean
gimp_image_undo_freeze (GimpImage *image)
{
GimpImagePrivate *private;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
private = GIMP_IMAGE_GET_PRIVATE (image);
private->undo_freeze_count++;
if (private->undo_freeze_count == 1)
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_FREEZE, NULL);
return TRUE;
}
gboolean
gimp_image_undo_thaw (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->undo_freeze_count > 0, FALSE);
private->undo_freeze_count--;
if (private->undo_freeze_count == 0)
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_THAW, NULL);
return TRUE;
}
void
gimp_image_undo_event (GimpImage *image,
GimpUndoEvent event,
@ -2168,6 +2102,8 @@ gimp_image_undo_event (GimpImage *image,
}
/* dirty counters */
/* NOTE about the image->dirty counter:
* If 0, then the image is clean (ie, copy on disk is the same as the one
* in memory).
@ -2305,7 +2241,6 @@ gimp_image_get_dirty_time (const GimpImage *image)
return GIMP_IMAGE_GET_PRIVATE (image)->dirty_time;
}
/**
* gimp_image_saved:
* @image:
@ -2342,6 +2277,7 @@ gimp_image_exported (GimpImage *image,
g_signal_emit (image, gimp_image_signals[EXPORTED], 0, uri);
}
/* flush this image's displays */
void

View File

@ -265,18 +265,13 @@ void gimp_image_size_changed_detailed (GimpImage *image,
gint previous_origin_y,
gint previous_width,
gint previous_height);
/* undo */
gboolean gimp_image_undo_is_enabled (const GimpImage *image);
gboolean gimp_image_undo_enable (GimpImage *image);
gboolean gimp_image_undo_disable (GimpImage *image);
gboolean gimp_image_undo_freeze (GimpImage *image);
gboolean gimp_image_undo_thaw (GimpImage *image);
void gimp_image_undo_event (GimpImage *image,
GimpUndoEvent event,
GimpUndo *undo);
/* dirty counters */
gint gimp_image_dirty (GimpImage *image,
GimpDirtyMask dirty_mask);
gint gimp_image_clean (GimpImage *image,

View File

@ -32,6 +32,7 @@
#include "gimp.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimplayer.h"
#include "gimpprojection.h"
#include "gimptemplate.h"

View File

@ -33,6 +33,7 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimpimage-undo.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimptoolinfo.h"

View File

@ -44,6 +44,7 @@
#include "core/gimpimage-guides.h"
#include "core/gimpimage-private.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpimage-undo.h"
#include "core/gimpitemstack.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"