GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 884b3aa7 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Made drawable/layer properties (visibility, opacity etc.) undoable (fixes

2003-03-17  Michael Natterer  <mitch@gimp.org>

	Made drawable/layer properties (visibility, opacity etc.)
	undoable (fixes bug #73893).

	* app/core/core-enums.[ch]: added undo types/groups for
	visibility, mode, opacity, linked and preserve_trans.

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
	ref'ed GimpItem pointer so (1) this doesn't need to be done by all
	undo steps related to an item and (2) the item the undo step is
	for can be determined from outside the undo system.

	* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
	which returns a new GimpItemUndo.

	* app/core/gimpimage-undo-push.[ch]: use it for all item related
	undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
	and GimpVectors pointers from the private undo structs. Added
	undo push functions for the new undo types added above.

	* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
	"gboolean push_undo" parameter.

	* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
	_preserve_trans, _linked): added "gboolean push_undo" parameters.

	* app/core/gimpimage-mask.c
	* app/core/gimpimage-merge.c
	* app/core/gimplayer-floating-sel.c
	* app/tools/gimpmovetool.c
	* app/xcf/xcf-load.c
	* app/widgets/gimpdrawablelistitem.c
	* app/widgets/gimplayerlistitem.c
	* app/widgets/gimplayerlistview.c: changed accordingly.

	* tools/pdbgen/pdb/channel.pdb
	* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
	the foo_accessors() functions. Removed $func from foo_accesors()
	because we don't manipulate items without using getters/setters
	any longer.

	* app/pdb/channel_cmds.c
	* app/pdb/layer_cmds.c: regenerated.

	* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
	which carries an additional "GdkModifierType state" parameter as
	in GimpCellRendererViewable .

	* app/widgets/gimpcontainertreeview.c: emit "clicked" from
	the toggle renderer, not "toggled" so the callbacks get the
	modifier state.

	* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
	visible by <shift>+click" feature as in 1.2.

	* app/widgets/gimplayertreeview.c: compress layer opacity undos by
	looking at the top of the undo stack and not pushing an undo if
	there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
	layer.
parent c356f32a
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 Sven Neumann <sven@gimp.org>
* plug-ins/ifscompose/ifscompose.c (run): put the actual effect
......@@ -123,6 +123,8 @@ libappcore_a_sources = \
gimpimagemap.h \
gimpitem.c \
gimpitem.h \
gimpitemundo.c \
gimpitemundo.h \
gimplayer.c \
gimplayer.h \
gimplayer-floating-sel.c \
......
......@@ -436,11 +436,13 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_GROUP_IMAGE_QMASK, N_("QuickMask"), "group-image-qmask" },
{ GIMP_UNDO_GROUP_IMAGE_GUIDE, N_("Guide"), "group-image-guide" },
{ GIMP_UNDO_GROUP_ITEM_PROPERTIES, N_("Item Properties"), "group-item-properties" },
{ GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY, N_("Drawable Visilibity"), "group-drawable-visibility" },
{ GIMP_UNDO_GROUP_LAYER_SCALE, N_("Scale Layer"), "group-layer-scale" },
{ GIMP_UNDO_GROUP_LAYER_RESIZE, N_("Resize Layer"), "group-layer-resize" },
{ GIMP_UNDO_GROUP_LAYER_DISPLACE, N_("Move Layer"), "group-layer-displace" },
{ GIMP_UNDO_GROUP_LAYER_LINKED, N_("Linked Layer"), "group-layer-linked" },
{ GIMP_UNDO_GROUP_LAYER_APPLY_MASK, N_("Apply Layer Mask"), "group-layer-apply-mask" },
{ GIMP_UNDO_GROUP_FS_TO_LAYER, N_("Floating Selection to Layer"), "group-fs-to-layer" },
{ GIMP_UNDO_GROUP_FS_FLOAT, N_("Float Selection"), "group-fs-float" },
{ GIMP_UNDO_GROUP_FS_ANCHOR, N_("Anchor Floating Selection"), "group-fs-anchor" },
{ GIMP_UNDO_GROUP_EDIT_PASTE, N_("Paste"), "group-edit-paste" },
......@@ -461,22 +463,27 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_IMAGE_GUIDE, N_("Guide"), "image-guide" },
{ GIMP_UNDO_MASK, N_("Selection Mask"), "mask" },
{ GIMP_UNDO_ITEM_RENAME, N_("Rename Item"), "item-rename" },
{ GIMP_UNDO_DRAWABLE_VISIBILITY, N_("Drawable Visibility"), "drawable-visibility" },
{ GIMP_UNDO_LAYER_ADD, N_("New Layer"), "layer-add" },
{ GIMP_UNDO_LAYER_REMOVE, N_("Delete Layer"), "layer-remove" },
{ GIMP_UNDO_LAYER_MOD, N_("Layer Mod"), "layer-mod" },
{ GIMP_UNDO_LAYER_MASK_ADD, N_("Add Layer Mask"), "layer-mask-add" },
{ GIMP_UNDO_LAYER_MASK_REMOVE, N_("Delete Layer Mask"), "layer-mask-remove" },
{ GIMP_UNDO_LAYER_REPOSITION, N_("Layer Reposition"), "layer-reposition" },
{ GIMP_UNDO_LAYER_DISPLACE, N_("Layer Move"), "layer-displace" },
{ GIMP_UNDO_LAYER_REPOSITION, N_("Reposition Layer"), "layer-reposition" },
{ GIMP_UNDO_LAYER_DISPLACE, N_("Move Layer"), "layer-displace" },
{ GIMP_UNDO_LAYER_MODE, N_("Set Layer Mode"), "layer-mode" },
{ GIMP_UNDO_LAYER_OPACITY, N_("Set Layer Opacity"), "layer-opacity" },
{ GIMP_UNDO_LAYER_PRESERVE_TRANS, N_("Set Preserve Trans"), "layer-preserve-trans" },
{ GIMP_UNDO_LAYER_LINKED, N_("Set Layer Linked"), "layer-linked" },
{ GIMP_UNDO_CHANNEL_ADD, N_("New Channel"), "channel-add" },
{ GIMP_UNDO_CHANNEL_REMOVE, N_("Delete Channel"), "channel-remove" },
{ GIMP_UNDO_CHANNEL_MOD, N_("Channel Mod"), "channel-mod" },
{ GIMP_UNDO_CHANNEL_REPOSITION, N_("Channel Reposition"), "channel-reposition" },
{ GIMP_UNDO_CHANNEL_REPOSITION, N_("Reposition Channel"), "channel-reposition" },
{ GIMP_UNDO_CHANNEL_COLOR, N_("Channel Color"), "channel-color" },
{ GIMP_UNDO_VECTORS_ADD, N_("New Vectors"), "vectors-add" },
{ GIMP_UNDO_VECTORS_REMOVE, N_("Delete Vectors"), "vectors-remove" },
{ GIMP_UNDO_VECTORS_MOD, N_("Vectors Mod"), "vectors-mod" },
{ GIMP_UNDO_VECTORS_REPOSITION, N_("Vectors Reposition"), "vectors-reposition" },
{ GIMP_UNDO_VECTORS_REPOSITION, N_("Reposition Vectors"), "vectors-reposition" },
{ GIMP_UNDO_FS_TO_LAYER, N_("FS to Layer"), "fs-to-layer" },
{ GIMP_UNDO_FS_RIGOR, N_("FS Rigor"), "fs-rigor" },
{ GIMP_UNDO_FS_RELAX, N_("FS Relax"), "fs-relax" },
......
......@@ -318,34 +318,36 @@ typedef enum /*< pdb-skip >*/
/* Type NO_UNDO_GROUP (0) is special - in the gimpimage structure it
* means there is no undo group currently being added to.
*/
GIMP_UNDO_GROUP_NONE = 0, /*< desc="<<invalid>>" >*/
GIMP_UNDO_GROUP_NONE = 0, /*< desc="<<invalid>>" >*/
GIMP_UNDO_GROUP_FIRST = GIMP_UNDO_GROUP_NONE, /*< skip >*/
GIMP_UNDO_GROUP_IMAGE_SCALE, /*< desc="Scale Image" >*/
GIMP_UNDO_GROUP_IMAGE_RESIZE, /*< desc="Resize Image" >*/
GIMP_UNDO_GROUP_IMAGE_CONVERT, /*< desc="Convert Image" >*/
GIMP_UNDO_GROUP_IMAGE_CROP, /*< desc="Crop Image" >*/
GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, /*< desc="Merge Layers" >*/
GIMP_UNDO_GROUP_IMAGE_QMASK, /*< desc="QuickMask" >*/
GIMP_UNDO_GROUP_IMAGE_GUIDE, /*< desc="Guide" >*/
GIMP_UNDO_GROUP_ITEM_PROPERTIES, /*< desc="Item Properties" >*/
GIMP_UNDO_GROUP_LAYER_SCALE, /*< desc="Scale Layer" >*/
GIMP_UNDO_GROUP_LAYER_RESIZE, /*< desc="Resize Layer" >*/
GIMP_UNDO_GROUP_LAYER_DISPLACE, /*< desc="Move Layer" >*/
GIMP_UNDO_GROUP_LAYER_LINKED, /*< desc="Linked Layer" >*/
GIMP_UNDO_GROUP_LAYER_APPLY_MASK, /*< desc="Apply Layer Mask" >*/
GIMP_UNDO_GROUP_FS_FLOAT, /*< desc="Float Selection" >*/
GIMP_UNDO_GROUP_FS_ANCHOR, /*< desc="Anchor Floating Selection" >*/
GIMP_UNDO_GROUP_EDIT_PASTE, /*< desc="Paste" >*/
GIMP_UNDO_GROUP_EDIT_CUT, /*< desc="Cut" >*/
GIMP_UNDO_GROUP_EDIT_COPY, /*< desc="Copy" >*/
GIMP_UNDO_GROUP_TEXT, /*< desc="Text" >*/
GIMP_UNDO_GROUP_TRANSFORM, /*< desc="Transform" >*/
GIMP_UNDO_GROUP_PAINT, /*< desc="Paint" >*/
GIMP_UNDO_GROUP_PARASITE_ATTACH, /*< desc="Attach Parasite" >*/
GIMP_UNDO_GROUP_PARASITE_REMOVE, /*< desc="Remove Parasite" >*/
GIMP_UNDO_GROUP_MISC, /*< desc="Plug-In" >*/
GIMP_UNDO_GROUP_IMAGE_SCALE, /*< desc="Scale Image" >*/
GIMP_UNDO_GROUP_IMAGE_RESIZE, /*< desc="Resize Image" >*/
GIMP_UNDO_GROUP_IMAGE_CONVERT, /*< desc="Convert Image" >*/
GIMP_UNDO_GROUP_IMAGE_CROP, /*< desc="Crop Image" >*/
GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, /*< desc="Merge Layers" >*/
GIMP_UNDO_GROUP_IMAGE_QMASK, /*< desc="QuickMask" >*/
GIMP_UNDO_GROUP_IMAGE_GUIDE, /*< desc="Guide" >*/
GIMP_UNDO_GROUP_ITEM_PROPERTIES, /*< desc="Item Properties" >*/
GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY,/*< desc="Drawable Visilibity" >*/
GIMP_UNDO_GROUP_LAYER_SCALE, /*< desc="Scale Layer" >*/
GIMP_UNDO_GROUP_LAYER_RESIZE, /*< desc="Resize Layer" >*/
GIMP_UNDO_GROUP_LAYER_DISPLACE, /*< desc="Move Layer" >*/
GIMP_UNDO_GROUP_LAYER_LINKED, /*< desc="Linked Layer" >*/
GIMP_UNDO_GROUP_LAYER_APPLY_MASK, /*< desc="Apply Layer Mask" >*/
GIMP_UNDO_GROUP_FS_TO_LAYER, /*< desc="Floating Selection to Layer" >*/
GIMP_UNDO_GROUP_FS_FLOAT, /*< desc="Float Selection" >*/
GIMP_UNDO_GROUP_FS_ANCHOR, /*< desc="Anchor Floating Selection" >*/
GIMP_UNDO_GROUP_EDIT_PASTE, /*< desc="Paste" >*/
GIMP_UNDO_GROUP_EDIT_CUT, /*< desc="Cut" >*/
GIMP_UNDO_GROUP_EDIT_COPY, /*< desc="Copy" >*/
GIMP_UNDO_GROUP_TEXT, /*< desc="Text" >*/
GIMP_UNDO_GROUP_TRANSFORM, /*< desc="Transform" >*/
GIMP_UNDO_GROUP_PAINT, /*< desc="Paint" >*/
GIMP_UNDO_GROUP_PARASITE_ATTACH, /*< desc="Attach Parasite" >*/
GIMP_UNDO_GROUP_PARASITE_REMOVE, /*< desc="Remove Parasite" >*/
GIMP_UNDO_GROUP_MISC, /*< desc="Plug-In" >*/
GIMP_UNDO_GROUP_LAST = GIMP_UNDO_GROUP_MISC, /*< skip >*/
......@@ -360,22 +362,27 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_IMAGE_GUIDE, /*< desc="Guide" >*/
GIMP_UNDO_MASK, /*< desc="Selection Mask" >*/
GIMP_UNDO_ITEM_RENAME, /*< desc="Rename Item" >*/
GIMP_UNDO_DRAWABLE_VISIBILITY, /*< desc="Drawable Visibility" >*/
GIMP_UNDO_LAYER_ADD, /*< desc="New Layer" >*/
GIMP_UNDO_LAYER_REMOVE, /*< desc="Delete Layer" >*/
GIMP_UNDO_LAYER_MOD, /*< desc="Layer Mod" >*/
GIMP_UNDO_LAYER_MASK_ADD, /*< desc="Add Layer Mask" >*/
GIMP_UNDO_LAYER_MASK_REMOVE, /*< desc="Delete Layer Mask" >*/
GIMP_UNDO_LAYER_REPOSITION, /*< desc="Layer Reposition" >*/
GIMP_UNDO_LAYER_DISPLACE, /*< desc="Layer Move" >*/
GIMP_UNDO_LAYER_REPOSITION, /*< desc="Reposition Layer" >*/
GIMP_UNDO_LAYER_DISPLACE, /*< desc="Move Layer" >*/
GIMP_UNDO_LAYER_MODE, /*< desc="Set Layer Mode" >*/
GIMP_UNDO_LAYER_OPACITY, /*< desc="Set Layer Opacity" >*/
GIMP_UNDO_LAYER_PRESERVE_TRANS, /*< desc="Set Preserve Trans" >*/
GIMP_UNDO_LAYER_LINKED, /*< desc="Set Layer Linked" >*/
GIMP_UNDO_CHANNEL_ADD, /*< desc="New Channel" >*/
GIMP_UNDO_CHANNEL_REMOVE, /*< desc="Delete Channel" >*/
GIMP_UNDO_CHANNEL_MOD, /*< desc="Channel Mod" >*/
GIMP_UNDO_CHANNEL_REPOSITION, /*< desc="Channel Reposition" >*/
GIMP_UNDO_CHANNEL_REPOSITION, /*< desc="Reposition Channel" >*/
GIMP_UNDO_CHANNEL_COLOR, /*< desc="Channel Color" >*/
GIMP_UNDO_VECTORS_ADD, /*< desc="New Vectors" >*/
GIMP_UNDO_VECTORS_REMOVE, /*< desc="Delete Vectors" >*/
GIMP_UNDO_VECTORS_MOD, /*< desc="Vectors Mod" >*/
GIMP_UNDO_VECTORS_REPOSITION, /*< desc="Vectors Reposition" >*/
GIMP_UNDO_VECTORS_REPOSITION, /*< desc="Reposition Vectors" >*/
GIMP_UNDO_FS_TO_LAYER, /*< desc="FS to Layer" >*/
GIMP_UNDO_FS_RIGOR, /*< desc="FS Rigor" >*/
GIMP_UNDO_FS_RELAX, /*< desc="FS Relax" >*/
......
......@@ -111,6 +111,7 @@ typedef struct _GimpEnvironTable GimpEnvironTable;
/* undo objects */
typedef struct _GimpUndo GimpUndo;
typedef struct _GimpItemUndo GimpItemUndo;
typedef struct _GimpUndoStack GimpUndoStack;
typedef struct _GimpUndoAccumulator GimpUndoAccumulator;
......
......@@ -377,13 +377,33 @@ gimp_channel_get_opacity (const GimpChannel *channel)
void
gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity)
gdouble opacity,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
channel->color.a = opacity;
if (channel->color.a != opacity)
{
if (push_undo)
{
GimpImage *gimage;
gimage = gimp_item_get_image (GIMP_ITEM (channel));
if (gimage)
gimp_image_undo_push_channel_color (gimage, _("Set Channel Opacity"),
channel);
}
channel->color.a = opacity;
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
}
}
gboolean
......
......@@ -85,7 +85,8 @@ GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity);
gdouble opacity,
gboolean push_undo);
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
......
......@@ -377,13 +377,33 @@ gimp_channel_get_opacity (const GimpChannel *channel)
void
gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity)
gdouble opacity,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
channel->color.a = opacity;
if (channel->color.a != opacity)
{
if (push_undo)
{
GimpImage *gimage;
gimage = gimp_item_get_image (GIMP_ITEM (channel));
if (gimage)
gimp_image_undo_push_channel_color (gimage, _("Set Channel Opacity"),
channel);
}
channel->color.a = opacity;
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
}
}
gboolean
......
......@@ -85,7 +85,8 @@ GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity);
gdouble opacity,
gboolean push_undo);
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
......
......@@ -662,15 +662,22 @@ gimp_drawable_get_visible (const GimpDrawable *drawable)
void
gimp_drawable_set_visible (GimpDrawable *drawable,
gboolean visible)
gboolean visible,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
visible = visible ? TRUE : FALSE;
if (drawable->visible != visible)
{
drawable->visible = visible;
if (push_undo)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimage)
gimp_image_undo_push_drawable_visibility (gimage, NULL, drawable);
}
drawable->visible = visible ? TRUE : FALSE;
g_signal_emit (drawable, gimp_drawable_signals[VISIBILITY_CHANGED], 0);
......
......@@ -118,7 +118,8 @@ gint gimp_drawable_height (const GimpDrawable *drawable);
gboolean gimp_drawable_get_visible (const GimpDrawable *drawable);
void gimp_drawable_set_visible (GimpDrawable *drawable,
gboolean visible);
gboolean visible,
gboolean push_undo);
void gimp_drawable_offsets (const GimpDrawable *drawable,
gint *offset_x,
......
......@@ -643,7 +643,7 @@ gimp_image_mask_save (GimpImage *gimage)
FALSE));
/* saved selections are not visible by default */
gimp_drawable_set_visible (GIMP_DRAWABLE (new_channel), FALSE);
gimp_drawable_set_visible (GIMP_DRAWABLE (new_channel), FALSE, FALSE);
gimp_image_add_channel (gimage, new_channel, -1);
......
......@@ -487,11 +487,11 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_object_set_name (GIMP_OBJECT (merge_layer), name);
g_free (name);
gimp_drawable_set_visible (GIMP_DRAWABLE (merge_layer), TRUE, TRUE);
/* End the merge undo group */
gimp_image_undo_group_end (gimage);
gimp_drawable_set_visible (GIMP_DRAWABLE (merge_layer), TRUE);
gimp_drawable_update (GIMP_DRAWABLE (merge_layer),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE (merge_layer)),
......
This diff is collapsed.
......@@ -65,6 +65,13 @@ gboolean gimp_image_undo_push_item_rename (GimpImage *gimage,
GimpItem *item);
/* drawable undos */
gboolean gimp_image_undo_push_drawable_visibility (GimpImage *gimage,
const gchar *undo_desc,
GimpDrawable *drawable);
/* layer undos */
gboolean gimp_image_undo_push_layer_add (GimpImage *gimage,
......@@ -94,6 +101,18 @@ gboolean gimp_image_undo_push_layer_reposition (GimpImage *gimage,
gboolean gimp_image_undo_push_layer_displace (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
gboolean gimp_image_undo_push_layer_mode (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
gboolean gimp_image_undo_push_layer_opacity (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
gboolean gimp_image_undo_push_layer_preserve_trans (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
gboolean gimp_image_undo_push_layer_linked (GimpImage *gimage,
const gchar *undo_desc,
GimpLayer *layer);
/* channel undos */
......
......@@ -27,6 +27,8 @@
#include "gimp.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimpitem.h"
#include "gimpitemundo.h"
#include "gimplist.h"
#include "gimpundostack.h"
......@@ -190,11 +192,29 @@ gimp_image_undo_push (GimpImage *gimage,
gboolean dirties_image,
GimpUndoPopFunc pop_func,
GimpUndoFreeFunc free_func)
{
return gimp_image_undo_push_item (gimage, NULL,
size, struct_size,
type, name, dirties_image,
pop_func, free_func);
}
GimpUndo *
gimp_image_undo_push_item (GimpImage *gimage,
GimpItem *item,
gsize size,
gsize struct_size,
GimpUndoType type,
const gchar *name,
gboolean dirties_image,
GimpUndoPopFunc pop_func,
GimpUndoFreeFunc free_func)
{
GimpUndo *new;
gpointer undo_struct = NULL;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (item == NULL || GIMP_IS_ITEM (item), NULL);
g_return_val_if_fail (type > GIMP_UNDO_GROUP_LAST, NULL);
if (! name)
......@@ -224,12 +244,22 @@ gimp_image_undo_push (GimpImage *gimage,
if (struct_size > 0)
undo_struct = g_malloc0 (struct_size);
new = gimp_undo_new (gimage,
type,
name,
undo_struct, size,
dirties_image,
pop_func, free_func);
if (item)
{
new = gimp_item_undo_new (gimage, item,
type, name,
undo_struct, size,
dirties_image,
pop_func, free_func);
}
else
{
new = gimp_undo_new (gimage,
type, name,
undo_struct, size,
dirties_image,
pop_func, free_func);
}
if (gimage->pushing_undo_group == GIMP_UNDO_GROUP_NONE)
{
......
......@@ -38,6 +38,15 @@ GimpUndo * gimp_image_undo_push (GimpImage *gimage,
gboolean dirties_image,
GimpUndoPopFunc pop_func,
GimpUndoFreeFunc free_func);
GimpUndo * gimp_image_undo_push_item (GimpImage *gimage,
GimpItem *item,
gsize size,
gsize struct_size,
GimpUndoType type,
const gchar *name,
gboolean dirties_image,
GimpUndoPopFunc pop_func,
GimpUndoFreeFunc free_func);
#endif /* __GIMP_IMAGE_UNDO_H__ */
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "core-types.h"
#include "gimpimage.h"
#include "gimpitem.h"
#include "gimpitemundo.h"
static void gimp_item_undo_class_init (GimpItemUndoClass *klass);
static void gimp_item_undo_init (GimpItemUndo *undo);
static void gimp_item_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode);
static GimpUndoClass *parent_class = NULL;
GType
gimp_item_undo_get_type (void)
{
static GType undo_type = 0;
if (! undo_type)
{
static const GTypeInfo undo_info =
{
sizeof (GimpItemUndoClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_item_undo_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpItemUndo),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_item_undo_init,
};
undo_type = g_type_register_static (GIMP_TYPE_UNDO,
"GimpItemUndo",
&undo_info, 0);
}
return undo_type;
}
static void
gimp_item_undo_class_init (GimpItemUndoClass *klass)
{
GObjectClass *object_class;
GimpUndoClass *undo_class;
object_class = G_OBJECT_CLASS (klass);
undo_class = GIMP_UNDO_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
undo_class->free = gimp_item_undo_free;
}
static void
gimp_item_undo_init (GimpItemUndo *undo)
{
undo->item = NULL;
}
static void
gimp_item_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode)
{
GimpItemUndo *item_undo;
item_undo = GIMP_ITEM_UNDO (undo);
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
if (item_undo->item)
{
g_object_unref (item_undo->item);
item_undo->item = NULL;
}
}
GimpUndo *
gimp_item_undo_new (GimpImage *gimage,
GimpItem *item,
GimpUndoType undo_type,
const gchar *name,
gpointer data,
gsize size,
gboolean dirties_image,
GimpUndoPopFunc pop_func,
GimpUndoFreeFunc free_func)
{
GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (size == 0 || data != NULL, NULL);
undo = g_object_new (GIMP_TYPE_ITEM_UNDO,
"name", name,
NULL);
undo->gimage = gimage;
undo->undo_type = undo_type;
undo->data = data;
undo->size = size;
undo->dirties_image = dirties_image ? TRUE : FALSE;
undo->pop_func = pop_func;
undo->free_func = free_func;
GIMP_ITEM_UNDO (undo)->item = g_object_ref (item);
return undo;
}
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_ITEM_UNDO_H__
#define __GIMP_ITEM_UNDO_H__
#include "gimpundo.h"
#define GIMP_TYPE_ITEM_UNDO (gimp_item_undo_get_type ())
#define GIMP_ITEM_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ITEM_UNDO, GimpItemUndo))
#define GIMP_ITEM_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ITEM_UNDO, GimpItemUndoClass))
#define GIMP_IS_ITEM_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ITEM_UNDO))
#define GIMP_IS_ITEM_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ITEM_UNDO))
#define GIMP_ITEM_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ITEM_UNDO, GimpItemUndoClass))
typedef struct _GimpItemUndoClass GimpItemUndoClass;
struct _GimpItemUndo
{
GimpUndo parent_instance;