General undo cleanup:

2002-02-23  Michael Natterer  <mitch@gimp.org>

	General undo cleanup:

	* app/undo.[ch]: made all undo structs private. Changed all
	undo_push_foo() functions to take useful parameters instead of
	"gpointer foo_ptr" and create the undo structs internally.
	Renamed lots of functions so they are more self-explanatory
	(like undo_push_gimage_mod -> undo_push_image_size). Added some
	undo functions (channel reordering is undoable now).  Never pass
	in a UndoType, as they are reseved for groups now (see below).
	Lots of cleanup and stuff...

	* app/undo_types.h: is a private header now which defines "enum
	UndoImplType" which is reserved for actual undo operations.
	All enum values are named "FOO_UNDO".

	* app/core/core-types.h: added the "UndoType" enum here and don't
	include "undo_types.h" any more. The UndoType values are all
	named "FOO_UNDO_GROUP" and are reserved for undo groups.

	The ID space of actual undo operations and undo groups
	is now strictly disjunct.

	* app/core/gimpchannel.h
	* app/core/gimpimage.h
	* app/core/gimplayer.h
	* app/core/gimplayermask.h
	* app/paint/gimppaintcore.h
	* app/tools/gimptransformtool.h: removed undo stuct definitions.

	* app/undo_history.c
	* app/path_transform.h
	* app/core/gimpchannel.c
	* app/core/gimpdrawable-transform.c
	* app/core/gimpedit.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage-crop.c
	* app/core/gimpimage-mask.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimage-qmask.c
	* app/core/gimpimage-resize.c
	* app/core/gimpimage-scale.c
	* app/core/gimpimage.c
	* app/core/gimplayer-floating-sel.c
	* app/core/gimplayer.c
	* app/display/gimpdisplayshell-dnd.c
	* app/gui/channels-commands.c
	* app/gui/image-commands.c
	* app/gui/layers-commands.c
	* app/gui/paths-dialog.c
	* app/paint/gimppaintcore.c
	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimptexttool.c
	* app/tools/gimptransformtool.c
	* tools/pdbgen/pdb/guides.pdb
	* tools/pdbgen/pdb/layer.pdb
	* tools/pdbgen/pdb/undo.pdb: changed accordingly.

	* app/pdb/guides_cmds.c
	* app/pdb/layer_cmds.c
	* app/pdb/undo_cmds.c: regenerated.

	* app/core/gimpimage.[ch]: added infrastructure for holding a
	GimpList of GimpVectors objects. The API is the same as for layers
	and channels. Not used yet.
This commit is contained in:
Michael Natterer 2002-02-23 17:29:19 +00:00 committed by Michael Natterer
parent b414ec7c00
commit a3c3e7d3a6
54 changed files with 3993 additions and 3158 deletions

View File

@ -1,3 +1,73 @@
2002-02-23 Michael Natterer <mitch@gimp.org>
General undo cleanup:
* app/undo.[ch]: made all undo structs private. Changed all
undo_push_foo() functions to take useful parameters instead of
"gpointer foo_ptr" and create the undo structs internally.
Renamed lots of functions so they are more self-explanatory
(like undo_push_gimage_mod -> undo_push_image_size). Added some
undo functions (channel reordering is undoable now). Never pass
in a UndoType, as they are reseved for groups now (see below).
Lots of cleanup and stuff...
* app/undo_types.h: is a private header now which defines "enum
UndoImplType" which is reserved for actual undo operations.
All enum values are named "FOO_UNDO".
* app/core/core-types.h: added the "UndoType" enum here and don't
include "undo_types.h" any more. The UndoType values are all
named "FOO_UNDO_GROUP" and are reserved for undo groups.
The ID space of actual undo operations and undo groups
is now strictly disjunct.
* app/core/gimpchannel.h
* app/core/gimpimage.h
* app/core/gimplayer.h
* app/core/gimplayermask.h
* app/paint/gimppaintcore.h
* app/tools/gimptransformtool.h: removed undo stuct definitions.
* app/undo_history.c
* app/path_transform.h
* app/core/gimpchannel.c
* app/core/gimpdrawable-transform.c
* app/core/gimpedit.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-crop.c
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimpimage-qmask.c
* app/core/gimpimage-resize.c
* app/core/gimpimage-scale.c
* app/core/gimpimage.c
* app/core/gimplayer-floating-sel.c
* app/core/gimplayer.c
* app/display/gimpdisplayshell-dnd.c
* app/gui/channels-commands.c
* app/gui/image-commands.c
* app/gui/layers-commands.c
* app/gui/paths-dialog.c
* app/paint/gimppaintcore.c
* app/tools/gimpbezierselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/tools/gimptexttool.c
* app/tools/gimptransformtool.c
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/layer.pdb
* tools/pdbgen/pdb/undo.pdb: changed accordingly.
* app/pdb/guides_cmds.c
* app/pdb/layer_cmds.c
* app/pdb/undo_cmds.c: regenerated.
* app/core/gimpimage.[ch]: added infrastructure for holding a
GimpList of GimpVectors objects. The API is the same as for layers
and channels. Not used yet.
2002-02-22 Sven Neumann <sven@gimp.org>
* HACKING

View File

