don't want sub-undo type undo_push_channel() takes ADD or REMOVE type

Fri Oct  1 15:18:34 1999  Austin Donnelly  <and1000@research.att.com>

	* app/channel.h: don't want sub-undo type
	* app/gimpimage.c: undo_push_channel() takes ADD or REMOVE type
	* app/undo.c: undo_push_channel() takes type.  More specific
	    CHANNEL_{ADD,REMOVE}_UNDO types.
	* app/undo.h: undo_push_channel() prototype.
	* app/undo_types.h: More specific CHANNEL_{ADD,REMOVE}_UNDO types.
This commit is contained in:
Austin Donnelly 1999-10-01 19:26:56 +00:00 committed by Austin Donnelly
parent 11409e97fb
commit 4b4d3934db
18 changed files with 137 additions and 163 deletions

View File

@ -1,3 +1,12 @@
Fri Oct 1 15:18:34 1999 Austin Donnelly <and1000@research.att.com>
* app/channel.h: don't want sub-undo type
* app/gimpimage.c: undo_push_channel() takes ADD or REMOVE type
* app/undo.c: undo_push_channel() takes type. More specific
CHANNEL_{ADD,REMOVE}_UNDO types.
* app/undo.h: undo_push_channel() prototype.
* app/undo_types.h: More specific CHANNEL_{ADD,REMOVE}_UNDO types.
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org> Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default * gimprc.in: comment typo fix, plus add %D* to default

View File

@ -48,12 +48,6 @@ typedef enum
GtkType gimp_channel_get_type (void); GtkType gimp_channel_get_type (void);
typedef enum /*< skip >*/
{
CHANNEL_ADD_UNDO,
CHANNEL_REMOVE_UNDO
} ChannelUndoType;
/* Special undo type */ /* Special undo type */
typedef struct _ChannelUndo ChannelUndo; typedef struct _ChannelUndo ChannelUndo;
@ -63,8 +57,6 @@ struct _ChannelUndo
Channel *channel; /* the actual channel */ Channel *channel; /* the actual channel */
gint prev_position; /* former position in list */ gint prev_position; /* former position in list */
Channel *prev_channel; /* previous active channel */ Channel *prev_channel; /* previous active channel */
ChannelUndoType undo_type; /* is this a new channel undo */
/* or a remove channel undo? */
}; };
/* Special undo type */ /* Special undo type */

View File

@ -48,12 +48,6 @@ typedef enum
GtkType gimp_channel_get_type (void); GtkType gimp_channel_get_type (void);
typedef enum /*< skip >*/
{
CHANNEL_ADD_UNDO,
CHANNEL_REMOVE_UNDO
} ChannelUndoType;
/* Special undo type */ /* Special undo type */
typedef struct _ChannelUndo ChannelUndo; typedef struct _ChannelUndo ChannelUndo;
@ -63,8 +57,6 @@ struct _ChannelUndo
Channel *channel; /* the actual channel */ Channel *channel; /* the actual channel */
gint prev_position; /* former position in list */ gint prev_position; /* former position in list */
Channel *prev_channel; /* previous active channel */ Channel *prev_channel; /* previous active channel */
ChannelUndoType undo_type; /* is this a new channel undo */
/* or a remove channel undo? */
}; };
/* Special undo type */ /* Special undo type */

View File

