1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an 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 2 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, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-06-08 06:51:23 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
#include "tools/tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
#include "base/tile.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "gimp-parasites.h"
|
|
|
|
#include "gimp.h"
|
|
|
|
#include "gimpchannel.h"
|
|
|
|
#include "gimpcontext.h"
|
|
|
|
#include "gimpimage-guides.h"
|
|
|
|
#include "gimpimage-mask.h"
|
|
|
|
#include "gimpimage-projection.h"
|
|
|
|
#include "gimpimage-undo.h"
|
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimplayer-floating-sel.h"
|
|
|
|
#include "gimplayer.h"
|
|
|
|
#include "gimplayermask.h"
|
|
|
|
#include "gimplist.h"
|
|
|
|
#include "gimpparasitelist.h"
|
|
|
|
#include "gimpundo.h"
|
|
|
|
#include "gimpundostack.h"
|
2003-02-13 01:11:34 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint/gimppaintcore.h"
|
|
|
|
|
2003-02-01 02:08:32 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
|
|
|
|
2000-02-16 21:52:33 +08:00
|
|
|
#include "path_transform.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1999-04-23 14:07:09 +08:00
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/****************/
|
|
|
|
/* Image Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/****************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
typedef struct _ImageUndo ImageUndo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
struct _ImageUndo
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
TileManager *tiles;
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable;
|
2000-05-27 06:28:40 +08:00
|
|
|
gint x1, y1, x2, y2;
|
2000-06-08 06:51:23 +08:00
|
|
|
gboolean sparse;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_image (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_image (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2)
|
2000-05-27 06:28:40 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
x1 = CLAMP (x1, 0, gimp_drawable_width (drawable));
|
|
|
|
y1 = CLAMP (y1, 0, gimp_drawable_height (drawable));
|
|
|
|
x2 = CLAMP (x2, 0, gimp_drawable_width (drawable));
|
|
|
|
y2 = CLAMP (y2, 0, gimp_drawable_height (drawable));
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ImageUndo) + ((x2 - x1) * (y2 - y1) *
|
|
|
|
gimp_drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size, sizeof (ImageUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image,
|
|
|
|
undo_free_image)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ImageUndo *image_undo;
|
|
|
|
TileManager *tiles;
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
image_undo = new->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-28 02:47:48 +08:00
|
|
|
/* If we cannot create a new temp buf -- either because our
|
|
|
|
* parameters are degenerate or something else failed, simply
|
|
|
|
* return an unsuccessful push.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2001-01-15 05:11:52 +08:00
|
|
|
tiles = tile_manager_new ((x2 - x1), (y2 - y1),
|
|
|
|
gimp_drawable_bytes (drawable));
|
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
2000-05-27 06:28:40 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
|
|
|
pixel_region_init (&destPR, tiles,
|
|
|
|
0, 0, (x2 - x1), (y2 - y1), TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
|
|
|
|
/* set the image undo structure */
|
2002-02-24 01:29:19 +08:00
|
|
|
image_undo->tiles = tiles;
|
1998-01-22 15:02:57 +08:00
|
|
|
image_undo->drawable = drawable;
|
2002-02-24 01:29:19 +08:00
|
|
|
image_undo->x1 = x1;
|
|
|
|
image_undo->y1 = y1;
|
|
|
|
image_undo->x2 = x2;
|
|
|
|
image_undo->y2 = y2;
|
|
|
|
image_undo->sparse = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_mod (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
TileManager *tiles,
|
|
|
|
gboolean sparse)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
|
|
|
gint dwidth, dheight;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
g_return_val_if_fail (tiles != NULL, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
dwidth = gimp_drawable_width (drawable);
|
|
|
|
dheight = gimp_drawable_height (drawable);
|
1998-07-25 02:52:03 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
x1 = CLAMP (x1, 0, dwidth);
|
|
|
|
y1 = CLAMP (y1, 0, dheight);
|
|
|
|
x2 = CLAMP (x2, 0, dwidth);
|
|
|
|
y2 = CLAMP (y2, 0, dheight);
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ImageUndo) + tile_manager_get_memsize (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size, sizeof (ImageUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE_MOD, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image,
|
|
|
|
undo_free_image)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ImageUndo *image_undo;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
image_undo = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-06-08 06:51:23 +08:00
|
|
|
image_undo->tiles = tiles;
|
1998-01-22 15:02:57 +08:00
|
|
|
image_undo->drawable = drawable;
|
2000-06-08 06:51:23 +08:00
|
|
|
image_undo->x1 = x1;
|
|
|
|
image_undo->y1 = y1;
|
|
|
|
image_undo->x2 = x2;
|
|
|
|
image_undo->y2 = y2;
|
|
|
|
image_undo->sparse = sparse;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_image (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
ImageUndo *image_undo;
|
1997-11-25 06:05:25 +08:00
|
|
|
TileManager *tiles;
|
2000-05-27 06:28:40 +08:00
|
|
|
PixelRegion PR1, PR2;
|
2003-02-13 01:11:34 +08:00
|
|
|
gint x, y;
|
|
|
|
gint w, h;
|
|
|
|
|
|
|
|
image_undo = (ImageUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tiles = image_undo->tiles;
|
|
|
|
|
|
|
|
/* some useful values */
|
|
|
|
x = image_undo->x1;
|
|
|
|
y = image_undo->y1;
|
|
|
|
|
|
|
|
if (image_undo->sparse == FALSE)
|
|
|
|
{
|
2001-01-23 21:01:48 +08:00
|
|
|
w = tile_manager_width (tiles);
|
|
|
|
h = tile_manager_height (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
pixel_region_init (&PR1, tiles,
|
|
|
|
0, 0, w, h, TRUE);
|
2001-01-15 05:11:52 +08:00
|
|
|
pixel_region_init (&PR2, gimp_drawable_data (image_undo->drawable),
|
2000-05-27 06:28:40 +08:00
|
|
|
x, y, w, h, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* swap the regions */
|
|
|
|
swap_region (&PR1, &PR2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
Tile *src_tile;
|
|
|
|
Tile *dest_tile;
|
|
|
|
|
|
|
|
w = image_undo->x2 - image_undo->x1;
|
|
|
|
h = image_undo->y2 - image_undo->y1;
|
|
|
|
|
|
|
|
for (i = y; i < image_undo->y2; i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
|
|
|
|
{
|
|
|
|
for (j = x; j < image_undo->x2; j += (TILE_WIDTH - (j % TILE_WIDTH)))
|
|
|
|
{
|
1998-08-16 03:17:36 +08:00
|
|
|
src_tile = tile_manager_get_tile (tiles, j, i, FALSE, FALSE);
|
1998-08-12 01:35:34 +08:00
|
|
|
if (tile_is_valid (src_tile) == TRUE)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-08-12 01:35:34 +08:00
|
|
|
/* swap tiles, not pixels! */
|
|
|
|
|
2003-02-28 02:47:48 +08:00
|
|
|
src_tile = tile_manager_get_tile (tiles,
|
|
|
|
j, i, TRUE, FALSE /*TRUE*/);
|
2001-01-15 05:11:52 +08:00
|
|
|
dest_tile = tile_manager_get_tile (gimp_drawable_data (image_undo->drawable), j, i, TRUE, FALSE /* TRUE */);
|
1998-08-12 01:35:34 +08:00
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
tile_manager_map_tile (tiles, j, i, dest_tile);
|
2001-01-15 05:11:52 +08:00
|
|
|
tile_manager_map_tile (gimp_drawable_data (image_undo->drawable), j, i, src_tile);
|
1998-08-12 01:35:34 +08:00
|
|
|
#if 0
|
|
|
|
swap_pixels (tile_data_pointer (src_tile, 0, 0),
|
|
|
|
tile_data_pointer (dest_tile, 0, 0),
|
|
|
|
tile_size (src_tile));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tile_release (dest_tile, FALSE /* TRUE */);
|
|
|
|
tile_release (src_tile, FALSE /* TRUE */);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (image_undo->drawable, x, y, w, h);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_image (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ImageUndo *image_undo;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
image_undo = (ImageUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tile_manager_destroy (image_undo->tiles);
|
|
|
|
g_free (image_undo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
/*********************/
|
|
|
|
/* Image Type Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/*********************/
|
2002-02-24 02:29:07 +08:00
|
|
|
|
|
|
|
typedef struct _ImageTypeUndo ImageTypeUndo;
|
|
|
|
|
|
|
|
struct _ImageTypeUndo
|
|
|
|
{
|
|
|
|
GimpImageBaseType base_type;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_image_type (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_image_type (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 02:29:07 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_type (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc)
|
2002-02-24 02:29:07 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-24 02:29:07 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ImageTypeUndo),
|
|
|
|
sizeof (ImageTypeUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE_TYPE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image_type,
|
|
|
|
undo_free_image_type)))
|
2002-02-24 02:29:07 +08:00
|
|
|
{
|
|
|
|
ImageTypeUndo *itu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
itu = new->data;
|
2002-02-24 02:29:07 +08:00
|
|
|
|
|
|
|
itu->base_type = gimage->base_type;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_image_type (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 02:29:07 +08:00
|
|
|
{
|
|
|
|
ImageTypeUndo *itu;
|
|
|
|
GimpImageBaseType tmp;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
itu = (ImageTypeUndo *) undo->data;
|
2002-02-24 02:29:07 +08:00
|
|
|
|
|
|
|
tmp = itu->base_type;
|
2003-02-20 20:47:42 +08:00
|
|
|
itu->base_type = undo->gimage->base_type;
|
|
|
|
undo->gimage->base_type = tmp;
|
2002-02-24 02:29:07 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_projection_allocate (undo->gimage);
|
|
|
|
gimp_image_colormap_changed (undo->gimage, -1);
|
2002-02-24 02:29:07 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (itu->base_type != undo->gimage->base_type)
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->mode_changed = TRUE;
|
2002-02-24 02:29:07 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_image_type (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-24 02:29:07 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-24 02:29:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/*********************/
|
|
|
|
/* Image Size Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/*********************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _ImageSizeUndo ImageSizeUndo;
|
|
|
|
|
|
|
|
struct _ImageSizeUndo
|
|
|
|
{
|
2002-02-24 02:29:07 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
2002-02-24 01:29:19 +08:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_image_size (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_image_size (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_size (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ImageSizeUndo),
|
|
|
|
sizeof (ImageSizeUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE_SIZE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image_size,
|
|
|
|
undo_free_image_size)))
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
ImageSizeUndo *isu;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
isu = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
isu->width = gimage->width;
|
|
|
|
isu->height = gimage->height;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_image_size (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2002-02-24 02:29:07 +08:00
|
|
|
ImageSizeUndo *isu;
|
2003-02-13 01:11:34 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
isu = (ImageSizeUndo *) undo->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
width = isu->width;
|
|
|
|
height = isu->height;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
isu->width = undo->gimage->width;
|
|
|
|
isu->height = undo->gimage->height;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
undo->gimage->width = width;
|
|
|
|
undo->gimage->height = height;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_projection_allocate (undo->gimage);
|
|
|
|
gimp_image_mask_invalidate (undo->gimage);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (undo->gimage->width != isu->width ||
|
|
|
|
undo->gimage->height != isu->height)
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->size_changed = TRUE;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_image_size (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* Image Resolution Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/***************************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _ResolutionUndo ResolutionUndo;
|
|
|
|
|
|
|
|
struct _ResolutionUndo
|
|
|
|
{
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
GimpUnit unit;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_image_resolution (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_image_resolution (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_resolution (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ResolutionUndo),
|
|
|
|
sizeof (ResolutionUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE_RESOLUTION, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image_resolution,
|
|
|
|
undo_free_image_resolution)))
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
ResolutionUndo *ru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ru = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
ru->xres = gimage->xresolution;
|
|
|
|
ru->yres = gimage->yresolution;
|
|
|
|
ru->unit = gimage->unit;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_image_resolution (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
ResolutionUndo *ru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ru = (ResolutionUndo *) undo->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (ABS (ru->xres - undo->gimage->xresolution) >= 1e-5 ||
|
|
|
|
ABS (ru->yres - undo->gimage->yresolution) >= 1e-5)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
xres = undo->gimage->xresolution;
|
|
|
|
yres = undo->gimage->yresolution;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
undo->gimage->xresolution = ru->xres;
|
|
|
|
undo->gimage->yresolution = ru->yres;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ru->xres = xres;
|
|
|
|
ru->yres = yres;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->resolution_changed = TRUE;
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (ru->unit != undo->gimage->unit)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUnit unit;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
unit = undo->gimage->unit;
|
|
|
|
undo->gimage->unit = ru->unit;
|
2003-02-13 01:11:34 +08:00
|
|
|
ru->unit = unit;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->unit_changed = TRUE;
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_image_resolution (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************/
|
|
|
|
/* Qmask Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/****************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _QmaskUndo QmaskUndo;
|
1999-10-19 04:55:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _QmaskUndo
|
1999-10-19 04:55:25 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
gboolean qmask_state;
|
1999-10-19 04:55:25 +08:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_image_qmask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_image_qmask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_qmask (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (QmaskUndo),
|
|
|
|
sizeof (QmaskUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE_QMASK, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image_qmask,
|
|
|
|
undo_free_image_qmask)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
QmaskUndo *qu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
qu = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
qu->qmask_state = gimage->qmask_state;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_image_qmask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
QmaskUndo *qu;
|
2002-08-20 18:22:23 +08:00
|
|
|
gboolean tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
qu = (QmaskUndo *) undo->data;
|
|
|
|
|
|
|
|
tmp = undo->gimage->qmask_state;
|
|
|
|
undo->gimage->qmask_state = qu->qmask_state;
|
|
|
|
qu->qmask_state = tmp;
|
2000-05-27 06:28:40 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->qmask_changed = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-20 20:47:42 +08:00
|
|
|
undo_free_image_qmask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
1999-10-19 04:55:25 +08:00
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/****************/
|
|
|
|
/* Guide Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/****************/
|
1999-10-19 04:55:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _GuideUndo GuideUndo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _GuideUndo
|
|
|
|
{
|
|
|
|
GimpGuide *guide;
|
|
|
|
GimpGuide orig;
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_image_guide (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_image_guide (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_guide (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpGuide *guide)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (guide != NULL, FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (GuideUndo),
|
|
|
|
sizeof (GuideUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_IMAGE_GUIDE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_image_guide,
|
|
|
|
undo_free_image_guide)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GuideUndo *gu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
gu = new->data;
|
2001-02-14 12:55:21 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
guide->ref_count++;
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gu->guide = guide;
|
|
|
|
gu->orig = *guide;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_image_guide (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
GuideUndo *gu;
|
2003-02-14 22:14:29 +08:00
|
|
|
GimpGuide tmp_guide;
|
2002-02-24 01:29:19 +08:00
|
|
|
gint tmp_ref;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gu = (GuideUndo *) undo->data;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_update_guide (undo->gimage, gu->guide);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
tmp_ref = gu->guide->ref_count;
|
|
|
|
tmp_guide = *(gu->guide);
|
2003-02-14 22:14:29 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
*(gu->guide) = gu->orig;
|
2003-02-14 22:14:29 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gu->guide->ref_count = tmp_ref;
|
|
|
|
gu->orig = tmp_guide;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_update_guide (undo->gimage, gu->guide);
|
2001-03-31 22:47:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-20 20:47:42 +08:00
|
|
|
undo_free_image_guide (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
GuideUndo *gu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gu = (GuideUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gu->guide->ref_count--;
|
|
|
|
if (gu->guide->position < 0 && gu->guide->ref_count <= 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_remove_guide (undo->gimage, gu->guide);
|
|
|
|
g_free (gu->guide);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-02-20 20:47:42 +08:00
|
|
|
g_free (gu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2002-08-20 18:22:23 +08:00
|
|
|
/***************/
|
|
|
|
/* Mask Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/***************/
|
2002-08-20 18:22:23 +08:00
|
|
|
|
|
|
|
typedef struct _MaskUndo MaskUndo;
|
|
|
|
|
|
|
|
struct _MaskUndo
|
|
|
|
{
|
|
|
|
GimpChannel *channel; /* the channel this undo is for */
|
|
|
|
TileManager *tiles; /* the actual mask */
|
|
|
|
gint x, y; /* offsets */
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-08-20 18:22:23 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_mask (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *mask)
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
|
|
|
TileManager *undo_tiles;
|
|
|
|
gint x1, y1, x2, y2;
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-08-20 18:22:23 +08:00
|
|
|
gsize size;
|
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CHANNEL (mask), FALSE);
|
|
|
|
|
2002-08-20 18:22:23 +08:00
|
|
|
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
|
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
|
|
|
|
undo_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
|
|
|
|
|
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles,
|
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
|
|
|
pixel_region_init (&destPR, undo_tiles,
|
|
|
|
0, 0, (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
undo_tiles = NULL;
|
|
|
|
|
|
|
|
size = sizeof (MaskUndo);
|
|
|
|
|
|
|
|
if (undo_tiles)
|
|
|
|
size += tile_manager_get_memsize (undo_tiles);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size, sizeof (MaskUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_MASK, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
FALSE,
|
|
|
|
undo_pop_mask,
|
|
|
|
undo_free_mask)))
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
MaskUndo *mu;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
mu = new->data;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
mu->channel = mask;
|
|
|
|
mu->tiles = undo_tiles;
|
|
|
|
mu->x = x1;
|
|
|
|
mu->y = y1;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (undo_tiles)
|
|
|
|
tile_manager_destroy (undo_tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
MaskUndo *mu;
|
2002-08-20 18:22:23 +08:00
|
|
|
TileManager *new_tiles;
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint width, height;
|
|
|
|
guchar empty = 0;
|
|
|
|
|
|
|
|
width = height = 0;
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
mu = (MaskUndo *) undo->data;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (gimp_channel_bounds (mu->channel, &x1, &y1, &x2, &y2))
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
|
|
|
new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (mu->channel)->tiles,
|
2002-08-20 18:22:23 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
|
|
|
pixel_region_init (&destPR, new_tiles,
|
|
|
|
0, 0, (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (mu->channel)->tiles,
|
2002-08-20 18:22:23 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
|
|
|
|
color_region (&srcPR, &empty);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new_tiles = NULL;
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (mu->tiles)
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
width = tile_manager_width (mu->tiles);
|
|
|
|
height = tile_manager_height (mu->tiles);
|
2002-08-20 18:22:23 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
pixel_region_init (&srcPR, mu->tiles,
|
2002-08-20 18:22:23 +08:00
|
|
|
0, 0, width, height, FALSE);
|
2003-02-20 20:47:42 +08:00
|
|
|
pixel_region_init (&destPR, GIMP_DRAWABLE (mu->channel)->tiles,
|
|
|
|
mu->x, mu->y, width, height, TRUE);
|
2002-08-20 18:22:23 +08:00
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
tile_manager_destroy (mu->tiles);
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (mu->channel == gimp_image_get_mask (undo->gimage))
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
|
|
|
/* invalidate the current bounds and boundary of the mask */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_mask_invalidate (undo->gimage);
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
mu->channel->boundary_known = FALSE;
|
|
|
|
GIMP_DRAWABLE (mu->channel)->preview_valid = FALSE;
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (mu->tiles)
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
mu->channel->empty = FALSE;
|
|
|
|
mu->channel->x1 = mu->x;
|
|
|
|
mu->channel->y1 = mu->y;
|
|
|
|
mu->channel->x2 = mu->x + width;
|
|
|
|
mu->channel->y2 = mu->y + height;
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
mu->channel->empty = TRUE;
|
|
|
|
mu->channel->x1 = 0;
|
|
|
|
mu->channel->y1 = 0;
|
|
|
|
mu->channel->x2 = GIMP_DRAWABLE (mu->channel)->width;
|
|
|
|
mu->channel->y2 = GIMP_DRAWABLE (mu->channel)->height;
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we know the bounds */
|
2003-02-20 20:47:42 +08:00
|
|
|
mu->channel->bounds_known = TRUE;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
|
|
|
/* set the new mask undo parameters */
|
2003-02-20 20:47:42 +08:00
|
|
|
mu->tiles = new_tiles;
|
|
|
|
mu->x = x1;
|
|
|
|
mu->y = y1;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (mu->channel == gimp_image_get_mask (undo->gimage))
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->mask_changed = TRUE;
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (mu->channel),
|
2002-08-20 18:22:23 +08:00
|
|
|
0, 0,
|
2003-02-20 20:47:42 +08:00
|
|
|
GIMP_DRAWABLE (mu->channel)->width,
|
|
|
|
GIMP_DRAWABLE (mu->channel)->height);
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-08-20 18:22:23 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
MaskUndo *mu;
|
|
|
|
|
|
|
|
mu = (MaskUndo *) undo->data;
|
2002-08-20 18:22:23 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (mu->tiles)
|
|
|
|
tile_manager_destroy (mu->tiles);
|
2003-02-13 01:11:34 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
g_free (mu);
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/**********************/
|
|
|
|
/* Item Rename Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/**********************/
|
2002-02-26 08:04:55 +08:00
|
|
|
|
|
|
|
typedef struct _ItemRenameUndo ItemRenameUndo;
|
|
|
|
|
|
|
|
struct _ItemRenameUndo
|
|
|
|
{
|
|
|
|
GimpItem *item;
|
|
|
|
gchar *old_name;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_item_rename (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_item_rename (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-26 08:04:55 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_item_rename (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpItem *item)
|
2002-02-26 08:04:55 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ItemRenameUndo),
|
|
|
|
sizeof (ItemRenameUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_ITEM_RENAME, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_item_rename,
|
|
|
|
undo_free_item_rename)))
|
2002-02-26 08:04:55 +08:00
|
|
|
{
|
|
|
|
ItemRenameUndo *iru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
iru = new->data;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
|
|
|
iru->item = item;
|
|
|
|
iru->old_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_item_rename (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-26 08:04:55 +08:00
|
|
|
{
|
|
|
|
ItemRenameUndo *iru;
|
|
|
|
gchar *tmp;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
iru = (ItemRenameUndo *) undo->data;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
|
|
|
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (iru->item)));
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (iru->item), iru->old_name);
|
|
|
|
g_free (iru->old_name);
|
|
|
|
iru->old_name = tmp;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_item_rename (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-26 08:04:55 +08:00
|
|
|
{
|
|
|
|
ItemRenameUndo *iru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
iru = (ItemRenameUndo *) undo->data;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
|
|
|
g_free (iru->old_name);
|
|
|
|
g_free (iru);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/***************************/
|
|
|
|
/* Layer Add/Remove Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/***************************/
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _LayerUndo LayerUndo;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _LayerUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer; /* the actual layer */
|
|
|
|
gint prev_position; /* former position in list */
|
|
|
|
GimpLayer *prev_layer; /* previous active layer */
|
|
|
|
};
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_push_layer (GimpImage *gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
const gchar *undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndoType type,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer);
|
|
|
|
static gboolean undo_pop_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
1998-06-06 11:49:01 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_add (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_layer (gimage, undo_desc, GIMP_UNDO_LAYER_ADD,
|
2002-02-24 01:29:19 +08:00
|
|
|
layer, prev_position, prev_layer);
|
2001-03-11 21:15:41 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_remove (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_layer (gimage, undo_desc, GIMP_UNDO_LAYER_REMOVE,
|
2002-02-24 01:29:19 +08:00
|
|
|
layer, prev_position, prev_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_push_layer (GimpImage *gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
const gchar *undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndoType type,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
g_return_val_if_fail (prev_layer == NULL || GIMP_IS_LAYER (prev_layer),
|
|
|
|
FALSE);
|
2003-02-13 19:23:50 +08:00
|
|
|
g_return_val_if_fail (type == GIMP_UNDO_LAYER_ADD ||
|
2003-02-14 22:14:29 +08:00
|
|
|
type == GIMP_UNDO_LAYER_REMOVE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size, sizeof (LayerUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
type, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_layer,
|
|
|
|
undo_free_layer)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
LayerUndo *lu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lu = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lu->layer = g_object_ref (layer);
|
2002-02-24 01:29:19 +08:00
|
|
|
lu->prev_position = prev_position;
|
|
|
|
lu->prev_layer = prev_layer;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-29 08:46:04 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerUndo *lu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lu = (LayerUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
if ((undo_mode == GIMP_UNDO_MODE_UNDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_LAYER_ADD) ||
|
|
|
|
(undo_mode == GIMP_UNDO_MODE_REDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_LAYER_REMOVE))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* remove layer */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the current position */
|
2003-02-20 20:47:42 +08:00
|
|
|
lu->prev_position = gimp_image_get_layer_index (undo->gimage, lu->layer);
|
2002-02-26 08:04:55 +08:00
|
|
|
|
2003-02-03 21:45:40 +08:00
|
|
|
/* if exists, set the previous layer */
|
|
|
|
if (lu->prev_layer)
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_layer (undo->gimage, lu->prev_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* remove the layer */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_container_remove (undo->gimage->layers, GIMP_OBJECT (lu->layer));
|
|
|
|
undo->gimage->layer_stack = g_slist_remove (undo->gimage->layer_stack,
|
|
|
|
lu->layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* reset the gimage values */
|
2001-01-29 07:25:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (lu->layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
undo->gimage->floating_sel = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
/* reset the old drawable */
|
|
|
|
floating_sel_reset (lu->layer);
|
2001-05-08 09:32:25 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_floating_selection_changed (undo->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (lu->layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->width,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->height);
|
2002-08-28 22:09:14 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (gimp_container_num_children (undo->gimage->layers) == 1 &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_LIST (undo->gimage->layers)->list->data))
|
2002-08-28 22:09:14 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->alpha_changed = TRUE;
|
2002-08-28 22:09:14 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* restore layer */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the active layer */
|
2003-02-20 20:47:42 +08:00
|
|
|
lu->prev_layer = gimp_image_get_active_layer (undo->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* hide the current selection--for all views */
|
2003-02-20 20:47:42 +08:00
|
|
|
if (gimp_image_get_active_layer (undo->gimage))
|
|
|
|
gimp_layer_invalidate_boundary (gimp_image_get_active_layer (undo->gimage));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* if this is a floating selection, set the fs pointer */
|
2001-01-29 07:25:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (lu->layer))
|
2003-02-20 20:47:42 +08:00
|
|
|
undo->gimage->floating_sel = lu->layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
if (gimp_container_num_children (undo->gimage->layers) == 1 &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_LIST (undo->gimage->layers)->list->data))
|
2002-08-28 22:09:14 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
accum->alpha_changed = TRUE;
|
2002-08-28 22:09:14 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* add the new layer */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_container_insert (undo->gimage->layers,
|
2001-02-19 21:06:09 +08:00
|
|
|
GIMP_OBJECT (lu->layer), lu->prev_position);
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_layer (undo->gimage, lu->layer);
|
1998-09-27 04:07:46 +08:00
|
|
|
|
2001-05-08 09:32:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (lu->layer))
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_floating_selection_changed (undo->gimage);
|
2001-05-08 09:32:25 +08:00
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (lu->layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->width,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerUndo *lu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lu = (LayerUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (lu->layer);
|
2003-02-14 22:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (lu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/********************/
|
|
|
|
/* Layer Mod Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/********************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-29 00:54:11 +08:00
|
|
|
typedef struct _LayerModUndo LayerModUndo;
|
|
|
|
|
|
|
|
struct _LayerModUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
TileManager *tiles;
|
|
|
|
GimpImageType type;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_layer_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_layer_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_mod (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
TileManager *tiles;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
2001-01-23 21:01:48 +08:00
|
|
|
tiles = GIMP_DRAWABLE (layer)->tiles;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (LayerModUndo) + tile_manager_get_memsize (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size, sizeof (LayerModUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_LAYER_MOD, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_layer_mod,
|
|
|
|
undo_free_layer_mod)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
LayerModUndo *lmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lmu = new->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
lmu->layer = layer;
|
|
|
|
lmu->tiles = tiles;
|
|
|
|
lmu->type = GIMP_DRAWABLE (layer)->type;
|
|
|
|
lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_layer_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-01-30 01:27:34 +08:00
|
|
|
LayerModUndo *lmu;
|
|
|
|
GimpImageType layer_type;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
TileManager *tiles;
|
|
|
|
GimpLayer *layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lmu = (LayerModUndo *) undo->data;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
layer = lmu->layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the first update */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_update (undo->gimage,
|
2001-11-01 05:18:57 +08:00
|
|
|
GIMP_DRAWABLE (layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (layer)->width,
|
|
|
|
GIMP_DRAWABLE (layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
tiles = lmu->tiles;
|
2002-02-26 08:04:55 +08:00
|
|
|
layer_type = lmu->type;
|
2003-01-30 01:27:34 +08:00
|
|
|
offset_x = lmu->offset_x;
|
|
|
|
offset_y = lmu->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
lmu->tiles = GIMP_DRAWABLE (layer)->tiles;
|
|
|
|
lmu->type = GIMP_DRAWABLE (layer)->type;
|
|
|
|
lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
2001-11-01 05:18:57 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (layer)->tiles = tiles;
|
2001-01-23 21:01:48 +08:00
|
|
|
GIMP_DRAWABLE (layer)->width = tile_manager_width (tiles);
|
|
|
|
GIMP_DRAWABLE (layer)->height = tile_manager_height (tiles);
|
|
|
|
GIMP_DRAWABLE (layer)->bytes = tile_manager_bpp (tiles);
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (layer)->type = layer_type;
|
2000-12-14 02:53:35 +08:00
|
|
|
GIMP_DRAWABLE (layer)->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type);
|
2001-11-29 00:54:11 +08:00
|
|
|
GIMP_DRAWABLE (layer)->offset_x = offset_x;
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y = offset_y;
|
2003-01-30 01:27:34 +08:00
|
|
|
|
2003-02-03 21:45:40 +08:00
|
|
|
if (layer->mask)
|
1998-01-22 15:02:57 +08:00
|
|
|
{
|
2002-08-20 18:22:23 +08:00
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_x = offset_x;
|
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_y = offset_y;
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
if (GIMP_IMAGE_TYPE_HAS_ALPHA (GIMP_DRAWABLE (layer)->type) !=
|
|
|
|
GIMP_IMAGE_TYPE_HAS_ALPHA (lmu->type) &&
|
2003-02-20 20:47:42 +08:00
|
|
|
undo->gimage->layers->num_children == 1)
|
2001-11-01 05:18:57 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_alpha_changed (undo->gimage);
|
2001-11-01 05:18:57 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
if (GIMP_DRAWABLE (layer)->width != tile_manager_width (lmu->tiles) ||
|
|
|
|
GIMP_DRAWABLE (layer)->height != tile_manager_height (lmu->tiles))
|
|
|
|
{
|
|
|
|
gimp_viewable_size_changed (GIMP_VIEWABLE (layer));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the second update */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (layer)->width,
|
2001-11-01 05:18:57 +08:00
|
|
|
GIMP_DRAWABLE (layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_layer_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
LayerModUndo *lmu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lmu = (LayerModUndo *) undo->data;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
|
|
|
tile_manager_destroy (lmu->tiles);
|
|
|
|
g_free (lmu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/********************************/
|
|
|
|
/* Layer Mask Add/Remove Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/********************************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _LayerMaskUndo LayerMaskUndo;
|
|
|
|
|
|
|
|
struct _LayerMaskUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer; /* the layer */
|
|
|
|
GimpLayerMask *mask; /* the layer mask */
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_push_layer_mask (GimpImage *gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
const gchar *undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndoType type,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask);
|
|
|
|
static gboolean undo_pop_layer_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_layer_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_mask_add (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_layer_mask (gimage, undo_desc, GIMP_UNDO_LAYER_MASK_ADD,
|
2002-02-24 01:29:19 +08:00
|
|
|
layer, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_mask_remove (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_layer_mask (gimage, undo_desc, GIMP_UNDO_LAYER_MASK_REMOVE,
|
2002-02-24 01:29:19 +08:00
|
|
|
layer, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_push_layer_mask (GimpImage *gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpUndoType type,
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), FALSE);
|
2003-02-13 19:23:50 +08:00
|
|
|
g_return_val_if_fail (type == GIMP_UNDO_LAYER_MASK_ADD ||
|
2003-02-14 22:14:29 +08:00
|
|
|
type == GIMP_UNDO_LAYER_MASK_REMOVE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size,
|
|
|
|
sizeof (LayerMaskUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
type, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_layer_mask,
|
|
|
|
undo_free_layer_mask)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
LayerMaskUndo *lmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lmu = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-28 02:47:48 +08:00
|
|
|
lmu->layer = layer;
|
|
|
|
lmu->mask = g_object_ref (mask);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-29 00:44:22 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_layer_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerMaskUndo *lmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lmu = (LayerMaskUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
if ((undo_mode == GIMP_UNDO_MODE_UNDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_LAYER_MASK_ADD) ||
|
|
|
|
(undo_mode == GIMP_UNDO_MODE_REDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_LAYER_MASK_REMOVE))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
/* remove layer mask */
|
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
gimp_layer_apply_mask (lmu->layer, GIMP_MASK_DISCARD, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
/* restore layer */
|
|
|
|
|
2002-08-20 18:22:23 +08:00
|
|
|
gimp_layer_add_mask (lmu->layer, lmu->mask, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_layer_mask (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerMaskUndo *lmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lmu = (LayerMaskUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (lmu->mask);
|
2003-02-14 22:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (lmu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/***************************/
|
|
|
|
/* Layer re-position Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/***************************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _LayerRepositionUndo LayerRepositionUndo;
|
|
|
|
|
|
|
|
struct _LayerRepositionUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
gint old_position;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_layer_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_layer_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_reposition (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (LayerRepositionUndo),
|
|
|
|
sizeof (LayerRepositionUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_LAYER_REPOSITION, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_layer_reposition,
|
|
|
|
undo_free_layer_reposition)))
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
LayerRepositionUndo *lru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lru = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
lru->layer = layer;
|
|
|
|
lru->old_position = gimp_image_get_layer_index (gimage, layer);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_layer_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
LayerRepositionUndo *lru;
|
2002-02-24 01:29:19 +08:00
|
|
|
gint pos;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lru = (LayerRepositionUndo *) undo->data;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* what's the layer's current index? */
|
2003-02-20 20:47:42 +08:00
|
|
|
pos = gimp_image_get_layer_index (undo->gimage, lru->layer);
|
|
|
|
gimp_image_position_layer (undo->gimage, lru->layer, lru->old_position,
|
2003-02-17 21:33:29 +08:00
|
|
|
FALSE, NULL);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
lru->old_position = pos;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_layer_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Layer displacement Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/*****************************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _LayerDisplaceUndo LayerDisplaceUndo;
|
|
|
|
|
|
|
|
struct _LayerDisplaceUndo
|
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
GSList *path_undo;
|
2002-02-24 01:29:19 +08:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_layer_displace (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_layer_displace (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_layer_displace (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *layer)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (LayerDisplaceUndo),
|
|
|
|
sizeof (LayerDisplaceUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_LAYER_DISPLACE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_layer_displace,
|
|
|
|
undo_free_layer_displace)))
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
LayerDisplaceUndo *ldu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ldu = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ldu->layer = g_object_ref (layer);
|
|
|
|
ldu->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
ldu->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
2002-02-24 01:29:19 +08:00
|
|
|
ldu->path_undo = path_transform_start_undo (gimage);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_layer_displace (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
LayerDisplaceUndo *ldu;
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
gint old_offset_x;
|
|
|
|
gint old_offset_y;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ldu = (LayerDisplaceUndo *) undo->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
layer = ldu->layer;
|
|
|
|
|
|
|
|
old_offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
old_offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (layer)->width,
|
|
|
|
GIMP_DRAWABLE (layer)->height);
|
|
|
|
|
|
|
|
GIMP_DRAWABLE (layer)->offset_x = ldu->offset_x;
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y = ldu->offset_y;
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (layer)->width,
|
|
|
|
GIMP_DRAWABLE (layer)->height);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if (layer->mask)
|
|
|
|
{
|
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_x = ldu->offset_x;
|
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_y = ldu->offset_y;
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer->mask),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (layer->mask)->width,
|
|
|
|
GIMP_DRAWABLE (layer->mask)->height);
|
|
|
|
}
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
/* invalidate the selection boundary because of a layer modification */
|
|
|
|
gimp_layer_invalidate_boundary (layer);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
ldu->offset_x = old_offset_x;
|
|
|
|
ldu->offset_y = old_offset_y;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
/* Now undo paths bits */
|
|
|
|
if (ldu->path_undo)
|
2003-02-20 20:47:42 +08:00
|
|
|
path_transform_do_undo (undo->gimage, ldu->path_undo);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
return TRUE;
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_layer_displace (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
LayerDisplaceUndo *ldu;
|
|
|
|
|
|
|
|
ldu = (LayerDisplaceUndo *) undo->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
g_object_unref (ldu->layer);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
if (ldu->path_undo)
|
|
|
|
path_transform_free_undo (ldu->path_undo);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (ldu);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Add/Remove Channel Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/*****************************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _ChannelUndo ChannelUndo;
|
|
|
|
|
|
|
|
struct _ChannelUndo
|
|
|
|
{
|
|
|
|
GimpChannel *channel; /* the actual channel */
|
|
|
|
gint prev_position; /* former position in list */
|
|
|
|
GimpChannel *prev_channel; /* previous active channel */
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_push_channel (GimpImage *gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
const gchar *undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndoType type,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel);
|
|
|
|
static gboolean undo_pop_channel (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_channel (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_channel_add (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_channel (gimage, undo_desc, GIMP_UNDO_CHANNEL_ADD,
|
2002-02-24 01:29:19 +08:00
|
|
|
channel, prev_position, prev_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_channel_remove (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_channel (gimage, undo_desc, GIMP_UNDO_CHANNEL_REMOVE,
|
2002-02-24 01:29:19 +08:00
|
|
|
channel, prev_position, prev_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
undo_push_channel (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpUndoType type,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
|
|
|
g_return_val_if_fail (prev_channel == NULL || GIMP_IS_CHANNEL (prev_channel),
|
|
|
|
FALSE);
|
2003-02-13 19:23:50 +08:00
|
|
|
g_return_val_if_fail (type == GIMP_UNDO_CHANNEL_ADD ||
|
2003-02-14 22:14:29 +08:00
|
|
|
type == GIMP_UNDO_CHANNEL_REMOVE, FALSE);
|
1999-10-02 03:26:56 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ChannelUndo) + gimp_object_get_memsize (GIMP_OBJECT (channel));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size,
|
|
|
|
sizeof (ChannelUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
type, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_channel,
|
|
|
|
undo_free_channel)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ChannelUndo *cu;
|
2001-02-19 21:06:09 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cu = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cu->channel = g_object_ref (channel);
|
2002-02-24 01:29:19 +08:00
|
|
|
cu->prev_position = prev_position;
|
|
|
|
cu->prev_channel = prev_channel;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-02-19 21:06:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_channel (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ChannelUndo *cu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cu = (ChannelUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
if ((undo_mode == GIMP_UNDO_MODE_UNDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_CHANNEL_ADD) ||
|
|
|
|
(undo_mode == GIMP_UNDO_MODE_REDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_CHANNEL_REMOVE))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* remove channel */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the current position */
|
2003-02-20 20:47:42 +08:00
|
|
|
cu->prev_position = gimp_image_get_channel_index (undo->gimage,
|
|
|
|
cu->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* remove the channel */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_container_remove (undo->gimage->channels, GIMP_OBJECT (cu->channel));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-03 21:45:40 +08:00
|
|
|
/* if exists, set the previous channel */
|
2002-02-26 01:58:50 +08:00
|
|
|
if (cu->prev_channel)
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_channel (undo->gimage, cu->prev_channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the area */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (cu->channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->width,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* restore channel */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the active channel */
|
2003-02-20 20:47:42 +08:00
|
|
|
cu->prev_channel = gimp_image_get_active_channel (undo->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* add the new channel */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_container_insert (undo->gimage->channels,
|
2001-02-19 21:06:09 +08:00
|
|
|
GIMP_OBJECT (cu->channel), cu->prev_position);
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/* set the new channel */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_channel (undo->gimage, cu->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the area */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (cu->channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->width,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_channel (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ChannelUndo *cu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cu = (ChannelUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (cu->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (cu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/**********************/
|
|
|
|
/* Channel Mod Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/**********************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
typedef struct _ChannelModUndo ChannelModUndo;
|
|
|
|
|
|
|
|
struct _ChannelModUndo
|
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpChannel *channel;
|
|
|
|
TileManager *tiles;
|
2001-11-29 09:06:44 +08:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_channel_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_channel_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_channel_mod (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *channel)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
TileManager *tiles;
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
tiles = GIMP_DRAWABLE (channel)->tiles;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
size = sizeof (ChannelModUndo) + tile_manager_get_memsize (tiles);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size,
|
|
|
|
sizeof (ChannelModUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_CHANNEL_MOD, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_channel_mod,
|
|
|
|
undo_free_channel_mod)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ChannelModUndo *cmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cmu = new->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
cmu->channel = channel;
|
|
|
|
cmu->tiles = tiles;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_channel_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
ChannelModUndo *cmu;
|
2001-11-29 09:06:44 +08:00
|
|
|
TileManager *tiles;
|
|
|
|
GimpChannel *channel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cmu = (ChannelModUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
channel = cmu->channel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the first update */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (channel)->width,
|
|
|
|
GIMP_DRAWABLE (channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
tiles = cmu->tiles;
|
|
|
|
|
|
|
|
cmu->tiles = GIMP_DRAWABLE (channel)->tiles;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
GIMP_DRAWABLE (channel)->tiles = tiles;
|
|
|
|
GIMP_DRAWABLE (channel)->width = tile_manager_width (tiles);
|
|
|
|
GIMP_DRAWABLE (channel)->height = tile_manager_height (tiles);
|
2001-01-23 21:01:48 +08:00
|
|
|
GIMP_CHANNEL (channel)->bounds_known = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-30 01:27:34 +08:00
|
|
|
if (GIMP_DRAWABLE (channel)->width != tile_manager_width (cmu->tiles) ||
|
|
|
|
GIMP_DRAWABLE (channel)->height != tile_manager_height (cmu->tiles))
|
|
|
|
{
|
|
|
|
gimp_viewable_size_changed (GIMP_VIEWABLE (channel));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the second update */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (channel)->width,
|
|
|
|
GIMP_DRAWABLE (channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_channel_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
ChannelModUndo *cmu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cmu = (ChannelModUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
tile_manager_destroy (cmu->tiles);
|
|
|
|
|
|
|
|
g_free (cmu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/******************************/
|
|
|
|
/* Channel re-position Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/******************************/
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _ChannelRepositionUndo ChannelRepositionUndo;
|
|
|
|
|
|
|
|
struct _ChannelRepositionUndo
|
|
|
|
{
|
|
|
|
GimpChannel *channel;
|
|
|
|
gint old_position;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_channel_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_channel_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_channel_reposition (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *channel)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ChannelRepositionUndo),
|
|
|
|
sizeof (ChannelRepositionUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_CHANNEL_REPOSITION, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_channel_reposition,
|
|
|
|
undo_free_channel_reposition)))
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
|
|
|
ChannelRepositionUndo *cru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cru = new->data;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
cru->channel = channel;
|
|
|
|
cru->old_position = gimp_image_get_channel_index (gimage, channel);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_channel_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
ChannelRepositionUndo *cru;
|
2002-02-24 01:29:19 +08:00
|
|
|
gint pos;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
cru = (ChannelRepositionUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* what's the channel's current index? */
|
2003-02-20 20:47:42 +08:00
|
|
|
pos = gimp_image_get_channel_index (undo->gimage, cru->channel);
|
|
|
|
gimp_image_position_channel (undo->gimage, cru->channel, cru->old_position,
|
2003-02-17 21:33:29 +08:00
|
|
|
FALSE, NULL);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
cru->old_position = pos;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_channel_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-25 05:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-17 10:25:39 +08:00
|
|
|
/************************/
|
|
|
|
/* Channel color Undo */
|
|
|
|
/************************/
|
|
|
|
|
|
|
|
typedef struct _ChannelColorUndo ChannelColorUndo;
|
|
|
|
|
|
|
|
struct _ChannelColorUndo
|
|
|
|
{
|
|
|
|
GimpChannel *channel;
|
|
|
|
GimpRGB old_color;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_channel_color (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_channel_color (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_image_undo_push_channel_color (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpChannel *channel)
|
|
|
|
{
|
|
|
|
GimpUndo *new;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
|
|
|
|
|
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ChannelColorUndo),
|
|
|
|
sizeof (ChannelColorUndo),
|
|
|
|
GIMP_UNDO_CHANNEL_COLOR, undo_desc,
|
|
|
|
TRUE,
|
|
|
|
undo_pop_channel_color,
|
|
|
|
undo_free_channel_color)))
|
|
|
|
{
|
|
|
|
ChannelColorUndo *ccu;
|
|
|
|
|
|
|
|
ccu = new->data;
|
|
|
|
|
|
|
|
ccu->channel = channel;
|
|
|
|
gimp_channel_get_color (channel , &ccu->old_color);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_channel_color (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
|
|
|
{
|
|
|
|
ChannelColorUndo *ccu;
|
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
ccu = (ChannelColorUndo *) undo->data;
|
|
|
|
|
|
|
|
gimp_channel_get_color (ccu->channel, &color);
|
|
|
|
gimp_channel_set_color (ccu->channel, &ccu->old_color, FALSE);
|
|
|
|
ccu->old_color = color;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_channel_color (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
|
|
|
{
|
|
|
|
g_free (undo->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
/*****************************/
|
|
|
|
/* Add/Remove Vectors Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/*****************************/
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
typedef struct _VectorsUndo VectorsUndo;
|
|
|
|
|
|
|
|
struct _VectorsUndo
|
|
|
|
{
|
|
|
|
GimpVectors *vectors; /* the actual vectors */
|
|
|
|
gint prev_position; /* former position in list */
|
|
|
|
GimpVectors *prev_vectors; /* previous active vectors */
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_push_vectors (GimpImage *gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
const gchar *undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndoType type,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors);
|
|
|
|
static gboolean undo_pop_vectors (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_vectors (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_vectors_add (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_vectors (gimage, undo_desc, GIMP_UNDO_VECTORS_ADD,
|
2002-02-25 05:00:58 +08:00
|
|
|
vectors, prev_position, prev_vectors);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_vectors_remove (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
return undo_push_vectors (gimage, undo_desc, GIMP_UNDO_VECTORS_REMOVE,
|
2002-02-25 05:00:58 +08:00
|
|
|
vectors, prev_position, prev_vectors);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
undo_push_vectors (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpUndoType type,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
|
|
|
g_return_val_if_fail (prev_vectors == NULL || GIMP_IS_VECTORS (prev_vectors),
|
|
|
|
FALSE);
|
2003-02-13 19:23:50 +08:00
|
|
|
g_return_val_if_fail (type == GIMP_UNDO_VECTORS_ADD ||
|
2003-02-14 22:14:29 +08:00
|
|
|
type == GIMP_UNDO_VECTORS_REMOVE, FALSE);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
size = sizeof (VectorsUndo) + gimp_object_get_memsize (GIMP_OBJECT (vectors));
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size,
|
|
|
|
sizeof (VectorsUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
type, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_vectors,
|
|
|
|
undo_free_vectors)))
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsUndo *vu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vu = new->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vu->vectors = g_object_ref (vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
vu->prev_position = prev_position;
|
|
|
|
vu->prev_vectors = prev_vectors;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_vectors (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsUndo *vu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vu = (VectorsUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
if ((undo_mode == GIMP_UNDO_MODE_UNDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_VECTORS_ADD) ||
|
|
|
|
(undo_mode == GIMP_UNDO_MODE_REDO &&
|
|
|
|
undo->undo_type == GIMP_UNDO_VECTORS_REMOVE))
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
/* remove vectors */
|
|
|
|
|
|
|
|
/* record the current position */
|
2003-02-20 20:47:42 +08:00
|
|
|
vu->prev_position = gimp_image_get_vectors_index (undo->gimage,
|
|
|
|
vu->vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
/* remove the vectors */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_container_remove (undo->gimage->vectors, GIMP_OBJECT (vu->vectors));
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-03 21:45:40 +08:00
|
|
|
/* if exists, set the previous vectors */
|
2002-02-26 01:58:50 +08:00
|
|
|
if (vu->prev_vectors)
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_vectors (undo->gimage, vu->prev_vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* restore vectors */
|
|
|
|
|
|
|
|
/* record the active vectors */
|
2003-02-20 20:47:42 +08:00
|
|
|
vu->prev_vectors = gimp_image_get_active_vectors (undo->gimage);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
/* add the new vectors */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_container_insert (undo->gimage->vectors,
|
2002-02-25 05:00:58 +08:00
|
|
|
GIMP_OBJECT (vu->vectors), vu->prev_position);
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/* set the new vectors */
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_vectors (undo->gimage, vu->vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_vectors (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsUndo *vu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vu = (VectorsUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (vu->vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
g_free (vu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************/
|
|
|
|
/* Vectors Mod Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/**********************/
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
typedef struct _VectorsModUndo VectorsModUndo;
|
|
|
|
|
|
|
|
struct _VectorsModUndo
|
|
|
|
{
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpVectors *undo_vectors;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_vectors_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_vectors_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_vectors_mod (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpVectors *vectors)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
|
|
|
gsize size;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
size = (sizeof (VectorsModUndo) +
|
|
|
|
gimp_object_get_memsize (GIMP_OBJECT (vectors)));
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
size,
|
|
|
|
sizeof (VectorsModUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_VECTORS_MOD, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_vectors_mod,
|
|
|
|
undo_free_vectors_mod)))
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsModUndo *vmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vmu = new->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
vmu->vectors = vectors;
|
2003-02-11 21:52:47 +08:00
|
|
|
vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
|
|
|
|
G_TYPE_FROM_INSTANCE (vectors),
|
|
|
|
FALSE));
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_vectors_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsModUndo *vmu;
|
|
|
|
GimpVectors *temp;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vmu = (VectorsModUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
temp = vmu->undo_vectors;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vmu->undo_vectors =
|
|
|
|
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vmu->vectors),
|
|
|
|
G_TYPE_FROM_INSTANCE (vmu->vectors),
|
|
|
|
FALSE));
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-01 02:08:32 +08:00
|
|
|
gimp_vectors_copy_strokes (temp, vmu->vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-01 02:08:32 +08:00
|
|
|
g_object_unref (temp);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_vectors_mod (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsModUndo *vmu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vmu = (VectorsModUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-01 02:08:32 +08:00
|
|
|
g_object_unref (vmu->undo_vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
g_free (vmu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************/
|
|
|
|
/* Vectors re-position Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/******************************/
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
typedef struct _VectorsRepositionUndo VectorsRepositionUndo;
|
|
|
|
|
|
|
|
struct _VectorsRepositionUndo
|
|
|
|
{
|
|
|
|
GimpVectors *vectors;
|
|
|
|
gint old_position;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_vectors_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_vectors_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_vectors_reposition (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpVectors *vectors)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (VectorsRepositionUndo),
|
|
|
|
sizeof (VectorsRepositionUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_VECTORS_REPOSITION, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_vectors_reposition,
|
|
|
|
undo_free_vectors_reposition)))
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsRepositionUndo *vru;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vru = new->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
vru->vectors = vectors;
|
|
|
|
vru->old_position = gimp_image_get_vectors_index (gimage, vectors);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_vectors_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsRepositionUndo *vru;
|
|
|
|
gint pos;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
vru = (VectorsRepositionUndo *) undo->data;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
/* what's the vectors's current index? */
|
2003-02-20 20:47:42 +08:00
|
|
|
pos = gimp_image_get_vectors_index (undo->gimage, vru->vectors);
|
|
|
|
gimp_image_position_vectors (undo->gimage, vru->vectors, vru->old_position,
|
2003-02-17 21:33:29 +08:00
|
|
|
FALSE, NULL);
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
vru->old_position = pos;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_vectors_reposition (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (undo->data);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/**************************************/
|
|
|
|
/* Floating Selection to Layer Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/**************************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _FStoLayerUndo FStoLayerUndo;
|
|
|
|
|
|
|
|
struct _FStoLayerUndo
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpLayer *floating_layer; /* the floating layer */
|
|
|
|
GimpDrawable *drawable; /* drawable of floating sel */
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_fs_to_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_fs_to_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_fs_to_layer (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *floating_layer,
|
|
|
|
GimpDrawable *drawable)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (FStoLayerUndo),
|
|
|
|
sizeof (FStoLayerUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_FS_TO_LAYER, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_fs_to_layer,
|
|
|
|
undo_free_fs_to_layer)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
FStoLayerUndo *fsu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
fsu = new->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
fsu->floating_layer = floating_layer;
|
|
|
|
fsu->drawable = drawable;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (floating_layer->fs.backing_store);
|
|
|
|
floating_layer->fs.backing_store = NULL;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_fs_to_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FStoLayerUndo *fsu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
fsu = (FStoLayerUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
switch (undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_UNDO:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Update the preview for the floating sel */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
fsu->floating_layer->fs.drawable = fsu->drawable;
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_set_active_layer (undo->gimage, fsu->floating_layer);
|
|
|
|
undo->gimage->floating_sel = fsu->floating_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* restore the contents of the drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
floating_sel_store (fsu->floating_layer,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->width,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->height);
|
|
|
|
fsu->floating_layer->fs.initial = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* clear the selection */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_layer_invalidate_boundary (fsu->floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the preview for the gimage and underlying drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_REDO:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* restore the contents of the drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
floating_sel_restore (fsu->floating_layer,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->width,
|
|
|
|
GIMP_DRAWABLE (fsu->floating_layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the preview for the gimage and underlying drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* clear the selection */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_layer_invalidate_boundary (fsu->floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the pointers */
|
2002-02-24 01:29:19 +08:00
|
|
|
fsu->floating_layer->fs.drawable = NULL;
|
2003-02-20 20:47:42 +08:00
|
|
|
undo->gimage->floating_sel = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the fs drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_image_floating_selection_changed (undo->gimage);
|
2001-05-08 09:32:25 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_fs_to_layer (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FStoLayerUndo *fsu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
fsu = (FStoLayerUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if (undo_mode == GIMP_UNDO_MODE_UNDO)
|
2001-11-10 00:54:56 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (fsu->floating_layer->fs.backing_store);
|
|
|
|
fsu->floating_layer->fs.backing_store = NULL;
|
2001-11-10 00:54:56 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (fsu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
/* Floating Selection Rigor Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/***********************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
typedef struct _FSRigorUndo FSRigorUndo;
|
|
|
|
|
|
|
|
struct _FSRigorUndo
|
|
|
|
{
|
|
|
|
GimpLayer *floating_layer;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_fs_rigor (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_fs_rigor (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_fs_rigor (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *floating_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
sizeof (FSRigorUndo),
|
|
|
|
sizeof (FSRigorUndo),
|
|
|
|
GIMP_UNDO_FS_RIGOR, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
FALSE,
|
|
|
|
undo_pop_fs_rigor,
|
|
|
|
undo_free_fs_rigor)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
FSRigorUndo *fsu;
|
2003-02-13 01:11:34 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu = new->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu->floating_layer = g_object_ref (floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-02-03 21:45:40 +08:00
|
|
|
|
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_fs_rigor (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
FSRigorUndo *fsu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu = (FSRigorUndo *) undo->data;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
if (! gimp_layer_is_floating_sel (fsu->floating_layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
switch (undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_UNDO:
|
2003-02-14 22:14:29 +08:00
|
|
|
floating_sel_relax (fsu->floating_layer, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_REDO:
|
2003-02-14 22:14:29 +08:00
|
|
|
floating_sel_rigor (fsu->floating_layer, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_fs_rigor (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
FSRigorUndo *fsu;
|
|
|
|
|
|
|
|
fsu = (FSRigorUndo *) undo->data;
|
|
|
|
|
|
|
|
g_object_unref (fsu->floating_layer);
|
|
|
|
|
|
|
|
g_free (fsu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
/* Floating Selection Relax Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/***********************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
typedef struct _FSRelaxUndo FSRelaxUndo;
|
|
|
|
|
|
|
|
struct _FSRelaxUndo
|
|
|
|
{
|
|
|
|
GimpLayer *floating_layer;
|
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_fs_relax (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_fs_relax (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_fs_relax (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpLayer *floating_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (gint32),
|
|
|
|
sizeof (gint32),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_FS_RELAX, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
FALSE,
|
|
|
|
undo_pop_fs_relax,
|
|
|
|
undo_free_fs_relax)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
FSRelaxUndo *fsu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu = new->data;
|
2003-02-13 01:11:34 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu->floating_layer = g_object_ref (floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-02-03 21:45:40 +08:00
|
|
|
|
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_fs_relax (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
FSRelaxUndo *fsu;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu = (FSRelaxUndo *) undo->data;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
if (! gimp_layer_is_floating_sel (fsu->floating_layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
switch (undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_UNDO:
|
2003-02-14 22:14:29 +08:00
|
|
|
floating_sel_rigor (fsu->floating_layer, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_REDO:
|
2003-02-14 22:14:29 +08:00
|
|
|
floating_sel_relax (fsu->floating_layer, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_fs_relax (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
FSRelaxUndo *fsu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
fsu = (FSRelaxUndo *) undo->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_object_unref (fsu->floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_free (fsu);
|
1999-09-30 00:44:52 +08:00
|
|
|
}
|
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/*******************/
|
|
|
|
/* Parasite Undo */
|
2003-02-13 01:11:34 +08:00
|
|
|
/*******************/
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
typedef struct _ParasiteUndo ParasiteUndo;
|
|
|
|
|
|
|
|
struct _ParasiteUndo
|
|
|
|
{
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpImage *gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpItem *item;
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *parasite;
|
|
|
|
gchar *name;
|
1999-04-23 14:07:09 +08:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_parasite (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
|
|
|
static void undo_free_parasite (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_parasite (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
gpointer parasite)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ParasiteUndo),
|
|
|
|
sizeof (ParasiteUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_PARASITE_ATTACH, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_parasite,
|
|
|
|
undo_free_parasite)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
pu = new->data;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = NULL;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (gimp_parasite_name (parasite));
|
|
|
|
pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_image_parasite_remove (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
const gchar *name)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ParasiteUndo),
|
|
|
|
sizeof (ParasiteUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_PARASITE_REMOVE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_parasite,
|
|
|
|
undo_free_parasite)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
pu = new->data;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = NULL;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (name);
|
|
|
|
pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_item_parasite (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpItem *item,
|
|
|
|
gpointer parasite)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ParasiteUndo),
|
|
|
|
sizeof (ParasiteUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_PARASITE_ATTACH, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_parasite,
|
|
|
|
undo_free_parasite)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
pu = new->data;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = NULL;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = item;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (gimp_parasite_name (parasite));
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (item,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_item_parasite_remove (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GimpItem *item,
|
|
|
|
const gchar *name)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
sizeof (ParasiteUndo),
|
|
|
|
sizeof (ParasiteUndo),
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_PARASITE_REMOVE, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_parasite,
|
|
|
|
undo_free_parasite)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
pu = new->data;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = NULL;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = item;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (name);
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (item,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_parasite (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
ParasiteUndo *pu;
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *tmp;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
pu = (ParasiteUndo *) undo->data;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
tmp = pu->parasite;
|
2000-05-27 06:28:40 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
if (pu->gimage)
|
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (undo->gimage,
|
2003-02-14 22:14:29 +08:00
|
|
|
pu->name));
|
2000-01-26 07:06:12 +08:00
|
|
|
if (tmp)
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_parasite_list_add (pu->gimage->parasites, tmp);
|
2000-01-26 07:06:12 +08:00
|
|
|
else
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_parasite_list_remove (pu->gimage->parasites, pu->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
}
|
2003-02-14 22:14:29 +08:00
|
|
|
else if (pu->item)
|
2000-01-26 07:06:12 +08:00
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (pu->item,
|
|
|
|
pu->name));
|
2000-01-26 07:06:12 +08:00
|
|
|
if (tmp)
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_parasite_list_add (pu->item->parasites, tmp);
|
2000-01-26 07:06:12 +08:00
|
|
|
else
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_parasite_list_remove (pu->item->parasites, pu->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
}
|
1999-04-23 14:07:09 +08:00
|
|
|
else
|
2000-01-26 07:06:12 +08:00
|
|
|
{
|
2003-02-20 20:47:42 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_parasite_find (undo->gimage->gimp,
|
2003-02-14 22:14:29 +08:00
|
|
|
pu->name));
|
2000-01-26 07:06:12 +08:00
|
|
|
if (tmp)
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_parasite_attach (undo->gimage->gimp, tmp);
|
2000-01-26 07:06:12 +08:00
|
|
|
else
|
2003-02-20 20:47:42 +08:00
|
|
|
gimp_parasite_detach (undo->gimage->gimp, pu->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
}
|
2003-02-03 21:45:40 +08:00
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
if (tmp)
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_free (tmp);
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_free_parasite (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
ParasiteUndo *pu;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
pu = (ParasiteUndo *) undo->data;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if (pu->parasite)
|
|
|
|
gimp_parasite_free (pu->parasite);
|
|
|
|
if (pu->name)
|
|
|
|
g_free (pu->name);
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
g_free (pu);
|
1999-04-23 14:07:09 +08:00
|
|
|
}
|
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/******************************************************************************/
|
|
|
|
/* Something for which programmer is too lazy to write an undo function for */
|
2003-02-13 01:11:34 +08:00
|
|
|
/******************************************************************************/
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
static gboolean undo_pop_cantundo (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum);
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_image_undo_push_cantundo (GimpImage *gimage,
|
|
|
|
const gchar *undo_desc)
|
1999-08-23 22:34:58 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
GimpUndo *new;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
/* This is the sole purpose of this type of undo: the ability to
|
|
|
|
* mark an image as having been mutated, without really providing
|
2002-02-24 01:29:19 +08:00
|
|
|
* any adequate undo facility.
|
|
|
|
*/
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
if ((new = gimp_image_undo_push (gimage,
|
|
|
|
0, 0,
|
2003-02-14 22:14:29 +08:00
|
|
|
GIMP_UNDO_CANT, undo_desc,
|
2003-02-13 01:11:34 +08:00
|
|
|
TRUE,
|
|
|
|
undo_pop_cantundo,
|
|
|
|
NULL)))
|
2002-02-26 08:04:55 +08:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
return FALSE;
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2003-02-13 01:11:34 +08:00
|
|
|
undo_pop_cantundo (GimpUndo *undo,
|
|
|
|
GimpUndoMode undo_mode,
|
|
|
|
GimpUndoAccumulator *accum)
|
1999-08-23 22:34:58 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
switch (undo_mode)
|
2000-01-26 07:06:12 +08:00
|
|
|
{
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_UNDO:
|
2003-02-14 22:14:29 +08:00
|
|
|
g_message (_("Can't undo %s"), GIMP_OBJECT (undo)->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
break;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2003-02-13 01:11:34 +08:00
|
|
|
case GIMP_UNDO_MODE_REDO:
|
2000-01-26 07:06:12 +08:00
|
|
|
break;
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
return TRUE;
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|