@ -359,7 +359,7 @@ channels_new_channel_query (GimpImage *gimage,
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
new_channel = gimp_channel_new (gimage,
width, height,

View File

@ -432,7 +432,7 @@ image_scale_implement (ImageResize *image_scale)
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
gimp_image_set_resolution (gimage,
image_scale->resize->resolution_x,
@ -444,7 +444,7 @@ image_scale_implement (ImageResize *image_scale)
if (image_scale->resize->unit != gimage->unit)
{
if (! display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
gimp_image_set_unit (gimage, image_scale->resize->unit);
@ -460,7 +460,7 @@ image_scale_implement (ImageResize *image_scale)
GimpProgress *progress;
if (! display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
progress = gimp_progress_start (image_scale->gdisp,
_("Scaling..."),

View File

@ -512,9 +512,6 @@ new_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = options->gimage))
{
/* Start a group undo */
undo_push_group_start (gimage, LAYER_ADD_UNDO);
layer = gimp_layer_new (gimage, options->xsize, options->ysize,
gimp_image_base_type_with_alpha (gimage),
layer_name, OPAQUE_OPACITY, GIMP_NORMAL_MODE);
@ -525,9 +522,6 @@ new_layer_query_ok_callback (GtkWidget *widget,
fill_type);
gimp_image_add_layer (gimage, layer, -1);
/* End the group undo */
undo_push_group_end (gimage);
gdisplays_flush ();
}
else
@ -577,7 +571,7 @@ layers_new_layer_query (GimpImage *gimage,
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
new_layer = gimp_layer_new (gimage, width, height,
gimp_image_base_type_with_alpha (gimage),
@ -1008,7 +1002,7 @@ scale_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = GIMP_DRAWABLE (layer)->gimage) != NULL)
{
undo_push_group_start (gimage, LAYER_SCALE_UNDO);
undo_push_group_start (gimage, LAYER_SCALE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
@ -1097,7 +1091,7 @@ resize_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = GIMP_DRAWABLE (layer)->gimage) != NULL)
{
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);

View File

@ -28,8 +28,6 @@
#include "plug-in/plug-in-types.h"
#include "vectors/vectors-types.h"
#include "undo_types.h" /* EEK */
#include "core/core-enums.h"
@ -124,6 +122,43 @@ typedef enum
PATTERN_BUCKET_FILL
} BucketFillMode;
typedef enum /*< pdb-skip >*/ /*< skip >*/
{
/* NOTE: If you change this list, please update the textual mapping at
* the bottom of undo.c as well.
*/
/* Type NO_UNDO_GROUP (0) is special - in the gimpimage structure it
* means there is no undo group currently being added to.
*/
NO_UNDO_GROUP = 0,
FIRST_UNDO_GROUP = NO_UNDO_GROUP,
IMAGE_SCALE_UNDO_GROUP,
IMAGE_RESIZE_UNDO_GROUP,
IMAGE_CONVERT_UNDO_GROUP,
IMAGE_CROP_UNDO_GROUP,
IMAGE_LAYERS_MERGE_UNDO_GROUP,
IMAGE_QMASK_UNDO_GROUP,
IMAGE_GUIDE_UNDO_GROUP,
LAYER_SCALE_UNDO_GROUP,
LAYER_RESIZE_UNDO_GROUP,
LAYER_DISPLACE_UNDO_GROUP,
LAYER_LINKED_UNDO_GROUP,
LAYER_APPLY_MASK_UNDO_GROUP,
FS_FLOAT_UNDO_GROUP,
FS_ANCHOR_UNDO_GROUP,
EDIT_PASTE_UNDO_GROUP,
EDIT_CUT_UNDO_GROUP,
TEXT_UNDO_GROUP,
TRANSFORM_UNDO_GROUP,
PAINT_UNDO_GROUP,
MISC_UNDO_GROUP,
LAST_UNDO_GROUP = MISC_UNDO_GROUP
} UndoType;
/* base objects */

View File

@ -59,7 +59,7 @@ gimp_edit_cut (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
undo_push_group_start (gimage, EDIT_CUT_UNDO);
undo_push_group_start (gimage, EDIT_CUT_UNDO_GROUP);
/* See if the gimage mask is empty */
empty = gimp_image_mask_is_empty (gimage);
@ -187,7 +187,7 @@ gimp_edit_paste (GimpImage *gimage,
return NULL;
/* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
/* Set the offsets to the center of the image */
if (drawable)

View File

@ -612,7 +612,7 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
/* Start a transform undo group */
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
undo_push_group_start (gimage, TRANSFORM_UNDO_GROUP);
/* Cut/Copy from the specified drawable */
float_tiles = gimp_drawable_transform_cut (drawable, &new_layer);
@ -659,7 +659,7 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
/* Start a transform undo group */
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
undo_push_group_start (gimage, TRANSFORM_UNDO_GROUP);
/* Cut/Copy from the specified drawable */
float_tiles = gimp_drawable_transform_cut (drawable, &new_layer);
@ -761,7 +761,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
&(GIMP_DRAWABLE (layer)->offset_y));
/* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
floating_sel_attach (layer, drawable);

View File

@ -1199,12 +1199,10 @@ void
gimp_channel_push_undo (GimpChannel *mask)
{
gint x1, y1, x2, y2;
MaskUndo *mask_undo;
TileManager *undo_tiles;
PixelRegion srcPR, destPR;
GimpImage *gimage;
mask_undo = g_new (MaskUndo, 1);
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
{
undo_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
@ -1216,13 +1214,10 @@ gimp_channel_push_undo (GimpChannel *mask)
else
undo_tiles = NULL;
mask_undo->tiles = undo_tiles;
mask_undo->x = x1;
mask_undo->y = y1;
/* push the undo buffer onto the undo stack */
gimage = GIMP_DRAWABLE (mask)->gimage;
undo_push_mask (gimage, mask_undo);
undo_push_image_mask (gimage, undo_tiles, x1, y1);
gimp_image_mask_invalidate (gimage);
/* invalidate the preview */

View File

@ -63,25 +63,6 @@ struct _GimpChannelClass
};
/* Special undo types */
typedef struct _ChannelUndo ChannelUndo;
typedef struct _MaskUndo MaskUndo;
struct _ChannelUndo
{
GimpChannel *channel; /* the actual channel */
gint prev_position; /* former position in list */
GimpChannel *prev_channel; /* previous active channel */
};
struct _MaskUndo
{
TileManager *tiles; /* the actual mask */
gint x, y; /* offsets */
};
/* function declarations */
GType gimp_channel_get_type (void) G_GNUC_CONST;
@ -114,7 +95,7 @@ void gimp_channel_resize (GimpChannel *channel,
gint offy);
/* selection mask functions */
/* selection mask functions */
GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width,

View File

@ -1199,12 +1199,10 @@ void
gimp_channel_push_undo (GimpChannel *mask)
{
gint x1, y1, x2, y2;
MaskUndo *mask_undo;
TileManager *undo_tiles;
PixelRegion srcPR, destPR;
GimpImage *gimage;
mask_undo = g_new (MaskUndo, 1);
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
{
undo_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
@ -1216,13 +1214,10 @@ gimp_channel_push_undo (GimpChannel *mask)
else
undo_tiles = NULL;
mask_undo->tiles = undo_tiles;
mask_undo->x = x1;
mask_undo->y = y1;
/* push the undo buffer onto the undo stack */
gimage = GIMP_DRAWABLE (mask)->gimage;
undo_push_mask (gimage, mask_undo);
undo_push_image_mask (gimage, undo_tiles, x1, y1);
gimp_image_mask_invalidate (gimage);
/* invalidate the preview */

View File

@ -63,25 +63,6 @@ struct _GimpChannelClass
};
/* Special undo types */
typedef struct _ChannelUndo ChannelUndo;
typedef struct _MaskUndo MaskUndo;
struct _ChannelUndo
{
GimpChannel *channel; /* the actual channel */
gint prev_position; /* former position in list */
GimpChannel *prev_channel; /* previous active channel */
};
struct _MaskUndo
{
TileManager *tiles; /* the actual mask */
gint x, y; /* offsets */
};
/* function declarations */
GType gimp_channel_get_type (void) G_GNUC_CONST;
@ -114,7 +95,7 @@ void gimp_channel_resize (GimpChannel *channel,
gint offy);
/* selection mask functions */
/* selection mask functions */
GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width,

View File

@ -612,7 +612,7 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
/* Start a transform undo group */
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
undo_push_group_start (gimage, TRANSFORM_UNDO_GROUP);
/* Cut/Copy from the specified drawable */
float_tiles = gimp_drawable_transform_cut (drawable, &new_layer);
@ -659,7 +659,7 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
/* Start a transform undo group */
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
undo_push_group_start (gimage, TRANSFORM_UNDO_GROUP);
/* Cut/Copy from the specified drawable */
float_tiles = gimp_drawable_transform_cut (drawable, &new_layer);
@ -761,7 +761,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
&(GIMP_DRAWABLE (layer)->offset_y));
/* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
floating_sel_attach (layer, drawable);

View File

@ -59,7 +59,7 @@ gimp_edit_cut (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
undo_push_group_start (gimage, EDIT_CUT_UNDO);
undo_push_group_start (gimage, EDIT_CUT_UNDO_GROUP);
/* See if the gimage mask is empty */
empty = gimp_image_mask_is_empty (gimage);
@ -187,7 +187,7 @@ gimp_edit_paste (GimpImage *gimage,
return NULL;
/* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
/* Set the offsets to the center of the image */
if (drawable)

View File

@ -737,14 +737,14 @@ gimp_image_convert (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_CONVERT_UNDO_GROUP);
/* Relax the floating selection */
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
/* Push the image size to the stack */
undo_push_gimage_mod (gimage);
undo_push_image_size (gimage);
/* Set the new base type */
old_type = gimage->base_type;

View File

@ -115,7 +115,7 @@ gimp_image_crop (GimpImage *gimage,
if (active_layer_only)
{
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
layer = gimp_image_get_active_layer (gimage);
@ -138,14 +138,14 @@ gimp_image_crop (GimpImage *gimage,
{
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, CROP_UNDO);
undo_push_group_start (gimage, IMAGE_CROP_UNDO_GROUP);
/* relax the floating layer */
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
/* Push the image size to the stack */
undo_push_gimage_mod (gimage);
undo_push_image_size (gimage);
/* Set the new width and height */
gimage->width = width;
@ -214,7 +214,7 @@ gimp_image_crop (GimpImage *gimage,
guide_list_ptr = gimage->guides;
while ( guide_list_ptr != NULL)
{
undo_push_guide (gimage, (GimpGuide *) guide_list_ptr->data);
undo_push_image_guide (gimage, (GimpGuide *) guide_list_ptr->data);
guide_list_ptr = guide_list_ptr->next;
}
undo_push_group_end (gimage);

View File

@ -385,7 +385,7 @@ gimp_image_mask_float (GimpImage *gimage,
}
/* Start an undo group */
undo_push_group_start (gimage, FLOAT_MASK_UNDO);
undo_push_group_start (gimage, FS_FLOAT_UNDO_GROUP);
/* Cut the selected region */
tiles = gimp_image_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
@ -616,7 +616,7 @@ gimp_image_mask_stroke (GimpImage *gimage,
gimp_image_mask_stroking = TRUE;
/* Start an undo group */
undo_push_group_start (gimage, PAINT_CORE_UNDO);
undo_push_group_start (gimage, PAINT_UNDO_GROUP);
seg = 0;
cpnt = 0;

View File

@ -298,7 +298,7 @@ gimp_image_merge_layers (GimpImage *gimage,
return NULL;
/* Start a merge undo group */
undo_push_group_start (gimage, LAYER_MERGE_UNDO);
undo_push_group_start (gimage, IMAGE_LAYERS_MERGE_UNDO_GROUP);
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (layer)));

View File

@ -67,7 +67,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
if (! mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
undo_push_group_start (gimage, IMAGE_QMASK_UNDO_GROUP);
if (gimp_image_mask_is_empty (gimage))
{
@ -106,7 +106,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
undo_push_qmask (gimage);
undo_push_image_qmask (gimage);
undo_push_group_end (gimage);
@ -122,13 +122,13 @@ gimp_image_set_qmask_state (GimpImage *gimage,
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
undo_push_group_start (gimage, IMAGE_QMASK_UNDO_GROUP);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
undo_push_image_qmask (gimage);
if (gimage->qmask_inverted)
gimp_channel_invert (mask);

View File

@ -67,7 +67,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
if (! mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
undo_push_group_start (gimage, IMAGE_QMASK_UNDO_GROUP);
if (gimp_image_mask_is_empty (gimage))
{
@ -106,7 +106,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
undo_push_qmask (gimage);
undo_push_image_qmask (gimage);
undo_push_group_end (gimage);
@ -122,13 +122,13 @@ gimp_image_set_qmask_state (GimpImage *gimage,
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
undo_push_group_start (gimage, IMAGE_QMASK_UNDO_GROUP);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
undo_push_image_qmask (gimage);
if (gimage->qmask_inverted)
gimp_channel_invert (mask);

View File

@ -57,14 +57,14 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO_GROUP);
/* Relax the floating selection */
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
/* Push the image size to the stack */
undo_push_gimage_mod (gimage);
undo_push_image_size (gimage);
/* Set the new width and height */
gimage->width = new_width;
@ -92,14 +92,14 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);

View File

@ -69,14 +69,14 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
/* Relax the floating selection */
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
/* Push the image size to the stack */
undo_push_gimage_mod (gimage);
undo_push_image_size (gimage);
/* Set the new width and height */
@ -158,11 +158,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:

File diff suppressed because it is too large Load Diff

View File

@ -20,98 +20,8 @@
#define __UNDO_H__
gboolean undo_push_group_start (GimpImage *gimage,
UndoType type);
gboolean undo_push_group_end (GimpImage *gimage);
gboolean undo_push_image (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean undo_push_image_mod (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2,
gpointer tiles_ptr,
gboolean sparse);
gboolean undo_push_mask (GimpImage *gimage,
gpointer mask_ptr);
gboolean undo_push_layer_displace (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_transform (GimpImage *gimage,
gpointer tu_ptr);
gboolean undo_push_paint (GimpImage *gimage,
gpointer pu_ptr);
gboolean undo_push_layer (GimpImage *gimage,
UndoType type,
gpointer lu_ptr);
gboolean undo_push_layer_mod (GimpImage *gimage,
gpointer layer_ptr);
gboolean undo_push_layer_mask (GimpImage *gimage,
UndoType type,
gpointer lmu_prt);
gboolean undo_push_layer_change (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_channel (GimpImage *gimage,
UndoType type,
gpointer cu_ptr);
gboolean undo_push_channel_mod (GimpImage *gimage,
gpointer cmu_ptr);
gboolean undo_push_fs_to_layer (GimpImage *gimage,
gpointer fsu_ptr);
gboolean undo_push_fs_rigor (GimpImage *gimage,
gint32 layer_ID);
gboolean undo_push_fs_relax (GimpImage *gimage,
gint32 layer_ID);
gboolean undo_push_gimage_mod (GimpImage *gimage);
gboolean undo_push_guide (GimpImage *gimage,
gpointer guide);
gboolean undo_push_image_parasite (GimpImage *gimage,
gpointer parasite);
gboolean undo_push_drawable_parasite (GimpImage *gimage,
GimpDrawable *drawable,
gpointer parasite);
gboolean undo_push_image_parasite_remove
(GimpImage *gimage,
const gchar *name);
gboolean undo_push_drawable_parasite_remove
(GimpImage *gimage,
GimpDrawable *drabable,
const gchar *name);
gboolean undo_push_qmask (GimpImage *gimage);
gboolean undo_push_resolution (GimpImage *gimage);
gboolean undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_cantundo (GimpImage *gimage,
const gchar *action);
/* Argument to undo_event signal emitted by images */
gboolean undo_pop (GimpImage *gimage);
gboolean undo_redo (GimpImage *gimage);
void undo_free (GimpImage *gimage);
const gchar *undo_get_undo_name (GimpImage *gimage);
const gchar *undo_get_redo_name (GimpImage *gimage);
/* Stack peeking functions */
typedef gint (*undo_map_fn) (const gchar *undoitemname,
gpointer data);
void undo_map_over_undo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
void undo_map_over_redo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
UndoType undo_get_undo_top_type (GimpImage *gimage);
/* Argument to undo_event signal emitted by gimages: */
typedef enum
{
UNDO_PUSHED, /* a new undo has been added to the undo stack */
@ -122,4 +32,154 @@ typedef enum
} undo_event_t;
/* Stack peeking functions */
typedef gint (*undo_map_fn) (const gchar *undoitemname,
gpointer data);
/* main undo functions */
gboolean undo_pop (GimpImage *gimage);
gboolean undo_redo (GimpImage *gimage);
void undo_free (GimpImage *gimage);
const gchar * undo_get_undo_name (GimpImage *gimage);
const gchar * undo_get_redo_name (GimpImage *gimage);
void undo_map_over_undo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
void undo_map_over_redo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
UndoType undo_get_undo_top_type (GimpImage *gimage);
/* undo groups */
gboolean undo_push_group_start (GimpImage *gimage,
UndoType type);
gboolean undo_push_group_end (GimpImage *gimage);
/* image undos */
gboolean undo_push_image (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean undo_push_image_mod (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2,
TileManager *tiles,
gboolean sparse);
gboolean undo_push_image_size (GimpImage *gimage);
gboolean undo_push_image_resolution (GimpImage *gimage);
gboolean undo_push_image_mask (GimpImage *gimage,
TileManager *tiles,
gint x,
gint y);
gboolean undo_push_image_qmask (GimpImage *gimage);
gboolean undo_push_image_guide (GimpImage *gimage,
GimpGuide *guide);
/* layer undos */
gboolean undo_push_layer_add (GimpImage *gimage,
GimpLayer *layer,
gint prev_position,
GimpLayer *prev_layer);
gboolean undo_push_layer_remove (GimpImage *gimage,
GimpLayer *layer,
gint prev_position,
GimpLayer *prev_layer);
gboolean undo_push_layer_mod (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_mask_add (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
gboolean undo_push_layer_mask_remove (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
gboolean undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_displace (GimpImage *gimage,
GimpLayer *layer);
/* channel undos */
gboolean undo_push_channel_add (GimpImage *gimage,
GimpChannel *channel,
gint prev_position,
GimpChannel *prev_channel);
gboolean undo_push_channel_remove (GimpImage *gimage,
GimpChannel *channel,
gint prev_position,
GimpChannel *prev_channel);
gboolean undo_push_channel_mod (GimpImage *gimage,
GimpChannel *channel);
gboolean undo_push_channel_reposition (GimpImage *gimage,
GimpChannel *channel);
/* floating selection undos */
gboolean undo_push_fs_to_layer (GimpImage *gimage,
GimpLayer *floating_layer,
GimpDrawable *drawable);
gboolean undo_push_fs_rigor (GimpImage *gimage,
gint32 layer_ID);
gboolean undo_push_fs_relax (GimpImage *gimage,
gint32 layer_ID);
/* transform/paint drawable undos */
gboolean undo_push_transform (GimpImage *gimage,
gint tool_ID,
GType tool_type,
gdouble *trans_info,
TileManager *original,
GSList *path_undo);
gboolean undo_push_paint (GimpImage *gimage,
gint core_ID,
GType core_type,
GimpCoords *last_coords);
/* parasite undos */
gboolean undo_push_image_parasite (GimpImage *gimage,
gpointer parasite);
gboolean undo_push_image_parasite_remove
(GimpImage *gimage,
const gchar *name);
gboolean undo_push_drawable_parasite (GimpImage *gimage,
GimpDrawable *drawable,
gpointer parasite);
gboolean undo_push_drawable_parasite_remove
(GimpImage *gimage,
GimpDrawable *drabable,
const gchar *name);
/* EEK undo */
gboolean undo_push_cantundo (GimpImage *gimage,
const gchar *action);
#endif /* __UNDO_H__ */

View File

@ -51,6 +51,8 @@
#include "gimpparasitelist.h"
#include "gimpundostack.h"
#include "vectors/gimpvectors.h"
#include "path.h"
#include "undo.h"
@ -71,6 +73,7 @@ enum
FLOATING_SELECTION_CHANGED,
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
ACTIVE_VECTORS_CHANGED,
COMPONENT_VISIBILITY_CHANGED,
COMPONENT_ACTIVE_CHANGED,
MASK_CHANGED,
@ -223,6 +226,15 @@ gimp_image_class_init (GimpImageClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_VECTORS_CHANGED] =
g_signal_new ("active_vectors_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, active_vectors_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[COMPONENT_VISIBILITY_CHANGED] =
g_signal_new ("component_visibility_changed",
G_TYPE_FROM_CLASS (klass),
@ -366,6 +378,7 @@ gimp_image_class_init (GimpImageClass *klass)
klass->floating_selection_changed = NULL;
klass->active_layer_changed = NULL;
klass->active_channel_changed = NULL;
klass->active_vectors_changed = NULL;
klass->component_visibility_changed = NULL;
klass->component_active_changed = NULL;
klass->mask_changed = NULL;
@ -419,6 +432,8 @@ gimp_image_init (GimpImage *gimage)
GIMP_CONTAINER_POLICY_STRONG);
gimage->channels = gimp_list_new (GIMP_TYPE_CHANNEL,
GIMP_CONTAINER_POLICY_STRONG);
gimage->vectors = gimp_list_new (GIMP_TYPE_VECTORS,
GIMP_CONTAINER_POLICY_STRONG);
gimage->layer_stack = NULL;
gimage->active_layer = NULL;
@ -442,7 +457,7 @@ gimp_image_init (GimpImage *gimage)
gimage->undo_bytes = 0;
gimage->undo_levels = 0;
gimage->group_count = 0;
gimage->pushing_undo_group = UNDO_NULL;
gimage->pushing_undo_group = NO_UNDO_GROUP;
gimage->new_undo_stack = gimp_undo_stack_new (gimage);
gimage->new_redo_stack = gimp_undo_stack_new (gimage);
@ -499,6 +514,11 @@ gimp_image_finalize (GObject *object)
g_object_unref (G_OBJECT (gimage->channels));
gimage->channels = NULL;
}
if (gimage->vectors)
{
g_object_unref (G_OBJECT (gimage->vectors));
gimage->vectors = NULL;
}
if (gimage->layer_stack)
{
g_slist_free (gimage->layer_stack);
@ -585,6 +605,7 @@ gimp_image_get_memsize (GimpObject *object)
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->layers));
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->channels));
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->vectors));
memsize += g_slist_length (gimage->layer_stack) * sizeof (GSList);
@ -1034,7 +1055,7 @@ gimp_image_set_resolution (GimpImage *gimage,
if ((ABS (gimage->xresolution - xresolution) >= 1e-5) ||
(ABS (gimage->yresolution - yresolution) >= 1e-5))
{
undo_push_resolution (gimage);
undo_push_image_resolution (gimage);
gimage->xresolution = xresolution;
gimage->yresolution = yresolution;
@ -1072,7 +1093,7 @@ gimp_image_set_unit (GimpImage *gimage,
if (gimage->unit != unit)
{
undo_push_resolution (gimage);
undo_push_image_resolution (gimage);
gimage->unit = unit;
@ -2175,6 +2196,14 @@ gimp_image_get_channels (const GimpImage *gimage)
return gimage->channels;
}
GimpContainer *
gimp_image_get_vectors (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->vectors;
}
void
gimp_image_set_paths (GimpImage *gimage,
PathList *paths)
@ -2235,6 +2264,14 @@ gimp_image_get_active_channel (const GimpImage *gimage)
return gimage->active_channel;
}
GimpVectors *
gimp_image_get_active_vectors (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->active_vectors;
}
GimpLayer *
gimp_image_set_active_layer (GimpImage *gimage,
GimpLayer *layer)
@ -2283,6 +2320,7 @@ gimp_image_set_active_channel (GimpImage *gimage,
GimpChannel *channel)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
/* Not if there is a floating selection */
if (gimp_image_floating_sel (gimage))
@ -2343,6 +2381,31 @@ gimp_image_unset_active_channel (GimpImage *gimage)
return channel;
}
GimpVectors *
gimp_image_set_active_vectors (GimpImage *gimage,
GimpVectors *vectors)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
/* First, find the vectors
* If it doesn't exist, find the first vectors that does
*/
if (! gimp_container_have (gimage->vectors, GIMP_OBJECT (vectors)))
vectors = (GimpVectors *)
gimp_container_get_child_by_index (gimage->vectors, 0);
if (vectors != gimage->active_vectors)
{
gimage->active_vectors = vectors;
g_signal_emit (G_OBJECT (gimage),
gimp_image_signals[ACTIVE_VECTORS_CHANGED], 0);
}
return vectors;
}
gint
gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer)
@ -2365,8 +2428,19 @@ gimp_image_get_channel_index (const GimpImage *gimage,
GIMP_OBJECT (channel));
}
gint
gimp_image_get_vectors_index (const GimpImage *gimage,
const GimpVectors *vectors)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), -1);
return gimp_container_get_child_index (gimage->vectors,
GIMP_OBJECT (vectors));
}
GimpLayer *
gimp_image_get_layer_by_tattoo (const GimpImage *gimage,
gimp_image_get_layer_by_tattoo (const GimpImage *gimage,
GimpTattoo tattoo)
{
GimpLayer *layer;
@ -2409,6 +2483,52 @@ gimp_image_get_channel_by_tattoo (const GimpImage *gimage,
return NULL;
}
GimpVectors *
gimp_image_get_vectors_by_tattoo (const GimpImage *gimage,
GimpTattoo tattoo)
{
GimpVectors *vectors;
GList *list;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
{
vectors = (GimpVectors *) list->data;
#if 0
if (gimp_vectors_get_tattoo (GIMP_VECTORS (vectors)) == tattoo)
return vectors;
#endif
}
return NULL;
}
GimpLayer *
gimp_image_get_layer_by_name (const GimpImage *gimage,
const gchar *name)
{
GimpLayer *layer;
GList *list;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
if (! strcmp (gimp_object_get_name (GIMP_OBJECT (layer)), name))
return layer;
}
return NULL;
}
GimpChannel *
gimp_image_get_channel_by_name (const GimpImage *gimage,
const gchar *name)
@ -2418,13 +2538,36 @@ gimp_image_get_channel_by_name (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
for (list = GIMP_LIST (gimage->channels)->list;
list;
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
channel = (GimpChannel *) list->data;
if (! strcmp (gimp_object_get_name (GIMP_OBJECT (channel)), name))
return channel;
return channel;
}
return NULL;
}
GimpVectors *
gimp_image_get_vectors_by_name (const GimpImage *gimage,
const gchar *name)
{
GimpVectors *vectors;
GList *list;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
{
vectors = (GimpVectors *) list->data;
if (! strcmp (gimp_object_get_name (GIMP_OBJECT (vectors)), name))
return vectors;
}
return NULL;
@ -2435,8 +2578,6 @@ gimp_image_add_layer (GimpImage *gimage,
GimpLayer *layer,
gint position)
{
LayerUndo *lu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
@ -2455,12 +2596,10 @@ gimp_image_add_layer (GimpImage *gimage,
return FALSE;
}
/* Prepare a layer undo and push it */
lu = g_new (LayerUndo, 1);
lu->layer = layer;
lu->prev_position = 0;
lu->prev_layer = gimp_image_get_active_layer (gimage);
undo_push_layer (gimage, LAYER_ADD_UNDO, lu);
undo_push_layer_add (gimage,
layer,
0,
gimp_image_get_active_layer (gimage));
/* If the layer is a floating selection, set the ID */
if (gimp_layer_is_floating_sel (layer))
@ -2522,8 +2661,7 @@ void
gimp_image_remove_layer (GimpImage *gimage,
GimpLayer *layer)
{
LayerUndo *lu;
gint x, y, w, h;
gint x, y, w, h;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_LAYER (layer));
@ -2531,14 +2669,11 @@ gimp_image_remove_layer (GimpImage *gimage,
g_return_if_fail (gimp_container_have (gimage->layers,
GIMP_OBJECT (layer)));
/* Push a layer undo */
lu = g_new (LayerUndo, 1);
lu->layer = layer;
lu->prev_position = gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (layer));
lu->prev_layer = layer;
undo_push_layer (gimage, LAYER_REMOVE_UNDO, lu);
undo_push_layer_remove (gimage,
layer,
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (layer)),
layer);
g_object_ref (G_OBJECT (layer));
@ -2747,8 +2882,6 @@ gimp_image_add_channel (GimpImage *gimage,
GimpChannel *channel,
gint position)
{
ChannelUndo *cu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
@ -2767,12 +2900,10 @@ gimp_image_add_channel (GimpImage *gimage,
return FALSE;
}
/* Push a channel undo */
cu = g_new (ChannelUndo, 1);
cu->channel = channel;
cu->prev_position = 0;
cu->prev_channel = gimp_image_get_active_channel (gimage);
undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel_add (gimage,
channel,
0,
gimp_image_get_active_channel (gimage));
/* add the channel to the list */
gimp_container_add (gimage->channels, GIMP_OBJECT (channel));
@ -2795,21 +2926,17 @@ void
gimp_image_remove_channel (GimpImage *gimage,
GimpChannel *channel)
{
ChannelUndo *cu;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (gimp_container_have (gimage->channels,
GIMP_OBJECT (channel)));
/* Prepare a channel undo--push it below */
cu = g_new (ChannelUndo, 1);
cu->channel = channel;
cu->prev_position = gimp_container_get_child_index (gimage->channels,
GIMP_OBJECT (channel));
cu->prev_channel = gimp_image_get_active_channel (gimage);
undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
undo_push_channel_remove (gimage,
channel,
gimp_container_get_child_index (gimage->channels,
GIMP_OBJECT (channel)),
gimp_image_get_active_channel (gimage));
g_object_ref (G_OBJECT (channel));
@ -2884,7 +3011,7 @@ gboolean
gimp_image_position_channel (GimpImage *gimage,
GimpChannel *channel,
gint new_index,
gboolean push_undo /* FIXME unused */)
gboolean push_undo)
{
gint index;
gint num_channels;
@ -2904,6 +3031,9 @@ gimp_image_position_channel (GimpImage *gimage,
if (new_index == index)
return TRUE;
if (push_undo)
undo_push_channel_reposition (gimage, channel);
gimp_container_reorder (gimage->channels,
GIMP_OBJECT (channel), new_index);
@ -2915,6 +3045,171 @@ gimp_image_position_channel (GimpImage *gimage,
return TRUE;
}
gboolean
gimp_image_add_vectors (GimpImage *gimage,
GimpVectors *vectors,
gint position)
{
#if 0
VectorsUndo *vu;
#endif
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
#if 0
if (GIMP_VECTORS (vectors)->gimage != NULL &&
GIMP_VECTORS (vectors)->gimage != gimage)
{
g_warning ("%s: attempting to add vectors to wrong image.",
G_GNUC_PRETTY_FUNCTION);
return FALSE;
}
#endif
if (gimp_container_have (gimage->vectors, GIMP_OBJECT (vectors)))
{
g_warning ("%s: trying to add vectors to image twice.",
G_GNUC_PRETTY_FUNCTION);
return FALSE;
}
#if 0
/* Push a vectors undo */
vu = g_new (VectorsUndo, 1);
vu->vectors = vectors;
vu->prev_position = 0;
vu->prev_vectors = gimp_image_get_active_vectors (gimage);
undo_push_vectors (gimage, VECTORS_ADD_UNDO, vu);
#endif
/* add the vectors to the list */
gimp_container_add (gimage->vectors, GIMP_OBJECT (vectors));
g_object_unref (G_OBJECT (vectors));
/* notify this gimage of the currently active vectors */
gimp_image_set_active_vectors (gimage, vectors);
return TRUE;
}
void
gimp_image_remove_vectors (GimpImage *gimage,
GimpVectors *vectors)
{
#if 0
VectorsUndo *vu;
#endif
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
g_return_if_fail (gimp_container_have (gimage->vectors,
GIMP_OBJECT (vectors)));
#if 0
/* Prepare a channel undo--push it below */
vu = g_new (VectorsUndo, 1);
vu->vectors = vectors;
vu->prev_position = gimp_container_get_child_index (gimage->vectors,
GIMP_OBJECT (vectors));
vu->prev_vectors = gimp_image_get_active_vectors (gimage);
undo_push_vectors (gimage, VECTORS_REMOVE_UNDO, vu);
#endif
g_object_ref (G_OBJECT (vectors));
gimp_container_remove (gimage->vectors, GIMP_OBJECT (vectors));
#if 0
/* Send out REMOVED signal from vectors */
gimp_vectors_removed (GIMP_VECTORS (vectors));
#endif
if (vectors == gimp_image_get_active_vectors (gimage))
{
if (gimp_container_num_children (gimage->vectors) > 0)
{
gimp_image_set_active_vectors
(gimage,
GIMP_VECTORS (gimp_container_get_child_by_index (gimage->vectors,
0)));
}
}
g_object_unref (G_OBJECT (vectors));
}
gboolean
gimp_image_raise_vectors (GimpImage *gimage,
GimpVectors *vectors)
{
gint index;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
index = gimp_container_get_child_index (gimage->vectors,
GIMP_OBJECT (vectors));
if (index == 0)
{
g_message (_("Vectors cannot be raised higher."));
return FALSE;
}
return gimp_image_position_vectors (gimage, vectors, index - 1, TRUE);
}
gboolean
gimp_image_lower_vectors (GimpImage *gimage,
GimpVectors *vectors)
{
gint index;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
index = gimp_container_get_child_index (gimage->vectors,
GIMP_OBJECT (vectors));
if (index == gimp_container_num_children (gimage->vectors) - 1)
{
g_message (_("Vectors cannot be lowered more."));
return FALSE;
}
return gimp_image_position_vectors (gimage, vectors, index + 1, TRUE);
}
gboolean
gimp_image_position_vectors (GimpImage *gimage,
GimpVectors *vectors,
gint new_index,
gboolean push_undo /* FIXME unused */)
{
gint index;
gint num_vectors;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
index = gimp_container_get_child_index (gimage->vectors,
GIMP_OBJECT (vectors));
if (index < 0)
return FALSE;
num_vectors = gimp_container_num_children (gimage->vectors);
new_index = CLAMP (new_index, 0, num_vectors - 1);
if (new_index == index)
return TRUE;
gimp_container_reorder (gimage->vectors,
GIMP_OBJECT (vectors), new_index);
return TRUE;
}
gboolean
gimp_image_layer_boundary (const GimpImage *gimage,
BoundSeg **segs,

View File

@ -130,10 +130,13 @@ struct _GimpImage
/* Layer/Channel attributes */
GimpContainer *layers; /* the list of layers */
GimpContainer *channels; /* the list of masks */
GimpContainer *vectors; /* the list of vectors */
GSList *layer_stack; /* the layers in MRU order */
GimpLayer *active_layer; /* the active layer */
GimpChannel *active_channel; /* the active channel */
GimpVectors *active_vectors; /* the active vectors */
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
@ -174,6 +177,7 @@ struct _GimpImageClass
void (* floating_selection_changed) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* active_vectors_changed) (GimpImage *gimage);
void (* component_visibility_changed) (GimpImage *gimage,
GimpChannelType channel);
void (* component_active_changed) (GimpImage *gimage,
@ -369,10 +373,11 @@ gboolean gimp_image_set_tattoo_state (GimpImage *gimage,
GimpTattoo gimp_image_get_tattoo_state (GimpImage *gimage);
/* layers / channels / paths */
/* layers / channels / vectors / old paths */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
GimpContainer * gimp_image_get_vectors (const GimpImage *gimage);
void gimp_image_set_paths (GimpImage *gimage,
PathList *paths);
@ -381,23 +386,36 @@ PathList * gimp_image_get_paths (const GimpImage *gimage);
GimpDrawable * gimp_image_active_drawable (const GimpImage *gimage);
GimpLayer * gimp_image_get_active_layer (const GimpImage *gimage);
GimpChannel * gimp_image_get_active_channel (const GimpImage *gimage);
GimpVectors * gimp_image_get_active_vectors (const GimpImage *gimage);
GimpLayer * gimp_image_set_active_layer (GimpImage *gimage,
GimpLayer *layer);
GimpChannel * gimp_image_set_active_channel (GimpImage *gimage,
GimpChannel *channel);
GimpChannel * gimp_image_unset_active_channel (GimpImage *gimage);
GimpVectors * gimp_image_set_active_vectors (GimpImage *gimage,
GimpVectors *vectors);
gint gimp_image_get_layer_index (const GimpImage *gimage,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *gimage,
const GimpChannel *channel);
gint gimp_image_get_vectors_index (const GimpImage *gimage,
const GimpVectors *vectors);
GimpLayer * gimp_image_get_layer_by_tattoo (const GimpImage *gimage,
GimpTattoo tatoo);
GimpChannel * gimp_image_get_channel_by_tattoo (const GimpImage *gimage,
GimpTattoo tatoo);
GimpVectors * gimp_image_get_vectors_by_tattoo (const GimpImage *gimage,
GimpTattoo tatoo);
GimpLayer * gimp_image_get_layer_by_name (const GimpImage *gimage,
const gchar *name);
GimpChannel * gimp_image_get_channel_by_name (const GimpImage *gimage,
const gchar *name);
GimpVectors * gimp_image_get_vectors_by_name (const GimpImage *gimage,
const gchar *name);
gboolean gimp_image_add_layer (GimpImage *gimage,
GimpLayer *layer,
@ -433,6 +451,21 @@ gboolean gimp_image_position_channel (GimpImage *gimage,
gint new_index,
gboolean push_undo);
gboolean gimp_image_add_vectors (GimpImage *gimage,
GimpVectors *vectors,
gint position);
void gimp_image_remove_vectors (GimpImage *gimage,
GimpVectors *vectors);
gboolean gimp_image_raise_vectors (GimpImage *gimage,
GimpVectors *vectors);
gboolean gimp_image_lower_vectors (GimpImage *gimage,
GimpVectors *vectors);
gboolean gimp_image_position_vectors (GimpImage *gimage,
GimpVectors *vectors,
gint new_index,
gboolean push_undo);
gboolean gimp_image_layer_boundary (const GimpImage *gimage,
BoundSeg **segs,
gint *n_segs);

View File

@ -127,7 +127,7 @@ floating_sel_anchor (GimpLayer *layer)
}
/* Start a floating selection anchoring undo */
undo_push_group_start (gimage, FS_ANCHOR_UNDO);
undo_push_group_start (gimage, FS_ANCHOR_UNDO_GROUP);
/* Invalidate the previews of the layer that will be composited
* with the floating section.
@ -183,11 +183,11 @@ floating_sel_reset (GimpLayer *layer)
void
floating_sel_to_layer (GimpLayer *layer)
{
FStoLayerUndo *fsu;
gint off_x, off_y;
gint width, height;
GimpImage *gimage;
gint off_x, off_y;
gint width, height;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (! (gimage = gimp_drawable_gimage (GIMP_DRAWABLE (layer))))
return;
@ -213,18 +213,15 @@ floating_sel_to_layer (GimpLayer *layer)
width = gimp_drawable_width (layer->fs.drawable);
height = gimp_drawable_height (layer->fs.drawable);
/* allocate the undo structure */
fsu = g_new (FStoLayerUndo, 1);
fsu->layer = layer;
fsu->drawable = layer->fs.drawable;
undo_push_fs_to_layer (gimage, fsu);
undo_push_fs_to_layer (gimage,
layer,
layer->fs.drawable);
/* clear the selection */
gimp_layer_invalidate_boundary (layer);
/* Set pointers */
layer->fs.drawable = NULL;
layer->fs.drawable = NULL;
gimage->floating_sel = NULL;
gimp_drawable_set_visible (GIMP_DRAWABLE (layer), TRUE);

View File

@ -533,8 +533,7 @@ gimp_layer_add_mask (GimpLayer *layer,
GimpLayerMask *mask,
gboolean push_undo)
{
GimpImage *gimage;
LayerMaskUndo *lmu;
GimpImage *gimage;
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
@ -589,13 +588,7 @@ gimp_layer_add_mask (GimpLayer *layer,
GIMP_DRAWABLE (layer)->height);
if (push_undo)
{
/* Prepare a layer undo and push it */
lmu = g_new0 (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = mask;
undo_push_layer_mask (gimage, LAYER_MASK_ADD_UNDO, lmu);
}
undo_push_layer_mask_add (gimage, layer, mask);
g_signal_emit (G_OBJECT (layer), layer_signals[MASK_CHANGED], 0);
@ -744,14 +737,12 @@ gimp_layer_apply_mask (GimpLayer *layer,
MaskApplyMode mode,
gboolean push_undo)
{
GimpImage *gimage;
LayerMaskUndo *lmu = NULL;
gint off_x;
gint off_y;
PixelRegion srcPR, maskPR;
gboolean view_changed = FALSE;
GimpImage *gimage;
gint off_x;
gint off_y;
PixelRegion srcPR, maskPR;
gboolean view_changed = FALSE;
g_return_if_fail (layer != NULL);
g_return_if_fail (GIMP_IS_LAYER (layer));
if (! layer->mask)
@ -768,18 +759,14 @@ gimp_layer_apply_mask (GimpLayer *layer,
if (push_undo)
{
/* Start an undo group */
undo_push_group_start (gimage, LAYER_APPLY_MASK_UNDO);
undo_push_group_start (gimage, LAYER_APPLY_MASK_UNDO_GROUP);
/* Prepare a layer mask undo--push it below */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = layer->mask;
undo_push_layer_mask_remove (gimage, layer, layer->mask);
}
/* check if applying the mask changes the projection */
if ((mode == APPLY && (!layer->mask->apply_mask || layer->mask->show_mask)) ||
(mode == DISCARD && ( layer->mask->apply_mask || layer->mask->show_mask)))
if ((mode == APPLY && (! layer->mask->apply_mask || layer->mask->show_mask)) ||
(mode == DISCARD && ( layer->mask->apply_mask || layer->mask->show_mask)))
{
view_changed = TRUE;
}
@ -812,17 +799,11 @@ gimp_layer_apply_mask (GimpLayer *layer,
GIMP_DRAWABLE (layer)->preview_valid = FALSE;
}
g_object_unref (G_OBJECT (layer->mask));
layer->mask = NULL;
if (push_undo)
{
/* Push the undo--Important to do it here, AFTER applying
* the mask, in case the undo push fails and the
* mask is deleted
*/
undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu);
/* end the undo group */
undo_push_group_end (gimage);
}
@ -1296,7 +1277,7 @@ gimp_layer_resize_to_image (GimpLayer *layer)
if (!(gimage = GIMP_DRAWABLE (layer)->gimage))
return;
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);

View File

@ -70,22 +70,6 @@ struct _GimpLayerClass
};
/* Special undo types */
struct _LayerUndo
{
GimpLayer *layer; /* the actual layer */
gint prev_position; /* former position in list */
GimpLayer *prev_layer; /* previous active layer */
};
struct _FStoLayerUndo
{
GimpLayer *layer; /* the layer */
GimpDrawable *drawable; /* drawable of floating sel */
};
/* function declarations */
GType gimp_layer_get_type (void) G_GNUC_CONST;

View File

@ -54,15 +54,6 @@ struct _GimpLayerMaskClass
};
/* Special undo type */
struct _LayerMaskUndo
{
GimpLayer *layer; /* the layer */
GimpLayerMask *mask; /* the layer mask */
};
/* function declarations */
GType gimp_layer_mask_get_type (void) G_GNUC_CONST;

View File

@ -61,7 +61,7 @@ gimp_display_shell_drop_drawable (GtkWidget *widget,
drawable = GIMP_DRAWABLE (viewable);
undo_push_group_start (gdisp->gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gdisp->gimage, EDIT_PASTE_UNDO_GROUP);
new_layer = gimp_layer_new_from_drawable (gdisp->gimage, drawable);

View File

@ -359,7 +359,7 @@ channels_new_channel_query (GimpImage *gimage,
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
new_channel = gimp_channel_new (gimage,
width, height,

View File

@ -432,7 +432,7 @@ image_scale_implement (ImageResize *image_scale)
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
gimp_image_set_resolution (gimage,
image_scale->resize->resolution_x,
@ -444,7 +444,7 @@ image_scale_implement (ImageResize *image_scale)
if (image_scale->resize->unit != gimage->unit)
{
if (! display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
gimp_image_set_unit (gimage, image_scale->resize->unit);
@ -460,7 +460,7 @@ image_scale_implement (ImageResize *image_scale)
GimpProgress *progress;
if (! display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO_GROUP);
progress = gimp_progress_start (image_scale->gdisp,
_("Scaling..."),

View File

@ -512,9 +512,6 @@ new_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = options->gimage))
{
/* Start a group undo */
undo_push_group_start (gimage, LAYER_ADD_UNDO);
layer = gimp_layer_new (gimage, options->xsize, options->ysize,
gimp_image_base_type_with_alpha (gimage),
layer_name, OPAQUE_OPACITY, GIMP_NORMAL_MODE);
@ -525,9 +522,6 @@ new_layer_query_ok_callback (GtkWidget *widget,
fill_type);
gimp_image_add_layer (gimage, layer, -1);
/* End the group undo */
undo_push_group_end (gimage);
gdisplays_flush ();
}
else
@ -577,7 +571,7 @@ layers_new_layer_query (GimpImage *gimage,
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
undo_push_group_start (gimage, EDIT_PASTE_UNDO_GROUP);
new_layer = gimp_layer_new (gimage, width, height,
gimp_image_base_type_with_alpha (gimage),
@ -1008,7 +1002,7 @@ scale_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = GIMP_DRAWABLE (layer)->gimage) != NULL)
{
undo_push_group_start (gimage, LAYER_SCALE_UNDO);
undo_push_group_start (gimage, LAYER_SCALE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
@ -1097,7 +1091,7 @@ resize_layer_query_ok_callback (GtkWidget *widget,
if ((gimage = GIMP_DRAWABLE (layer)->gimage) != NULL)
{
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);

View File

@ -2113,7 +2113,7 @@ paths_dialog_export_path_callback (GtkWidget *widget,
* undo buffer. So deleted paths will not suddenly reappear. (I did say
* generally paths are not part of the undo structures).
*/
PathUndo *
GSList *
path_transform_start_undo (GimpImage *gimage)
{
/* Save only the locked paths away */
@ -2142,11 +2142,11 @@ path_transform_start_undo (GimpImage *gimage)
}
}
return (PathUndo *) undo_list;
return undo_list;
}
void
path_transform_free_undo (PathUndo *pundo)
path_transform_free_undo (GSList *pundo)
{
GSList *pundolist = (GSList*)pundo;
Path *p;
@ -2164,7 +2164,7 @@ path_transform_free_undo (PathUndo *pundo)
void
path_transform_do_undo (GimpImage *gimage,
PathUndo *pundo)
GSList *pundo)
{
GSList *pundolist;
/* Restore the paths as they were before this transform took place. */

View File

@ -409,8 +409,7 @@ void
gimp_paint_core_finish (GimpPaintCore *core,
GimpDrawable *drawable)
{
GimpImage *gimage;
GimpPaintCoreUndo *pu;
GimpImage *gimage;
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
@ -426,15 +425,12 @@ gimp_paint_core_finish (GimpPaintCore *core,
(core->y2 == core->y1))
return;
undo_push_group_start (gimage, PAINT_CORE_UNDO);
undo_push_group_start (gimage, PAINT_UNDO_GROUP);
pu = g_new0 (GimpPaintCoreUndo, 1);
pu->core_ID = core->ID;
pu->core_type = G_TYPE_FROM_INSTANCE (core);
pu->last_coords = core->start_coords;
/* Push a paint undo */
undo_push_paint (gimage, pu);
undo_push_paint (gimage,
core->ID,
G_TYPE_FROM_INSTANCE (core),
&core->start_coords);
/* push an undo */
gimp_drawable_apply_image (drawable,

View File

@ -138,17 +138,6 @@ struct _GimpPaintCoreClass
};
typedef struct _GimpPaintCoreUndo GimpPaintCoreUndo;
struct _GimpPaintCoreUndo
{
gint core_ID;
GType core_type;
GimpCoords last_coords;
};
GType gimp_paint_core_get_type (void) G_GNUC_CONST;
void gimp_paint_core_paint (GimpPaintCore *core,

View File

@ -20,10 +20,10 @@
#define __PATH_TRANSFORM_H__
PathUndo * path_transform_start_undo (GimpImage *gimage);
void path_transform_free_undo (PathUndo *pundo);
GSList * path_transform_start_undo (GimpImage *gimage);
void path_transform_free_undo (GSList *pundo);
void path_transform_do_undo (GimpImage *gimage,
PathUndo *pundo);
GSList *pundo);
void path_transform_current_path (GimpImage *gimage,
GimpMatrix3 transform,

View File

@ -75,7 +75,7 @@ image_add_hguide_invoker (Gimp *gimp,
if (offset < gimage->height)
{
guide = gimp_image_add_hguide (gimage);
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position = offset;
guide_ID = guide->guide_ID;
}
@ -154,7 +154,7 @@ image_add_vguide_invoker (Gimp *gimp,
if (offset < gimage->width)
{
guide = gimp_image_add_vguide (gimage);
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position = offset;
guide_ID = guide->guide_ID;
}
@ -241,7 +241,7 @@ image_delete_guide_invoker (Gimp *gimp,
tmp_next = guides->next;
undo_push_guide (gimage, ((GimpGuide *) guides->data));
undo_push_image_guide (gimage, ((GimpGuide *) guides->data));
gimp_image_delete_guide (gimage, (GimpGuide *) guides->data);
guides = tmp_next;
}

View File

@ -398,7 +398,7 @@ layer_scale_invoker (Gimp *gimp,
{
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, LAYER_SCALE_UNDO);
undo_push_group_start (gimage, LAYER_SCALE_UNDO_GROUP);
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
@ -492,7 +492,7 @@ layer_resize_invoker (Gimp *gimp,
{
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
@ -631,7 +631,7 @@ layer_translate_invoker (Gimp *gimp,
{
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, LINKED_LAYER_UNDO);
undo_push_group_start (gimage, LAYER_LINKED_UNDO_GROUP);
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
@ -762,7 +762,7 @@ layer_set_offsets_invoker (Gimp *gimp,
{
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, LINKED_LAYER_UNDO);
undo_push_group_start (gimage, LAYER_LINKED_UNDO_GROUP);
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);

View File

@ -53,7 +53,7 @@ undo_push_group_start_invoker (Gimp *gimp,
success = FALSE;
if (success)
undo_push_group_start (gimage, MISC_UNDO);
undo_push_group_start (gimage, MISC_UNDO_GROUP);
return procedural_db_return_args (&undo_push_group_start_proc, success);
}

View File

@ -3416,7 +3416,7 @@ bezier_stroke (GimpBezierSelectTool *bezier_sel,
rpnts = g_new0 (BezierRenderPnts, 1);
/* Start an undo group */
undo_push_group_start (gdisp->gimage, PAINT_CORE_UNDO);
undo_push_group_start (gdisp->gimage, PAINT_UNDO_GROUP);
bezier_gen_points (bezier_sel,open_path,rpnts);

View File

@ -241,7 +241,7 @@ init_edit_selection (GimpTool *tool,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO);
undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO_GROUP);
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&off_x, &off_y);
@ -894,7 +894,7 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
if (inc_x == 0 && inc_y == 0 && mask_inc_x == 0 && mask_inc_y == 0)
return;
undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO);
undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO_GROUP);
if (mask_inc_x != 0 || mask_inc_y != 0)
gimp_image_mask_translate (gdisp->gimage, mask_inc_x, mask_inc_y);

View File

@ -292,12 +292,13 @@ gimp_measure_tool_button_press (GimpTool *tool,
gdisp->gimage->width)));
if (create_hguide && create_vguide)
undo_push_group_start (gdisp->gimage, GUIDE_UNDO);
undo_push_group_start (gdisp->gimage,
IMAGE_GUIDE_UNDO_GROUP);
if (create_hguide)
{
guide = gimp_image_add_hguide (gdisp->gimage);
undo_push_guide (gdisp->gimage, guide);
undo_push_image_guide (gdisp->gimage, guide);
guide->position = measure_tool->y[i];
gimp_image_update_guide (gdisp->gimage, guide);
@ -306,7 +307,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
if (create_vguide)
{
guide = gimp_image_add_vguide (gdisp->gimage);
undo_push_guide (gdisp->gimage, guide);
undo_push_image_guide (gdisp->gimage, guide);
guide->position = measure_tool->x[i];
gimp_image_update_guide (gdisp->gimage, guide);

View File

@ -261,7 +261,7 @@ gimp_move_tool_button_press (GimpTool *tool,
if (gdisp->draw_guides &&
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y)))
{
undo_push_guide (gdisp->gimage, guide);
undo_push_image_guide (gdisp->gimage, guide);
gimp_image_update_guide (gdisp->gimage, guide);
gimp_image_remove_guide (gdisp->gimage, guide);
@ -647,7 +647,7 @@ gimp_move_tool_start_guide (GimpTool *tool,
move->disp = gdisp;
undo_push_guide (gdisp->gimage, move->guide);
undo_push_image_guide (gdisp->gimage, move->guide);
gimp_tool_set_cursor (tool, gdisp,
GDK_HAND2,

View File

@ -488,7 +488,7 @@ text_render (GimpImage *gimage,
apply_mask_to_region (&textPR, &maskPR, OPAQUE_OPACITY);
/* Start a group undo */
undo_push_group_start (gimage, TEXT_UNDO);
undo_push_group_start (gimage, TEXT_UNDO_GROUP);
/* Set the layer offsets */
GIMP_DRAWABLE (layer)->offset_x = text_x;

View File

@ -708,12 +708,10 @@ static void
gimp_transform_tool_doit (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
GimpTool *tool;
TileManager *new_tiles;
TransformUndo *tu;
PathUndo *pundo;
gboolean new_layer;
gint i;
GimpTool *tool;
TileManager *new_tiles;
GSList *path_undo;
gboolean new_layer;
gimp_set_busy (gdisp->gimage->gimp);
@ -728,7 +726,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
tool->preserve = TRUE;
/* Start a transform undo group */
undo_push_group_start (gdisp->gimage, TRANSFORM_CORE_UNDO);
undo_push_group_start (gdisp->gimage, TRANSFORM_UNDO_GROUP);
/* With the old UI, if original is NULL, then this is the
* first transformation. In the new UI, it is always so, right?
@ -744,7 +742,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
&new_layer);
pundo = path_transform_start_undo (gdisp->gimage);
path_undo = path_transform_start_undo (gdisp->gimage);
/* Send the request for the transformation to the tool...
*/
@ -764,23 +762,17 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
new_tiles,
new_layer);
/* create and initialize the transform_undo structure */
tu = g_new0 (TransformUndo, 1);
tu->tool_ID = tool->ID;
tu->tool_type = G_TYPE_FROM_INSTANCE (tool);
for (i = 0; i < TRAN_INFO_SIZE; i++)
tu->trans_info[i] = tr_tool->old_trans_info[i];
tu->original = NULL;
tu->path_undo = pundo;
/* Make a note of the new current drawable (since we may have
* a floating selection, etc now.
*/
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
undo_push_transform (gdisp->gimage, tu);
undo_push_transform (gdisp->gimage,
tool->ID,
G_TYPE_FROM_INSTANCE (tool),
tr_tool->old_trans_info,
NULL,
path_undo);
}
/* push the undo group end */

View File

@ -22,9 +22,7 @@
#include "gimpdrawtool.h"
/* FIXME */
#include "gui/gui-types.h"
#include "gui/gui-types.h" /* FIXME */
/* buffer sizes for scaling information strings (for the info dialog) */
@ -106,18 +104,6 @@ struct _GimpTransformToolClass
};
typedef struct _TransformUndo TransformUndo;
struct _TransformUndo
{
gint tool_ID;
GType tool_type;
TransInfo trans_info;
TileManager *original;
gpointer path_undo;
};
GType gimp_transform_tool_get_type (void) G_GNUC_CONST;

2835
app/undo.c

File diff suppressed because it is too large Load Diff

View File

@ -20,98 +20,8 @@
#define __UNDO_H__
gboolean undo_push_group_start (GimpImage *gimage,
UndoType type);
gboolean undo_push_group_end (GimpImage *gimage);
gboolean undo_push_image (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean undo_push_image_mod (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2,
gpointer tiles_ptr,
gboolean sparse);
gboolean undo_push_mask (GimpImage *gimage,
gpointer mask_ptr);
gboolean undo_push_layer_displace (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_transform (GimpImage *gimage,
gpointer tu_ptr);
gboolean undo_push_paint (GimpImage *gimage,
gpointer pu_ptr);
gboolean undo_push_layer (GimpImage *gimage,
UndoType type,
gpointer lu_ptr);
gboolean undo_push_layer_mod (GimpImage *gimage,
gpointer layer_ptr);
gboolean undo_push_layer_mask (GimpImage *gimage,
UndoType type,
gpointer lmu_prt);
gboolean undo_push_layer_change (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_channel (GimpImage *gimage,
UndoType type,
gpointer cu_ptr);
gboolean undo_push_channel_mod (GimpImage *gimage,
gpointer cmu_ptr);
gboolean undo_push_fs_to_layer (GimpImage *gimage,
gpointer fsu_ptr);
gboolean undo_push_fs_rigor (GimpImage *gimage,
gint32 layer_ID);
gboolean undo_push_fs_relax (GimpImage *gimage,
gint32 layer_ID);
gboolean undo_push_gimage_mod (GimpImage *gimage);
gboolean undo_push_guide (GimpImage *gimage,
gpointer guide);
gboolean undo_push_image_parasite (GimpImage *gimage,
gpointer parasite);
gboolean undo_push_drawable_parasite (GimpImage *gimage,
GimpDrawable *drawable,
gpointer parasite);
gboolean undo_push_image_parasite_remove
(GimpImage *gimage,
const gchar *name);
gboolean undo_push_drawable_parasite_remove
(GimpImage *gimage,
GimpDrawable *drabable,
const gchar *name);
gboolean undo_push_qmask (GimpImage *gimage);
gboolean undo_push_resolution (GimpImage *gimage);
gboolean undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_cantundo (GimpImage *gimage,
const gchar *action);
/* Argument to undo_event signal emitted by images */
gboolean undo_pop (GimpImage *gimage);
gboolean undo_redo (GimpImage *gimage);
void undo_free (GimpImage *gimage);
const gchar *undo_get_undo_name (GimpImage *gimage);
const gchar *undo_get_redo_name (GimpImage *gimage);
/* Stack peeking functions */
typedef gint (*undo_map_fn) (const gchar *undoitemname,
gpointer data);
void undo_map_over_undo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
void undo_map_over_redo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
UndoType undo_get_undo_top_type (GimpImage *gimage);
/* Argument to undo_event signal emitted by gimages: */
typedef enum
{
UNDO_PUSHED, /* a new undo has been added to the undo stack */
@ -122,4 +32,154 @@ typedef enum
} undo_event_t;
/* Stack peeking functions */
typedef gint (*undo_map_fn) (const gchar *undoitemname,
gpointer data);
/* main undo functions */
gboolean undo_pop (GimpImage *gimage);
gboolean undo_redo (GimpImage *gimage);
void undo_free (GimpImage *gimage);
const gchar * undo_get_undo_name (GimpImage *gimage);
const gchar * undo_get_redo_name (GimpImage *gimage);
void undo_map_over_undo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
void undo_map_over_redo_stack (GimpImage *gimage,
undo_map_fn fn,
gpointer data);
UndoType undo_get_undo_top_type (GimpImage *gimage);
/* undo groups */
gboolean undo_push_group_start (GimpImage *gimage,
UndoType type);
gboolean undo_push_group_end (GimpImage *gimage);
/* image undos */
gboolean undo_push_image (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean undo_push_image_mod (GimpImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2,
TileManager *tiles,
gboolean sparse);
gboolean undo_push_image_size (GimpImage *gimage);
gboolean undo_push_image_resolution (GimpImage *gimage);
gboolean undo_push_image_mask (GimpImage *gimage,
TileManager *tiles,
gint x,
gint y);
gboolean undo_push_image_qmask (GimpImage *gimage);
gboolean undo_push_image_guide (GimpImage *gimage,
GimpGuide *guide);
/* layer undos */
gboolean undo_push_layer_add (GimpImage *gimage,
GimpLayer *layer,
gint prev_position,
GimpLayer *prev_layer);
gboolean undo_push_layer_remove (GimpImage *gimage,
GimpLayer *layer,
gint prev_position,
GimpLayer *prev_layer);
gboolean undo_push_layer_mod (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_mask_add (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
gboolean undo_push_layer_mask_remove (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
gboolean undo_push_layer_rename (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GimpImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_displace (GimpImage *gimage,
GimpLayer *layer);
/* channel undos */
gboolean undo_push_channel_add (GimpImage *gimage,
GimpChannel *channel,
gint prev_position,
GimpChannel *prev_channel);
gboolean undo_push_channel_remove (GimpImage *gimage,
GimpChannel *channel,
gint prev_position,
GimpChannel *prev_channel);
gboolean undo_push_channel_mod (GimpImage *gimage,
GimpChannel *channel);
gboolean undo_push_channel_reposition (GimpImage *gimage,
GimpChannel *channel);
/* floating selection undos */
gboolean undo_push_fs_to_layer (GimpImage *gimage,
GimpLayer *floating_layer,
GimpDrawable *drawable);
gboolean undo_push_fs_rigor (GimpImage *gimage,
gint32 layer_ID);
gboolean undo_push_fs_relax (GimpImage *gimage,
gint32 layer_ID);
/* transform/paint drawable undos */
gboolean undo_push_transform (GimpImage *gimage,
gint tool_ID,
GType tool_type,
gdouble *trans_info,
TileManager *original,
GSList *path_undo);
gboolean undo_push_paint (GimpImage *gimage,
gint core_ID,
GType core_type,
GimpCoords *last_coords);
/* parasite undos */
gboolean undo_push_image_parasite (GimpImage *gimage,
gpointer parasite);
gboolean undo_push_image_parasite_remove
(GimpImage *gimage,
const gchar *name);
gboolean undo_push_drawable_parasite (GimpImage *gimage,
GimpDrawable *drawable,
gpointer parasite);
gboolean undo_push_drawable_parasite_remove
(GimpImage *gimage,
GimpDrawable *drabable,
const gchar *name);
/* EEK undo */
gboolean undo_push_cantundo (GimpImage *gimage,
const gchar *action);
#endif /* __UNDO_H__ */

View File

@ -68,6 +68,7 @@
#include "gimprc.h"
#include "undo.h"
#include "undo_types.h"
#include "libgimp/gimpintl.h"
@ -302,7 +303,7 @@ undo_history_set_pixmap_idle (gpointer data)
utype = undo_get_undo_top_type (idle->gimage);
if ((utype != MASK_UNDO && utype != QMASK_UNDO) ||
if ((utype != IMAGE_MASK_UNDO && utype != IMAGE_QMASK_UNDO) ||
(mbuf = mask_render_preview (idle->gimage, &width, &height)) == NULL)
{
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (idle->gimage),

View File

@ -20,71 +20,41 @@
#define __UNDO_TYPES_H__
typedef struct _LayerUndo LayerUndo;
typedef struct _LayerMaskUndo LayerMaskUndo;
typedef struct _FStoLayerUndo FStoLayerUndo;
typedef GSList PathUndo;
/* Undo types */
/* NOTE: If you change this list, please update the textual mapping at
* the bottom of undo.c as well.
/* Undo types which actually do something, unlike the ones in
* core/core-types.h, which are only for pushing groups
*/
typedef enum
{
/* Type UNDO_NULL (0) is special - in the gimpimage structure it
* means there is no undo group currently being added to.
*/
UNDO_NULL = 0, /* Picky compilers demand this in the enumeration - gosgood@idt.net */
IMAGE_UNDO,
IMAGE_UNDO = LAST_UNDO_GROUP + 1,
IMAGE_MOD_UNDO,
MASK_UNDO,
LAYER_DISPLACE_UNDO,
TRANSFORM_UNDO,
PAINT_UNDO,
IMAGE_SIZE_UNDO,
IMAGE_RESOLUTION_UNDO,
IMAGE_MASK_UNDO,
IMAGE_QMASK_UNDO,
IMAGE_GUIDE_UNDO,
LAYER_ADD_UNDO,
LAYER_REMOVE_UNDO,
LAYER_MOD,
LAYER_MOD_UNDO,
LAYER_MASK_ADD_UNDO,
LAYER_MASK_REMOVE_UNDO,
LAYER_RENAME_UNDO,
LAYER_REPOSITION_UNDO,
LAYER_DISPLACE_UNDO,
CHANNEL_ADD_UNDO,
CHANNEL_REMOVE_UNDO,
CHANNEL_MOD,
CHANNEL_MOD_UNDO,
CHANNEL_REPOSITION_UNDO,
FS_TO_LAYER_UNDO,
GIMAGE_MOD,
FS_RIGOR,
FS_RELAX,
GUIDE_UNDO,
TEXT_UNDO,
FLOAT_MASK_UNDO,
EDIT_PASTE_UNDO,
EDIT_CUT_UNDO,
TRANSFORM_CORE_UNDO,
PAINT_CORE_UNDO,
FLOATING_LAYER_UNDO,
LINKED_LAYER_UNDO,
LAYER_APPLY_MASK_UNDO,
LAYER_MERGE_UNDO,
FS_ANCHOR_UNDO,
GIMAGE_MOD_UNDO,
CROP_UNDO,
LAYER_SCALE_UNDO,
LAYER_RESIZE_UNDO,
QMASK_UNDO,
FS_RIGOR_UNDO,
FS_RELAX_UNDO,
TRANSFORM_UNDO,
PAINT_UNDO,
PARASITE_ATTACH_UNDO,
PARASITE_REMOVE_UNDO,
RESOLUTION_UNDO,
IMAGE_SCALE_UNDO,
IMAGE_RESIZE_UNDO,
MISC_UNDO = 100
} UndoType;
CANT_UNDO
} UndoImplType;
#endif /* __UNDO_TYPES_H__ */

View File

@ -55,7 +55,7 @@ HELP
if (offset < gimage->$max)
{
guide = gimp_image_add_${func}guide (gimage);
undo_push_guide (gimage, guide);
undo_push_image_guide (gimage, guide);
guide->position = offset;
guide_ID = guide->guide_ID;
}
@ -112,7 +112,7 @@ HELP
tmp_next = guides->next;
undo_push_guide (gimage, ((GimpGuide *) guides->data));
undo_push_image_guide (gimage, ((GimpGuide *) guides->data));
gimp_image_delete_guide (gimage, (GimpGuide *) guides->data);
guides = tmp_next;
}

View File

@ -49,7 +49,7 @@ sub layer_change_invoke {
{
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, ${undo}_UNDO);
undo_push_group_start (gimage, ${undo}_UNDO_GROUP);
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
@ -387,7 +387,7 @@ HELP
desc => "Offset in $_ direction" }
}
&layer_change_invoke('LINKED_LAYER', <<'CODE');
&layer_change_invoke('LAYER_LINKED', <<'CODE');
{
for (layer_list = GIMP_LIST (gimage->layers)->list;
layer_list;

View File

@ -38,7 +38,7 @@ HELP
&inargs;
%invoke = ( code => 'undo_push_group_start (gimage, MISC_UNDO);' );
%invoke = ( code => 'undo_push_group_start (gimage, MISC_UNDO_GROUP);' );
}
sub undo_push_group_end {