@ -48,12 +48,6 @@ typedef enum
GtkType gimp_channel_get_type (void); GtkType gimp_channel_get_type (void);
typedef enum /*< skip >*/
{
CHANNEL_ADD_UNDO,
CHANNEL_REMOVE_UNDO
} ChannelUndoType;
/* Special undo type */ /* Special undo type */
typedef struct _ChannelUndo ChannelUndo; typedef struct _ChannelUndo ChannelUndo;
@ -63,8 +57,6 @@ struct _ChannelUndo
Channel *channel; /* the actual channel */ Channel *channel; /* the actual channel */
gint prev_position; /* former position in list */ gint prev_position; /* former position in list */
Channel *prev_channel; /* previous active channel */ Channel *prev_channel; /* previous active channel */
ChannelUndoType undo_type; /* is this a new channel undo */
/* or a remove channel undo? */
}; };
/* Special undo type */ /* Special undo type */

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -1639,18 +1639,23 @@ undo_free_layer_mask (UndoState state,
/* New Channel Undo */ /* New Channel Undo */
int int
undo_push_channel (GImage *gimage, undo_push_channel (GImage *gimage,
void *cu_ptr) UndoType type,
void *cu_ptr)
{ {
ChannelUndo *cu; ChannelUndo *cu;
Undo *new; Undo *new;
int size; int size;
g_return_val_if_fail (type == CHANNEL_ADD_UNDO ||
type == CHANNEL_REMOVE_UNDO,
FALSE);
cu = (ChannelUndo *) cu_ptr; cu = (ChannelUndo *) cu_ptr;
size = channel_size (cu->channel) + sizeof (ChannelUndo); size = channel_size (cu->channel) + sizeof (ChannelUndo);
if ((new = undo_push (gimage, size, CHANNEL_UNDO, TRUE))) if ((new = undo_push (gimage, size, type, TRUE)))
{ {
new->data = cu_ptr; new->data = cu_ptr;
new->pop_func = undo_pop_channel; new->pop_func = undo_pop_channel;
@ -1660,7 +1665,7 @@ undo_push_channel (GImage *gimage,
} }
else else
{ {
if (cu->undo_type == CHANNEL_REMOVE_UNDO) if (type == CHANNEL_REMOVE_UNDO)
channel_delete (cu->channel); channel_delete (cu->channel);
g_free (cu); g_free (cu);
return FALSE; return FALSE;
@ -1679,8 +1684,8 @@ undo_pop_channel (GImage *gimage,
cu = (ChannelUndo *) cu_ptr; cu = (ChannelUndo *) cu_ptr;
/* remove channel */ /* remove channel */
if ((state == UNDO && cu->undo_type == CHANNEL_ADD_UNDO) || if ((state == UNDO && type == CHANNEL_ADD_UNDO) ||
(state == REDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) (state == REDO && type == CHANNEL_REMOVE_UNDO))
{ {
/* record the current position */ /* record the current position */
cu->prev_position = gimage_get_channel_index (gimage, cu->channel); cu->prev_position = gimage_get_channel_index (gimage, cu->channel);
@ -1729,8 +1734,8 @@ undo_free_channel (UndoState state,
* stack and it's a channel add, or if we're freeing from * stack and it's a channel add, or if we're freeing from
* the undo stack and it's a channel remove * the undo stack and it's a channel remove
*/ */
if ((state == REDO && cu->undo_type == CHANNEL_ADD_UNDO) || if ((state == REDO && type == CHANNEL_ADD_UNDO) ||
(state == UNDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) (state == UNDO && type == CHANNEL_REMOVE_UNDO))
channel_delete (cu->channel); channel_delete (cu->channel);
g_free (cu); g_free (cu);
@ -2730,46 +2735,47 @@ static struct undo_name_t {
UndoType type; UndoType type;
const char *name; const char *name;
} undo_name[] = { } undo_name[] = {
{0, N_("<<invalid>>")}, {0, N_("<<invalid>>")},
{IMAGE_UNDO, N_("image")}, {IMAGE_UNDO, N_("image")},
{IMAGE_MOD_UNDO, N_("image mod")}, {IMAGE_MOD_UNDO, N_("image mod")},
{MASK_UNDO, N_("mask")}, {MASK_UNDO, N_("mask")},
{LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */
{TRANSFORM_UNDO, N_("transform")}, {TRANSFORM_UNDO, N_("transform")},
{PAINT_UNDO, N_("paint")}, {PAINT_UNDO, N_("paint")},
{LAYER_ADD_UNDO, N_("new layer")}, {LAYER_ADD_UNDO, N_("new layer")},
{LAYER_REMOVE_UNDO, N_("delete layer")}, {LAYER_REMOVE_UNDO, N_("delete layer")},
{LAYER_MOD, N_("layer mod")}, {LAYER_MOD, N_("layer mod")},
{LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */
{LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */
{LAYER_RENAME_UNDO, N_("rename layer")}, {LAYER_RENAME_UNDO, N_("rename layer")},
{LAYER_POSITION, N_("layer position")}, /* unused? */ {LAYER_POSITION, N_("layer position")}, /* unused? */
{CHANNEL_UNDO, N_("channel")}, {CHANNEL_ADD_UNDO, N_("new channel")},
{CHANNEL_MOD, N_("channel mod")}, {CHANNEL_REMOVE_UNDO, N_("delete channel")},
{FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ {CHANNEL_MOD, N_("channel mod")},
{GIMAGE_MOD, N_("gimage")}, {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */
{FS_RIGOR, N_("FS rigor")}, {GIMAGE_MOD, N_("gimage")},
{FS_RELAX, N_("FS relax")}, {FS_RIGOR, N_("FS rigor")},
{GUIDE_UNDO, N_("guide")}, {FS_RELAX, N_("FS relax")},
{FLOAT_MASK_UNDO, N_("float selection")}, {GUIDE_UNDO, N_("guide")},
{EDIT_PASTE_UNDO, N_("paste")}, {FLOAT_MASK_UNDO, N_("float selection")},
{EDIT_CUT_UNDO, N_("cut")}, {EDIT_PASTE_UNDO, N_("paste")},
{TRANSFORM_CORE_UNDO, N_("transform core")}, {EDIT_CUT_UNDO, N_("cut")},
{PAINT_CORE_UNDO, N_("paint core")}, {TRANSFORM_CORE_UNDO, N_("transform core")},
{FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ {PAINT_CORE_UNDO, N_("paint core")},
{LINKED_LAYER_UNDO, N_("linked layer")}, {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */
{LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ {LINKED_LAYER_UNDO, N_("linked layer")},
{LAYER_MERGE_UNDO, N_("layer merge")}, {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */
{FS_ANCHOR_UNDO, N_("FS anchor")}, {LAYER_MERGE_UNDO, N_("layer merge")},
{GIMAGE_MOD_UNDO, N_("gimage mod")}, {FS_ANCHOR_UNDO, N_("FS anchor")},
{CROP_UNDO, N_("crop")}, {GIMAGE_MOD_UNDO, N_("gimage mod")},
{LAYER_SCALE_UNDO, N_("layer scale")}, {CROP_UNDO, N_("crop")},
{LAYER_RESIZE_UNDO, N_("layer resize")}, {LAYER_SCALE_UNDO, N_("layer scale")},
{QMASK_UNDO, N_("quickmask")}, {LAYER_RESIZE_UNDO, N_("layer resize")},
{PARASITE_ATTACH_UNDO, N_("attach parasite")}, {QMASK_UNDO, N_("quickmask")},
{PARASITE_REMOVE_UNDO, N_("remove parasite")}, {PARASITE_ATTACH_UNDO, N_("attach parasite")},
{RESOLUTION_UNDO, N_("resolution change")}, {PARASITE_REMOVE_UNDO, N_("remove parasite")},
{MISC_UNDO, N_("misc")} {RESOLUTION_UNDO, N_("resolution change")},
{MISC_UNDO, N_("misc")}
}; };
#define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t)) #define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t))

View File

@ -39,7 +39,7 @@ int undo_push_layer_mod (GImage *, void *);
int undo_push_layer_mask (GImage *, UndoType, void *); int undo_push_layer_mask (GImage *, UndoType, void *);
int undo_push_layer_change (GImage *, int); int undo_push_layer_change (GImage *, int);
int undo_push_layer_position (GImage *, int); int undo_push_layer_position (GImage *, int);
int undo_push_channel (GImage *, void *); int undo_push_channel (GImage *, UndoType, void *);
int undo_push_channel_mod (GImage *, void *); int undo_push_channel_mod (GImage *, void *);
int undo_push_fs_to_layer (GImage *, void *); int undo_push_fs_to_layer (GImage *, void *);
int undo_push_fs_rigor (GImage *, int); int undo_push_fs_rigor (GImage *, int);

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -48,12 +48,6 @@ typedef enum
GtkType gimp_channel_get_type (void); GtkType gimp_channel_get_type (void);
typedef enum /*< skip >*/
{
CHANNEL_ADD_UNDO,
CHANNEL_REMOVE_UNDO
} ChannelUndoType;
/* Special undo type */ /* Special undo type */
typedef struct _ChannelUndo ChannelUndo; typedef struct _ChannelUndo ChannelUndo;
@ -63,8 +57,6 @@ struct _ChannelUndo
Channel *channel; /* the actual channel */ Channel *channel; /* the actual channel */
gint prev_position; /* former position in list */ gint prev_position; /* former position in list */
Channel *prev_channel; /* previous active channel */ Channel *prev_channel; /* previous active channel */
ChannelUndoType undo_type; /* is this a new channel undo */
/* or a remove channel undo? */
}; };
/* Special undo type */ /* Special undo type */

View File

@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = 0; cu->prev_position = 0;
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 0; undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu);
undo_push_channel (gimage, cu);
/* add the channel to the list */ /* add the channel to the list */
gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel));
@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage,
cu->channel = channel; cu->channel = channel;
cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_position = gimp_image_get_channel_index (gimage, channel);
cu->prev_channel = gimage->active_channel; cu->prev_channel = gimage->active_channel;
cu->undo_type = 1;
gimage->channels = g_slist_remove (gimage->channels, channel); gimage->channels = g_slist_remove (gimage->channels, channel);
@ -3277,7 +3275,7 @@ gimp_image_remove_channel (GimpImage *gimage,
drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel))); drawable_update (GIMP_DRAWABLE(channel), 0, 0, drawable_width (GIMP_DRAWABLE(channel)), drawable_height (GIMP_DRAWABLE(channel)));
/* Important to push the undo here in case the push fails */ /* Important to push the undo here in case the push fails */
undo_push_channel (gimage, cu); undo_push_channel (gimage, CHANNEL_REMOVE_UNDO, cu);
return channel; return channel;
} }

View File

@ -1639,18 +1639,23 @@ undo_free_layer_mask (UndoState state,
/* New Channel Undo */ /* New Channel Undo */
int int
undo_push_channel (GImage *gimage, undo_push_channel (GImage *gimage,
void *cu_ptr) UndoType type,
void *cu_ptr)
{ {
ChannelUndo *cu; ChannelUndo *cu;
Undo *new; Undo *new;
int size; int size;
g_return_val_if_fail (type == CHANNEL_ADD_UNDO ||
type == CHANNEL_REMOVE_UNDO,
FALSE);
cu = (ChannelUndo *) cu_ptr; cu = (ChannelUndo *) cu_ptr;
size = channel_size (cu->channel) + sizeof (ChannelUndo); size = channel_size (cu->channel) + sizeof (ChannelUndo);
if ((new = undo_push (gimage, size, CHANNEL_UNDO, TRUE))) if ((new = undo_push (gimage, size, type, TRUE)))
{ {
new->data = cu_ptr; new->data = cu_ptr;
new->pop_func = undo_pop_channel; new->pop_func = undo_pop_channel;
@ -1660,7 +1665,7 @@ undo_push_channel (GImage *gimage,
} }
else else
{ {
if (cu->undo_type == CHANNEL_REMOVE_UNDO) if (type == CHANNEL_REMOVE_UNDO)
channel_delete (cu->channel); channel_delete (cu->channel);
g_free (cu); g_free (cu);
return FALSE; return FALSE;
@ -1679,8 +1684,8 @@ undo_pop_channel (GImage *gimage,
cu = (ChannelUndo *) cu_ptr; cu = (ChannelUndo *) cu_ptr;
/* remove channel */ /* remove channel */
if ((state == UNDO && cu->undo_type == CHANNEL_ADD_UNDO) || if ((state == UNDO && type == CHANNEL_ADD_UNDO) ||
(state == REDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) (state == REDO && type == CHANNEL_REMOVE_UNDO))
{ {
/* record the current position */ /* record the current position */
cu->prev_position = gimage_get_channel_index (gimage, cu->channel); cu->prev_position = gimage_get_channel_index (gimage, cu->channel);
@ -1729,8 +1734,8 @@ undo_free_channel (UndoState state,
* stack and it's a channel add, or if we're freeing from * stack and it's a channel add, or if we're freeing from
* the undo stack and it's a channel remove * the undo stack and it's a channel remove
*/ */
if ((state == REDO && cu->undo_type == CHANNEL_ADD_UNDO) || if ((state == REDO && type == CHANNEL_ADD_UNDO) ||
(state == UNDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) (state == UNDO && type == CHANNEL_REMOVE_UNDO))
channel_delete (cu->channel); channel_delete (cu->channel);
g_free (cu); g_free (cu);
@ -2730,46 +2735,47 @@ static struct undo_name_t {
UndoType type; UndoType type;
const char *name; const char *name;
} undo_name[] = { } undo_name[] = {
{0, N_("<<invalid>>")}, {0, N_("<<invalid>>")},
{IMAGE_UNDO, N_("image")}, {IMAGE_UNDO, N_("image")},
{IMAGE_MOD_UNDO, N_("image mod")}, {IMAGE_MOD_UNDO, N_("image mod")},
{MASK_UNDO, N_("mask")}, {MASK_UNDO, N_("mask")},
{LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */
{TRANSFORM_UNDO, N_("transform")}, {TRANSFORM_UNDO, N_("transform")},
{PAINT_UNDO, N_("paint")}, {PAINT_UNDO, N_("paint")},
{LAYER_ADD_UNDO, N_("new layer")}, {LAYER_ADD_UNDO, N_("new layer")},
{LAYER_REMOVE_UNDO, N_("delete layer")}, {LAYER_REMOVE_UNDO, N_("delete layer")},
{LAYER_MOD, N_("layer mod")}, {LAYER_MOD, N_("layer mod")},
{LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */
{LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */
{LAYER_RENAME_UNDO, N_("rename layer")}, {LAYER_RENAME_UNDO, N_("rename layer")},
{LAYER_POSITION, N_("layer position")}, /* unused? */ {LAYER_POSITION, N_("layer position")}, /* unused? */
{CHANNEL_UNDO, N_("channel")}, {CHANNEL_ADD_UNDO, N_("new channel")},
{CHANNEL_MOD, N_("channel mod")}, {CHANNEL_REMOVE_UNDO, N_("delete channel")},
{FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ {CHANNEL_MOD, N_("channel mod")},
{GIMAGE_MOD, N_("gimage")}, {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */
{FS_RIGOR, N_("FS rigor")}, {GIMAGE_MOD, N_("gimage")},
{FS_RELAX, N_("FS relax")}, {FS_RIGOR, N_("FS rigor")},
{GUIDE_UNDO, N_("guide")}, {FS_RELAX, N_("FS relax")},
{FLOAT_MASK_UNDO, N_("float selection")}, {GUIDE_UNDO, N_("guide")},
{EDIT_PASTE_UNDO, N_("paste")}, {FLOAT_MASK_UNDO, N_("float selection")},
{EDIT_CUT_UNDO, N_("cut")}, {EDIT_PASTE_UNDO, N_("paste")},
{TRANSFORM_CORE_UNDO, N_("transform core")}, {EDIT_CUT_UNDO, N_("cut")},
{PAINT_CORE_UNDO, N_("paint core")}, {TRANSFORM_CORE_UNDO, N_("transform core")},
{FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ {PAINT_CORE_UNDO, N_("paint core")},
{LINKED_LAYER_UNDO, N_("linked layer")}, {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */
{LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ {LINKED_LAYER_UNDO, N_("linked layer")},
{LAYER_MERGE_UNDO, N_("layer merge")}, {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */
{FS_ANCHOR_UNDO, N_("FS anchor")}, {LAYER_MERGE_UNDO, N_("layer merge")},
{GIMAGE_MOD_UNDO, N_("gimage mod")}, {FS_ANCHOR_UNDO, N_("FS anchor")},
{CROP_UNDO, N_("crop")}, {GIMAGE_MOD_UNDO, N_("gimage mod")},
{LAYER_SCALE_UNDO, N_("layer scale")}, {CROP_UNDO, N_("crop")},
{LAYER_RESIZE_UNDO, N_("layer resize")}, {LAYER_SCALE_UNDO, N_("layer scale")},
{QMASK_UNDO, N_("quickmask")}, {LAYER_RESIZE_UNDO, N_("layer resize")},
{PARASITE_ATTACH_UNDO, N_("attach parasite")}, {QMASK_UNDO, N_("quickmask")},
{PARASITE_REMOVE_UNDO, N_("remove parasite")}, {PARASITE_ATTACH_UNDO, N_("attach parasite")},
{RESOLUTION_UNDO, N_("resolution change")}, {PARASITE_REMOVE_UNDO, N_("remove parasite")},
{MISC_UNDO, N_("misc")} {RESOLUTION_UNDO, N_("resolution change")},
{MISC_UNDO, N_("misc")}
}; };
#define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t)) #define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t))

View File

@ -39,7 +39,7 @@ int undo_push_layer_mod (GImage *, void *);
int undo_push_layer_mask (GImage *, UndoType, void *); int undo_push_layer_mask (GImage *, UndoType, void *);
int undo_push_layer_change (GImage *, int); int undo_push_layer_change (GImage *, int);
int undo_push_layer_position (GImage *, int); int undo_push_layer_position (GImage *, int);
int undo_push_channel (GImage *, void *); int undo_push_channel (GImage *, UndoType, void *);
int undo_push_channel_mod (GImage *, void *); int undo_push_channel_mod (GImage *, void *);
int undo_push_fs_to_layer (GImage *, void *); int undo_push_fs_to_layer (GImage *, void *);
int undo_push_fs_rigor (GImage *, int); int undo_push_fs_rigor (GImage *, int);

View File

@ -42,7 +42,8 @@ typedef enum
LAYER_MASK_REMOVE_UNDO, LAYER_MASK_REMOVE_UNDO,
LAYER_RENAME_UNDO, LAYER_RENAME_UNDO,
LAYER_POSITION, LAYER_POSITION,
CHANNEL_UNDO, CHANNEL_ADD_UNDO,
CHANNEL_REMOVE_UNDO,
CHANNEL_MOD, CHANNEL_MOD,
FS_TO_LAYER_UNDO, FS_TO_LAYER_UNDO,
GIMAGE_MOD, GIMAGE_MOD,