From 4b4d3934db1278133b6b5375069e5c94a7ed5643 Mon Sep 17 00:00:00 2001 From: Austin Donnelly Date: Fri, 1 Oct 1999 19:26:56 +0000 Subject: [PATCH] don't want sub-undo type undo_push_channel() takes ADD or REMOVE type Fri Oct 1 15:18:34 1999 Austin Donnelly * 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. --- ChangeLog | 9 +++ app/channel.h | 8 --- app/core/gimpchannel-combine.h | 8 --- app/core/gimpchannel.h | 8 --- app/core/gimpimage-guides.c | 6 +- app/core/gimpimage-merge.c | 6 +- app/core/gimpimage-projection.c | 6 +- app/core/gimpimage-resize.c | 6 +- app/core/gimpimage-scale.c | 6 +- app/core/gimpimage-undo-push.c | 102 +++++++++++++++------------- app/core/gimpimage-undo-push.h | 2 +- app/core/gimpimage.c | 6 +- app/core/gimpprojection-construct.c | 6 +- app/gimpchannel.h | 8 --- app/gimpimage.c | 6 +- app/undo.c | 102 +++++++++++++++------------- app/undo.h | 2 +- app/undo_types.h | 3 +- 18 files changed, 137 insertions(+), 163 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2fef5877b..b1af9fb77e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Oct 1 15:18:34 1999 Austin Donnelly + + * 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 * gimprc.in: comment typo fix, plus add %D* to default diff --git a/app/channel.h b/app/channel.h index e092fa3ee0..6b7d461081 100644 --- a/app/channel.h +++ b/app/channel.h @@ -48,12 +48,6 @@ typedef enum GtkType gimp_channel_get_type (void); -typedef enum /*< skip >*/ -{ - CHANNEL_ADD_UNDO, - CHANNEL_REMOVE_UNDO -} ChannelUndoType; - /* Special undo type */ typedef struct _ChannelUndo ChannelUndo; @@ -63,8 +57,6 @@ struct _ChannelUndo Channel *channel; /* the actual channel */ gint prev_position; /* former position in list */ Channel *prev_channel; /* previous active channel */ - ChannelUndoType undo_type; /* is this a new channel undo */ - /* or a remove channel undo? */ }; /* Special undo type */ diff --git a/app/core/gimpchannel-combine.h b/app/core/gimpchannel-combine.h index e092fa3ee0..6b7d461081 100644 --- a/app/core/gimpchannel-combine.h +++ b/app/core/gimpchannel-combine.h @@ -48,12 +48,6 @@ typedef enum GtkType gimp_channel_get_type (void); -typedef enum /*< skip >*/ -{ - CHANNEL_ADD_UNDO, - CHANNEL_REMOVE_UNDO -} ChannelUndoType; - /* Special undo type */ typedef struct _ChannelUndo ChannelUndo; @@ -63,8 +57,6 @@ struct _ChannelUndo Channel *channel; /* the actual channel */ gint prev_position; /* former position in list */ Channel *prev_channel; /* previous active channel */ - ChannelUndoType undo_type; /* is this a new channel undo */ - /* or a remove channel undo? */ }; /* Special undo type */ diff --git a/app/core/gimpchannel.h b/app/core/gimpchannel.h index e092fa3ee0..6b7d461081 100644 --- a/app/core/gimpchannel.h +++ b/app/core/gimpchannel.h @@ -48,12 +48,6 @@ typedef enum GtkType gimp_channel_get_type (void); -typedef enum /*< skip >*/ -{ - CHANNEL_ADD_UNDO, - CHANNEL_REMOVE_UNDO -} ChannelUndoType; - /* Special undo type */ typedef struct _ChannelUndo ChannelUndo; @@ -63,8 +57,6 @@ struct _ChannelUndo Channel *channel; /* the actual channel */ gint prev_position; /* former position in list */ Channel *prev_channel; /* previous active channel */ - ChannelUndoType undo_type; /* is this a new channel undo */ - /* or a remove channel undo? */ }; /* Special undo type */ diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 449f458f1b..67d36d84fd 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -1639,18 +1639,23 @@ undo_free_layer_mask (UndoState state, /* New Channel Undo */ int -undo_push_channel (GImage *gimage, - void *cu_ptr) +undo_push_channel (GImage *gimage, + UndoType type, + void *cu_ptr) { ChannelUndo *cu; Undo *new; int size; + g_return_val_if_fail (type == CHANNEL_ADD_UNDO || + type == CHANNEL_REMOVE_UNDO, + FALSE); + cu = (ChannelUndo *) cu_ptr; 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->pop_func = undo_pop_channel; @@ -1660,7 +1665,7 @@ undo_push_channel (GImage *gimage, } else { - if (cu->undo_type == CHANNEL_REMOVE_UNDO) + if (type == CHANNEL_REMOVE_UNDO) channel_delete (cu->channel); g_free (cu); return FALSE; @@ -1679,8 +1684,8 @@ undo_pop_channel (GImage *gimage, cu = (ChannelUndo *) cu_ptr; /* remove channel */ - if ((state == UNDO && cu->undo_type == CHANNEL_ADD_UNDO) || - (state == REDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) + if ((state == UNDO && type == CHANNEL_ADD_UNDO) || + (state == REDO && type == CHANNEL_REMOVE_UNDO)) { /* record the current position */ 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 * the undo stack and it's a channel remove */ - if ((state == REDO && cu->undo_type == CHANNEL_ADD_UNDO) || - (state == UNDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) + if ((state == REDO && type == CHANNEL_ADD_UNDO) || + (state == UNDO && type == CHANNEL_REMOVE_UNDO)) channel_delete (cu->channel); g_free (cu); @@ -2730,46 +2735,47 @@ static struct undo_name_t { UndoType type; const char *name; } undo_name[] = { - {0, N_("<>")}, - {IMAGE_UNDO, N_("image")}, - {IMAGE_MOD_UNDO, N_("image mod")}, - {MASK_UNDO, N_("mask")}, - {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ - {TRANSFORM_UNDO, N_("transform")}, - {PAINT_UNDO, N_("paint")}, - {LAYER_ADD_UNDO, N_("new layer")}, - {LAYER_REMOVE_UNDO, N_("delete layer")}, - {LAYER_MOD, N_("layer mod")}, - {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ - {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ - {LAYER_RENAME_UNDO, N_("rename layer")}, - {LAYER_POSITION, N_("layer position")}, /* unused? */ - {CHANNEL_UNDO, N_("channel")}, - {CHANNEL_MOD, N_("channel mod")}, - {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ - {GIMAGE_MOD, N_("gimage")}, - {FS_RIGOR, N_("FS rigor")}, - {FS_RELAX, N_("FS relax")}, - {GUIDE_UNDO, N_("guide")}, - {FLOAT_MASK_UNDO, N_("float selection")}, - {EDIT_PASTE_UNDO, N_("paste")}, - {EDIT_CUT_UNDO, N_("cut")}, - {TRANSFORM_CORE_UNDO, N_("transform core")}, - {PAINT_CORE_UNDO, N_("paint core")}, - {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ - {LINKED_LAYER_UNDO, N_("linked layer")}, - {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ - {LAYER_MERGE_UNDO, N_("layer merge")}, - {FS_ANCHOR_UNDO, N_("FS anchor")}, - {GIMAGE_MOD_UNDO, N_("gimage mod")}, - {CROP_UNDO, N_("crop")}, - {LAYER_SCALE_UNDO, N_("layer scale")}, - {LAYER_RESIZE_UNDO, N_("layer resize")}, - {QMASK_UNDO, N_("quickmask")}, - {PARASITE_ATTACH_UNDO, N_("attach parasite")}, - {PARASITE_REMOVE_UNDO, N_("remove parasite")}, - {RESOLUTION_UNDO, N_("resolution change")}, - {MISC_UNDO, N_("misc")} + {0, N_("<>")}, + {IMAGE_UNDO, N_("image")}, + {IMAGE_MOD_UNDO, N_("image mod")}, + {MASK_UNDO, N_("mask")}, + {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ + {TRANSFORM_UNDO, N_("transform")}, + {PAINT_UNDO, N_("paint")}, + {LAYER_ADD_UNDO, N_("new layer")}, + {LAYER_REMOVE_UNDO, N_("delete layer")}, + {LAYER_MOD, N_("layer mod")}, + {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ + {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ + {LAYER_RENAME_UNDO, N_("rename layer")}, + {LAYER_POSITION, N_("layer position")}, /* unused? */ + {CHANNEL_ADD_UNDO, N_("new channel")}, + {CHANNEL_REMOVE_UNDO, N_("delete channel")}, + {CHANNEL_MOD, N_("channel mod")}, + {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ + {GIMAGE_MOD, N_("gimage")}, + {FS_RIGOR, N_("FS rigor")}, + {FS_RELAX, N_("FS relax")}, + {GUIDE_UNDO, N_("guide")}, + {FLOAT_MASK_UNDO, N_("float selection")}, + {EDIT_PASTE_UNDO, N_("paste")}, + {EDIT_CUT_UNDO, N_("cut")}, + {TRANSFORM_CORE_UNDO, N_("transform core")}, + {PAINT_CORE_UNDO, N_("paint core")}, + {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ + {LINKED_LAYER_UNDO, N_("linked layer")}, + {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ + {LAYER_MERGE_UNDO, N_("layer merge")}, + {FS_ANCHOR_UNDO, N_("FS anchor")}, + {GIMAGE_MOD_UNDO, N_("gimage mod")}, + {CROP_UNDO, N_("crop")}, + {LAYER_SCALE_UNDO, N_("layer scale")}, + {LAYER_RESIZE_UNDO, N_("layer resize")}, + {QMASK_UNDO, N_("quickmask")}, + {PARASITE_ATTACH_UNDO, N_("attach parasite")}, + {PARASITE_REMOVE_UNDO, N_("remove parasite")}, + {RESOLUTION_UNDO, N_("resolution change")}, + {MISC_UNDO, N_("misc")} }; #define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t)) diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h index 1f726f3b49..cbbe82860b 100644 --- a/app/core/gimpimage-undo-push.h +++ b/app/core/gimpimage-undo-push.h @@ -39,7 +39,7 @@ int undo_push_layer_mod (GImage *, void *); int undo_push_layer_mask (GImage *, UndoType, void *); int undo_push_layer_change (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_fs_to_layer (GImage *, void *); int undo_push_fs_rigor (GImage *, int); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index e1eefd064c..8bb7a26c72 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/gimpchannel.h b/app/gimpchannel.h index e092fa3ee0..6b7d461081 100644 --- a/app/gimpchannel.h +++ b/app/gimpchannel.h @@ -48,12 +48,6 @@ typedef enum GtkType gimp_channel_get_type (void); -typedef enum /*< skip >*/ -{ - CHANNEL_ADD_UNDO, - CHANNEL_REMOVE_UNDO -} ChannelUndoType; - /* Special undo type */ typedef struct _ChannelUndo ChannelUndo; @@ -63,8 +57,6 @@ struct _ChannelUndo Channel *channel; /* the actual channel */ gint prev_position; /* former position in list */ Channel *prev_channel; /* previous active channel */ - ChannelUndoType undo_type; /* is this a new channel undo */ - /* or a remove channel undo? */ }; /* Special undo type */ diff --git a/app/gimpimage.c b/app/gimpimage.c index e1eefd064c..8bb7a26c72 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -3232,8 +3232,7 @@ gimp_image_add_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = 0; cu->prev_channel = gimage->active_channel; - cu->undo_type = 0; - undo_push_channel (gimage, cu); + undo_push_channel (gimage, CHANNEL_ADD_UNDO, cu); /* add the channel to the list */ gimage->channels = g_slist_prepend (gimage->channels, channel_ref (channel)); @@ -3261,7 +3260,6 @@ gimp_image_remove_channel (GimpImage *gimage, cu->channel = channel; cu->prev_position = gimp_image_get_channel_index (gimage, channel); cu->prev_channel = gimage->active_channel; - cu->undo_type = 1; 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))); /* 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; } diff --git a/app/undo.c b/app/undo.c index 449f458f1b..67d36d84fd 100644 --- a/app/undo.c +++ b/app/undo.c @@ -1639,18 +1639,23 @@ undo_free_layer_mask (UndoState state, /* New Channel Undo */ int -undo_push_channel (GImage *gimage, - void *cu_ptr) +undo_push_channel (GImage *gimage, + UndoType type, + void *cu_ptr) { ChannelUndo *cu; Undo *new; int size; + g_return_val_if_fail (type == CHANNEL_ADD_UNDO || + type == CHANNEL_REMOVE_UNDO, + FALSE); + cu = (ChannelUndo *) cu_ptr; 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->pop_func = undo_pop_channel; @@ -1660,7 +1665,7 @@ undo_push_channel (GImage *gimage, } else { - if (cu->undo_type == CHANNEL_REMOVE_UNDO) + if (type == CHANNEL_REMOVE_UNDO) channel_delete (cu->channel); g_free (cu); return FALSE; @@ -1679,8 +1684,8 @@ undo_pop_channel (GImage *gimage, cu = (ChannelUndo *) cu_ptr; /* remove channel */ - if ((state == UNDO && cu->undo_type == CHANNEL_ADD_UNDO) || - (state == REDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) + if ((state == UNDO && type == CHANNEL_ADD_UNDO) || + (state == REDO && type == CHANNEL_REMOVE_UNDO)) { /* record the current position */ 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 * the undo stack and it's a channel remove */ - if ((state == REDO && cu->undo_type == CHANNEL_ADD_UNDO) || - (state == UNDO && cu->undo_type == CHANNEL_REMOVE_UNDO)) + if ((state == REDO && type == CHANNEL_ADD_UNDO) || + (state == UNDO && type == CHANNEL_REMOVE_UNDO)) channel_delete (cu->channel); g_free (cu); @@ -2730,46 +2735,47 @@ static struct undo_name_t { UndoType type; const char *name; } undo_name[] = { - {0, N_("<>")}, - {IMAGE_UNDO, N_("image")}, - {IMAGE_MOD_UNDO, N_("image mod")}, - {MASK_UNDO, N_("mask")}, - {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ - {TRANSFORM_UNDO, N_("transform")}, - {PAINT_UNDO, N_("paint")}, - {LAYER_ADD_UNDO, N_("new layer")}, - {LAYER_REMOVE_UNDO, N_("delete layer")}, - {LAYER_MOD, N_("layer mod")}, - {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ - {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ - {LAYER_RENAME_UNDO, N_("rename layer")}, - {LAYER_POSITION, N_("layer position")}, /* unused? */ - {CHANNEL_UNDO, N_("channel")}, - {CHANNEL_MOD, N_("channel mod")}, - {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ - {GIMAGE_MOD, N_("gimage")}, - {FS_RIGOR, N_("FS rigor")}, - {FS_RELAX, N_("FS relax")}, - {GUIDE_UNDO, N_("guide")}, - {FLOAT_MASK_UNDO, N_("float selection")}, - {EDIT_PASTE_UNDO, N_("paste")}, - {EDIT_CUT_UNDO, N_("cut")}, - {TRANSFORM_CORE_UNDO, N_("transform core")}, - {PAINT_CORE_UNDO, N_("paint core")}, - {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ - {LINKED_LAYER_UNDO, N_("linked layer")}, - {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ - {LAYER_MERGE_UNDO, N_("layer merge")}, - {FS_ANCHOR_UNDO, N_("FS anchor")}, - {GIMAGE_MOD_UNDO, N_("gimage mod")}, - {CROP_UNDO, N_("crop")}, - {LAYER_SCALE_UNDO, N_("layer scale")}, - {LAYER_RESIZE_UNDO, N_("layer resize")}, - {QMASK_UNDO, N_("quickmask")}, - {PARASITE_ATTACH_UNDO, N_("attach parasite")}, - {PARASITE_REMOVE_UNDO, N_("remove parasite")}, - {RESOLUTION_UNDO, N_("resolution change")}, - {MISC_UNDO, N_("misc")} + {0, N_("<>")}, + {IMAGE_UNDO, N_("image")}, + {IMAGE_MOD_UNDO, N_("image mod")}, + {MASK_UNDO, N_("mask")}, + {LAYER_DISPLACE_UNDO, N_("layer move")}, /* ok */ + {TRANSFORM_UNDO, N_("transform")}, + {PAINT_UNDO, N_("paint")}, + {LAYER_ADD_UNDO, N_("new layer")}, + {LAYER_REMOVE_UNDO, N_("delete layer")}, + {LAYER_MOD, N_("layer mod")}, + {LAYER_MASK_ADD_UNDO, N_("add layer mask")}, /* ok */ + {LAYER_MASK_REMOVE_UNDO, N_("delete layer mask")}, /* ok */ + {LAYER_RENAME_UNDO, N_("rename layer")}, + {LAYER_POSITION, N_("layer position")}, /* unused? */ + {CHANNEL_ADD_UNDO, N_("new channel")}, + {CHANNEL_REMOVE_UNDO, N_("delete channel")}, + {CHANNEL_MOD, N_("channel mod")}, + {FS_TO_LAYER_UNDO, N_("FS to layer")}, /* ok */ + {GIMAGE_MOD, N_("gimage")}, + {FS_RIGOR, N_("FS rigor")}, + {FS_RELAX, N_("FS relax")}, + {GUIDE_UNDO, N_("guide")}, + {FLOAT_MASK_UNDO, N_("float selection")}, + {EDIT_PASTE_UNDO, N_("paste")}, + {EDIT_CUT_UNDO, N_("cut")}, + {TRANSFORM_CORE_UNDO, N_("transform core")}, + {PAINT_CORE_UNDO, N_("paint core")}, + {FLOATING_LAYER_UNDO, N_("floating layer")}, /* unused! */ + {LINKED_LAYER_UNDO, N_("linked layer")}, + {LAYER_APPLY_MASK_UNDO, N_("apply layer mask")}, /* ok */ + {LAYER_MERGE_UNDO, N_("layer merge")}, + {FS_ANCHOR_UNDO, N_("FS anchor")}, + {GIMAGE_MOD_UNDO, N_("gimage mod")}, + {CROP_UNDO, N_("crop")}, + {LAYER_SCALE_UNDO, N_("layer scale")}, + {LAYER_RESIZE_UNDO, N_("layer resize")}, + {QMASK_UNDO, N_("quickmask")}, + {PARASITE_ATTACH_UNDO, N_("attach parasite")}, + {PARASITE_REMOVE_UNDO, N_("remove parasite")}, + {RESOLUTION_UNDO, N_("resolution change")}, + {MISC_UNDO, N_("misc")} }; #define NUM_NAMES (sizeof (undo_name) / sizeof (struct undo_name_t)) diff --git a/app/undo.h b/app/undo.h index 1f726f3b49..cbbe82860b 100644 --- a/app/undo.h +++ b/app/undo.h @@ -39,7 +39,7 @@ int undo_push_layer_mod (GImage *, void *); int undo_push_layer_mask (GImage *, UndoType, void *); int undo_push_layer_change (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_fs_to_layer (GImage *, void *); int undo_push_fs_rigor (GImage *, int); diff --git a/app/undo_types.h b/app/undo_types.h index 3ad95dcb4c..0109e206d0 100644 --- a/app/undo_types.h +++ b/app/undo_types.h @@ -42,7 +42,8 @@ typedef enum LAYER_MASK_REMOVE_UNDO, LAYER_RENAME_UNDO, LAYER_POSITION, - CHANNEL_UNDO, + CHANNEL_ADD_UNDO, + CHANNEL_REMOVE_UNDO, CHANNEL_MOD, FS_TO_LAYER_UNDO, GIMAGE_MOD,