From 7a6a8d9dbbe233250ddba17b4c9be95368780c1a Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 14 Feb 2003 14:14:29 +0000 Subject: [PATCH] Moved the undo step implementations to the core and pass around lots of 2003-02-14 Michael Natterer Moved the undo step implementations to the core and pass around lots of "const gchar *undo_desc". Fixes bug #104367. * app/Makefile.am * app/undo.[ch]: removed... * app/core/Makefile.am * app/core/gimpimage-undo-push.[ch]: ...and added here. * app/paint/Makefile.am * app/tools/Makefile.am * app/paint/gimppaintcore-undo.[ch] * app/tools/gimptransformtool-undo.[ch]: new files for the paint and transform undos. * app/core/gimppaintinfo.[ch]: added a blurb. * app/paint/gimpairbrush.c * app/paint/gimpclone.c * app/paint/gimpconvolve.c * app/paint/gimpdodgeburn.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.c * app/paint/gimpsmudge.c * app/paint/paint-types.h * app/paint/paint.c: pass the blurb when registering the core. * app/core/gimpdrawable.[ch] * app/core/gimpimage.[ch] * app/core/gimpimage-mask-select.[ch] * app/core/gimpimage-mask.[ch] * app/core/gimpimagemap.[ch] * app/core/gimplayer-floating-sel.[ch]: added "undo_desc" parameters to all undo pushing helper functions. * app/undo_history.c * app/core/gimpchannel.c * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpdrawable-transform.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-qmask.c * app/core/gimpimage-resize.c * app/core/gimpimage-scale.c * app/core/gimpimage-undo.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimplayermask.c * app/display/gimpdisplayshell-dnd.c * app/file/file-open.c * app/file/file-save.c * app/gui/channels-commands.c * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/paths-dialog.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/text/gimptext-compat.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpimagemaptool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/selection_tools.pdb: changed accordingly: pass "undo_desc" strings, changed includes or simply removed inclusion of "undo.h". Some random cleanups. * tools/pdbgen/pdb/guides.pdb: cleaned up a lot. Fixed gimp_image_find_next_guide() to not return guides with position < 0 (and made it shorter and readable). * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/guides_cmds.c * app/pdb/layer_cmds.c * app/pdb/selection_cmds.c * app/pdb/selection_tools_cmds.c: regenerated. --- ChangeLog | 109 + app/Makefile.am | 4 +- app/actions/channels-commands.c | 8 +- app/actions/file-commands.c | 2 - app/actions/image-commands.c | 2 - app/actions/layers-commands.c | 7 +- app/actions/select-commands.c | 2 +- app/actions/vectors-commands.c | 7 +- app/core/Makefile.am | 2 + app/core/gimp-edit.c | 10 +- app/core/gimp-transform-region.c | 9 +- app/core/gimpchannel-combine.c | 43 +- app/core/gimpchannel-select.c | 39 +- app/core/gimpchannel-select.h | 2 + app/core/gimpchannel.c | 43 +- app/core/gimpdrawable-blend.c | 5 +- app/core/gimpdrawable-bucket-fill.c | 5 +- app/core/gimpdrawable-desaturate.c | 4 +- app/core/gimpdrawable-equalize.c | 4 +- app/core/gimpdrawable-invert.c | 4 +- app/core/gimpdrawable-offset.c | 4 +- app/core/gimpdrawable-transform.c | 9 +- app/core/gimpdrawable.c | 28 +- app/core/gimpdrawable.h | 6 +- app/core/gimpedit.c | 10 +- app/core/gimpimage-convert.c | 27 +- app/core/gimpimage-crop.c | 17 +- app/core/gimpimage-guides.c | 2 - app/core/gimpimage-mask-select.c | 39 +- app/core/gimpimage-mask-select.h | 2 + app/core/gimpimage-mask.c | 42 +- app/core/gimpimage-mask.h | 6 +- app/core/gimpimage-merge.c | 1 - app/core/gimpimage-qmask.c | 9 +- app/core/gimpimage-quick-mask.c | 9 +- app/core/gimpimage-resize.c | 9 +- app/core/gimpimage-scale.c | 9 +- app/core/gimpimage-undo-push.c | 824 +++---- app/core/gimpimage-undo-push.h | 225 +- app/core/gimpimage-undo.c | 14 +- app/core/gimpimage.c | 97 +- app/core/gimpimage.h | 2 + app/core/gimpimagemap.c | 34 +- app/core/gimpimagemap.h | 3 +- app/core/gimpitem.c | 17 +- app/core/gimplayer-floating-sel.c | 35 +- app/core/gimplayer-floating-sel.h | 6 +- app/core/gimplayer.c | 29 +- app/core/gimplayermask.c | 2 - app/core/gimppaintinfo.c | 10 + app/core/gimppaintinfo.h | 2 + app/dialogs/file-open-dialog.c | 2 - app/display/gimpdisplayshell-dnd.c | 2 - app/file/file-open.c | 2 - app/file/file-save.c | 2 - app/gui/channels-commands.c | 8 +- app/gui/file-commands.c | 2 - app/gui/file-open-dialog.c | 2 - app/gui/image-commands.c | 2 - app/gui/layers-commands.c | 7 +- app/gui/paths-dialog.c | 1 - app/gui/select-commands.c | 2 +- app/gui/vectors-commands.c | 7 +- app/paint/Makefile.am | 2 + app/paint/gimpairbrush.c | 7 +- app/paint/gimpclone.c | 5 +- app/paint/gimpconvolve.c | 7 +- app/paint/gimpdodgeburn.c | 7 +- app/paint/gimperaser.c | 7 +- app/paint/gimpink.c | 7 +- app/paint/gimppaintbrush.c | 7 +- app/paint/gimppaintcore-undo.c | 123 + app/paint/gimppaintcore-undo.h | 28 + app/paint/gimppaintcore.c | 32 +- app/paint/gimppencil.c | 7 +- app/paint/gimpsmudge.c | 7 +- app/paint/gimpsourcecore.c | 5 +- app/paint/paint-types.h | 3 +- app/paint/paint.c | 16 +- app/pdb/color_cmds.c | 18 +- app/pdb/drawable_cmds.c | 4 +- app/pdb/guides_cmds.c | 112 +- app/pdb/layer_cmds.c | 1 - app/pdb/selection_cmds.c | 4 +- app/pdb/selection_tools_cmds.c | 2 + app/text/gimptext-compat.c | 4 +- app/tools/Makefile.am | 2 + app/tools/gimpbezierselecttool.c | 2 +- app/tools/gimpbrushtool.c | 2 - app/tools/gimpbucketfilltool.c | 2 - app/tools/gimpeditselectiontool.c | 1 - app/tools/gimpfreeselecttool.c | 4 +- app/tools/gimpfuzzyselecttool.c | 3 +- app/tools/gimpimagemaptool.c | 15 +- app/tools/gimpinktool.c | 7 +- app/tools/gimpiscissorstool.c | 1 + app/tools/gimpmeasuretool.c | 11 +- app/tools/gimpmovetool.c | 11 +- app/tools/gimppainttool.c | 2 - app/tools/gimprectselecttool.c | 4 +- app/tools/gimpregionselecttool.c | 3 +- app/tools/gimptexttool.c | 2 - app/tools/gimptransformtool-undo.c | 170 ++ app/tools/gimptransformtool-undo.h | 32 + app/tools/gimptransformtool.c | 24 +- app/undo.c | 3123 -------------------------- app/undo.h | 161 -- app/undo_history.c | 2 - app/widgets/gimpchannellistview.c | 1 + app/widgets/gimpchanneltreeview.c | 1 + app/widgets/gimpdrawablelistview.c | 2 - app/widgets/gimpdrawabletreeview.c | 2 - app/widgets/gimpselectioneditor.c | 2 +- tools/pdbgen/pdb/color.pdb | 19 +- tools/pdbgen/pdb/drawable.pdb | 5 +- tools/pdbgen/pdb/guides.pdb | 119 +- tools/pdbgen/pdb/layer.pdb | 2 +- tools/pdbgen/pdb/selection.pdb | 16 +- tools/pdbgen/pdb/selection_tools.pdb | 3 +- 119 files changed, 1627 insertions(+), 4423 deletions(-) create mode 100644 app/paint/gimppaintcore-undo.c create mode 100644 app/paint/gimppaintcore-undo.h create mode 100644 app/tools/gimptransformtool-undo.c create mode 100644 app/tools/gimptransformtool-undo.h delete mode 100644 app/undo.c delete mode 100644 app/undo.h diff --git a/ChangeLog b/ChangeLog index 2948969bda..642f7b9377 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,112 @@ +2003-02-14 Michael Natterer + + Moved the undo step implementations to the core and pass around + lots of "const gchar *undo_desc". Fixes bug #104367. + + * app/Makefile.am + * app/undo.[ch]: removed... + + * app/core/Makefile.am + * app/core/gimpimage-undo-push.[ch]: ...and added here. + + * app/paint/Makefile.am + * app/tools/Makefile.am + * app/paint/gimppaintcore-undo.[ch] + * app/tools/gimptransformtool-undo.[ch]: new files for the + paint and transform undos. + + * app/core/gimppaintinfo.[ch]: added a blurb. + + * app/paint/gimpairbrush.c + * app/paint/gimpclone.c + * app/paint/gimpconvolve.c + * app/paint/gimpdodgeburn.c + * app/paint/gimperaser.c + * app/paint/gimppaintbrush.c + * app/paint/gimppaintcore.c + * app/paint/gimppencil.c + * app/paint/gimpsmudge.c + * app/paint/paint-types.h + * app/paint/paint.c: pass the blurb when registering the core. + + * app/core/gimpdrawable.[ch] + * app/core/gimpimage.[ch] + * app/core/gimpimage-mask-select.[ch] + * app/core/gimpimage-mask.[ch] + * app/core/gimpimagemap.[ch] + * app/core/gimplayer-floating-sel.[ch]: added "undo_desc" parameters + to all undo pushing helper functions. + + * app/undo_history.c + * app/core/gimpchannel.c + * app/core/gimpdrawable-blend.c + * app/core/gimpdrawable-bucket-fill.c + * app/core/gimpdrawable-desaturate.c + * app/core/gimpdrawable-equalize.c + * app/core/gimpdrawable-invert.c + * app/core/gimpdrawable-offset.c + * app/core/gimpdrawable-transform.c + * app/core/gimpedit.c + * app/core/gimpimage-convert.c + * app/core/gimpimage-crop.c + * app/core/gimpimage-guides.c + * app/core/gimpimage-merge.c + * app/core/gimpimage-qmask.c + * app/core/gimpimage-resize.c + * app/core/gimpimage-scale.c + * app/core/gimpimage-undo.c + * app/core/gimpitem.c + * app/core/gimplayer.c + * app/core/gimplayermask.c + * app/display/gimpdisplayshell-dnd.c + * app/file/file-open.c + * app/file/file-save.c + * app/gui/channels-commands.c + * app/gui/file-commands.c + * app/gui/file-open-dialog.c + * app/gui/image-commands.c + * app/gui/layers-commands.c + * app/gui/paths-dialog.c + * app/gui/select-commands.c + * app/gui/vectors-commands.c + * app/text/gimptext-compat.c + * app/tools/gimpbezierselecttool.c + * app/tools/gimpbucketfilltool.c + * app/tools/gimpeditselectiontool.c + * app/tools/gimpfreeselecttool.c + * app/tools/gimpfuzzyselecttool.c + * app/tools/gimpimagemaptool.c + * app/tools/gimpinktool.c + * app/tools/gimpiscissorstool.c + * app/tools/gimpmeasuretool.c + * app/tools/gimpmovetool.c + * app/tools/gimppainttool.c + * app/tools/gimprectselecttool.c + * app/tools/gimptexttool.c + * app/tools/gimptransformtool.c + * app/widgets/gimpchannellistview.c + * app/widgets/gimpdrawablelistview.c + * app/widgets/gimpselectioneditor.c + * tools/pdbgen/pdb/color.pdb + * tools/pdbgen/pdb/drawable.pdb + * tools/pdbgen/pdb/guides.pdb + * tools/pdbgen/pdb/layer.pdb + * tools/pdbgen/pdb/selection.pdb + * tools/pdbgen/pdb/selection_tools.pdb: changed accordingly: pass + "undo_desc" strings, changed includes or simply removed inclusion + of "undo.h". Some random cleanups. + + * tools/pdbgen/pdb/guides.pdb: cleaned up a lot. Fixed + gimp_image_find_next_guide() to not return guides with + position < 0 (and made it shorter and readable). + + * app/pdb/color_cmds.c + * app/pdb/drawable_cmds.c + * app/pdb/guides_cmds.c + * app/pdb/layer_cmds.c + * app/pdb/selection_cmds.c + * app/pdb/selection_tools_cmds.c: regenerated. + 2003-02-14 Sven Neumann * app/core/gimplayermask.c (gimp_layer_mask_duplicate): return the diff --git a/app/Makefile.am b/app/Makefile.am index f835ae8d71..b2d9935dbf 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -51,9 +51,7 @@ bye_sources = \ path.c \ path.h \ pathP.h \ - path_transform.h \ - undo.c \ - undo.h + path_transform.h ## ## stuff diff --git a/app/actions/channels-commands.c b/app/actions/channels-commands.c index 5dd1d30c01..f803efa7bc 100644 --- a/app/actions/channels-commands.c +++ b/app/actions/channels-commands.c @@ -33,6 +33,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimpimage-mask-select.h" #include "widgets/gimpcolorpanel.h" @@ -43,8 +44,6 @@ #include "channels-commands.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -150,6 +149,7 @@ channels_channel_to_sel (GtkWidget *widget, return_if_no_channel (gimage, active_channel, data); gimp_image_mask_select_channel (gimage, + _("Channel to Selection"), active_channel, 0, 0, op, @@ -425,7 +425,9 @@ edit_channel_query_ok_callback (GtkWidget *widget, if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel)))) { - undo_push_item_rename (options->gimage, GIMP_ITEM (channel)); + gimp_image_undo_push_item_rename (options->gimage, + _("Rename Channel"), + GIMP_ITEM (channel)); gimp_object_set_name (GIMP_OBJECT (channel), new_name); } diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c index 32b87628ae..3427e6094f 100644 --- a/app/actions/file-commands.c +++ b/app/actions/file-commands.c @@ -47,8 +47,6 @@ #include "file-save-dialog.h" #include "menus.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c index 16ceb02a5b..f87e7f00ee 100644 --- a/app/actions/image-commands.c +++ b/app/actions/image-commands.c @@ -45,8 +45,6 @@ #include "image-commands.h" #include "resize-dialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c index df03b0eade..fbd97bd42f 100644 --- a/app/actions/layers-commands.c +++ b/app/actions/layers-commands.c @@ -34,6 +34,7 @@ #include "core/gimpimage-mask.h" #include "core/gimpimage-merge.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimplayer.h" #include "core/gimplayer-floating-sel.h" #include "core/gimplayermask.h" @@ -50,8 +51,6 @@ #include "layers-commands.h" #include "resize-dialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -768,7 +767,9 @@ edit_layer_query_ok_callback (GtkWidget *widget, floating_sel_to_layer (layer); } - undo_push_item_rename (options->gimage, GIMP_ITEM (layer)); + gimp_image_undo_push_item_rename (options->gimage, + _("Rename Layer"), + GIMP_ITEM (layer)); gimp_object_set_name (GIMP_OBJECT (layer), new_name); diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c index 9a55fde41a..42eb597cb2 100644 --- a/app/actions/select-commands.c +++ b/app/actions/select-commands.c @@ -116,7 +116,7 @@ select_none_cmd_callback (GtkWidget *widget, GimpImage *gimage; return_if_no_image (gimage, data); - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); gimp_image_flush (gimage); } diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index 4b9b193cc5..3b7d28d0de 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -32,6 +32,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" +#include "core/gimpimage-undo-push.h" #include "core/gimplist.h" #include "core/gimppaintinfo.h" #include "core/gimptoolinfo.h" @@ -52,8 +53,6 @@ #include "vectors-commands.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -533,7 +532,9 @@ edit_vectors_query_ok_callback (GtkWidget *widget, if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors)))) { - undo_push_item_rename (options->gimage, GIMP_ITEM (vectors)); + gimp_image_undo_push_item_rename (options->gimage, + _("Rename Path"), + GIMP_ITEM (vectors)); gimp_object_set_name (GIMP_OBJECT (vectors), new_name); } diff --git a/app/core/Makefile.am b/app/core/Makefile.am index 453fbb357d..a87d5c8005 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -115,6 +115,8 @@ libappcore_a_sources = \ gimpimage-scale.h \ gimpimage-undo.c \ gimpimage-undo.h \ + gimpimage-undo-push.c \ + gimpimage-undo-push.h \ gimpimagefile.c \ gimpimagefile.h \ gimpimagemap.c \ diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c index 2b7ed27e94..8e7a4f70ab 100644 --- a/app/core/gimp-edit.c +++ b/app/core/gimp-edit.c @@ -42,8 +42,6 @@ #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -222,7 +220,7 @@ gimp_edit_paste (GimpImage *gimage, * it seems like the correct behavior. */ if (! gimp_image_mask_is_empty (gimage) && ! paste_into) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); /* if there's a drawable, add a new floating selection */ if (drawable != NULL) @@ -314,7 +312,8 @@ gimp_edit_clear (GimpImage *gimage, color_region (&bufPR, col); pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, + gimp_image_apply_image (gimage, drawable, &bufPR, + TRUE, _("Clear"), GIMP_OPACITY_OPAQUE, GIMP_ERASE_MODE, NULL, x1, y1); @@ -389,7 +388,8 @@ gimp_edit_fill (GimpImage *gimage, color_region (&bufPR, col); pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, + gimp_image_apply_image (gimage, drawable, &bufPR, + TRUE, _("Fill"), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, NULL, x1, y1); diff --git a/app/core/gimp-transform-region.c b/app/core/gimp-transform-region.c index bae96f3b73..f717b744eb 100644 --- a/app/core/gimp-transform-region.c +++ b/app/core/gimp-transform-region.c @@ -39,11 +39,10 @@ #include "gimpimage.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -802,9 +801,11 @@ gimp_drawable_transform_paste (GimpDrawable *drawable, /* Push an undo */ if (layer) - undo_push_layer_mod (gimage, layer); + gimp_image_undo_push_layer_mod (gimage, _("Transform Layer"), + layer); else if (channel) - undo_push_channel_mod (gimage, channel); + gimp_image_undo_push_channel_mod (gimage, _("Transform Channel"), + channel); /* set the current layer's data */ drawable->tiles = tiles; diff --git a/app/core/gimpchannel-combine.c b/app/core/gimpchannel-combine.c index 946ce4650f..d6b05e159b 100644 --- a/app/core/gimpchannel-combine.c +++ b/app/core/gimpchannel-combine.c @@ -39,12 +39,11 @@ #include "paint-funcs/paint-funcs.h" #include "gimpimage.h" +#include "gimpimage-undo-push.h" #include "gimpchannel.h" #include "gimplayer.h" #include "gimpparasitelist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -59,7 +58,8 @@ static GimpItem * gimp_channel_duplicate (GimpItem *item, GType new_type, gboolean add_alpha); -static void gimp_channel_push_undo (GimpChannel *mask); +static void gimp_channel_push_undo (GimpChannel *mask, + const gchar *undo_desc); static void gimp_channel_validate (TileManager *tm, Tile *tile); @@ -212,7 +212,8 @@ gimp_channel_duplicate (GimpItem *item, } static void -gimp_channel_push_undo (GimpChannel *mask) +gimp_channel_push_undo (GimpChannel *mask, + const gchar *undo_desc) { GimpImage *gimage; @@ -220,7 +221,7 @@ gimp_channel_push_undo (GimpChannel *mask) g_return_if_fail (gimage != NULL); - undo_push_mask (gimage, mask); + gimp_image_undo_push_mask (gimage, undo_desc, mask); mask->boundary_known = FALSE; @@ -382,7 +383,9 @@ gimp_channel_scale (GimpChannel *channel, scale_region (&srcPR, &destPR, interpolation_type); /* Push the channel on the undo stack */ - undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), channel); + gimp_image_undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), + _("Scale Channel"), + channel); /* Configure the new channel */ GIMP_DRAWABLE (channel)->tiles = new_tiles; @@ -488,7 +491,9 @@ gimp_channel_resize (GimpChannel *channel, copy_region (&srcPR, &destPR); /* Push the channel on the undo stack */ - undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), channel); + gimp_image_undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), + _("Resize Channel"), + channel); /* Configure the new channel */ GIMP_DRAWABLE (channel)->tiles = new_tiles; @@ -1293,7 +1298,7 @@ gimp_channel_feather (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Feather Channel")); pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles, 0, 0, @@ -1315,7 +1320,7 @@ gimp_channel_sharpen (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Sharpen Channel")); pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles, 0, 0, @@ -1340,7 +1345,7 @@ gimp_channel_clear (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Clear Channel")); if (mask->bounds_known && !mask->empty) { @@ -1378,7 +1383,7 @@ gimp_channel_all (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Fill Channel")); /* clear the mask */ pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles, @@ -1403,7 +1408,7 @@ gimp_channel_invert (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Invert Channel")); if (mask->bounds_known && mask->empty) { @@ -1469,7 +1474,7 @@ gimp_channel_border (GimpChannel *mask, y2 += radius_y; if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Border Channel")); pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2-x1), (y2-y1), TRUE); @@ -1526,7 +1531,7 @@ gimp_channel_grow (GimpChannel *mask, y2 = GIMP_DRAWABLE (mask)->height; if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Grow Channel")); /* need full extents for grow, not! */ pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2 - x1), @@ -1577,7 +1582,7 @@ gimp_channel_shrink (GimpChannel *mask, y2++; if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Shrink Channel")); pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2 - x1), (y2 - y1), TRUE); @@ -1602,7 +1607,7 @@ gimp_channel_translate (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Translate Channel")); gimp_channel_bounds (mask, &x1, &y1, &x2, &y2); x1 = CLAMP ((x1 + off_x), 0, GIMP_DRAWABLE (mask)->width); @@ -1678,7 +1683,7 @@ gimp_channel_load (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (channel)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Channel Load")); /* copy the channel to the mask */ pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles, @@ -1707,7 +1712,7 @@ gimp_channel_layer_alpha (GimpChannel *mask, g_return_if_fail (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Channel from Alpha")); /* clear the mask if it is not already known to be empty */ if (! (mask->bounds_known && mask->empty)) @@ -1744,7 +1749,7 @@ gimp_channel_layer_mask (GimpChannel *mask, g_return_if_fail (gimp_layer_get_mask (layer)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Channel from Mask")); /* clear the mask if it is not already known to be empty */ if (! (mask->bounds_known && mask->empty)) diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c index 7e23be93c3..f2f8e1992f 100644 --- a/app/core/gimpchannel-select.c +++ b/app/core/gimpchannel-select.c @@ -32,6 +32,8 @@ #include "vectors/gimpstroke.h" #include "vectors/gimpvectors.h" +#include "libgimp/gimpintl.h" + void gimp_image_mask_select_rectangle (GimpImage *gimage, @@ -48,9 +50,9 @@ gimp_image_mask_select_rectangle (GimpImage *gimage, /* if applicable, replace the current selection */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, _("Rectangular Selection")); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Rectangular Selection")); /* if feathering for rect, make a new mask with the * rectangle and feather that with the old mask @@ -95,9 +97,9 @@ gimp_image_mask_select_ellipse (GimpImage *gimage, /* if applicable, replace the current selection */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, _("Ellipse Selection")); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Ellipse Selection")); /* if feathering for rect, make a new mask with the * rectangle and feather that with the old mask @@ -129,14 +131,15 @@ gimp_image_mask_select_ellipse (GimpImage *gimage, } void -gimp_image_mask_select_polygon (GimpImage *gimage, - gint n_points, - GimpVector2 *points, - GimpChannelOps op, - gboolean antialias, - gboolean feather, - gdouble feather_radius_x, - gdouble feather_radius_y) +gimp_image_mask_select_polygon (GimpImage *gimage, + const gchar *undo_name, + gint n_points, + GimpVector2 *points, + GimpChannelOps op, + gboolean antialias, + gboolean feather, + gdouble feather_radius_x, + gdouble feather_radius_y) { GimpScanConvert *scan_convert; GimpChannel *mask; @@ -147,9 +150,9 @@ gimp_image_mask_select_polygon (GimpImage *gimage, * or insure that a floating selection is anchored down... */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, undo_name); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, undo_name); #define SUPERSAMPLE 3 @@ -219,6 +222,7 @@ gimp_image_mask_select_vectors (GimpImage *gimage, } gimp_image_mask_select_polygon (GIMP_ITEM (vectors)->gimage, + _("Selection from Path"), coords->len, points, op, @@ -234,6 +238,7 @@ gimp_image_mask_select_vectors (GimpImage *gimage, void gimp_image_mask_select_channel (GimpImage *gimage, + const gchar *undo_desc, GimpChannel *channel, gint offset_x, gint offset_y, @@ -247,9 +252,9 @@ gimp_image_mask_select_channel (GimpImage *gimage, /* if applicable, replace the current selection */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, undo_desc); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, undo_desc); if (feather) gimp_channel_feather (channel, @@ -302,6 +307,7 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage, } gimp_image_mask_select_channel (gimage, + _("Select Fuzzy"), mask, mask_x, mask_y, @@ -352,6 +358,7 @@ gimp_image_mask_select_by_color (GimpImage *gimage, } gimp_image_mask_select_channel (gimage, + _("Select by Color"), mask, mask_x, mask_y, diff --git a/app/core/gimpchannel-select.h b/app/core/gimpchannel-select.h index 0d233cafeb..c20844afe3 100644 --- a/app/core/gimpchannel-select.h +++ b/app/core/gimpchannel-select.h @@ -42,6 +42,7 @@ void gimp_image_mask_select_ellipse (GimpImage *gimage, gdouble feather_radius_y); void gimp_image_mask_select_polygon (GimpImage *gimage, + const gchar *undo_desc, gint n_points, GimpVector2 *points, GimpChannelOps op, @@ -59,6 +60,7 @@ void gimp_image_mask_select_vectors (GimpImage *gimage, gdouble feather_radius_y); void gimp_image_mask_select_channel (GimpImage *gimage, + const gchar *undo_desc, GimpChannel *channel, gint offset_x, gint offset_y, diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index 946ce4650f..d6b05e159b 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -39,12 +39,11 @@ #include "paint-funcs/paint-funcs.h" #include "gimpimage.h" +#include "gimpimage-undo-push.h" #include "gimpchannel.h" #include "gimplayer.h" #include "gimpparasitelist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -59,7 +58,8 @@ static GimpItem * gimp_channel_duplicate (GimpItem *item, GType new_type, gboolean add_alpha); -static void gimp_channel_push_undo (GimpChannel *mask); +static void gimp_channel_push_undo (GimpChannel *mask, + const gchar *undo_desc); static void gimp_channel_validate (TileManager *tm, Tile *tile); @@ -212,7 +212,8 @@ gimp_channel_duplicate (GimpItem *item, } static void -gimp_channel_push_undo (GimpChannel *mask) +gimp_channel_push_undo (GimpChannel *mask, + const gchar *undo_desc) { GimpImage *gimage; @@ -220,7 +221,7 @@ gimp_channel_push_undo (GimpChannel *mask) g_return_if_fail (gimage != NULL); - undo_push_mask (gimage, mask); + gimp_image_undo_push_mask (gimage, undo_desc, mask); mask->boundary_known = FALSE; @@ -382,7 +383,9 @@ gimp_channel_scale (GimpChannel *channel, scale_region (&srcPR, &destPR, interpolation_type); /* Push the channel on the undo stack */ - undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), channel); + gimp_image_undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), + _("Scale Channel"), + channel); /* Configure the new channel */ GIMP_DRAWABLE (channel)->tiles = new_tiles; @@ -488,7 +491,9 @@ gimp_channel_resize (GimpChannel *channel, copy_region (&srcPR, &destPR); /* Push the channel on the undo stack */ - undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), channel); + gimp_image_undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (channel)), + _("Resize Channel"), + channel); /* Configure the new channel */ GIMP_DRAWABLE (channel)->tiles = new_tiles; @@ -1293,7 +1298,7 @@ gimp_channel_feather (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Feather Channel")); pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles, 0, 0, @@ -1315,7 +1320,7 @@ gimp_channel_sharpen (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Sharpen Channel")); pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles, 0, 0, @@ -1340,7 +1345,7 @@ gimp_channel_clear (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Clear Channel")); if (mask->bounds_known && !mask->empty) { @@ -1378,7 +1383,7 @@ gimp_channel_all (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Fill Channel")); /* clear the mask */ pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles, @@ -1403,7 +1408,7 @@ gimp_channel_invert (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Invert Channel")); if (mask->bounds_known && mask->empty) { @@ -1469,7 +1474,7 @@ gimp_channel_border (GimpChannel *mask, y2 += radius_y; if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Border Channel")); pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2-x1), (y2-y1), TRUE); @@ -1526,7 +1531,7 @@ gimp_channel_grow (GimpChannel *mask, y2 = GIMP_DRAWABLE (mask)->height; if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Grow Channel")); /* need full extents for grow, not! */ pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2 - x1), @@ -1577,7 +1582,7 @@ gimp_channel_shrink (GimpChannel *mask, y2++; if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Shrink Channel")); pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2 - x1), (y2 - y1), TRUE); @@ -1602,7 +1607,7 @@ gimp_channel_translate (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (mask)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Translate Channel")); gimp_channel_bounds (mask, &x1, &y1, &x2, &y2); x1 = CLAMP ((x1 + off_x), 0, GIMP_DRAWABLE (mask)->width); @@ -1678,7 +1683,7 @@ gimp_channel_load (GimpChannel *mask, g_return_if_fail (GIMP_IS_CHANNEL (channel)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Channel Load")); /* copy the channel to the mask */ pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles, @@ -1707,7 +1712,7 @@ gimp_channel_layer_alpha (GimpChannel *mask, g_return_if_fail (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Channel from Alpha")); /* clear the mask if it is not already known to be empty */ if (! (mask->bounds_known && mask->empty)) @@ -1744,7 +1749,7 @@ gimp_channel_layer_mask (GimpChannel *mask, g_return_if_fail (gimp_layer_get_mask (layer)); if (push_undo) - gimp_channel_push_undo (mask); + gimp_channel_push_undo (mask, _("Channel from Mask")); /* clear the mask if it is not already known to be empty */ if (! (mask->bounds_known && mask->empty)) diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index 6164adcba5..16065ac4bf 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -41,6 +41,8 @@ #include "gimpimage.h" #include "gimpimage-mask.h" +#include "libgimp/gimpintl.h" + typedef gdouble (* BlendRepeatFunc) (gdouble); @@ -229,7 +231,8 @@ gimp_drawable_blend (GimpDrawable *drawable, } pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, + gimp_image_apply_image (gimage, drawable, &bufPR, + TRUE, _("Blend"), opacity, paint_mode, NULL, x1, y1); diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c index 060fa6adbc..6627af0b81 100644 --- a/app/core/gimpdrawable-bucket-fill.c +++ b/app/core/gimpdrawable-bucket-fill.c @@ -40,8 +40,6 @@ #include "gimpimage-mask.h" #include "gimppattern.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -313,7 +311,8 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable, /* Apply it to the image */ pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, + gimp_image_apply_image (gimage, drawable, &bufPR, + TRUE, _("Bucket Fill"), opacity, paint_mode, NULL, x1, y1); tile_manager_destroy (buf_tiles); diff --git a/app/core/gimpdrawable-desaturate.c b/app/core/gimpdrawable-desaturate.c index 3eabaf2ab7..51d0a014c8 100644 --- a/app/core/gimpdrawable-desaturate.c +++ b/app/core/gimpdrawable-desaturate.c @@ -28,6 +28,8 @@ #include "gimpdrawable-desaturate.h" #include "gimpimage.h" +#include "libgimp/gimpintl.h" + void gimp_drawable_desaturate (GimpDrawable *drawable) @@ -90,7 +92,7 @@ gimp_drawable_desaturate (GimpDrawable *drawable) } } - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Desaturate")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } diff --git a/app/core/gimpdrawable-equalize.c b/app/core/gimpdrawable-equalize.c index 73cc033e3e..bc9ea1b78a 100644 --- a/app/core/gimpdrawable-equalize.c +++ b/app/core/gimpdrawable-equalize.c @@ -36,6 +36,8 @@ #include "gimpdrawable-histogram.h" #include "gimpimage.h" +#include "libgimp/gimpintl.h" + void gimp_drawable_equalize (GimpDrawable *drawable, @@ -80,7 +82,7 @@ gimp_drawable_equalize (GimpDrawable *drawable, gimp_lut_free (lut); gimp_histogram_free (hist); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Equalize")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } diff --git a/app/core/gimpdrawable-invert.c b/app/core/gimpdrawable-invert.c index 246f7b50a5..74bc04df80 100644 --- a/app/core/gimpdrawable-invert.c +++ b/app/core/gimpdrawable-invert.c @@ -30,6 +30,8 @@ #include "gimpdrawable.h" #include "gimpdrawable-invert.h" +#include "libgimp/gimpintl.h" + void gimp_drawable_invert (GimpDrawable *drawable) @@ -51,7 +53,7 @@ gimp_drawable_invert (GimpDrawable *drawable) gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Invert")); gimp_drawable_update (drawable, x1, y1, diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c index 8739725f1a..0b025e275f 100644 --- a/app/core/gimpdrawable-offset.c +++ b/app/core/gimpdrawable-offset.c @@ -38,6 +38,8 @@ #include "gimpdrawable-offset.h" #include "gimpimage.h" +#include "libgimp/gimpintl.h" + void gimp_drawable_offset (GimpDrawable *drawable, @@ -307,7 +309,7 @@ gimp_drawable_offset (GimpDrawable *drawable, } /* push an undo */ - gimp_drawable_push_undo (drawable, + gimp_drawable_push_undo (drawable, _("Offset Drawable"), 0, 0, gimp_drawable_width (drawable), gimp_drawable_height (drawable), diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c index bae96f3b73..f717b744eb 100644 --- a/app/core/gimpdrawable-transform.c +++ b/app/core/gimpdrawable-transform.c @@ -39,11 +39,10 @@ #include "gimpimage.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -802,9 +801,11 @@ gimp_drawable_transform_paste (GimpDrawable *drawable, /* Push an undo */ if (layer) - undo_push_layer_mod (gimage, layer); + gimp_image_undo_push_layer_mod (gimage, _("Transform Layer"), + layer); else if (channel) - undo_push_channel_mod (gimage, channel); + gimp_image_undo_push_channel_mod (gimage, _("Transform Channel"), + channel); /* set the current layer's data */ drawable->tiles = tiles; diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index eb3cedcea8..5e724e753d 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -43,14 +43,13 @@ #include "gimpdrawable-preview.h" #include "gimpimage.h" #include "gimpimage-mask.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplist.h" #include "gimpmarshal.h" #include "gimpparasitelist.h" #include "gimppreviewcache.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -344,7 +343,8 @@ gimp_drawable_update (GimpDrawable *drawable, } void -gimp_drawable_push_undo (GimpDrawable *drawable, +gimp_drawable_push_undo (GimpDrawable *drawable, + const gchar *undo_desc, gint x1, gint y1, gint x2, @@ -355,19 +355,22 @@ gimp_drawable_push_undo (GimpDrawable *drawable, g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); if (! tiles) - undo_push_image (gimp_item_get_image (GIMP_ITEM (drawable)), - drawable, - x1, y1, x2, y2); + gimp_image_undo_push_image (gimp_item_get_image (GIMP_ITEM (drawable)), + undo_desc, + drawable, + x1, y1, x2, y2); else - undo_push_image_mod (gimp_item_get_image (GIMP_ITEM (drawable)), - drawable, - x1, y1, x2, y2, - tiles, sparse); + gimp_image_undo_push_image_mod (gimp_item_get_image (GIMP_ITEM (drawable)), + undo_desc, + drawable, + x1, y1, x2, y2, + tiles, sparse); } void gimp_drawable_merge_shadow (GimpDrawable *drawable, - gboolean push_undo) + gboolean push_undo, + const gchar *undo_desc) { GimpImage *gimage; PixelRegion shadowPR; @@ -387,7 +390,8 @@ gimp_drawable_merge_shadow (GimpDrawable *drawable, gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); pixel_region_init (&shadowPR, gimage->shadow, x1, y1, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &shadowPR, push_undo, + gimp_image_apply_image (gimage, drawable, &shadowPR, + push_undo, undo_desc, GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE, NULL, x1, y1); } diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h index 05fba15b46..141f2e6042 100644 --- a/app/core/gimpdrawable.h +++ b/app/core/gimpdrawable.h @@ -78,7 +78,8 @@ void gimp_drawable_update (GimpDrawable *drawable, gint w, gint h); -void gimp_drawable_push_undo (GimpDrawable *drawable, +void gimp_drawable_push_undo (GimpDrawable *drawable, + const gchar *undo_desc, gint x1, gint y1, gint x2, @@ -87,7 +88,8 @@ void gimp_drawable_push_undo (GimpDrawable *drawable, gboolean sparse); void gimp_drawable_merge_shadow (GimpDrawable *drawable, - gboolean push_undo); + gboolean push_undo, + const gchar *undo_desc); void gimp_drawable_fill (GimpDrawable *drawable, const GimpRGB *color); diff --git a/app/core/gimpedit.c b/app/core/gimpedit.c index 2b7ed27e94..8e7a4f70ab 100644 --- a/app/core/gimpedit.c +++ b/app/core/gimpedit.c @@ -42,8 +42,6 @@ #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -222,7 +220,7 @@ gimp_edit_paste (GimpImage *gimage, * it seems like the correct behavior. */ if (! gimp_image_mask_is_empty (gimage) && ! paste_into) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); /* if there's a drawable, add a new floating selection */ if (drawable != NULL) @@ -314,7 +312,8 @@ gimp_edit_clear (GimpImage *gimage, color_region (&bufPR, col); pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, + gimp_image_apply_image (gimage, drawable, &bufPR, + TRUE, _("Clear"), GIMP_OPACITY_OPAQUE, GIMP_ERASE_MODE, NULL, x1, y1); @@ -389,7 +388,8 @@ gimp_edit_fill (GimpImage *gimage, color_region (&bufPR, col); pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE); - gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, + gimp_image_apply_image (gimage, drawable, &bufPR, + TRUE, _("Fill"), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, NULL, x1, y1); diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c index 21ba7eaef7..b3e2868eb9 100644 --- a/app/core/gimpimage-convert.c +++ b/app/core/gimpimage-convert.c @@ -140,13 +140,12 @@ #include "gimpimage.h" #include "gimpimage-projection.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplist.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimppalette.h" -#include "undo.h" - #include "cpercep.h" #include "gimpimage-convert-fsdither.h" #include "gimpimage-convert-data.h" @@ -733,7 +732,8 @@ gimp_image_convert (GimpImage *gimage, GimpImageBaseType old_type; GList *list; GimpImageType new_layer_type; - TileManager *new_tiles; + TileManager *new_tiles; + const gchar *undo_desc = NULL; g_return_if_fail (gimage != NULL); g_return_if_fail (GIMP_IS_IMAGE (gimage)); @@ -747,15 +747,30 @@ gimp_image_convert (GimpImage *gimage, /* Get the floating layer if one exists */ floating_layer = gimp_image_floating_sel (gimage); + switch (new_type) + { + case GIMP_RGB: + undo_desc = _("Convert Image to RGB"); + break; + + case GIMP_GRAY: + undo_desc = _("Convert Image to Grayscale"); + break; + + case GIMP_INDEXED: + undo_desc = _("Convert Image to Indexed"); + break; + } + gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_CONVERT, - _("Convert")); + undo_desc); /* Relax the floating selection */ if (floating_layer) floating_sel_relax (floating_layer, TRUE); /* Push the image type to the stack */ - undo_push_image_type (gimage); + gimp_image_undo_push_image_type (gimage, NULL); /* Set the new base type */ old_type = gimage->base_type; @@ -928,7 +943,7 @@ gimp_image_convert (GimpImage *gimage, } /* Push the layer onto the undo stack */ - undo_push_layer_mod (gimage, layer); + gimp_image_undo_push_layer_mod (gimage, NULL, layer); GIMP_DRAWABLE (layer)->tiles = new_tiles; GIMP_DRAWABLE (layer)->type = new_layer_type; diff --git a/app/core/gimpimage-crop.c b/app/core/gimpimage-crop.c index 8e1e041369..c114b95f75 100644 --- a/app/core/gimpimage-crop.c +++ b/app/core/gimpimage-crop.c @@ -34,12 +34,11 @@ #include "gimpimage-mask.h" #include "gimpimage-projection.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -98,7 +97,6 @@ gimp_image_crop (GimpImage *gimage, GimpLayer *layer; GimpLayer *floating_layer; GimpChannel *channel; - GList *guide_list_ptr; GList *list; gint width, height; gint lx1, ly1, lx2, ly2; @@ -151,7 +149,7 @@ gimp_image_crop (GimpImage *gimage, floating_sel_relax (floating_layer, TRUE); /* Push the image size to the stack */ - undo_push_image_size (gimage); + gimp_image_undo_push_image_size (gimage, NULL); /* Set the new width and height */ gimage->width = width; @@ -217,12 +215,15 @@ gimp_image_crop (GimpImage *gimage, if (floating_layer) floating_sel_rigor (floating_layer, TRUE); - guide_list_ptr = gimage->guides; - while ( guide_list_ptr != NULL) + for (list = gimage->guides; list; list = g_list_next (list)) { - undo_push_image_guide (gimage, (GimpGuide *) guide_list_ptr->data); - guide_list_ptr = guide_list_ptr->next; + GimpGuide *guide; + + guide = (GimpGuide *) list->data; + + gimp_image_undo_push_image_guide (gimage, NULL, guide); } + gimp_image_undo_group_end (gimage); /* Adjust any guides we might have laying about */ diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index d0a3490d9e..9cf051b2a5 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -26,8 +26,6 @@ #include "gimpimage.h" #include "gimpimage-guides.h" -#include "undo.h" - #define GUIDE_EPSILON 5 diff --git a/app/core/gimpimage-mask-select.c b/app/core/gimpimage-mask-select.c index 7e23be93c3..f2f8e1992f 100644 --- a/app/core/gimpimage-mask-select.c +++ b/app/core/gimpimage-mask-select.c @@ -32,6 +32,8 @@ #include "vectors/gimpstroke.h" #include "vectors/gimpvectors.h" +#include "libgimp/gimpintl.h" + void gimp_image_mask_select_rectangle (GimpImage *gimage, @@ -48,9 +50,9 @@ gimp_image_mask_select_rectangle (GimpImage *gimage, /* if applicable, replace the current selection */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, _("Rectangular Selection")); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Rectangular Selection")); /* if feathering for rect, make a new mask with the * rectangle and feather that with the old mask @@ -95,9 +97,9 @@ gimp_image_mask_select_ellipse (GimpImage *gimage, /* if applicable, replace the current selection */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, _("Ellipse Selection")); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Ellipse Selection")); /* if feathering for rect, make a new mask with the * rectangle and feather that with the old mask @@ -129,14 +131,15 @@ gimp_image_mask_select_ellipse (GimpImage *gimage, } void -gimp_image_mask_select_polygon (GimpImage *gimage, - gint n_points, - GimpVector2 *points, - GimpChannelOps op, - gboolean antialias, - gboolean feather, - gdouble feather_radius_x, - gdouble feather_radius_y) +gimp_image_mask_select_polygon (GimpImage *gimage, + const gchar *undo_name, + gint n_points, + GimpVector2 *points, + GimpChannelOps op, + gboolean antialias, + gboolean feather, + gdouble feather_radius_x, + gdouble feather_radius_y) { GimpScanConvert *scan_convert; GimpChannel *mask; @@ -147,9 +150,9 @@ gimp_image_mask_select_polygon (GimpImage *gimage, * or insure that a floating selection is anchored down... */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, undo_name); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, undo_name); #define SUPERSAMPLE 3 @@ -219,6 +222,7 @@ gimp_image_mask_select_vectors (GimpImage *gimage, } gimp_image_mask_select_polygon (GIMP_ITEM (vectors)->gimage, + _("Selection from Path"), coords->len, points, op, @@ -234,6 +238,7 @@ gimp_image_mask_select_vectors (GimpImage *gimage, void gimp_image_mask_select_channel (GimpImage *gimage, + const gchar *undo_desc, GimpChannel *channel, gint offset_x, gint offset_y, @@ -247,9 +252,9 @@ gimp_image_mask_select_channel (GimpImage *gimage, /* if applicable, replace the current selection */ if (op == GIMP_CHANNEL_OP_REPLACE) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, undo_desc); else - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, undo_desc); if (feather) gimp_channel_feather (channel, @@ -302,6 +307,7 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage, } gimp_image_mask_select_channel (gimage, + _("Select Fuzzy"), mask, mask_x, mask_y, @@ -352,6 +358,7 @@ gimp_image_mask_select_by_color (GimpImage *gimage, } gimp_image_mask_select_channel (gimage, + _("Select by Color"), mask, mask_x, mask_y, diff --git a/app/core/gimpimage-mask-select.h b/app/core/gimpimage-mask-select.h index 0d233cafeb..c20844afe3 100644 --- a/app/core/gimpimage-mask-select.h +++ b/app/core/gimpimage-mask-select.h @@ -42,6 +42,7 @@ void gimp_image_mask_select_ellipse (GimpImage *gimage, gdouble feather_radius_y); void gimp_image_mask_select_polygon (GimpImage *gimage, + const gchar *undo_desc, gint n_points, GimpVector2 *points, GimpChannelOps op, @@ -59,6 +60,7 @@ void gimp_image_mask_select_vectors (GimpImage *gimage, gdouble feather_radius_y); void gimp_image_mask_select_channel (GimpImage *gimage, + const gchar *undo_desc, GimpChannel *channel, gint offset_x, gint offset_y, diff --git a/app/core/gimpimage-mask.c b/app/core/gimpimage-mask.c index d32546637a..44d8f34566 100644 --- a/app/core/gimpimage-mask.c +++ b/app/core/gimpimage-mask.c @@ -35,14 +35,13 @@ #include "gimpimage.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplayermask.h" #include "gimppaintinfo.h" #include "gimptoolinfo.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -272,7 +271,7 @@ gimp_image_mask_extract (GimpImage *gimage, * push an undo */ if (cut_gimage && non_empty) - gimp_drawable_push_undo (drawable, x1, y1, x2, y2, NULL, FALSE); + gimp_drawable_push_undo (drawable, NULL, x1, y1, x2, y2, NULL, FALSE); gimp_drawable_offsets (drawable, &off_x, &off_y); @@ -300,7 +299,7 @@ gimp_image_mask_extract (GimpImage *gimage, if (cut_gimage) { /* Clear the region */ - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); /* Update the region */ gimp_image_update (gimage, @@ -415,7 +414,8 @@ gimp_image_mask_float (GimpImage *gimage, void -gimp_image_mask_push_undo (GimpImage *gimage) +gimp_image_mask_push_undo (GimpImage *gimage, + const gchar *undo_desc) { GimpChannel *mask; @@ -423,7 +423,7 @@ gimp_image_mask_push_undo (GimpImage *gimage) mask = gimp_image_get_mask (gimage); - undo_push_mask (gimage, mask); + gimp_image_undo_push_mask (gimage, undo_desc, mask); gimp_image_mask_invalidate (gimage); } @@ -435,7 +435,7 @@ gimp_image_mask_feather (GimpImage *gimage, { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Feather Selection")); gimp_channel_feather (gimp_image_get_mask (gimage), feather_radius_x, @@ -450,7 +450,7 @@ gimp_image_mask_sharpen (GimpImage *gimage) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Sharpen Selection")); gimp_channel_sharpen (gimp_image_get_mask (gimage), FALSE); @@ -458,11 +458,15 @@ gimp_image_mask_sharpen (GimpImage *gimage) } void -gimp_image_mask_clear (GimpImage *gimage) +gimp_image_mask_clear (GimpImage *gimage, + const gchar *undo_desc) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + if (! undo_desc) + undo_desc = _("Select None"); + + gimp_image_mask_push_undo (gimage, undo_desc); gimp_channel_clear (gimp_image_get_mask (gimage), FALSE); @@ -474,7 +478,7 @@ gimp_image_mask_all (GimpImage *gimage) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Select All")); gimp_channel_all (gimp_image_get_mask (gimage), FALSE); @@ -486,7 +490,7 @@ gimp_image_mask_invert (GimpImage *gimage) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Invert Selection")); gimp_channel_invert (gimp_image_get_mask (gimage), FALSE); @@ -500,7 +504,7 @@ gimp_image_mask_border (GimpImage *gimage, { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Border Selection")); gimp_channel_border (gimp_image_get_mask (gimage), border_radius_x, @@ -517,7 +521,7 @@ gimp_image_mask_grow (GimpImage *gimage, { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Grow Selection")); gimp_channel_grow (gimp_image_get_mask (gimage), grow_pixels_x, @@ -535,7 +539,7 @@ gimp_image_mask_shrink (GimpImage *gimage, { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Shrink Selection")); gimp_channel_shrink (gimp_image_get_mask (gimage), shrink_pixels_x, @@ -553,7 +557,7 @@ gimp_image_mask_load (GimpImage *gimage, g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (GIMP_IS_CHANNEL (channel)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Selection from Channel")); /* load the specified channel to the gimage mask */ gimp_channel_load (gimp_image_get_mask (gimage), channel, FALSE); @@ -568,7 +572,7 @@ gimp_image_mask_translate (GimpImage *gimage, { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Translate Selection")); gimp_channel_translate (gimp_image_get_mask (gimage), off_x, off_y, FALSE); @@ -585,7 +589,7 @@ gimp_image_mask_layer_alpha (GimpImage *gimage, if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))) { - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Selection from Alpha")); /* load the mask with the given layer's alpha channel */ gimp_channel_layer_alpha (gimp_image_get_mask (gimage), layer, FALSE); @@ -609,7 +613,7 @@ gimp_image_mask_layer_mask (GimpImage *gimage, if (gimp_layer_get_mask (layer)) { - gimp_image_mask_push_undo (gimage); + gimp_image_mask_push_undo (gimage, _("Selection from Mask")); /* load the mask with the given layer's mask */ gimp_channel_layer_mask (gimp_image_get_mask (gimage), layer, FALSE); diff --git a/app/core/gimpimage-mask.h b/app/core/gimpimage-mask.h index 61343d0f2c..7ba4180c4e 100644 --- a/app/core/gimpimage-mask.h +++ b/app/core/gimpimage-mask.h @@ -51,14 +51,16 @@ GimpLayer * gimp_image_mask_float (GimpImage *gimage, gint off_x, gint off_y); -void gimp_image_mask_push_undo (GimpImage *gimage); +void gimp_image_mask_push_undo (GimpImage *gimage, + const gchar *undo_desc); void gimp_image_mask_feather (GimpImage *gimage, gdouble feather_radius_x, gdouble feather_radius_y); void gimp_image_mask_sharpen (GimpImage *gimage); -void gimp_image_mask_clear (GimpImage *gimage); +void gimp_image_mask_clear (GimpImage *gimage, + const gchar *undo_name); void gimp_image_mask_all (GimpImage *gimage); void gimp_image_mask_invert (GimpImage *gimage); diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index 6fe375e32e..1899db45ae 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -47,7 +47,6 @@ #include "gimpundostack.h" #include "path.h" -#include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimpimage-qmask.c b/app/core/gimpimage-qmask.c index 7f80a15eba..158a4b4489 100644 --- a/app/core/gimpimage-qmask.c +++ b/app/core/gimpimage-qmask.c @@ -33,10 +33,9 @@ #include "gimpimage-mask.h" #include "gimpimage-qmask.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer-floating-sel.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -98,7 +97,7 @@ gimp_image_set_qmask_state (GimpImage *gimage, mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (gimp_image_get_mask (gimage)), G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)), FALSE)); - gimp_image_mask_clear (gimage); /* Clear the selection */ + gimp_image_mask_clear (gimage, NULL); /* Clear the selection */ gimp_image_add_channel (gimage, mask, 0); gimp_channel_set_color (mask, &color); @@ -108,7 +107,7 @@ gimp_image_set_qmask_state (GimpImage *gimage, if (gimage->qmask_inverted) gimp_channel_invert (mask, TRUE); - undo_push_image_qmask (gimage); + gimp_image_undo_push_image_qmask (gimage, NULL); gimp_image_undo_group_end (gimage); @@ -131,7 +130,7 @@ gimp_image_set_qmask_state (GimpImage *gimage, * call the qmask_removed_callback() which will set * the qmask_state to FALSE */ - undo_push_image_qmask (gimage); + gimp_image_undo_push_image_qmask (gimage, NULL); if (gimage->qmask_inverted) gimp_channel_invert (mask, TRUE); diff --git a/app/core/gimpimage-quick-mask.c b/app/core/gimpimage-quick-mask.c index 7f80a15eba..158a4b4489 100644 --- a/app/core/gimpimage-quick-mask.c +++ b/app/core/gimpimage-quick-mask.c @@ -33,10 +33,9 @@ #include "gimpimage-mask.h" #include "gimpimage-qmask.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer-floating-sel.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -98,7 +97,7 @@ gimp_image_set_qmask_state (GimpImage *gimage, mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (gimp_image_get_mask (gimage)), G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)), FALSE)); - gimp_image_mask_clear (gimage); /* Clear the selection */ + gimp_image_mask_clear (gimage, NULL); /* Clear the selection */ gimp_image_add_channel (gimage, mask, 0); gimp_channel_set_color (mask, &color); @@ -108,7 +107,7 @@ gimp_image_set_qmask_state (GimpImage *gimage, if (gimage->qmask_inverted) gimp_channel_invert (mask, TRUE); - undo_push_image_qmask (gimage); + gimp_image_undo_push_image_qmask (gimage, NULL); gimp_image_undo_group_end (gimage); @@ -131,7 +130,7 @@ gimp_image_set_qmask_state (GimpImage *gimage, * call the qmask_removed_callback() which will set * the qmask_state to FALSE */ - undo_push_image_qmask (gimage); + gimp_image_undo_push_image_qmask (gimage, NULL); if (gimage->qmask_inverted) gimp_channel_invert (mask, TRUE); diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index 03139d6996..a77e9a3fba 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -30,12 +30,11 @@ #include "gimpimage-projection.h" #include "gimpimage-resize.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -68,7 +67,7 @@ gimp_image_resize (GimpImage *gimage, floating_sel_relax (floating_layer, TRUE); /* Push the image size to the stack */ - undo_push_image_size (gimage); + gimp_image_undo_push_image_size (gimage, NULL); /* Set the new width and height */ gimage->width = new_width; @@ -96,14 +95,14 @@ gimp_image_resize (GimpImage *gimage, switch (guide->orientation) { case GIMP_ORIENTATION_HORIZONTAL: - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, NULL, guide); guide->position += offset_y; if (guide->position < 0 || guide->position > new_height) gimp_image_delete_guide (gimage, guide); break; case GIMP_ORIENTATION_VERTICAL: - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, NULL, guide); guide->position += offset_x; if (guide->position < 0 || guide->position > new_width) gimp_image_delete_guide (gimage, guide); diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index 3eaef3b7f0..fd8beb096a 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -29,12 +29,11 @@ #include "gimpimage-projection.h" #include "gimpimage-scale.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -80,7 +79,7 @@ gimp_image_scale (GimpImage *gimage, floating_sel_relax (floating_layer, TRUE); /* Push the image size to the stack */ - undo_push_image_size (gimage); + gimp_image_undo_push_image_size (gimage, NULL); /* Set the new width and height */ @@ -162,12 +161,12 @@ gimp_image_scale (GimpImage *gimage, switch (guide->orientation) { case GIMP_ORIENTATION_HORIZONTAL: - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, NULL, guide); guide->position = (guide->position * new_height) / old_height; break; case GIMP_ORIENTATION_VERTICAL: - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, NULL, guide); guide->position = (guide->position * new_width) / old_width; break; diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index a78710e760..f72eaf7279 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -35,36 +35,28 @@ #include "paint-funcs/paint-funcs.h" -#include "core/gimp.h" -#include "core/gimp-parasites.h" -#include "core/gimpchannel.h" -#include "core/gimpcontainer.h" -#include "core/gimpcontext.h" -#include "core/gimpimage.h" -#include "core/gimpimage-guides.h" -#include "core/gimpimage-mask.h" -#include "core/gimpimage-projection.h" -#include "core/gimplayer.h" -#include "core/gimplayer-floating-sel.h" -#include "core/gimplayermask.h" -#include "core/gimplist.h" -#include "core/gimpparasitelist.h" - -#include "core/gimpundo.h" -#include "core/gimpundostack.h" -#include "core/gimpimage-undo.h" +#include "gimp-parasites.h" +#include "gimp.h" +#include "gimpchannel.h" +#include "gimpcontext.h" +#include "gimpimage-guides.h" +#include "gimpimage-mask.h" +#include "gimpimage-projection.h" +#include "gimpimage-undo.h" +#include "gimpimage.h" +#include "gimplayer-floating-sel.h" +#include "gimplayer.h" +#include "gimplayermask.h" +#include "gimplist.h" +#include "gimpparasitelist.h" +#include "gimpundo.h" +#include "gimpundostack.h" #include "paint/gimppaintcore.h" #include "vectors/gimpvectors.h" -#include "tools/gimpbycolorselecttool.h" -#include "tools/gimppainttool.h" -#include "tools/gimptransformtool.h" -#include "tools/tool_manager.h" - #include "path_transform.h" -#include "undo.h" #include "libgimp/gimpintl.h" @@ -92,16 +84,20 @@ static void undo_free_image (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image (GimpImage *gimage, - GimpDrawable *drawable, - gint x1, - gint y1, - gint x2, - gint y2) +gimp_image_undo_push_image (GimpImage *gimage, + const gchar *undo_desc, + GimpDrawable *drawable, + gint x1, + gint y1, + gint x2, + gint y2) { GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); + x1 = CLAMP (x1, 0, gimp_drawable_width (drawable)); y1 = CLAMP (y1, 0, gimp_drawable_height (drawable)); x2 = CLAMP (x2, 0, gimp_drawable_width (drawable)); @@ -112,7 +108,7 @@ undo_push_image (GimpImage *gimage, if ((new = gimp_image_undo_push (gimage, size, sizeof (ImageUndo), - GIMP_UNDO_IMAGE, NULL, + GIMP_UNDO_IMAGE, undo_desc, TRUE, undo_pop_image, undo_free_image))) @@ -150,21 +146,23 @@ undo_push_image (GimpImage *gimage, } gboolean -undo_push_image_mod (GimpImage *gimage, - GimpDrawable *drawable, - gint x1, - gint y1, - gint x2, - gint y2, - TileManager *tiles, - gboolean sparse) +gimp_image_undo_push_image_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpDrawable *drawable, + gint x1, + gint y1, + gint x2, + gint y2, + TileManager *tiles, + gboolean sparse) { GimpUndo *new; gsize size; gint dwidth, dheight; - if (! tiles) - return FALSE; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); + g_return_val_if_fail (tiles != NULL, FALSE); dwidth = gimp_drawable_width (drawable); dheight = gimp_drawable_height (drawable); @@ -178,7 +176,7 @@ undo_push_image_mod (GimpImage *gimage, if ((new = gimp_image_undo_push (gimage, size, sizeof (ImageUndo), - GIMP_UNDO_IMAGE_MOD, NULL, + GIMP_UNDO_IMAGE_MOD, undo_desc, TRUE, undo_pop_image, undo_free_image))) @@ -311,14 +309,17 @@ static void undo_free_image_type (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image_type (GimpImage *gimage) +gimp_image_undo_push_image_type (GimpImage *gimage, + const gchar *undo_desc) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ImageTypeUndo), sizeof (ImageTypeUndo), - GIMP_UNDO_IMAGE_TYPE, NULL, + GIMP_UNDO_IMAGE_TYPE, undo_desc, TRUE, undo_pop_image_type, undo_free_image_type))) @@ -390,14 +391,17 @@ static void undo_free_image_size (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image_size (GimpImage *gimage) +gimp_image_undo_push_image_size (GimpImage *gimage, + const gchar *undo_desc) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ImageSizeUndo), sizeof (ImageSizeUndo), - GIMP_UNDO_IMAGE_SIZE, NULL, + GIMP_UNDO_IMAGE_SIZE, undo_desc, TRUE, undo_pop_image_size, undo_free_image_size))) @@ -479,14 +483,17 @@ static void undo_free_image_resolution (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image_resolution (GimpImage *gimage) +gimp_image_undo_push_image_resolution (GimpImage *gimage, + const gchar *undo_desc) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ResolutionUndo), sizeof (ResolutionUndo), - GIMP_UNDO_IMAGE_RESOLUTION, NULL, + GIMP_UNDO_IMAGE_RESOLUTION, undo_desc, TRUE, undo_pop_image_resolution, undo_free_image_resolution))) @@ -577,14 +584,17 @@ static void undo_free_image_qmask (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image_qmask (GimpImage *gimage) +gimp_image_undo_push_image_qmask (GimpImage *gimage, + const gchar *undo_desc) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (QmaskUndo), sizeof (QmaskUndo), - GIMP_UNDO_IMAGE_QMASK, NULL, + GIMP_UNDO_IMAGE_QMASK, undo_desc, TRUE, undo_pop_image_qmask, undo_free_image_qmask))) @@ -653,15 +663,19 @@ static void undo_free_image_guide (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image_guide (GimpImage *gimage, - GimpGuide *guide) +gimp_image_undo_push_image_guide (GimpImage *gimage, + const gchar *undo_desc, + GimpGuide *guide) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (guide != NULL, FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (GuideUndo), sizeof (GuideUndo), - GIMP_UNDO_IMAGE_GUIDE, NULL, + GIMP_UNDO_IMAGE_GUIDE, undo_desc, TRUE, undo_pop_image_guide, undo_free_image_guide))) @@ -689,18 +703,20 @@ undo_pop_image_guide (GimpUndo *undo, GimpUndoAccumulator *accum) { GuideUndo *data; - GimpGuide tmp; + GimpGuide tmp_guide; gint tmp_ref; data = (GuideUndo *) undo->data; gimp_image_update_guide (gimage, data->guide); - tmp_ref = data->guide->ref_count; - tmp = *(data->guide); + tmp_ref = data->guide->ref_count; + tmp_guide = *(data->guide); + *(data->guide) = data->orig; + data->guide->ref_count = tmp_ref; - data->orig = tmp; + data->orig = tmp_guide; gimp_image_update_guide (gimage, data->guide); @@ -748,14 +764,18 @@ static void undo_free_mask (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_mask (GimpImage *gimage, - GimpChannel *mask) +gimp_image_undo_push_mask (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *mask) { TileManager *undo_tiles; gint x1, y1, x2, y2; GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_CHANNEL (mask), FALSE); + if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2)) { PixelRegion srcPR, destPR; @@ -779,7 +799,7 @@ undo_push_mask (GimpImage *gimage, if ((new = gimp_image_undo_push (gimage, size, sizeof (MaskUndo), - GIMP_UNDO_MASK, NULL, + GIMP_UNDO_MASK, undo_desc, FALSE, undo_pop_mask, undo_free_mask))) @@ -940,15 +960,19 @@ static void undo_free_item_rename (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_item_rename (GimpImage *gimage, - GimpItem *item) +gimp_image_undo_push_item_rename (GimpImage *gimage, + const gchar *undo_desc, + GimpItem *item) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ItemRenameUndo), sizeof (ItemRenameUndo), - GIMP_UNDO_ITEM_RENAME, NULL, + GIMP_UNDO_ITEM_RENAME, undo_desc, TRUE, undo_pop_item_rename, undo_free_item_rename))) @@ -1015,6 +1039,7 @@ struct _LayerUndo }; static gboolean undo_push_layer (GimpImage *gimage, + const gchar *undo_desc, GimpUndoType type, GimpLayer *layer, gint prev_position, @@ -1028,27 +1053,30 @@ static void undo_free_layer (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_layer_add (GimpImage *gimage, - GimpLayer *layer, - gint prev_position, - GimpLayer *prev_layer) +gimp_image_undo_push_layer_add (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + gint prev_position, + GimpLayer *prev_layer) { - return undo_push_layer (gimage, GIMP_UNDO_LAYER_ADD, + return undo_push_layer (gimage, undo_desc, GIMP_UNDO_LAYER_ADD, layer, prev_position, prev_layer); } gboolean -undo_push_layer_remove (GimpImage *gimage, - GimpLayer *layer, - gint prev_position, - GimpLayer *prev_layer) +gimp_image_undo_push_layer_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + gint prev_position, + GimpLayer *prev_layer) { - return undo_push_layer (gimage, GIMP_UNDO_LAYER_REMOVE, + return undo_push_layer (gimage, undo_desc, GIMP_UNDO_LAYER_REMOVE, layer, prev_position, prev_layer); } static gboolean undo_push_layer (GimpImage *gimage, + const gchar *undo_desc, GimpUndoType type, GimpLayer *layer, gint prev_position, @@ -1057,15 +1085,18 @@ undo_push_layer (GimpImage *gimage, GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); + g_return_val_if_fail (prev_layer == NULL || GIMP_IS_LAYER (prev_layer), + FALSE); g_return_val_if_fail (type == GIMP_UNDO_LAYER_ADD || - type == GIMP_UNDO_LAYER_REMOVE, - FALSE); + type == GIMP_UNDO_LAYER_REMOVE, FALSE); size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer)); if ((new = gimp_image_undo_push (gimage, size, sizeof (LayerUndo), - type, NULL, + type, undo_desc, TRUE, undo_pop_layer, undo_free_layer))) @@ -1181,6 +1212,7 @@ undo_free_layer (GimpUndo *undo, lu = (LayerUndo *) undo->data; g_object_unref (lu->layer); + g_free (lu); } @@ -1209,20 +1241,24 @@ static void undo_free_layer_mod (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_layer_mod (GimpImage *gimage, - GimpLayer *layer) +gimp_image_undo_push_layer_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer) { GimpUndo *new; TileManager *tiles; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); + tiles = GIMP_DRAWABLE (layer)->tiles; size = sizeof (LayerModUndo) + tile_manager_get_memsize (tiles); if ((new = gimp_image_undo_push (gimage, size, sizeof (LayerModUndo), - GIMP_UNDO_LAYER_MOD, NULL, + GIMP_UNDO_LAYER_MOD, undo_desc, TRUE, undo_pop_layer_mod, undo_free_layer_mod))) @@ -1342,6 +1378,7 @@ struct _LayerMaskUndo }; static gboolean undo_push_layer_mask (GimpImage *gimage, + const gchar *undo_desc, GimpUndoType type, GimpLayer *layer, GimpLayerMask *mask); @@ -1354,42 +1391,47 @@ static void undo_free_layer_mask (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_layer_mask_add (GimpImage *gimage, - GimpLayer *layer, - GimpLayerMask *mask) +gimp_image_undo_push_layer_mask_add (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + GimpLayerMask *mask) { - return undo_push_layer_mask (gimage, GIMP_UNDO_LAYER_MASK_ADD, + return undo_push_layer_mask (gimage, undo_desc, GIMP_UNDO_LAYER_MASK_ADD, layer, mask); } gboolean -undo_push_layer_mask_remove (GimpImage *gimage, - GimpLayer *layer, - GimpLayerMask *mask) +gimp_image_undo_push_layer_mask_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + GimpLayerMask *mask) { - return undo_push_layer_mask (gimage, GIMP_UNDO_LAYER_MASK_REMOVE, + return undo_push_layer_mask (gimage, undo_desc, GIMP_UNDO_LAYER_MASK_REMOVE, layer, mask); } static gboolean undo_push_layer_mask (GimpImage *gimage, - GimpUndoType type, + const gchar *undo_desc, + GimpUndoType type, GimpLayer *layer, GimpLayerMask *mask) { GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), FALSE); g_return_val_if_fail (type == GIMP_UNDO_LAYER_MASK_ADD || - type == GIMP_UNDO_LAYER_MASK_REMOVE, - FALSE); + type == GIMP_UNDO_LAYER_MASK_REMOVE, FALSE); size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask)); if ((new = gimp_image_undo_push (gimage, size, sizeof (LayerMaskUndo), - type, NULL, + type, undo_desc, TRUE, undo_pop_layer_mask, undo_free_layer_mask))) @@ -1446,6 +1488,7 @@ undo_free_layer_mask (GimpUndo *undo, lmu = (LayerMaskUndo *) undo->data; g_object_unref (lmu->mask); + g_free (lmu); } @@ -1471,15 +1514,19 @@ static void undo_free_layer_reposition (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_layer_reposition (GimpImage *gimage, - GimpLayer *layer) +gimp_image_undo_push_layer_reposition (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (LayerRepositionUndo), sizeof (LayerRepositionUndo), - GIMP_UNDO_LAYER_REPOSITION, NULL, + GIMP_UNDO_LAYER_REPOSITION, undo_desc, TRUE, undo_pop_layer_reposition, undo_free_layer_reposition))) @@ -1549,15 +1596,19 @@ static void undo_free_layer_displace (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_layer_displace (GimpImage *gimage, - GimpLayer *layer) +gimp_image_undo_push_layer_displace (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (LayerDisplaceUndo), sizeof (LayerDisplaceUndo), - GIMP_UNDO_LAYER_DISPLACE, NULL, + GIMP_UNDO_LAYER_DISPLACE, undo_desc, TRUE, undo_pop_layer_displace, undo_free_layer_displace))) @@ -1661,6 +1712,7 @@ struct _ChannelUndo }; static gboolean undo_push_channel (GimpImage *gimage, + const gchar *undo_desc, GimpUndoType type, GimpChannel *channel, gint prev_position, @@ -1674,45 +1726,51 @@ static void undo_free_channel (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_channel_add (GimpImage *gimage, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel) +gimp_image_undo_push_channel_add (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel, + gint prev_position, + GimpChannel *prev_channel) { - return undo_push_channel (gimage, GIMP_UNDO_CHANNEL_ADD, + return undo_push_channel (gimage, undo_desc, GIMP_UNDO_CHANNEL_ADD, channel, prev_position, prev_channel); } gboolean -undo_push_channel_remove (GimpImage *gimage, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel) +gimp_image_undo_push_channel_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel, + gint prev_position, + GimpChannel *prev_channel) { - return undo_push_channel (gimage, GIMP_UNDO_CHANNEL_REMOVE, + return undo_push_channel (gimage, undo_desc, GIMP_UNDO_CHANNEL_REMOVE, channel, prev_position, prev_channel); } static gboolean -undo_push_channel (GimpImage *gimage, - GimpUndoType type, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel) +undo_push_channel (GimpImage *gimage, + const gchar *undo_desc, + GimpUndoType type, + GimpChannel *channel, + gint prev_position, + GimpChannel *prev_channel) { GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); + g_return_val_if_fail (prev_channel == NULL || GIMP_IS_CHANNEL (prev_channel), + FALSE); g_return_val_if_fail (type == GIMP_UNDO_CHANNEL_ADD || - type == GIMP_UNDO_CHANNEL_REMOVE, - FALSE); + type == GIMP_UNDO_CHANNEL_REMOVE, FALSE); size = sizeof (ChannelUndo) + gimp_object_get_memsize (GIMP_OBJECT (channel)); if ((new = gimp_image_undo_push (gimage, size, sizeof (ChannelUndo), - type, NULL, + type, undo_desc, TRUE, undo_pop_channel, undo_free_channel))) @@ -1824,13 +1882,17 @@ static void undo_free_channel_mod (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_channel_mod (GimpImage *gimage, - GimpChannel *channel) +gimp_image_undo_push_channel_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel) { TileManager *tiles; GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); + tiles = GIMP_DRAWABLE (channel)->tiles; size = sizeof (ChannelModUndo) + tile_manager_get_memsize (tiles); @@ -1838,7 +1900,7 @@ undo_push_channel_mod (GimpImage *gimage, if ((new = gimp_image_undo_push (gimage, size, sizeof (ChannelModUndo), - GIMP_UNDO_CHANNEL_MOD, NULL, + GIMP_UNDO_CHANNEL_MOD, undo_desc, TRUE, undo_pop_channel_mod, undo_free_channel_mod))) @@ -1938,15 +2000,19 @@ static void undo_free_channel_reposition (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_channel_reposition (GimpImage *gimage, - GimpChannel *channel) +gimp_image_undo_push_channel_reposition (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ChannelRepositionUndo), sizeof (ChannelRepositionUndo), - GIMP_UNDO_CHANNEL_REPOSITION, NULL, + GIMP_UNDO_CHANNEL_REPOSITION, undo_desc, TRUE, undo_pop_channel_reposition, undo_free_channel_reposition))) @@ -2007,6 +2073,7 @@ struct _VectorsUndo }; static gboolean undo_push_vectors (GimpImage *gimage, + const gchar *undo_desc, GimpUndoType type, GimpVectors *vectors, gint prev_position, @@ -2020,45 +2087,51 @@ static void undo_free_vectors (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_vectors_add (GimpImage *gimage, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors) +gimp_image_undo_push_vectors_add (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors, + gint prev_position, + GimpVectors *prev_vectors) { - return undo_push_vectors (gimage, GIMP_UNDO_VECTORS_ADD, + return undo_push_vectors (gimage, undo_desc, GIMP_UNDO_VECTORS_ADD, vectors, prev_position, prev_vectors); } gboolean -undo_push_vectors_remove (GimpImage *gimage, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors) +gimp_image_undo_push_vectors_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors, + gint prev_position, + GimpVectors *prev_vectors) { - return undo_push_vectors (gimage, GIMP_UNDO_VECTORS_REMOVE, + return undo_push_vectors (gimage, undo_desc, GIMP_UNDO_VECTORS_REMOVE, vectors, prev_position, prev_vectors); } static gboolean -undo_push_vectors (GimpImage *gimage, - GimpUndoType type, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors) +undo_push_vectors (GimpImage *gimage, + const gchar *undo_desc, + GimpUndoType type, + GimpVectors *vectors, + gint prev_position, + GimpVectors *prev_vectors) { GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); + g_return_val_if_fail (prev_vectors == NULL || GIMP_IS_VECTORS (prev_vectors), + FALSE); g_return_val_if_fail (type == GIMP_UNDO_VECTORS_ADD || - type == GIMP_UNDO_VECTORS_REMOVE, - FALSE); + type == GIMP_UNDO_VECTORS_REMOVE, FALSE); size = sizeof (VectorsUndo) + gimp_object_get_memsize (GIMP_OBJECT (vectors)); if ((new = gimp_image_undo_push (gimage, size, sizeof (VectorsUndo), - type, NULL, + type, undo_desc, TRUE, undo_pop_vectors, undo_free_vectors))) @@ -2158,19 +2231,23 @@ static void undo_free_vectors_mod (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_vectors_mod (GimpImage *gimage, - GimpVectors *vectors) +gimp_image_undo_push_vectors_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors) { GimpUndo *new; gsize size; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); + size = (sizeof (VectorsModUndo) + gimp_object_get_memsize (GIMP_OBJECT (vectors))); if ((new = gimp_image_undo_push (gimage, size, sizeof (VectorsModUndo), - GIMP_UNDO_VECTORS_MOD, NULL, + GIMP_UNDO_VECTORS_MOD, undo_desc, TRUE, undo_pop_vectors_mod, undo_free_vectors_mod))) @@ -2251,15 +2328,19 @@ static void undo_free_vectors_reposition (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_vectors_reposition (GimpImage *gimage, - GimpVectors *vectors) +gimp_image_undo_push_vectors_reposition (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (VectorsRepositionUndo), sizeof (VectorsRepositionUndo), - GIMP_UNDO_VECTORS_REPOSITION, NULL, + GIMP_UNDO_VECTORS_REPOSITION, undo_desc, TRUE, undo_pop_vectors_reposition, undo_free_vectors_reposition))) @@ -2327,16 +2408,21 @@ static void undo_free_fs_to_layer (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_fs_to_layer (GimpImage *gimage, - GimpLayer *floating_layer, - GimpDrawable *drawable) +gimp_image_undo_push_fs_to_layer (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *floating_layer, + GimpDrawable *drawable) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE); + g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (FStoLayerUndo), sizeof (FStoLayerUndo), - GIMP_UNDO_FS_TO_LAYER, NULL, + GIMP_UNDO_FS_TO_LAYER, undo_desc, TRUE, undo_pop_fs_to_layer, undo_free_fs_to_layer))) @@ -2443,6 +2529,13 @@ undo_free_fs_to_layer (GimpUndo *undo, /* Floating Selection Rigor Undo */ /***********************************/ +typedef struct _FSRigorUndo FSRigorUndo; + +struct _FSRigorUndo +{ + GimpLayer *floating_layer; +}; + static gboolean undo_pop_fs_rigor (GimpUndo *undo, GimpImage *gimage, GimpUndoMode undo_mode, @@ -2452,24 +2545,28 @@ static void undo_free_fs_rigor (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_fs_rigor (GimpImage *gimage, - gint layer_ID) +gimp_image_undo_push_fs_rigor (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *floating_layer) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE); + if ((new = gimp_image_undo_push (gimage, - sizeof (gint32), - sizeof (gint32), - GIMP_UNDO_FS_RIGOR, NULL, + sizeof (FSRigorUndo), + sizeof (FSRigorUndo), + GIMP_UNDO_FS_RIGOR, undo_desc, FALSE, undo_pop_fs_rigor, undo_free_fs_rigor))) { - gint32 *id; + FSRigorUndo *fsu; - id = new->data; + fsu = new->data; - *id = layer_ID; + fsu->floating_layer = g_object_ref (floating_layer); return TRUE; } @@ -2483,43 +2580,24 @@ undo_pop_fs_rigor (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { - gint32 layer_ID; - GimpLayer *floating_layer; - - layer_ID = *((gint32 *) undo->data); + FSRigorUndo *fsu; - if ((floating_layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, layer_ID)) == NULL) - return FALSE; + fsu = (FSRigorUndo *) undo->data; - if (! gimp_layer_is_floating_sel (floating_layer)) + if (! gimp_layer_is_floating_sel (fsu->floating_layer)) return FALSE; switch (undo_mode) { case GIMP_UNDO_MODE_UNDO: - /* restore the contents of drawable the floating layer is attached to */ - if (floating_layer->fs.initial == FALSE) - floating_sel_restore (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; + floating_sel_relax (fsu->floating_layer, FALSE); break; case GIMP_UNDO_MODE_REDO: - /* store the affected area from the drawable in the backing store */ - floating_sel_store (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; + floating_sel_rigor (fsu->floating_layer, FALSE); break; } - gimp_image_floating_selection_changed (gimage); - return TRUE; } @@ -2528,7 +2606,13 @@ undo_free_fs_rigor (GimpUndo *undo, GimpImage *gimage, GimpUndoMode undo_mode) { - g_free (undo->data); + FSRigorUndo *fsu; + + fsu = (FSRigorUndo *) undo->data; + + g_object_unref (fsu->floating_layer); + + g_free (fsu); } @@ -2536,6 +2620,13 @@ undo_free_fs_rigor (GimpUndo *undo, /* Floating Selection Relax Undo */ /***********************************/ +typedef struct _FSRelaxUndo FSRelaxUndo; + +struct _FSRelaxUndo +{ + GimpLayer *floating_layer; +}; + static gboolean undo_pop_fs_relax (GimpUndo *undo, GimpImage *gimage, GimpUndoMode undo_mode, @@ -2545,24 +2636,28 @@ static void undo_free_fs_relax (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_fs_relax (GimpImage *gimage, - gint32 layer_ID) +gimp_image_undo_push_fs_relax (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *floating_layer) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_LAYER (floating_layer), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (gint32), sizeof (gint32), - GIMP_UNDO_FS_RELAX, NULL, + GIMP_UNDO_FS_RELAX, undo_desc, FALSE, undo_pop_fs_relax, undo_free_fs_relax))) { - gint32 *id; + FSRelaxUndo *fsu; - id = new->data; + fsu = new->data; - *id = layer_ID; + fsu->floating_layer = g_object_ref (floating_layer); return TRUE; } @@ -2576,43 +2671,24 @@ undo_pop_fs_relax (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { - gint32 layer_ID; - GimpLayer *floating_layer; - - layer_ID = *((gint32 *) undo->data); + FSRelaxUndo *fsu; - if ((floating_layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, layer_ID)) == NULL) - return FALSE; + fsu = (FSRelaxUndo *) undo->data; - if (! gimp_layer_is_floating_sel (floating_layer)) + if (! gimp_layer_is_floating_sel (fsu->floating_layer)) return FALSE; switch (undo_mode) { case GIMP_UNDO_MODE_UNDO: - /* store the affected area from the drawable in the backing store */ - floating_sel_store (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; + floating_sel_rigor (fsu->floating_layer, FALSE); break; case GIMP_UNDO_MODE_REDO: - /* restore the contents of drawable the floating layer is attached to */ - if (floating_layer->fs.initial == FALSE) - floating_sel_restore (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; + floating_sel_relax (fsu->floating_layer, FALSE); break; } - gimp_image_floating_selection_changed (gimage); - return TRUE; } @@ -2621,237 +2697,13 @@ undo_free_fs_relax (GimpUndo *undo, GimpImage *gimage, GimpUndoMode undo_mode) { - g_free (undo->data); -} - - -/********************/ -/* Transform Undo */ -/********************/ - -typedef struct _TransformUndo TransformUndo; - -struct _TransformUndo -{ - gint tool_ID; - GType tool_type; + FSRelaxUndo *fsu; - TransInfo trans_info; - TileManager *original; - gpointer path_undo; -}; + fsu = (FSRelaxUndo *) undo->data; -static gboolean undo_pop_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); + g_object_unref (fsu->floating_layer); -gboolean -undo_push_transform (GimpImage *gimage, - gint tool_ID, - GType tool_type, - gdouble *trans_info, - TileManager *original, - GSList *path_undo) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (TransformUndo), - sizeof (TransformUndo), - GIMP_UNDO_TRANSFORM, NULL, - FALSE, - undo_pop_transform, - undo_free_transform))) - { - TransformUndo *tu; - gint i; - - tu = new->data; - - tu->tool_ID = tool_ID; - tu->tool_type = tool_type; - - for (i = 0; i < TRAN_INFO_SIZE; i++) - tu->trans_info[i] = trans_info[i]; - - tu->original = original; - tu->path_undo = path_undo; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - GimpTool *active_tool; - - active_tool = tool_manager_get_active (gimage->gimp); - - if (GIMP_IS_TRANSFORM_TOOL (active_tool)) - { - GimpTransformTool *tt; - TransformUndo *tu; - - tt = GIMP_TRANSFORM_TOOL (active_tool); - tu = (TransformUndo *) undo->data; - - path_transform_do_undo (gimage, tu->path_undo); - - /* only pop if the active tool is the tool that pushed this undo */ - if (tu->tool_ID == active_tool->ID) - { - TileManager *temp; - gdouble d; - gint i; - - /* swap the transformation information arrays */ - for (i = 0; i < TRAN_INFO_SIZE; i++) - { - d = tu->trans_info[i]; - tu->trans_info[i] = tt->trans_info[i]; - tt->trans_info[i] = d; - } - - /* swap the original buffer--the source buffer for repeated transforms - */ - temp = tu->original; - tu->original = tt->original; - tt->original = temp; - - /* If we're re-implementing the first transform, reactivate tool */ - if (undo_mode == GIMP_UNDO_MODE_REDO && tt->original) - { - gimp_tool_control_activate (active_tool->control); - - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt)); - } - } - } - - return TRUE; -} - -static void -undo_free_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - TransformUndo * tu; - - tu = (TransformUndo *) undo->data; - - if (tu->original) - tile_manager_destroy (tu->original); - path_transform_free_undo (tu->path_undo); - g_free (tu); -} - - -/****************/ -/* Paint Undo */ -/****************/ - -typedef struct _PaintUndo PaintUndo; - -struct _PaintUndo -{ - gint core_ID; - GType core_type; - - GimpCoords last_coords; -}; - -static gboolean undo_pop_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_paint (GimpImage *gimage, - gint core_ID, - GType core_type, - GimpCoords *last_coords) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (PaintUndo), - sizeof (PaintUndo), - GIMP_UNDO_PAINT, NULL, - FALSE, - undo_pop_paint, - undo_free_paint))) - { - PaintUndo *pu; - - pu = new->data; - - pu->core_ID = core_ID; - pu->core_type = core_type; - pu->last_coords = *last_coords; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - GimpTool *active_tool; - - active_tool = tool_manager_get_active (gimage->gimp); - - if (GIMP_IS_PAINT_TOOL (active_tool)) - { - GimpPaintTool *pt; - PaintUndo *pu; - - pt = GIMP_PAINT_TOOL (active_tool); - pu = (PaintUndo *) undo->data; - - /* only pop if the active paint core is the one that pushed this undo */ - if (pu->core_ID == pt->core->ID) - { - GimpCoords tmp_coords; - - /* swap the paint core information */ - tmp_coords = pt->core->last_coords; - pt->core->last_coords = pu->last_coords; - pu->last_coords = tmp_coords; - } - } - - return TRUE; -} - -static void -undo_free_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - PaintUndo *pu; - - pu = (PaintUndo *) undo->data; - - g_free (pu); + g_free (fsu); } @@ -2878,15 +2730,18 @@ static void undo_free_parasite (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -undo_push_image_parasite (GimpImage *gimage, - gpointer parasite) +gimp_image_undo_push_image_parasite (GimpImage *gimage, + const gchar *undo_desc, + gpointer parasite) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ParasiteUndo), sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_ATTACH, NULL, + GIMP_UNDO_PARASITE_ATTACH, undo_desc, TRUE, undo_pop_parasite, undo_free_parasite))) @@ -2908,15 +2763,18 @@ undo_push_image_parasite (GimpImage *gimage, } gboolean -undo_push_image_parasite_remove (GimpImage *gimage, - const gchar *name) +gimp_image_undo_push_image_parasite_remove (GimpImage *gimage, + const gchar *undo_desc, + const gchar *name) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ParasiteUndo), sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_REMOVE, NULL, + GIMP_UNDO_PARASITE_REMOVE, undo_desc, TRUE, undo_pop_parasite, undo_free_parasite))) @@ -2938,16 +2796,19 @@ undo_push_image_parasite_remove (GimpImage *gimage, } gboolean -undo_push_item_parasite (GimpImage *gimage, - GimpItem *item, - gpointer parasite) +gimp_image_undo_push_item_parasite (GimpImage *gimage, + const gchar *undo_desc, + GimpItem *item, + gpointer parasite) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ParasiteUndo), sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_ATTACH, NULL, + GIMP_UNDO_PARASITE_ATTACH, undo_desc, TRUE, undo_pop_parasite, undo_free_parasite))) @@ -2968,16 +2829,19 @@ undo_push_item_parasite (GimpImage *gimage, } gboolean -undo_push_item_parasite_remove (GimpImage *gimage, - GimpItem *item, - const gchar *name) +gimp_image_undo_push_item_parasite_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpItem *item, + const gchar *name) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + if ((new = gimp_image_undo_push (gimage, sizeof (ParasiteUndo), sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_REMOVE, NULL, + GIMP_UNDO_PARASITE_REMOVE, undo_desc, TRUE, undo_pop_parasite, undo_free_parasite))) @@ -2997,48 +2861,45 @@ undo_push_item_parasite_remove (GimpImage *gimage, return FALSE; } - static gboolean undo_pop_parasite (GimpUndo *undo, GimpImage *gimage, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { - ParasiteUndo *data; + ParasiteUndo *pu; GimpParasite *tmp; - data = (ParasiteUndo *) undo->data; + pu = (ParasiteUndo *) undo->data; - tmp = data->parasite; - - if (data->gimage) - { - data->parasite = - gimp_parasite_copy (gimp_image_parasite_find (gimage, data->name)); + tmp = pu->parasite; + if (pu->gimage) + { + pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage, + pu->name)); if (tmp) - gimp_parasite_list_add (data->gimage->parasites, tmp); + gimp_parasite_list_add (pu->gimage->parasites, tmp); else - gimp_parasite_list_remove (data->gimage->parasites, data->name); + gimp_parasite_list_remove (pu->gimage->parasites, pu->name); } - else if (data->item) + else if (pu->item) { - data->parasite = - gimp_parasite_copy (gimp_item_parasite_find (data->item, - data->name)); + pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (pu->item, + pu->name)); if (tmp) - gimp_parasite_list_add (data->item->parasites, tmp); + gimp_parasite_list_add (pu->item->parasites, tmp); else - gimp_parasite_list_remove (data->item->parasites, data->name); + gimp_parasite_list_remove (pu->item->parasites, pu->name); } else { - data->parasite = gimp_parasite_copy (gimp_parasite_find (gimage->gimp, - data->name)); + pu->parasite = gimp_parasite_copy (gimp_parasite_find (gimage->gimp, + pu->name)); if (tmp) gimp_parasite_attach (gimage->gimp, tmp); else - gimp_parasite_detach (gimage->gimp, data->name); + gimp_parasite_detach (gimage->gimp, pu->name); } if (tmp) @@ -3047,7 +2908,6 @@ undo_pop_parasite (GimpUndo *undo, return TRUE; } - static void undo_free_parasite (GimpUndo *undo, GimpImage *gimage, @@ -3076,11 +2936,13 @@ static gboolean undo_pop_cantundo (GimpUndo *undo, GimpUndoAccumulator *accum); gboolean -undo_push_cantundo (GimpImage *gimage, - const gchar *action) +gimp_image_undo_push_cantundo (GimpImage *gimage, + const gchar *undo_desc) { GimpUndo *new; + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + /* This is the sole purpose of this type of undo: the ability to * mark an image as having been mutated, without really providing * any adequate undo facility. @@ -3088,13 +2950,11 @@ undo_push_cantundo (GimpImage *gimage, if ((new = gimp_image_undo_push (gimage, 0, 0, - GIMP_UNDO_CANT, NULL, + GIMP_UNDO_CANT, undo_desc, TRUE, undo_pop_cantundo, NULL))) { - new->data = (gpointer) action; - return TRUE; } @@ -3107,12 +2967,10 @@ undo_pop_cantundo (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { - gchar *action = undo->data; - switch (undo_mode) { case GIMP_UNDO_MODE_UNDO: - g_message (_("Can't undo %s"), action); + g_message (_("Can't undo %s"), GIMP_OBJECT (undo)->name); break; case GIMP_UNDO_MODE_REDO: diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h index ce3da3d1f5..4edb23bb37 100644 --- a/app/core/gimpimage-undo-push.h +++ b/app/core/gimpimage-undo-push.h @@ -16,146 +16,163 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __UNDO_H__ -#define __UNDO_H__ +#ifndef __GIMP_IMAGE_UNDO_PUSH_H__ +#define __GIMP_IMAGE_UNDO_PUSH_H__ /* 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_type (GimpImage *gimage); -gboolean undo_push_image_size (GimpImage *gimage); -gboolean undo_push_image_resolution (GimpImage *gimage); -gboolean undo_push_image_qmask (GimpImage *gimage); -gboolean undo_push_image_guide (GimpImage *gimage, - GimpGuide *guide); +gboolean gimp_image_undo_push_image (GimpImage *gimage, + const gchar *undo_desc, + GimpDrawable *drawable, + gint x1, + gint y1, + gint x2, + gint y2); +gboolean gimp_image_undo_push_image_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpDrawable *drawable, + gint x1, + gint y1, + gint x2, + gint y2, + TileManager *tiles, + gboolean sparse); +gboolean gimp_image_undo_push_image_type (GimpImage *gimage, + const gchar *undo_desc); +gboolean gimp_image_undo_push_image_size (GimpImage *gimage, + const gchar *undo_desc); +gboolean gimp_image_undo_push_image_resolution (GimpImage *gimage, + const gchar *undo_desc); +gboolean gimp_image_undo_push_image_qmask (GimpImage *gimage, + const gchar *undo_desc); +gboolean gimp_image_undo_push_image_guide (GimpImage *gimage, + const gchar *undo_desc, + GimpGuide *guide); /* mask undo */ -gboolean undo_push_mask (GimpImage *gimage, - GimpChannel *mask); +gboolean gimp_image_undo_push_mask (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *mask); /* item undos */ -gboolean undo_push_item_rename (GimpImage *gimage, - GimpItem *item); +gboolean gimp_image_undo_push_item_rename (GimpImage *gimage, + const gchar *undo_desc, + GimpItem *item); /* 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_reposition (GimpImage *gimage, - GimpLayer *layer); -gboolean undo_push_layer_displace (GimpImage *gimage, - GimpLayer *layer); +gboolean gimp_image_undo_push_layer_add (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + gint prev_position, + GimpLayer *prev_layer); +gboolean gimp_image_undo_push_layer_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + gint prev_position, + GimpLayer *prev_layer); +gboolean gimp_image_undo_push_layer_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer); +gboolean gimp_image_undo_push_layer_mask_add (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + GimpLayerMask *mask); +gboolean gimp_image_undo_push_layer_mask_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + GimpLayerMask *mask); +gboolean gimp_image_undo_push_layer_reposition (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer); +gboolean gimp_image_undo_push_layer_displace (GimpImage *gimage, + const gchar *undo_desc, + 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); +gboolean gimp_image_undo_push_channel_add (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel, + gint prev_position, + GimpChannel *prev_channel); +gboolean gimp_image_undo_push_channel_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel, + gint prev_position, + GimpChannel *prev_channel); +gboolean gimp_image_undo_push_channel_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel); +gboolean gimp_image_undo_push_channel_reposition (GimpImage *gimage, + const gchar *undo_desc, + GimpChannel *channel); /* vectors undos */ -gboolean undo_push_vectors_add (GimpImage *gimage, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors); -gboolean undo_push_vectors_remove (GimpImage *gimage, - GimpVectors *channel, - gint prev_position, - GimpVectors *prev_vectors); -gboolean undo_push_vectors_mod (GimpImage *gimage, - GimpVectors *vectors); -gboolean undo_push_vectors_reposition (GimpImage *gimage, - GimpVectors *vectors); +gboolean gimp_image_undo_push_vectors_add (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors, + gint prev_position, + GimpVectors *prev_vectors); +gboolean gimp_image_undo_push_vectors_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *channel, + gint prev_position, + GimpVectors *prev_vectors); +gboolean gimp_image_undo_push_vectors_mod (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors); +gboolean gimp_image_undo_push_vectors_reposition (GimpImage *gimage, + const gchar *undo_desc, + GimpVectors *vectors); /* 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); +gboolean gimp_image_undo_push_fs_to_layer (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *floating_layer, + GimpDrawable *drawable); +gboolean gimp_image_undo_push_fs_rigor (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *floating_layer); +gboolean gimp_image_undo_push_fs_relax (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *floating_layer); /* parasite undos */ -gboolean undo_push_image_parasite (GimpImage *gimage, - gpointer parasite); -gboolean undo_push_image_parasite_remove (GimpImage *gimage, - const gchar *name); +gboolean gimp_image_undo_push_image_parasite (GimpImage *gimage, + const gchar *undo_desc, + gpointer parasite); +gboolean gimp_image_undo_push_image_parasite_remove (GimpImage *gimage, + const gchar *undo_desc, + const gchar *name); -gboolean undo_push_item_parasite (GimpImage *gimage, - GimpItem *item, - gpointer parasite); -gboolean undo_push_item_parasite_remove (GimpImage *gimage, - GimpItem *item, - const gchar *name); +gboolean gimp_image_undo_push_item_parasite (GimpImage *gimage, + const gchar *undo_desc, + GimpItem *item, + gpointer parasite); +gboolean gimp_image_undo_push_item_parasite_remove (GimpImage *gimage, + const gchar *undo_desc, + GimpItem *item, + const gchar *name); /* EEK undo */ -gboolean undo_push_cantundo (GimpImage *gimage, - const gchar *action); +gboolean gimp_image_undo_push_cantundo (GimpImage *gimage, + const gchar *undo_desc); -#endif /* __UNDO_H__ */ +#endif /* __GIMP_IMAGE_UNDO_PUSH_H__ */ diff --git a/app/core/gimpimage-undo.c b/app/core/gimpimage-undo.c index c006772ee0..447b7b5460 100644 --- a/app/core/gimpimage-undo.c +++ b/app/core/gimpimage-undo.c @@ -308,7 +308,13 @@ gimp_image_undo_free_space (GimpImage *gimage) max_undo_levels = 1024; /* FIXME */ undo_size = gimage->gimp->config->undo_size; - /* keep at least undo_levels undo steps */ +#if 0 + g_print ("undo_steps: %d undo_bytes: %d\n", + gimp_container_num_children (container), + gimp_object_get_memsize (GIMP_OBJECT (container))); +#endif + + /* keep at least min_undo_levels undo steps */ if (gimp_container_num_children (container) <= min_undo_levels) return; @@ -317,6 +323,12 @@ gimp_image_undo_free_space (GimpImage *gimage) { gimp_undo_stack_free_bottom (gimage->undo_stack, GIMP_UNDO_MODE_UNDO); +#if 0 + g_print ("freed one step: undo_steps: %d undo_bytes: %d\n", + gimp_container_num_children (container), + gimp_object_get_memsize (GIMP_OBJECT (container))); +#endif + gimp_image_undo_event (gimage, UNDO_EXPIRED); if (gimp_container_num_children (container) <= min_undo_levels) diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 84882ae0a2..b0bbedf288 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -44,6 +44,7 @@ #include "gimpimage-mask.h" #include "gimpimage-projection.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplayermask.h" @@ -57,7 +58,6 @@ #include "vectors/gimpvectors.h" #include "path.h" -#include "undo.h" #include "libgimp/gimpintl.h" @@ -1124,7 +1124,8 @@ gimp_image_set_resolution (GimpImage *gimage, if ((ABS (gimage->xresolution - xresolution) >= 1e-5) || (ABS (gimage->yresolution - yresolution) >= 1e-5)) { - undo_push_image_resolution (gimage); + gimp_image_undo_push_image_resolution (gimage, + _("Change Image Reolution")); gimage->xresolution = xresolution; gimage->yresolution = yresolution; @@ -1162,7 +1163,8 @@ gimp_image_set_unit (GimpImage *gimage, if (gimage->unit != unit) { - undo_push_image_resolution (gimage); + gimp_image_undo_push_image_resolution (gimage, + _("Change Image Unit")); gimage->unit = unit; @@ -1840,6 +1842,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *src2PR, gboolean push_undo, + const gchar *undo_desc, gdouble opacity, GimpLayerModeEffects mode, /* alternative to using drawable tiles as src1: */ @@ -1897,7 +1900,7 @@ gimp_image_apply_image (GimpImage *gimage, /* If the calling procedure specified an undo step... */ if (push_undo) - gimp_drawable_push_undo (drawable, x1, y1, x2, y2, NULL, FALSE); + gimp_drawable_push_undo (drawable, undo_desc, x1, y1, x2, y2, NULL, FALSE); /* configure the pixel regions * If an alternative to using the drawable's data as src1 was provided... @@ -1958,6 +1961,7 @@ gimp_image_replace_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *src2PR, gboolean push_undo, + const gchar *undo_desc, gdouble opacity, PixelRegion *maskPR, gint x, @@ -2014,7 +2018,7 @@ gimp_image_replace_image (GimpImage *gimage, /* If the calling procedure specified an undo step... */ if (push_undo) - gimp_drawable_push_undo (drawable, x1, y1, x2, y2, NULL, FALSE); + gimp_drawable_push_undo (drawable, undo_desc, x1, y1, x2, y2, NULL, FALSE); /* configure the pixel regions * If an alternative to using the drawable's data as src1 was provided... @@ -2132,7 +2136,9 @@ gimp_image_parasite_attach (GimpImage *gimage, /* only set the dirty bit manually if we can be saved and the new parasite differs from the current one and we aren't undoable */ if (gimp_parasite_is_undoable (parasite)) - undo_push_image_parasite (gimage, parasite); + gimp_image_undo_push_image_parasite (gimage, + _("Attach Paraite to Image"), + parasite); /* We used to push an cantundo on te stack here. This made the undo stack unusable (NULL on the stack) and prevented people from undoing after a @@ -2163,7 +2169,9 @@ gimp_image_parasite_detach (GimpImage *gimage, return; if (gimp_parasite_is_undoable (p)) - undo_push_image_parasite_remove (gimage, gimp_parasite_name (p)); + gimp_image_undo_push_image_parasite_remove (gimage, + _("Remove Parasite from Image"), + gimp_parasite_name (p)); gimp_parasite_list_remove (gimage->parasites, parasite); } @@ -2674,10 +2682,11 @@ gimp_image_add_layer (GimpImage *gimage, return FALSE; } - undo_push_layer_add (gimage, - layer, - 0, - gimp_image_get_active_layer (gimage)); + gimp_image_undo_push_layer_add (gimage, + _("Add Layer to Image"), + 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)) @@ -2751,14 +2760,14 @@ gimp_image_remove_layer (GimpImage *gimage, g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (GIMP_IS_LAYER (layer)); - g_return_if_fail (gimp_container_have (gimage->layers, - GIMP_OBJECT (layer))); + g_return_if_fail (gimp_container_have (gimage->layers, GIMP_OBJECT (layer))); - undo_push_layer_remove (gimage, - layer, - gimp_container_get_child_index (gimage->layers, - GIMP_OBJECT (layer)), - layer); + gimp_image_undo_push_layer_remove (gimage, + _("Remove Layer from Image"), + layer, + gimp_container_get_child_index (gimage->layers, + GIMP_OBJECT (layer)), + layer); g_object_ref (layer); @@ -2951,7 +2960,9 @@ gimp_image_position_layer (GimpImage *gimage, } if (push_undo) - undo_push_layer_reposition (gimage, layer); + gimp_image_undo_push_layer_reposition (gimage, + _("Reorder Layer"), + layer); gimp_container_reorder (gimage->layers, GIMP_OBJECT (layer), new_index); @@ -2990,10 +3001,11 @@ gimp_image_add_channel (GimpImage *gimage, return FALSE; } - undo_push_channel_add (gimage, - channel, - 0, - gimp_image_get_active_channel (gimage)); + gimp_image_undo_push_channel_add (gimage, + _("Add Channel to Image"), + channel, + 0, + gimp_image_get_active_channel (gimage)); /* add the layer to the list at the specified position */ if (position == -1) @@ -3039,11 +3051,12 @@ gimp_image_remove_channel (GimpImage *gimage, g_return_if_fail (gimp_container_have (gimage->channels, GIMP_OBJECT (channel))); - undo_push_channel_remove (gimage, - channel, - gimp_container_get_child_index (gimage->channels, - GIMP_OBJECT (channel)), - gimp_image_get_active_channel (gimage)); + gimp_image_undo_push_channel_remove (gimage, + _("Remove Layer from Image"), + channel, + gimp_container_get_child_index (gimage->channels, + GIMP_OBJECT (channel)), + gimp_image_get_active_channel (gimage)); g_object_ref (channel); @@ -3139,7 +3152,9 @@ gimp_image_position_channel (GimpImage *gimage, return TRUE; if (push_undo) - undo_push_channel_reposition (gimage, channel); + gimp_image_undo_push_channel_reposition (gimage, + _("Reorder Channel"), + channel); gimp_container_reorder (gimage->channels, GIMP_OBJECT (channel), new_index); @@ -3175,10 +3190,11 @@ gimp_image_add_vectors (GimpImage *gimage, return FALSE; } - undo_push_vectors_add (gimage, - vectors, - 0, - gimp_image_get_active_vectors (gimage)); + gimp_image_undo_push_vectors_add (gimage, + _("Add Path to Image"), + vectors, + 0, + gimp_image_get_active_vectors (gimage)); gimp_item_set_image (GIMP_ITEM (vectors), gimage); @@ -3219,11 +3235,12 @@ gimp_image_remove_vectors (GimpImage *gimage, g_return_if_fail (gimp_container_have (gimage->vectors, GIMP_OBJECT (vectors))); - undo_push_vectors_remove (gimage, - vectors, - gimp_container_get_child_index (gimage->vectors, - GIMP_OBJECT (vectors)), - gimp_image_get_active_vectors (gimage)); + gimp_image_undo_push_vectors_remove (gimage, + _("Remove Path from Image"), + vectors, + gimp_container_get_child_index (gimage->vectors, + GIMP_OBJECT (vectors)), + gimp_image_get_active_vectors (gimage)); g_object_ref (vectors); @@ -3319,7 +3336,9 @@ gimp_image_position_vectors (GimpImage *gimage, return TRUE; if (push_undo) - undo_push_vectors_reposition (gimage, vectors); + gimp_image_undo_push_vectors_reposition (gimage, + _("Reorder Path"), + vectors); gimp_container_reorder (gimage->vectors, GIMP_OBJECT (vectors), new_index); diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 6e18b5fb8f..6f3e430d4c 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -344,6 +344,7 @@ void gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *src2PR, gboolean push_undo, + const gchar *undo_desc, gdouble opacity, GimpLayerModeEffects mode, TileManager *src1_tiles, @@ -353,6 +354,7 @@ void gimp_image_replace_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *src2PR, gboolean push_undo, + const gchar *undo_desc, gdouble opacity, PixelRegion *maskPR, gint x, diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c index 09d806d271..9b292c049e 100644 --- a/app/core/gimpimagemap.c +++ b/app/core/gimpimagemap.c @@ -47,6 +47,8 @@ struct _GimpImageMap gboolean interactive; GimpDrawable *drawable; + gchar *undo_desc; + TileManager *undo_tiles; gint undo_offset_x; gint undo_offset_y; @@ -62,6 +64,8 @@ struct _GimpImageMap static void gimp_image_map_class_init (GimpImageMapClass *klass); static void gimp_image_map_init (GimpImageMap *image_map); +static void gimp_image_map_finalize (GObject *object); + static gboolean gimp_image_map_do (GimpImageMap *image_map); @@ -101,6 +105,10 @@ gimp_image_map_get_type (void) static void gimp_image_map_class_init (GimpImageMapClass *klass) { + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + parent_class = g_type_class_peek_parent (klass); image_map_signals[FLUSH] = @@ -111,6 +119,8 @@ gimp_image_map_class_init (GimpImageMapClass *klass) NULL, NULL, gimp_marshal_VOID__VOID, G_TYPE_NONE, 0); + + object_class->finalize = gimp_image_map_finalize; } static void @@ -126,9 +136,26 @@ gimp_image_map_init (GimpImageMap *image_map) image_map->idle_id = 0; } +static void +gimp_image_map_finalize (GObject *object) +{ + GimpImageMap *image_map; + + image_map = GIMP_IMAGE_MAP (object); + + if (image_map->undo_desc) + { + g_free (image_map->undo_desc); + image_map->undo_desc = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + GimpImageMap * gimp_image_map_new (gboolean interactive, - GimpDrawable *drawable) + GimpDrawable *drawable, + const gchar *undo_desc) { GimpImageMap *image_map; GimpImage *gimage; @@ -143,6 +170,7 @@ gimp_image_map_new (gboolean interactive, image_map->interactive = interactive ? TRUE : FALSE; image_map->drawable = drawable; + image_map->undo_desc = g_strdup (undo_desc); /* Interactive tools based on image_map disable the undo stack * to avert any unintented undo interaction through the UI @@ -298,6 +326,7 @@ gimp_image_map_commit (GimpImageMap *image_map) y2 = y1 + tile_manager_height (image_map->undo_tiles); gimp_drawable_push_undo (image_map->drawable, + image_map->undo_desc, x1, y1, x2, y2, image_map->undo_tiles, FALSE); } @@ -480,7 +509,8 @@ gimp_image_map_do (GimpImageMap *image_map) /* apply the results */ pixel_region_init (&shadowPR, gimage->shadow, x, y, w, h, FALSE); - gimp_image_apply_image (gimage, image_map->drawable, &shadowPR, FALSE, + gimp_image_apply_image (gimage, image_map->drawable, &shadowPR, + FALSE, NULL, GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE, NULL, x, y); diff --git a/app/core/gimpimagemap.h b/app/core/gimpimagemap.h index 76c74bdd08..692e0e8f26 100644 --- a/app/core/gimpimagemap.h +++ b/app/core/gimpimagemap.h @@ -56,7 +56,8 @@ struct _GimpImageMapClass GType gimp_image_map_get_type (void) G_GNUC_CONST; GimpImageMap * gimp_image_map_new (gboolean interactive, - GimpDrawable *drawable); + GimpDrawable *drawable, + const gchar *undo_desc); void gimp_image_map_apply (GimpImageMap *image_map, GimpImageMapApplyFunc apply_func, diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c index 93d0450c06..70a1a0d561 100644 --- a/app/core/gimpitem.c +++ b/app/core/gimpitem.c @@ -33,6 +33,7 @@ #include "gimpchannel.h" #include "gimpimage.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimpitem.h" #include "gimplayer.h" #include "gimplist.h" @@ -41,8 +42,6 @@ #include "vectors/gimpvectors.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -450,14 +449,15 @@ gimp_item_parasite_attach (GimpItem *item, gimp_image_undo_group_start (item->gimage, GIMP_UNDO_GROUP_PARASITE_ATTACH, _("Attach Parasite")); - undo_push_item_parasite (item->gimage, item, parasite); + gimp_image_undo_push_item_parasite (item->gimage, NULL, item, parasite); } else if (gimp_parasite_is_persistent (parasite) && ! gimp_parasite_compare (parasite, gimp_item_parasite_find (item, gimp_parasite_name (parasite)))) { - undo_push_cantundo (item->gimage, _("parasite attached to item")); + gimp_image_undo_push_cantundo (item->gimage, + _("Attach Parasite to Item")); } gimp_parasite_list_add (item->parasites, parasite); @@ -495,12 +495,15 @@ gimp_item_parasite_detach (GimpItem *item, if (gimp_parasite_is_undoable (parasite)) { - undo_push_item_parasite_remove (item->gimage, item, - gimp_parasite_name (parasite)); + gimp_image_undo_push_item_parasite_remove (item->gimage, + _("Remove Parasite from Item"), + item, + gimp_parasite_name (parasite)); } else if (gimp_parasite_is_persistent (parasite)) { - undo_push_cantundo (item->gimage, _("parasite detached from item")); + gimp_image_undo_push_cantundo (item->gimage, + _("Remove Parasite from Item")); } gimp_parasite_list_remove (item->parasites, name); diff --git a/app/core/gimplayer-floating-sel.c b/app/core/gimplayer-floating-sel.c index 5c948d1512..18e6dd0e15 100644 --- a/app/core/gimplayer-floating-sel.c +++ b/app/core/gimplayer-floating-sel.c @@ -33,12 +33,11 @@ #include "gimpimage.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplayermask.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -215,9 +214,10 @@ floating_sel_to_layer (GimpLayer *layer) width = gimp_drawable_width (layer->fs.drawable); height = gimp_drawable_height (layer->fs.drawable); - undo_push_fs_to_layer (gimage, - layer, - layer->fs.drawable); + gimp_image_undo_push_fs_to_layer (gimage, + _("Floating Selection to Layer"), + layer, + layer->fs.drawable); /* clear the selection */ gimp_layer_invalidate_boundary (layer); @@ -340,10 +340,8 @@ floating_sel_restore (GimpLayer *layer, void floating_sel_rigor (GimpLayer *layer, - gboolean undo) + gboolean push_undo) { - GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer)); - /* store the affected area from the drawable in the backing store */ floating_sel_store (layer, GIMP_DRAWABLE (layer)->offset_x, @@ -352,16 +350,16 @@ floating_sel_rigor (GimpLayer *layer, GIMP_DRAWABLE (layer)->height); layer->fs.initial = TRUE; - if (undo) - undo_push_fs_rigor (gimage, GIMP_ITEM (layer)->ID); + if (push_undo) + gimp_image_undo_push_fs_rigor (gimp_item_get_image (GIMP_ITEM (layer)), + NULL, + layer); } void floating_sel_relax (GimpLayer *layer, - gboolean undo) + gboolean push_undo) { - GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer)); - /* restore the contents of drawable the floating layer is attached to */ if (layer->fs.initial == FALSE) floating_sel_restore (layer, @@ -371,8 +369,10 @@ floating_sel_relax (GimpLayer *layer, GIMP_DRAWABLE (layer)->height); layer->fs.initial = TRUE; - if (undo) - undo_push_fs_relax (gimage, GIMP_ITEM (layer)->ID); + if (push_undo) + gimp_image_undo_push_fs_relax (gimp_item_get_image (GIMP_ITEM (layer)), + NULL, + layer); } void @@ -381,7 +381,7 @@ floating_sel_composite (GimpLayer *layer, gint y, gint w, gint h, - gboolean undo) + gboolean push_undo) { PixelRegion fsPR; GimpImage *gimage; @@ -466,7 +466,8 @@ floating_sel_composite (GimpLayer *layer, /* apply the fs with the undo specified by the value * passed to this function */ - gimp_image_apply_image (gimage, layer->fs.drawable, &fsPR, undo, + gimp_image_apply_image (gimage, layer->fs.drawable, &fsPR, + push_undo, NULL, layer->opacity, layer->mode, NULL, diff --git a/app/core/gimplayer-floating-sel.h b/app/core/gimplayer-floating-sel.h index f4e4e547fa..1d9439400f 100644 --- a/app/core/gimplayer-floating-sel.h +++ b/app/core/gimplayer-floating-sel.h @@ -37,15 +37,15 @@ void floating_sel_restore (GimpLayer *layer, gint w, gint h); void floating_sel_rigor (GimpLayer *layer, - gboolean undo); + gboolean push_undo); void floating_sel_relax (GimpLayer *layer, - gboolean undo); + gboolean push_undo); void floating_sel_composite (GimpLayer *layer, gint x, gint y, gint w, gint h, - gboolean undo); + gboolean push_undo); BoundSeg * floating_sel_boundary (GimpLayer *layer, gint *n_segs); void floating_sel_invalidate (GimpLayer *layer); diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 1c8f1731f3..5b79da8747 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -39,14 +39,13 @@ #include "gimpimage.h" #include "gimpimage-convert.h" #include "gimpimage-undo.h" +#include "gimpimage-undo-push.h" #include "gimplayer.h" #include "gimplayer-floating-sel.h" #include "gimplayermask.h" #include "gimpmarshal.h" #include "gimpparasitelist.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -608,7 +607,8 @@ gimp_layer_add_mask (GimpLayer *layer, GIMP_DRAWABLE (layer)->height); if (push_undo) - undo_push_layer_mask_add (gimage, layer, mask); + gimp_image_undo_push_layer_mask_add (gimage, _("Add Mask to Layer"), + layer, mask); g_signal_emit (layer, layer_signals[MASK_CHANGED], 0); @@ -791,7 +791,7 @@ gimp_layer_apply_mask (GimpLayer *layer, gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_APPLY_MASK, _("Apply Layer Mask")); - undo_push_layer_mask_remove (gimage, layer, layer->mask); + gimp_image_undo_push_layer_mask_remove (gimage, NULL, layer, layer->mask); } /* check if applying the mask changes the projection */ @@ -807,7 +807,7 @@ gimp_layer_apply_mask (GimpLayer *layer, if (mode == GIMP_MASK_APPLY) { if (push_undo) - gimp_drawable_push_undo (GIMP_DRAWABLE (layer), + gimp_drawable_push_undo (GIMP_DRAWABLE (layer), NULL, 0, 0, GIMP_DRAWABLE (layer)->width, GIMP_DRAWABLE (layer)->height, @@ -833,9 +833,7 @@ gimp_layer_apply_mask (GimpLayer *layer, layer->mask = NULL; if (push_undo) - { - gimp_image_undo_group_end (gimage); - } + gimp_image_undo_group_end (gimage); /* If applying actually changed the view */ if (view_changed) @@ -861,7 +859,9 @@ gimp_layer_translate (GimpLayer *layer, g_return_if_fail (GIMP_IS_LAYER (layer)); /* the undo call goes here */ - undo_push_layer_displace (gimp_item_get_image (GIMP_ITEM (layer)), layer); + gimp_image_undo_push_layer_displace (gimp_item_get_image (GIMP_ITEM (layer)), + _("Move Layer"), + layer); /* update the affected region */ gimp_drawable_update (GIMP_DRAWABLE (layer), @@ -928,7 +928,8 @@ gimp_layer_add_alpha (GimpLayer *layer) add_alpha_region (&srcPR, &destPR); /* Push the layer on the undo stack */ - undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)), layer); + gimp_image_undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)), + _("Add Alpha Channel"), layer); /* Configure the new layer */ GIMP_DRAWABLE (layer)->tiles = new_tiles; @@ -992,7 +993,9 @@ gimp_layer_scale_lowlevel (GimpLayer *layer, } /* Push the layer on the undo stack */ - undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)), layer); + gimp_image_undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)), + _("Scale Layer"), + layer); /* Configure the new layer */ @@ -1283,7 +1286,9 @@ gimp_layer_resize (GimpLayer *layer, copy_region (&srcPR, &destPR); /* Push the layer on the undo stack */ - undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)), layer); + gimp_image_undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)), + _("Resize Layer"), + layer); /* Configure the new layer */ GIMP_DRAWABLE (layer)->tiles = new_tiles; diff --git a/app/core/gimplayermask.c b/app/core/gimplayermask.c index 8f8bb746a0..f0fe0b7305 100644 --- a/app/core/gimplayermask.c +++ b/app/core/gimplayermask.c @@ -31,8 +31,6 @@ #include "gimplayermask.h" #include "gimpmarshal.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/core/gimppaintinfo.c b/app/core/gimppaintinfo.c index c44a6acbbd..529ee68d8c 100644 --- a/app/core/gimppaintinfo.c +++ b/app/core/gimppaintinfo.c @@ -80,6 +80,7 @@ gimp_paint_info_init (GimpPaintInfo *paint_info) { paint_info->gimp = NULL; paint_info->paint_type = G_TYPE_NONE; + paint_info->blurb = NULL; paint_info->pdb_string = NULL; paint_info->paint_options = NULL; } @@ -91,6 +92,12 @@ gimp_paint_info_finalize (GObject *object) paint_info = GIMP_PAINT_INFO (object); + if (paint_info->blurb) + { + g_free (paint_info->blurb); + paint_info->blurb = NULL; + } + if (paint_info->pdb_string) { g_free (paint_info->pdb_string); @@ -104,11 +111,13 @@ GimpPaintInfo * gimp_paint_info_new (Gimp *gimp, GType paint_type, GType paint_options_type, + const gchar *blurb, const gchar *pdb_string) { GimpPaintInfo *paint_info; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (blurb != NULL, NULL); g_return_val_if_fail (pdb_string != NULL, NULL); paint_info = g_object_new (GIMP_TYPE_PAINT_INFO, @@ -118,6 +127,7 @@ gimp_paint_info_new (Gimp *gimp, paint_info->gimp = gimp; paint_info->paint_type = paint_type; paint_info->paint_options_type = paint_options_type; + paint_info->blurb = g_strdup (blurb); paint_info->pdb_string = g_strdup (pdb_string); return paint_info; diff --git a/app/core/gimppaintinfo.h b/app/core/gimppaintinfo.h index 4e4bfe4cd7..2f152aee1e 100644 --- a/app/core/gimppaintinfo.h +++ b/app/core/gimppaintinfo.h @@ -42,6 +42,7 @@ struct _GimpPaintInfo GType paint_type; GType paint_options_type; + gchar *blurb; gchar *pdb_string; GimpPaintOptions *paint_options; @@ -58,6 +59,7 @@ GType gimp_paint_info_get_type (void) G_GNUC_CONST; GimpPaintInfo * gimp_paint_info_new (Gimp *gimp, GType paint_type, GType paint_options_type, + const gchar *blurb, const gchar *pdb_string); diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c index 8a6e85af8c..75b00015ee 100644 --- a/app/dialogs/file-open-dialog.c +++ b/app/dialogs/file-open-dialog.c @@ -61,8 +61,6 @@ #include "file-dialog-utils.h" #include "file-open-dialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c index d419f88087..27c25ed9b8 100644 --- a/app/display/gimpdisplayshell-dnd.c +++ b/app/display/gimpdisplayshell-dnd.c @@ -39,8 +39,6 @@ #include "gimpdisplayshell.h" #include "gimpdisplayshell-dnd.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/file/file-open.c b/app/file/file-open.c index fd22033f3b..fbcc5fa805 100644 --- a/app/file/file-open.c +++ b/app/file/file-open.c @@ -53,8 +53,6 @@ #include "file-open.h" #include "file-utils.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/file/file-save.c b/app/file/file-save.c index 1ba43a378b..1472d6d85e 100644 --- a/app/file/file-save.c +++ b/app/file/file-save.c @@ -56,8 +56,6 @@ #include "file-save.h" #include "file-utils.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/gui/channels-commands.c b/app/gui/channels-commands.c index 5dd1d30c01..f803efa7bc 100644 --- a/app/gui/channels-commands.c +++ b/app/gui/channels-commands.c @@ -33,6 +33,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimpimage-mask-select.h" #include "widgets/gimpcolorpanel.h" @@ -43,8 +44,6 @@ #include "channels-commands.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -150,6 +149,7 @@ channels_channel_to_sel (GtkWidget *widget, return_if_no_channel (gimage, active_channel, data); gimp_image_mask_select_channel (gimage, + _("Channel to Selection"), active_channel, 0, 0, op, @@ -425,7 +425,9 @@ edit_channel_query_ok_callback (GtkWidget *widget, if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (channel)))) { - undo_push_item_rename (options->gimage, GIMP_ITEM (channel)); + gimp_image_undo_push_item_rename (options->gimage, + _("Rename Channel"), + GIMP_ITEM (channel)); gimp_object_set_name (GIMP_OBJECT (channel), new_name); } diff --git a/app/gui/file-commands.c b/app/gui/file-commands.c index 32b87628ae..3427e6094f 100644 --- a/app/gui/file-commands.c +++ b/app/gui/file-commands.c @@ -47,8 +47,6 @@ #include "file-save-dialog.h" #include "menus.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/gui/file-open-dialog.c b/app/gui/file-open-dialog.c index 8a6e85af8c..75b00015ee 100644 --- a/app/gui/file-open-dialog.c +++ b/app/gui/file-open-dialog.c @@ -61,8 +61,6 @@ #include "file-dialog-utils.h" #include "file-open-dialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/gui/image-commands.c b/app/gui/image-commands.c index 16ceb02a5b..f87e7f00ee 100644 --- a/app/gui/image-commands.c +++ b/app/gui/image-commands.c @@ -45,8 +45,6 @@ #include "image-commands.h" #include "resize-dialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/gui/layers-commands.c b/app/gui/layers-commands.c index df03b0eade..fbd97bd42f 100644 --- a/app/gui/layers-commands.c +++ b/app/gui/layers-commands.c @@ -34,6 +34,7 @@ #include "core/gimpimage-mask.h" #include "core/gimpimage-merge.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimplayer.h" #include "core/gimplayer-floating-sel.h" #include "core/gimplayermask.h" @@ -50,8 +51,6 @@ #include "layers-commands.h" #include "resize-dialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -768,7 +767,9 @@ edit_layer_query_ok_callback (GtkWidget *widget, floating_sel_to_layer (layer); } - undo_push_item_rename (options->gimage, GIMP_ITEM (layer)); + gimp_image_undo_push_item_rename (options->gimage, + _("Rename Layer"), + GIMP_ITEM (layer)); gimp_object_set_name (GIMP_OBJECT (layer), new_name); diff --git a/app/gui/paths-dialog.c b/app/gui/paths-dialog.c index 45879a8d95..39ef7bbc31 100644 --- a/app/gui/paths-dialog.c +++ b/app/gui/paths-dialog.c @@ -63,7 +63,6 @@ #include "path.h" #include "pathP.h" #include "path_transform.h" -#include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/select-commands.c b/app/gui/select-commands.c index 9a55fde41a..42eb597cb2 100644 --- a/app/gui/select-commands.c +++ b/app/gui/select-commands.c @@ -116,7 +116,7 @@ select_none_cmd_callback (GtkWidget *widget, GimpImage *gimage; return_if_no_image (gimage, data); - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); gimp_image_flush (gimage); } diff --git a/app/gui/vectors-commands.c b/app/gui/vectors-commands.c index 4b9b193cc5..3b7d28d0de 100644 --- a/app/gui/vectors-commands.c +++ b/app/gui/vectors-commands.c @@ -32,6 +32,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" +#include "core/gimpimage-undo-push.h" #include "core/gimplist.h" #include "core/gimppaintinfo.h" #include "core/gimptoolinfo.h" @@ -52,8 +53,6 @@ #include "vectors-commands.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -533,7 +532,9 @@ edit_vectors_query_ok_callback (GtkWidget *widget, if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors)))) { - undo_push_item_rename (options->gimage, GIMP_ITEM (vectors)); + gimp_image_undo_push_item_rename (options->gimage, + _("Rename Path"), + GIMP_ITEM (vectors)); gimp_object_set_name (GIMP_OBJECT (vectors), new_name); } diff --git a/app/paint/Makefile.am b/app/paint/Makefile.am index 3619d33a63..2d2682b637 100644 --- a/app/paint/Makefile.am +++ b/app/paint/Makefile.am @@ -45,6 +45,8 @@ libapppaint_a_sources = \ gimppaintcore-kernels.h \ gimppaintcore-stroke.c \ gimppaintcore-stroke.h \ + gimppaintcore-undo.c \ + gimppaintcore-undo.h \ gimppaintoptions.c \ gimppaintoptions.h \ gimppencil.c \ diff --git a/app/paint/gimpairbrush.c b/app/paint/gimpairbrush.c index 78e1b38c95..532f3bfbdd 100644 --- a/app/paint/gimpairbrush.c +++ b/app/paint/gimpairbrush.c @@ -37,6 +37,8 @@ #include "gimpairbrush.h" #include "gimpairbrushoptions.h" +#include "libgimp/gimpintl.h" + typedef struct _AirbrushTimeout AirbrushTimeout; @@ -74,7 +76,10 @@ void gimp_airbrush_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_AIRBRUSH, GIMP_TYPE_AIRBRUSH_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_AIRBRUSH, + GIMP_TYPE_AIRBRUSH_OPTIONS, + _("Airbrush")); } GType diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index df70bcc63d..6c262a62ae 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -83,7 +83,10 @@ void gimp_clone_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_CLONE, GIMP_TYPE_CLONE_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_CLONE, + GIMP_TYPE_CLONE_OPTIONS, + _("Clone")); } GType diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c index 7929948922..7bfb068d4e 100644 --- a/app/paint/gimpconvolve.c +++ b/app/paint/gimpconvolve.c @@ -35,6 +35,8 @@ #include "gimpconvolve.h" #include "gimpconvolveoptions.h" +#include "libgimp/gimpintl.h" + #define FIELD_COLS 4 #define MIN_BLUR 64 /* (8/9 original pixel) */ @@ -114,7 +116,10 @@ void gimp_convolve_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_CONVOLVE, GIMP_TYPE_CONVOLVE_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_CONVOLVE, + GIMP_TYPE_CONVOLVE_OPTIONS, + _("Convolve")); } GType diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c index 98aa4b86f2..70ea7f3325 100644 --- a/app/paint/gimpdodgeburn.c +++ b/app/paint/gimpdodgeburn.c @@ -37,6 +37,8 @@ #include "gimpdodgeburn.h" #include "gimpdodgeburnoptions.h" +#include "libgimp/gimpintl.h" + static void gimp_dodge_burn_class_init (GimpDodgeBurnClass *klass); static void gimp_dodge_burn_init (GimpDodgeBurn *dodgeburn); @@ -78,7 +80,10 @@ void gimp_dodge_burn_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_DODGE_BURN, GIMP_TYPE_DODGE_BURN_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_DODGE_BURN, + GIMP_TYPE_DODGE_BURN_OPTIONS, + _("Dodge/Burn")); } GType diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index 53a69b876a..e324f3ca56 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -35,6 +35,8 @@ #include "gimperaser.h" #include "gimperaseroptions.h" +#include "libgimp/gimpintl.h" + static void gimp_eraser_class_init (GimpEraserClass *klass); static void gimp_eraser_init (GimpEraser *eraser); @@ -56,7 +58,10 @@ void gimp_eraser_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_ERASER, GIMP_TYPE_ERASER_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_ERASER, + GIMP_TYPE_ERASER_OPTIONS, + _("Eraser")); } GType diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index cef330b69c..e95f074713 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -38,6 +38,7 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" +#include "core/gimpimage-undo-push.h" #include "core/gimptoolinfo.h" #include "paint/gimppaintoptions.h" @@ -48,8 +49,6 @@ #include "gimpinktool.h" #include "gimpinktool-blob.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -715,7 +714,7 @@ static void ink_finish (GimpInkTool *ink_tool, GimpDrawable *drawable) { - gimp_drawable_push_undo (drawable, + gimp_drawable_push_undo (drawable, _("Ink"), ink_tool->x1, ink_tool->y1, ink_tool->x2, ink_tool->y2, undo_tiles, TRUE); @@ -1025,7 +1024,7 @@ ink_paste (GimpInkTool *ink_tool, /* apply the paint area to the gimage */ gimp_image_apply_image (gimage, drawable, &srcPR, - FALSE, + FALSE, NULL, gimp_context_get_opacity (context), gimp_context_get_paint_mode (context), undo_tiles, /* specify an alternative src1 */ diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c index 92a093ce05..794d884fdb 100644 --- a/app/paint/gimppaintbrush.c +++ b/app/paint/gimppaintbrush.c @@ -39,6 +39,8 @@ #include "gimppaintbrush.h" #include "gimppaintoptions.h" +#include "libgimp/gimpintl.h" + static void gimp_paintbrush_class_init (GimpPaintbrushClass *klass); static void gimp_paintbrush_init (GimpPaintbrush *paintbrush); @@ -59,7 +61,10 @@ void gimp_paintbrush_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_PAINTBRUSH, GIMP_TYPE_PAINT_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_PAINTBRUSH, + GIMP_TYPE_PAINT_OPTIONS, + _("Paintbrush")); } GType diff --git a/app/paint/gimppaintcore-undo.c b/app/paint/gimppaintcore-undo.c new file mode 100644 index 0000000000..2d5aaf43a5 --- /dev/null +++ b/app/paint/gimppaintcore-undo.c @@ -0,0 +1,123 @@ +/* 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 + +#include "paint-types.h" + +#include "core/gimpimage-undo.h" +#include "core/gimpimage.h" +#include "core/gimpundo.h" + +#include "gimppaintcore.h" + +#include "libgimp/gimpintl.h" + + +/****************/ +/* Paint Undo */ +/****************/ + +typedef struct _PaintUndo PaintUndo; + +struct _PaintUndo +{ + GimpPaintCore *core; + GimpCoords last_coords; +}; + +static gboolean undo_pop_paint (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode, + GimpUndoAccumulator *accum); +static void undo_free_paint (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode); + +gboolean +gimp_paint_core_push_undo (GimpImage *gimage, + const gchar *undo_desc, + GimpPaintCore *core) +{ + GimpUndo *new; + + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); + g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE); + + if ((new = gimp_image_undo_push (gimage, + sizeof (PaintUndo), + sizeof (PaintUndo), + GIMP_UNDO_PAINT, undo_desc, + FALSE, + undo_pop_paint, + undo_free_paint))) + { + PaintUndo *pu; + + pu = new->data; + + pu->core = core; + pu->last_coords = core->start_coords; + + g_object_add_weak_pointer (G_OBJECT (core), (gpointer) &pu->core); + + return TRUE; + } + + return FALSE; +} + +static gboolean +undo_pop_paint (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode, + GimpUndoAccumulator *accum) +{ + PaintUndo *pu; + + pu = (PaintUndo *) undo->data; + + /* only pop if the core still exists */ + if (pu->core) + { + GimpCoords tmp_coords; + + tmp_coords = pu->core->last_coords; + pu->core->last_coords = pu->last_coords; + pu->last_coords = tmp_coords; + } + + return TRUE; +} + +static void +undo_free_paint (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode) +{ + PaintUndo *pu; + + pu = (PaintUndo *) undo->data; + + if (pu->core) + g_object_remove_weak_pointer (G_OBJECT (pu->core), (gpointer) &pu->core); + + g_free (pu); +} diff --git a/app/paint/gimppaintcore-undo.h b/app/paint/gimppaintcore-undo.h new file mode 100644 index 0000000000..7a02d4d5eb --- /dev/null +++ b/app/paint/gimppaintcore-undo.h @@ -0,0 +1,28 @@ +/* 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_PAINT_CORE_UNDO_H__ +#define __GIMP_PAINT_CORE_UNDO_H__ + + +gboolean gimp_paint_core_push_undo (GimpImage *gimage, + const gchar *undo_desc, + GimpPaintCore *core); + + +#endif /* __GIMP_PAINT_CORE_UNDO_H__ */ diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c index edf60544cb..67c791f993 100644 --- a/app/paint/gimppaintcore.c +++ b/app/paint/gimppaintcore.c @@ -37,20 +37,22 @@ #include "paint-funcs/paint-funcs.h" +#include "core/gimp.h" #include "core/gimpbrush.h" +#include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-undo.h" #include "core/gimpmarshal.h" +#include "core/gimppaintinfo.h" #include "gimppaintcore.h" #include "gimppaintcore-kernels.h" +#include "gimppaintcore-undo.h" #include "gimppaintoptions.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -142,7 +144,7 @@ static void paint_line_pixmap_mask (GimpImage *dest, static GimpObjectClass *parent_class = NULL; -static gint global_core_ID = 0; +static gint global_core_ID = 1; GType @@ -419,7 +421,8 @@ void gimp_paint_core_finish (GimpPaintCore *core, GimpDrawable *drawable) { - GimpImage *gimage; + GimpPaintInfo *paint_info; + GimpImage *gimage; g_return_if_fail (GIMP_IS_PAINT_CORE (core)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); @@ -431,20 +434,19 @@ gimp_paint_core_finish (GimpPaintCore *core, /* Determine if any part of the image has been altered-- * if nothing has, then just return... */ - - if ((core->x2 == core->x1) || - (core->y2 == core->y1)) + if ((core->x2 == core->x1) || (core->y2 == core->y1)) return; + paint_info = (GimpPaintInfo *) + gimp_container_get_child_by_name (gimage->gimp->paint_info_list, + g_type_name (G_TYPE_FROM_INSTANCE (core))); + gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT, - _("Paint")); + paint_info ? paint_info->blurb : _("Paint")); - undo_push_paint (gimage, - core->ID, - G_TYPE_FROM_INSTANCE (core), - &core->start_coords); + gimp_paint_core_push_undo (gimage, NULL, core); - gimp_drawable_push_undo (drawable, + gimp_drawable_push_undo (drawable, NULL, core->x1, core->y1, core->x2, core->y2, core->undo_tiles, @@ -1452,7 +1454,7 @@ gimp_paint_core_paste (GimpPaintCore *core, /* apply the paint area to the gimage */ gimp_image_apply_image (gimage, drawable, &srcPR, - FALSE, + FALSE, NULL, image_opacity, paint_mode, alt, /* specify an alternative src1 */ core->canvas_buf->x, @@ -1564,7 +1566,7 @@ gimp_paint_core_replace (GimpPaintCore *core, /* apply the paint area to the gimage */ gimp_image_replace_image (gimage, drawable, &srcPR, - FALSE, + FALSE, NULL, image_opacity, &maskPR, core->canvas_buf->x, diff --git a/app/paint/gimppencil.c b/app/paint/gimppencil.c index 7d82f9e5ff..fe623c9391 100644 --- a/app/paint/gimppencil.c +++ b/app/paint/gimppencil.c @@ -37,6 +37,8 @@ #include "gimppaintoptions.h" #include "gimppencil.h" +#include "libgimp/gimpintl.h" + static void gimp_pencil_class_init (GimpPencilClass *klass); static void gimp_pencil_init (GimpPencil *pencil); @@ -58,7 +60,10 @@ void gimp_pencil_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_PENCIL, GIMP_TYPE_PAINT_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_PENCIL, + GIMP_TYPE_PAINT_OPTIONS, + _("Pencil")); } GType diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index 1a7809f8c1..d167e3e8e1 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -37,6 +37,8 @@ #include "gimpsmudge.h" #include "gimpsmudgeoptions.h" +#include "libgimp/gimpintl.h" + static void gimp_smudge_class_init (GimpSmudgeClass *klass); static void gimp_smudge_init (GimpSmudge *smudge); @@ -72,7 +74,10 @@ void gimp_smudge_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_SMUDGE, GIMP_TYPE_SMUDGE_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_SMUDGE, + GIMP_TYPE_SMUDGE_OPTIONS, + _("Smudge")); } GType diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index df70bcc63d..6c262a62ae 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -83,7 +83,10 @@ void gimp_clone_register (Gimp *gimp, GimpPaintRegisterCallback callback) { - (* callback) (gimp, GIMP_TYPE_CLONE, GIMP_TYPE_CLONE_OPTIONS); + (* callback) (gimp, + GIMP_TYPE_CLONE, + GIMP_TYPE_CLONE_OPTIONS, + _("Clone")); } GType diff --git a/app/paint/paint-types.h b/app/paint/paint-types.h index 21297c2cfd..c4f28b9b76 100644 --- a/app/paint/paint-types.h +++ b/app/paint/paint-types.h @@ -34,7 +34,8 @@ typedef struct _GimpPaintOptions GimpPaintOptions; typedef void (* GimpPaintRegisterCallback) (Gimp *gimp, GType paint_type, - GType paint_options_type); + GType paint_options_type, + const gchar *blurb); typedef void (* GimpPaintRegisterFunc) (Gimp *gimp, GimpPaintRegisterCallback callback); diff --git a/app/paint/paint.c b/app/paint/paint.c index 5c0e3dafdf..77100f4cd2 100644 --- a/app/paint/paint.c +++ b/app/paint/paint.c @@ -39,9 +39,10 @@ /* local function prototypes */ -static void paint_register (Gimp *gimp, - GType paint_type, - GType paint_options_type); +static void paint_register (Gimp *gimp, + GType paint_type, + GType paint_options_type, + const gchar *blurb); /* public functions */ @@ -91,9 +92,10 @@ paint_exit (Gimp *gimp) /* private functions */ static void -paint_register (Gimp *gimp, - GType paint_type, - GType paint_options_type) +paint_register (Gimp *gimp, + GType paint_type, + GType paint_options_type, + const gchar *blurb) { GimpPaintInfo *paint_info; const gchar *pdb_string; @@ -101,6 +103,7 @@ paint_register (Gimp *gimp, g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (g_type_is_a (paint_type, GIMP_TYPE_PAINT_CORE)); g_return_if_fail (g_type_is_a (paint_options_type, GIMP_TYPE_PAINT_OPTIONS)); + g_return_if_fail (blurb != NULL); if (paint_type == GIMP_TYPE_PENCIL) { @@ -142,6 +145,7 @@ paint_register (Gimp *gimp, paint_info = gimp_paint_info_new (gimp, paint_type, paint_options_type, + blurb, pdb_string); gimp_container_add (gimp->paint_info_list, GIMP_OBJECT (paint_info)); diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index e6f7821dbc..1424c756bf 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -47,6 +47,8 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "libgimp/gimpintl.h" + static ProcRecord brightness_contrast_proc; static ProcRecord levels_proc; static ProcRecord posterize_proc; @@ -126,7 +128,7 @@ brightness_contrast_invoker (Gimp *gimp, &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -251,7 +253,7 @@ levels_invoker (Gimp *gimp, &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -356,7 +358,7 @@ posterize_invoker (Gimp *gimp, &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -608,7 +610,7 @@ curves_spline_invoker (Gimp *gimp, &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -715,7 +717,7 @@ curves_explicit_invoker (Gimp *gimp, &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -832,7 +834,7 @@ color_balance_invoker (Gimp *gimp, color_balance (&srcPR, &destPR, &cb); } - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -1128,7 +1130,7 @@ hue_saturation_invoker (Gimp *gimp, hue_saturation (&srcPR, &destPR, &hs); } - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -1226,7 +1228,7 @@ threshold_invoker (Gimp *gimp, pixel_regions_process_parallel ((p_func) threshold_2, &tr, 2, &srcPR, &destPR); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } diff --git a/app/pdb/drawable_cmds.c b/app/pdb/drawable_cmds.c index 2d6936576b..b8b83c4db9 100644 --- a/app/pdb/drawable_cmds.c +++ b/app/pdb/drawable_cmds.c @@ -41,6 +41,8 @@ #include "core/gimplayer.h" #include "core/gimplayermask.h" +#include "libgimp/gimpintl.h" + static ProcRecord drawable_merge_shadow_proc; static ProcRecord drawable_fill_proc; static ProcRecord drawable_update_proc; @@ -108,7 +110,7 @@ drawable_merge_shadow_invoker (Gimp *gimp, undo = args[1].value.pdb_int ? TRUE : FALSE; if (success) - gimp_drawable_merge_shadow (drawable, undo); + gimp_drawable_merge_shadow (drawable, undo, _("Plug-In")); return procedural_db_return_args (&drawable_merge_shadow_proc, success); } diff --git a/app/pdb/guides_cmds.c b/app/pdb/guides_cmds.c index c6733723bb..aa81556f72 100644 --- a/app/pdb/guides_cmds.c +++ b/app/pdb/guides_cmds.c @@ -30,8 +30,10 @@ #include "core/core-enums.h" #include "core/gimpimage-guides.h" +#include "core/gimpimage-undo-push.h" #include "core/gimpimage.h" -#include "undo.h" + +#include "libgimp/gimpintl.h" static ProcRecord image_add_hguide_proc; static ProcRecord image_add_vguide_proc; @@ -75,7 +77,7 @@ image_add_hguide_invoker (Gimp *gimp, if (offset < gimage->height) { guide = gimp_image_add_hguide (gimage); - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, _("Add Horizontal Guide"), guide); guide->position = offset; guide_ID = guide->guide_ID; } @@ -154,7 +156,7 @@ image_add_vguide_invoker (Gimp *gimp, if (offset < gimage->width) { guide = gimp_image_add_vguide (gimage); - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, _("Add Vertical Guide"), guide); guide->position = offset; guide_ID = guide->guide_ID; } @@ -228,25 +230,18 @@ image_delete_guide_invoker (Gimp *gimp, { success = FALSE; - guides = gimage->guides; - - while (guides) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) + GimpGuide *g = (GimpGuide *) guides->data; + + if ((g->guide_ID == guide) && (g->position >= 0)) { - GList *tmp_next; + gimp_image_undo_push_image_guide (gimage, _("Remove Guide"), g); + gimp_image_delete_guide (gimage, g); success = TRUE; - - tmp_next = guides->next; - - undo_push_image_guide (gimage, ((GimpGuide *) guides->data)); - gimp_image_delete_guide (gimage, (GimpGuide *) guides->data); - guides = tmp_next; + break; } - else - guides = guides->next; } } @@ -293,6 +288,7 @@ image_find_next_guide_invoker (Gimp *gimp, gint32 guide; gint32 next_guide = 0; GList *guides; + gboolean guide_found; gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_IMAGE (gimage)) @@ -302,47 +298,35 @@ image_find_next_guide_invoker (Gimp *gimp, if (success) { - guides = gimage->guides; + success = FALSE; + guide_found = FALSE; - if (guides != NULL) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if (guide == 0) /* init - Return first guide ID in list */ + GimpGuide *g = (GimpGuide *) guides->data; + + if (g->position < 0) + continue; + + if (guide == 0) /* init - Return first guide ID in list */ { - while (guides && (((GimpGuide *) guides->data)->position < 0)) - guides = guides->next; + next_guide = g->guide_ID; - if (guides) /* didn't just come to end of list */ - next_guide = ((GimpGuide *) guides->data)->guide_ID; + success = TRUE; + break; + } + + if (! guide_found) + { + if (g->guide_ID == guide) + guide_found = TRUE; } else { - success = FALSE; - - while (guides) - { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) - { - GList* tmplist; - - success = TRUE; - - tmplist = guides->next; - - while (tmplist && (((GimpGuide *) tmplist->data)->position < 0)) - tmplist = tmplist->next; - - if (tmplist) - next_guide = ((GimpGuide *) tmplist->data)->guide_ID; - else - next_guide = 0; - - break; - } - - guides = guides->next; - } + next_guide = g->guide_ID; + success = TRUE; + break; } } } @@ -413,21 +397,19 @@ image_get_guide_orientation_invoker (Gimp *gimp, if (success) { - guides = gimage->guides; - success = FALSE; - while (guides) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) + GimpGuide *g = (GimpGuide *) guides->data; + + if ((g->guide_ID == guide) && (g->position >= 0)) { - orientation = ((GimpGuide *) guides->data)->orientation; + orientation = g->orientation; + success = TRUE; break; } - - guides = guides->next; } } @@ -497,21 +479,19 @@ image_get_guide_position_invoker (Gimp *gimp, if (success) { - guides = gimage->guides; - success = FALSE; - while (guides) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) + GimpGuide *g = (GimpGuide *) guides->data; + + if ((g->guide_ID == guide) && (g->position >= 0)) { - position = ((GimpGuide *) guides->data)->position; + position = g->position; + success = TRUE; break; } - - guides = guides->next; } } diff --git a/app/pdb/layer_cmds.c b/app/pdb/layer_cmds.c index 5e9ea578ef..90190b0116 100644 --- a/app/pdb/layer_cmds.c +++ b/app/pdb/layer_cmds.c @@ -40,7 +40,6 @@ #include "core/gimplayermask.h" #include "core/gimplist.h" #include "pdb_glue.h" -#include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/pdb/selection_cmds.c b/app/pdb/selection_cmds.c index 0e68c49b5f..e1d2958d65 100644 --- a/app/pdb/selection_cmds.c +++ b/app/pdb/selection_cmds.c @@ -438,7 +438,7 @@ selection_clear_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); return procedural_db_return_args (&selection_clear_proc, success); } @@ -606,7 +606,7 @@ selection_none_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); return procedural_db_return_args (&selection_none_proc, success); } diff --git a/app/pdb/selection_tools_cmds.c b/app/pdb/selection_tools_cmds.c index 6384409613..ffbb4e0d59 100644 --- a/app/pdb/selection_tools_cmds.c +++ b/app/pdb/selection_tools_cmds.c @@ -33,6 +33,7 @@ #include "core/gimpimage-mask-select.h" #include "core/gimpimage.h" +#include "libgimp/gimpintl.h" #include "libgimpcolor/gimpcolor.h" static ProcRecord by_color_select_proc; @@ -323,6 +324,7 @@ free_select_invoker (Gimp *gimp, if (success) gimp_image_mask_select_polygon (gimage, + _("Free Select"), num_segs, (GimpVector2 *) segs, operation, diff --git a/app/text/gimptext-compat.c b/app/text/gimptext-compat.c index eeef92d4d5..a34eab1d65 100644 --- a/app/text/gimptext-compat.c +++ b/app/text/gimptext-compat.c @@ -42,8 +42,6 @@ #include "gimptext-compat.h" #include "gimptextlayer.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -100,7 +98,7 @@ text_render (GimpImage *gimage, * it seems like the correct behavior. */ if (! gimp_image_mask_is_empty (gimage)) - gimp_image_mask_clear (gimage); + gimp_image_mask_clear (gimage, NULL); /* If the drawable is NULL, create a new layer */ if (drawable == NULL) diff --git a/app/tools/Makefile.am b/app/tools/Makefile.am index 1ee817294f..631e48e8fa 100644 --- a/app/tools/Makefile.am +++ b/app/tools/Makefile.am @@ -123,6 +123,8 @@ libapptools_a_SOURCES = \ gimptransformoptions.h \ gimptransformtool.c \ gimptransformtool.h \ + gimptransformtool-undo.c \ + gimptransformtool-undo.h \ gimpvectoroptions.c \ gimpvectoroptions.h \ gimpvectortool.c \ diff --git a/app/tools/gimpbezierselecttool.c b/app/tools/gimpbezierselecttool.c index 8dcea296a4..6a3d6b80e7 100644 --- a/app/tools/gimpbezierselecttool.c +++ b/app/tools/gimpbezierselecttool.c @@ -57,7 +57,6 @@ #include "app_procs.h" #include "path.h" #include "pathP.h" -#include "undo.h" #include "libgimp/gimpintl.h" @@ -2916,6 +2915,7 @@ bezier_to_sel_internal (GimpBezierSelectTool *bezier_sel, bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, TRUE); gimp_image_mask_select_channel (gdisp->gimage, + tool->tool_info->blurb, bezier_sel->mask, 0, 0, op, diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c index 73369e8eb1..34e0935be1 100644 --- a/app/tools/gimpbrushtool.c +++ b/app/tools/gimpbrushtool.c @@ -48,8 +48,6 @@ #include "gimppainttool.h" #include "tool_manager.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index d23c4103b9..1a7e72536e 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -39,8 +39,6 @@ #include "gimpbucketfilloptions.h" #include "gimpbucketfilltool.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index 7157868442..9fe36ebd4d 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -50,7 +50,6 @@ #include "tool_manager.h" #include "path_transform.h" -#include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index ab1bf05c83..b95098a9a1 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -42,7 +42,6 @@ #include "gimpfreeselecttool.h" #include "gimpselectionoptions.h" - #include "libgimp/gimpintl.h" @@ -244,13 +243,14 @@ gimp_free_select_tool_button_release (GimpTool *tool, floating_sel_anchor (gimp_image_floating_sel (gdisp->gimage)); /* Otherwise, clear the selection mask */ else - gimp_image_mask_clear (gdisp->gimage); + gimp_image_mask_clear (gdisp->gimage, NULL); gimp_image_flush (gdisp->gimage); return; } gimp_image_mask_select_polygon (gdisp->gimage, + tool->tool_info->blurb, free_sel->num_points, free_sel->points, GIMP_SELECTION_TOOL (tool)->op, diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index 33585ead1e..45c8bbbabb 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -271,7 +271,7 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, floating_sel_anchor (gimp_image_floating_sel (gdisp->gimage)); /* Otherwise, clear the selection mask */ else - gimp_image_mask_clear (gdisp->gimage); + gimp_image_mask_clear (gdisp->gimage, NULL); gimp_image_flush (gdisp->gimage); return; @@ -292,6 +292,7 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, } gimp_image_mask_select_channel (gdisp->gimage, + tool->tool_info->blurb, fuzzy_sel->fuzzy_mask, off_x, off_y, diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c index dab99bacf8..d012e4b240 100644 --- a/app/tools/gimpimagemaptool.c +++ b/app/tools/gimpimagemaptool.c @@ -183,21 +183,21 @@ gimp_image_map_tool_initialize (GimpTool *tool, GimpDisplay *gdisp) { GimpImageMapTool *image_map_tool; + GimpToolInfo *tool_info; GimpDrawable *drawable; image_map_tool = GIMP_IMAGE_MAP_TOOL (tool); + tool_info = tool->tool_info; + /* set gdisp so the dialog can be hidden on display destruction */ tool->gdisp = gdisp; if (! image_map_tool->shell) { - GimpToolInfo *tool_info; - GtkWidget *shell; - GtkWidget *vbox; - GtkWidget *toggle; - - tool_info = tool->tool_info; + GtkWidget *shell; + GtkWidget *vbox; + GtkWidget *toggle; image_map_tool->shell = shell = gimp_viewable_dialog_new (NULL, @@ -251,7 +251,8 @@ gimp_image_map_tool_initialize (GimpTool *tool, gtk_widget_show (image_map_tool->shell); image_map_tool->drawable = drawable; - image_map_tool->image_map = gimp_image_map_new (TRUE, drawable); + image_map_tool->image_map = gimp_image_map_new (TRUE, drawable, + tool_info->blurb); g_signal_connect (image_map_tool->image_map, "flush", G_CALLBACK (gimp_image_map_tool_flush), diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index cef330b69c..e95f074713 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -38,6 +38,7 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" +#include "core/gimpimage-undo-push.h" #include "core/gimptoolinfo.h" #include "paint/gimppaintoptions.h" @@ -48,8 +49,6 @@ #include "gimpinktool.h" #include "gimpinktool-blob.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -715,7 +714,7 @@ static void ink_finish (GimpInkTool *ink_tool, GimpDrawable *drawable) { - gimp_drawable_push_undo (drawable, + gimp_drawable_push_undo (drawable, _("Ink"), ink_tool->x1, ink_tool->y1, ink_tool->x2, ink_tool->y2, undo_tiles, TRUE); @@ -1025,7 +1024,7 @@ ink_paste (GimpInkTool *ink_tool, /* apply the paint area to the gimage */ gimp_image_apply_image (gimage, drawable, &srcPR, - FALSE, + FALSE, NULL, gimp_context_get_opacity (context), gimp_context_get_paint_mode (context), undo_tiles, /* specify an alternative src1 */ diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index e789d321af..dd0aa14084 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -491,6 +491,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool, gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); gimp_image_mask_select_channel (gdisp->gimage, + tool->tool_info->blurb, iscissors->mask, 0, 0, GIMP_SELECTION_TOOL (tool)->op, diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index ac0fcde5bb..d7d266aabe 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -39,6 +39,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-guides.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimptoolinfo.h" #include "widgets/gimpviewabledialog.h" @@ -52,8 +53,6 @@ #include "gimpmeasuretool.h" #include "tool_manager.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -288,7 +287,9 @@ gimp_measure_tool_button_press (GimpTool *tool, if (create_hguide) { guide = gimp_image_add_hguide (gdisp->gimage); - undo_push_image_guide (gdisp->gimage, guide); + gimp_image_undo_push_image_guide (gdisp->gimage, + _("Add Horizontal Guide"), + guide); guide->position = measure_tool->y[i]; gimp_image_update_guide (gdisp->gimage, guide); @@ -297,7 +298,9 @@ gimp_measure_tool_button_press (GimpTool *tool, if (create_vguide) { guide = gimp_image_add_vguide (gdisp->gimage); - undo_push_image_guide (gdisp->gimage, guide); + gimp_image_undo_push_image_guide (gdisp->gimage, + _("Add Vertical Guide"), + guide); guide->position = measure_tool->x[i]; gimp_image_update_guide (gdisp->gimage, guide); diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index c9a391deee..0d3cba0128 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -29,6 +29,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-guides.h" #include "core/gimpimage-mask.h" +#include "core/gimpimage-undo-push.h" #include "core/gimplayer.h" #include "core/gimplayer-floating-sel.h" #include "core/gimptoolinfo.h" @@ -44,8 +45,6 @@ #include "gimpmoveoptions.h" #include "gimpmovetool.h" -#include "undo.h" - #include "libgimp/gimpintl.h" @@ -245,7 +244,9 @@ gimp_move_tool_button_press (GimpTool *tool, if (gdisp->draw_guides && (guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y))) { - undo_push_image_guide (gdisp->gimage, guide); + gimp_image_undo_push_image_guide (gdisp->gimage, + _("Guide"), + guide); gimp_image_update_guide (gdisp->gimage, guide); gimp_image_remove_guide (gdisp->gimage, guide); @@ -640,7 +641,9 @@ gimp_move_tool_start_guide (GimpTool *tool, move->disp = gdisp; - undo_push_image_guide (gdisp->gimage, move->guide); + gimp_image_undo_push_image_guide (gdisp->gimage, + _("Add Guide"), + move->guide); gimp_tool_set_cursor (tool, gdisp, GDK_HAND2, diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index 73369e8eb1..34e0935be1 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -48,8 +48,6 @@ #include "gimppainttool.h" #include "tool_manager.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index 45d96eebb8..58a30a1326 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -288,7 +288,7 @@ gimp_rect_select_tool_button_release (GimpTool *tool, floating_sel_anchor (gimp_image_floating_sel (gdisp->gimage)); /* Otherwise, clear the selection mask */ else - gimp_image_mask_clear (gdisp->gimage); + gimp_image_mask_clear (gdisp->gimage, NULL); gimp_image_flush (gdisp->gimage); return; @@ -297,8 +297,6 @@ gimp_rect_select_tool_button_release (GimpTool *tool, x2 = x1 + w; y2 = y1 + h; - g_print ("rect_select: %d x %d\n", w, h); - gimp_rect_select_tool_rect_select (rect_sel, x1, y1, (x2 - x1), (y2 - y1)); diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index 33585ead1e..45c8bbbabb 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -271,7 +271,7 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, floating_sel_anchor (gimp_image_floating_sel (gdisp->gimage)); /* Otherwise, clear the selection mask */ else - gimp_image_mask_clear (gdisp->gimage); + gimp_image_mask_clear (gdisp->gimage, NULL); gimp_image_flush (gdisp->gimage); return; @@ -292,6 +292,7 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, } gimp_image_mask_select_channel (gdisp->gimage, + tool->tool_info->blurb, fuzzy_sel->fuzzy_mask, off_x, off_y, diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index 47fd8fc586..88678cfda3 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -52,8 +52,6 @@ #include "gimptextoptions.h" #include "gimptexttool.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/tools/gimptransformtool-undo.c b/app/tools/gimptransformtool-undo.c new file mode 100644 index 0000000000..5d9955d88e --- /dev/null +++ b/app/tools/gimptransformtool-undo.c @@ -0,0 +1,170 @@ +/* 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 + +#include "tools-types.h" + +#include "base/tile-manager.h" + +#include "core/gimpimage-undo.h" +#include "core/gimpimage.h" +#include "core/gimpundo.h" + +#include "gimptransformtool.h" +#include "gimptransformtool-undo.h" +#include "tool_manager.h" + +#include "path_transform.h" + +#include "libgimp/gimpintl.h" + + +/********************/ +/* Transform Undo */ +/********************/ + +typedef struct _TransformUndo TransformUndo; + +struct _TransformUndo +{ + gint tool_ID; + GType tool_type; + + TransInfo trans_info; + TileManager *original; + gpointer path_undo; +}; + +static gboolean undo_pop_transform (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode, + GimpUndoAccumulator *accum); +static void undo_free_transform (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode); + +gboolean +gimp_transform_tool_push_undo (GimpImage *gimage, + const gchar *undo_desc, + gint tool_ID, + GType tool_type, + gdouble *trans_info, + TileManager *original, + GSList *path_undo) +{ + GimpUndo *new; + + if ((new = gimp_image_undo_push (gimage, + sizeof (TransformUndo), + sizeof (TransformUndo), + GIMP_UNDO_TRANSFORM, undo_desc, + FALSE, + undo_pop_transform, + undo_free_transform))) + { + TransformUndo *tu; + gint i; + + tu = new->data; + + tu->tool_ID = tool_ID; + tu->tool_type = tool_type; + + for (i = 0; i < TRAN_INFO_SIZE; i++) + tu->trans_info[i] = trans_info[i]; + + tu->original = original; + tu->path_undo = path_undo; + + return TRUE; + } + + return FALSE; +} + +static gboolean +undo_pop_transform (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode, + GimpUndoAccumulator *accum) +{ + GimpTool *active_tool; + + active_tool = tool_manager_get_active (gimage->gimp); + + if (GIMP_IS_TRANSFORM_TOOL (active_tool)) + { + GimpTransformTool *tt; + TransformUndo *tu; + + tt = GIMP_TRANSFORM_TOOL (active_tool); + tu = (TransformUndo *) undo->data; + + path_transform_do_undo (gimage, tu->path_undo); + + /* only pop if the active tool is the tool that pushed this undo */ + if (tu->tool_ID == active_tool->ID) + { + TileManager *temp; + gdouble d; + gint i; + + /* swap the transformation information arrays */ + for (i = 0; i < TRAN_INFO_SIZE; i++) + { + d = tu->trans_info[i]; + tu->trans_info[i] = tt->trans_info[i]; + tt->trans_info[i] = d; + } + + /* swap the original buffer--the source buffer for repeated transforms + */ + temp = tu->original; + tu->original = tt->original; + tt->original = temp; + + /* If we're re-implementing the first transform, reactivate tool */ + if (undo_mode == GIMP_UNDO_MODE_REDO && tt->original) + { + gimp_tool_control_activate (active_tool->control); + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt)); + } + } + } + + return TRUE; +} + +static void +undo_free_transform (GimpUndo *undo, + GimpImage *gimage, + GimpUndoMode undo_mode) +{ + TransformUndo * tu; + + tu = (TransformUndo *) undo->data; + + if (tu->original) + tile_manager_destroy (tu->original); + path_transform_free_undo (tu->path_undo); + g_free (tu); +} diff --git a/app/tools/gimptransformtool-undo.h b/app/tools/gimptransformtool-undo.h new file mode 100644 index 0000000000..08efbdbd22 --- /dev/null +++ b/app/tools/gimptransformtool-undo.h @@ -0,0 +1,32 @@ +/* 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_TRANSFORM_TOOL_UNDO_H__ +#define __GIMP_TRANSFORM_TOOL_UNDO_H__ + + +gboolean gimp_transform_tool_push_undo (GimpImage *gimage, + const gchar *undo_desc, + gint tool_ID, + GType tool_type, + gdouble *trans_info, + TileManager *original, + GSList *path_undo); + + +#endif /* __GIMP_TRANSFORM_TOOL_UNDO_H__ */ diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index b901de642a..ac5125b7a5 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -41,6 +41,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimplayer.h" #include "core/gimpmarshal.h" #include "core/gimptoolinfo.h" @@ -53,11 +54,11 @@ #include "display/gimpdisplay-foreach.h" #include "display/gimpprogress.h" -#include "gimptransformtool.h" #include "gimptransformoptions.h" +#include "gimptransformtool.h" +#include "gimptransformtool-undo.h" #include "tool_manager.h" -#include "undo.h" #include "path_transform.h" #include "libgimp/gimpintl.h" @@ -319,7 +320,7 @@ gimp_transform_tool_button_press (GimpTool *tool, drawable = gimp_image_active_drawable (gdisp->gimage); - if (! tr_tool->notify_connected) + if (tr_tool->use_grid && ! tr_tool->notify_connected) { tr_tool->show_path = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options)->show_path; @@ -667,11 +668,12 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool) gint i, k, gci; tr_tool = GIMP_TRANSFORM_TOOL (draw_tool); - options = GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (draw_tool)->tool_info->tool_options); if (! tr_tool->use_grid) return; + options = GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (draw_tool)->tool_info->tool_options); + /* draw the bounding box */ gimp_draw_tool_draw_line (draw_tool, tr_tool->tx1, tr_tool->ty1, @@ -825,7 +827,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, /* Start a transform undo group */ gimp_image_undo_group_start (gdisp->gimage, GIMP_UNDO_GROUP_TRANSFORM, - _("Transform")); + tool->tool_info->blurb); /* With the old UI, if original is NULL, then this is the * first transformation. In the new UI, it is always so, right? @@ -866,12 +868,12 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, */ tool->drawable = gimp_image_active_drawable (gdisp->gimage); - undo_push_transform (gdisp->gimage, - tool->ID, - G_TYPE_FROM_INSTANCE (tool), - tr_tool->old_trans_info, - NULL, - path_undo); + gimp_transform_tool_push_undo (gdisp->gimage, NULL, + tool->ID, + G_TYPE_FROM_INSTANCE (tool), + tr_tool->old_trans_info, + NULL, + path_undo); } /* push the undo group end */ diff --git a/app/undo.c b/app/undo.c deleted file mode 100644 index a78710e760..0000000000 --- a/app/undo.c +++ /dev/null @@ -1,3123 +0,0 @@ -/* 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 -#include - -#include - -#include "libgimpbase/gimpbase.h" - -#include "tools/tools-types.h" - -#include "config/gimpcoreconfig.h" - -#include "base/pixel-region.h" -#include "base/tile-manager.h" -#include "base/tile.h" - -#include "paint-funcs/paint-funcs.h" - -#include "core/gimp.h" -#include "core/gimp-parasites.h" -#include "core/gimpchannel.h" -#include "core/gimpcontainer.h" -#include "core/gimpcontext.h" -#include "core/gimpimage.h" -#include "core/gimpimage-guides.h" -#include "core/gimpimage-mask.h" -#include "core/gimpimage-projection.h" -#include "core/gimplayer.h" -#include "core/gimplayer-floating-sel.h" -#include "core/gimplayermask.h" -#include "core/gimplist.h" -#include "core/gimpparasitelist.h" - -#include "core/gimpundo.h" -#include "core/gimpundostack.h" -#include "core/gimpimage-undo.h" - -#include "paint/gimppaintcore.h" - -#include "vectors/gimpvectors.h" - -#include "tools/gimpbycolorselecttool.h" -#include "tools/gimppainttool.h" -#include "tools/gimptransformtool.h" -#include "tools/tool_manager.h" - -#include "path_transform.h" -#include "undo.h" - -#include "libgimp/gimpintl.h" - - -/****************/ -/* Image Undo */ -/****************/ - -typedef struct _ImageUndo ImageUndo; - -struct _ImageUndo -{ - TileManager *tiles; - GimpDrawable *drawable; - gint x1, y1, x2, y2; - gboolean sparse; -}; - -static gboolean undo_pop_image (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_image (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image (GimpImage *gimage, - GimpDrawable *drawable, - gint x1, - gint y1, - gint x2, - gint y2) -{ - GimpUndo *new; - gsize size; - - x1 = CLAMP (x1, 0, gimp_drawable_width (drawable)); - y1 = CLAMP (y1, 0, gimp_drawable_height (drawable)); - x2 = CLAMP (x2, 0, gimp_drawable_width (drawable)); - y2 = CLAMP (y2, 0, gimp_drawable_height (drawable)); - - size = sizeof (ImageUndo) + ((x2 - x1) * (y2 - y1) * - gimp_drawable_bytes (drawable)); - - if ((new = gimp_image_undo_push (gimage, - size, sizeof (ImageUndo), - GIMP_UNDO_IMAGE, NULL, - TRUE, - undo_pop_image, - undo_free_image))) - { - ImageUndo *image_undo; - TileManager *tiles; - PixelRegion srcPR, destPR; - - image_undo = new->data; - - /* If we cannot create a new temp buf--either because our parameters are - * degenerate or something else failed, simply return an unsuccessful push. - */ - tiles = tile_manager_new ((x2 - x1), (y2 - y1), - gimp_drawable_bytes (drawable)); - pixel_region_init (&srcPR, gimp_drawable_data (drawable), - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, tiles, - 0, 0, (x2 - x1), (y2 - y1), TRUE); - copy_region (&srcPR, &destPR); - - /* set the image undo structure */ - image_undo->tiles = tiles; - image_undo->drawable = drawable; - image_undo->x1 = x1; - image_undo->y1 = y1; - image_undo->x2 = x2; - image_undo->y2 = y2; - image_undo->sparse = FALSE; - - return TRUE; - } - - return FALSE; -} - -gboolean -undo_push_image_mod (GimpImage *gimage, - GimpDrawable *drawable, - gint x1, - gint y1, - gint x2, - gint y2, - TileManager *tiles, - gboolean sparse) -{ - GimpUndo *new; - gsize size; - gint dwidth, dheight; - - if (! tiles) - return FALSE; - - dwidth = gimp_drawable_width (drawable); - dheight = gimp_drawable_height (drawable); - - x1 = CLAMP (x1, 0, dwidth); - y1 = CLAMP (y1, 0, dheight); - x2 = CLAMP (x2, 0, dwidth); - y2 = CLAMP (y2, 0, dheight); - - size = sizeof (ImageUndo) + tile_manager_get_memsize (tiles); - - if ((new = gimp_image_undo_push (gimage, - size, sizeof (ImageUndo), - GIMP_UNDO_IMAGE_MOD, NULL, - TRUE, - undo_pop_image, - undo_free_image))) - { - ImageUndo *image_undo; - - image_undo = new->data; - - image_undo->tiles = tiles; - image_undo->drawable = drawable; - image_undo->x1 = x1; - image_undo->y1 = y1; - image_undo->x2 = x2; - image_undo->y2 = y2; - image_undo->sparse = sparse; - - return TRUE; - } - - tile_manager_destroy (tiles); - - return FALSE; -} - -static gboolean -undo_pop_image (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ImageUndo *image_undo; - TileManager *tiles; - PixelRegion PR1, PR2; - gint x, y; - gint w, h; - - image_undo = (ImageUndo *) undo->data; - - tiles = image_undo->tiles; - - /* some useful values */ - x = image_undo->x1; - y = image_undo->y1; - - if (image_undo->sparse == FALSE) - { - w = tile_manager_width (tiles); - h = tile_manager_height (tiles); - - pixel_region_init (&PR1, tiles, - 0, 0, w, h, TRUE); - pixel_region_init (&PR2, gimp_drawable_data (image_undo->drawable), - x, y, w, h, TRUE); - - /* swap the regions */ - swap_region (&PR1, &PR2); - } - else - { - int i, j; - Tile *src_tile; - Tile *dest_tile; - - w = image_undo->x2 - image_undo->x1; - h = image_undo->y2 - image_undo->y1; - - for (i = y; i < image_undo->y2; i += (TILE_HEIGHT - (i % TILE_HEIGHT))) - { - for (j = x; j < image_undo->x2; j += (TILE_WIDTH - (j % TILE_WIDTH))) - { - src_tile = tile_manager_get_tile (tiles, j, i, FALSE, FALSE); - if (tile_is_valid (src_tile) == TRUE) - { - /* swap tiles, not pixels! */ - - src_tile = tile_manager_get_tile (tiles, j, i, TRUE, FALSE /* TRUE */); - dest_tile = tile_manager_get_tile (gimp_drawable_data (image_undo->drawable), j, i, TRUE, FALSE /* TRUE */); - - tile_manager_map_tile (tiles, j, i, dest_tile); - tile_manager_map_tile (gimp_drawable_data (image_undo->drawable), j, i, src_tile); -#if 0 - swap_pixels (tile_data_pointer (src_tile, 0, 0), - tile_data_pointer (dest_tile, 0, 0), - tile_size (src_tile)); -#endif - - tile_release (dest_tile, FALSE /* TRUE */); - tile_release (src_tile, FALSE /* TRUE */); - } - } - } - } - - gimp_drawable_update (image_undo->drawable, x, y, w, h); - - return TRUE; -} - -static void -undo_free_image (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - ImageUndo *image_undo; - - image_undo = (ImageUndo *) undo->data; - - tile_manager_destroy (image_undo->tiles); - g_free (image_undo); -} - - -/*********************/ -/* Image Type Undo */ -/*********************/ - -typedef struct _ImageTypeUndo ImageTypeUndo; - -struct _ImageTypeUndo -{ - GimpImageBaseType base_type; -}; - -static gboolean undo_pop_image_type (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_image_type (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image_type (GimpImage *gimage) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ImageTypeUndo), - sizeof (ImageTypeUndo), - GIMP_UNDO_IMAGE_TYPE, NULL, - TRUE, - undo_pop_image_type, - undo_free_image_type))) - { - ImageTypeUndo *itu; - - itu = new->data; - - itu->base_type = gimage->base_type; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_image_type (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ImageTypeUndo *itu; - GimpImageBaseType tmp; - - itu = (ImageTypeUndo *) undo->data; - - tmp = itu->base_type; - itu->base_type = gimage->base_type; - gimage->base_type = tmp; - - gimp_image_projection_allocate (gimage); - - gimp_image_colormap_changed (gimage, -1); - - if (itu->base_type != gimage->base_type) - accum->mode_changed = TRUE; - - return TRUE; -} - -static void -undo_free_image_type (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/*********************/ -/* Image Size Undo */ -/*********************/ - -typedef struct _ImageSizeUndo ImageSizeUndo; - -struct _ImageSizeUndo -{ - gint width; - gint height; -}; - -static gboolean undo_pop_image_size (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_image_size (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image_size (GimpImage *gimage) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ImageSizeUndo), - sizeof (ImageSizeUndo), - GIMP_UNDO_IMAGE_SIZE, NULL, - TRUE, - undo_pop_image_size, - undo_free_image_size))) - { - ImageSizeUndo *isu; - - isu = new->data; - - new->data = isu; - - isu->width = gimage->width; - isu->height = gimage->height; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_image_size (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ImageSizeUndo *isu; - gint width; - gint height; - - isu = (ImageSizeUndo *) undo->data; - - width = isu->width; - height = isu->height; - - isu->width = gimage->width; - isu->height = gimage->height; - - gimage->width = width; - gimage->height = height; - - gimp_image_projection_allocate (gimage); - gimp_image_mask_invalidate (gimage); - - if (gimage->width != isu->width || - gimage->height != isu->height) - accum->size_changed = TRUE; - - return TRUE; -} - -static void -undo_free_image_size (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/***************************/ -/* Image Resolution Undo */ -/***************************/ - -typedef struct _ResolutionUndo ResolutionUndo; - -struct _ResolutionUndo -{ - gdouble xres; - gdouble yres; - GimpUnit unit; -}; - -static gboolean undo_pop_image_resolution (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_image_resolution (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image_resolution (GimpImage *gimage) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ResolutionUndo), - sizeof (ResolutionUndo), - GIMP_UNDO_IMAGE_RESOLUTION, NULL, - TRUE, - undo_pop_image_resolution, - undo_free_image_resolution))) - { - ResolutionUndo *ru; - - ru = new->data; - - ru->xres = gimage->xresolution; - ru->yres = gimage->yresolution; - ru->unit = gimage->unit; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_image_resolution (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ResolutionUndo *ru; - - ru = (ResolutionUndo *) undo->data; - - if (ABS (ru->xres - gimage->xresolution) >= 1e-5 || - ABS (ru->yres - gimage->yresolution) >= 1e-5) - { - gdouble xres; - gdouble yres; - - xres = gimage->xresolution; - yres = gimage->yresolution; - - gimage->xresolution = ru->xres; - gimage->yresolution = ru->yres; - - ru->xres = xres; - ru->yres = yres; - - accum->resolution_changed = TRUE; - } - - if (ru->unit != gimage->unit) - { - GimpUnit unit; - - unit = gimage->unit; - gimage->unit = ru->unit; - ru->unit = unit; - - accum->unit_changed = TRUE; - } - - return TRUE; -} - -static void -undo_free_image_resolution (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/****************/ -/* Qmask Undo */ -/****************/ - -typedef struct _QmaskUndo QmaskUndo; - -struct _QmaskUndo -{ - GimpImage *gimage; - gboolean qmask; -}; - -static gboolean undo_pop_image_qmask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_image_qmask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image_qmask (GimpImage *gimage) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (QmaskUndo), - sizeof (QmaskUndo), - GIMP_UNDO_IMAGE_QMASK, NULL, - TRUE, - undo_pop_image_qmask, - undo_free_image_qmask))) - { - QmaskUndo *qu; - - qu = new->data; - - qu->gimage = gimage; - qu->qmask = gimage->qmask_state; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_image_qmask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - QmaskUndo *data; - gboolean tmp; - - data = (QmaskUndo *) undo->data; - - tmp = gimage->qmask_state; - gimage->qmask_state = data->qmask; - data->qmask = tmp; - - accum->qmask_changed = TRUE; - - return TRUE; -} - -static void -undo_free_image_qmask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/****************/ -/* Guide Undo */ -/****************/ - -typedef struct _GuideUndo GuideUndo; - -struct _GuideUndo -{ - GimpImage *gimage; - GimpGuide *guide; - GimpGuide orig; -}; - -static gboolean undo_pop_image_guide (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_image_guide (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image_guide (GimpImage *gimage, - GimpGuide *guide) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (GuideUndo), - sizeof (GuideUndo), - GIMP_UNDO_IMAGE_GUIDE, NULL, - TRUE, - undo_pop_image_guide, - undo_free_image_guide))) - { - GuideUndo *gu; - - gu = new->data; - - guide->ref_count++; - - gu->gimage = gimage; - gu->guide = guide; - gu->orig = *guide; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_image_guide (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - GuideUndo *data; - GimpGuide tmp; - gint tmp_ref; - - data = (GuideUndo *) undo->data; - - gimp_image_update_guide (gimage, data->guide); - - tmp_ref = data->guide->ref_count; - tmp = *(data->guide); - *(data->guide) = data->orig; - data->guide->ref_count = tmp_ref; - data->orig = tmp; - - gimp_image_update_guide (gimage, data->guide); - - return TRUE; -} - -static void -undo_free_image_guide (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - GuideUndo *data; - - data = (GuideUndo *) undo->data; - - data->guide->ref_count--; - if (data->guide->position < 0 && data->guide->ref_count <= 0) - { - gimp_image_remove_guide (gimage, data->guide); - g_free (data->guide); - } - g_free (data); -} - - -/***************/ -/* Mask Undo */ -/***************/ - -typedef struct _MaskUndo MaskUndo; - -struct _MaskUndo -{ - GimpChannel *channel; /* the channel this undo is for */ - TileManager *tiles; /* the actual mask */ - gint x, y; /* offsets */ -}; - -static gboolean undo_pop_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_mask (GimpImage *gimage, - GimpChannel *mask) -{ - TileManager *undo_tiles; - gint x1, y1, x2, y2; - GimpUndo *new; - gsize size; - - if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2)) - { - PixelRegion srcPR, destPR; - - undo_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1); - - pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles, - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, undo_tiles, - 0, 0, (x2 - x1), (y2 - y1), TRUE); - - copy_region (&srcPR, &destPR); - } - else - undo_tiles = NULL; - - size = sizeof (MaskUndo); - - if (undo_tiles) - size += tile_manager_get_memsize (undo_tiles); - - if ((new = gimp_image_undo_push (gimage, - size, sizeof (MaskUndo), - GIMP_UNDO_MASK, NULL, - FALSE, - undo_pop_mask, - undo_free_mask))) - { - MaskUndo *mask_undo; - - mask_undo = new->data; - - mask_undo->channel = mask; - mask_undo->tiles = undo_tiles; - mask_undo->x = x1; - mask_undo->y = y1; - - return TRUE; - } - - if (undo_tiles) - tile_manager_destroy (undo_tiles); - - return FALSE; -} - -static gboolean -undo_pop_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - MaskUndo *mask_undo; - TileManager *new_tiles; - PixelRegion srcPR, destPR; - gint x1, y1, x2, y2; - gint width, height; - guchar empty = 0; - - width = height = 0; - - mask_undo = (MaskUndo *) undo->data; - - if (gimp_channel_bounds (mask_undo->channel, &x1, &y1, &x2, &y2)) - { - new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1); - - pixel_region_init (&srcPR, GIMP_DRAWABLE (mask_undo->channel)->tiles, - x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, new_tiles, - 0, 0, (x2 - x1), (y2 - y1), TRUE); - - copy_region (&srcPR, &destPR); - - pixel_region_init (&srcPR, GIMP_DRAWABLE (mask_undo->channel)->tiles, - x1, y1, (x2 - x1), (y2 - y1), TRUE); - - color_region (&srcPR, &empty); - } - else - new_tiles = NULL; - - if (mask_undo->tiles) - { - width = tile_manager_width (mask_undo->tiles); - height = tile_manager_height (mask_undo->tiles); - - pixel_region_init (&srcPR, mask_undo->tiles, - 0, 0, width, height, FALSE); - pixel_region_init (&destPR, GIMP_DRAWABLE (mask_undo->channel)->tiles, - mask_undo->x, mask_undo->y, width, height, TRUE); - - copy_region (&srcPR, &destPR); - - tile_manager_destroy (mask_undo->tiles); - } - - if (mask_undo->channel == gimp_image_get_mask (gimage)) - { - /* invalidate the current bounds and boundary of the mask */ - gimp_image_mask_invalidate (gimage); - } - else - { - mask_undo->channel->boundary_known = FALSE; - GIMP_DRAWABLE (mask_undo->channel)->preview_valid = FALSE; - } - - if (mask_undo->tiles) - { - mask_undo->channel->empty = FALSE; - mask_undo->channel->x1 = mask_undo->x; - mask_undo->channel->y1 = mask_undo->y; - mask_undo->channel->x2 = mask_undo->x + width; - mask_undo->channel->y2 = mask_undo->y + height; - } - else - { - mask_undo->channel->empty = TRUE; - mask_undo->channel->x1 = 0; - mask_undo->channel->y1 = 0; - mask_undo->channel->x2 = GIMP_DRAWABLE (mask_undo->channel)->width; - mask_undo->channel->y2 = GIMP_DRAWABLE (mask_undo->channel)->height; - } - - /* we know the bounds */ - mask_undo->channel->bounds_known = TRUE; - - /* set the new mask undo parameters */ - mask_undo->tiles = new_tiles; - mask_undo->x = x1; - mask_undo->y = y1; - - if (mask_undo->channel == gimp_image_get_mask (gimage)) - { - accum->mask_changed = TRUE; - } - else - { - gimp_drawable_update (GIMP_DRAWABLE (mask_undo->channel), - 0, 0, - GIMP_DRAWABLE (mask_undo->channel)->width, - GIMP_DRAWABLE (mask_undo->channel)->height); - } - - return TRUE; -} - -static void -undo_free_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - MaskUndo *mask_undo; - - mask_undo = (MaskUndo *) undo->data; - - if (mask_undo->tiles) - tile_manager_destroy (mask_undo->tiles); - g_free (mask_undo); -} - - -/**********************/ -/* Item Rename Undo */ -/**********************/ - -typedef struct _ItemRenameUndo ItemRenameUndo; - -struct _ItemRenameUndo -{ - GimpItem *item; - gchar *old_name; -}; - -static gboolean undo_pop_item_rename (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_item_rename (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_item_rename (GimpImage *gimage, - GimpItem *item) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ItemRenameUndo), - sizeof (ItemRenameUndo), - GIMP_UNDO_ITEM_RENAME, NULL, - TRUE, - undo_pop_item_rename, - undo_free_item_rename))) - { - ItemRenameUndo *iru; - - iru = new->data; - - new->data = iru; - - iru->item = item; - iru->old_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item))); - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_item_rename (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ItemRenameUndo *iru; - gchar *tmp; - - iru = (ItemRenameUndo *) undo->data; - - tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (iru->item))); - gimp_object_set_name (GIMP_OBJECT (iru->item), iru->old_name); - g_free (iru->old_name); - iru->old_name = tmp; - - return TRUE; -} - -static void -undo_free_item_rename (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - ItemRenameUndo *iru; - - iru = (ItemRenameUndo *) undo->data; - - g_free (iru->old_name); - g_free (iru); -} - - -/***************************/ -/* Layer Add/Remove Undo */ -/***************************/ - -typedef struct _LayerUndo LayerUndo; - -struct _LayerUndo -{ - GimpLayer *layer; /* the actual layer */ - gint prev_position; /* former position in list */ - GimpLayer *prev_layer; /* previous active layer */ -}; - -static gboolean undo_push_layer (GimpImage *gimage, - GimpUndoType type, - GimpLayer *layer, - gint prev_position, - GimpLayer *prev_layer); -static gboolean undo_pop_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_layer_add (GimpImage *gimage, - GimpLayer *layer, - gint prev_position, - GimpLayer *prev_layer) -{ - return undo_push_layer (gimage, GIMP_UNDO_LAYER_ADD, - layer, prev_position, prev_layer); -} - -gboolean -undo_push_layer_remove (GimpImage *gimage, - GimpLayer *layer, - gint prev_position, - GimpLayer *prev_layer) -{ - return undo_push_layer (gimage, GIMP_UNDO_LAYER_REMOVE, - layer, prev_position, prev_layer); -} - -static gboolean -undo_push_layer (GimpImage *gimage, - GimpUndoType type, - GimpLayer *layer, - gint prev_position, - GimpLayer *prev_layer) -{ - GimpUndo *new; - gsize size; - - g_return_val_if_fail (type == GIMP_UNDO_LAYER_ADD || - type == GIMP_UNDO_LAYER_REMOVE, - FALSE); - - size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer)); - - if ((new = gimp_image_undo_push (gimage, - size, sizeof (LayerUndo), - type, NULL, - TRUE, - undo_pop_layer, - undo_free_layer))) - { - LayerUndo *lu; - - lu = new->data; - - lu->layer = g_object_ref (layer); - lu->prev_position = prev_position; - lu->prev_layer = prev_layer; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - LayerUndo *lu; - - lu = (LayerUndo *) undo->data; - - if ((undo_mode == GIMP_UNDO_MODE_UNDO && - undo->undo_type == GIMP_UNDO_LAYER_ADD) || - (undo_mode == GIMP_UNDO_MODE_REDO && - undo->undo_type == GIMP_UNDO_LAYER_REMOVE)) - { - /* remove layer */ - - /* record the current position */ - lu->prev_position = gimp_image_get_layer_index (gimage, lu->layer); - - /* if exists, set the previous layer */ - if (lu->prev_layer) - gimp_image_set_active_layer (gimage, lu->prev_layer); - - /* remove the layer */ - gimp_container_remove (gimage->layers, GIMP_OBJECT (lu->layer)); - gimage->layer_stack = g_slist_remove (gimage->layer_stack, lu->layer); - - /* reset the gimage values */ - if (gimp_layer_is_floating_sel (lu->layer)) - { - gimage->floating_sel = NULL; - /* reset the old drawable */ - floating_sel_reset (lu->layer); - - gimp_image_floating_selection_changed (gimage); - } - - gimp_drawable_update (GIMP_DRAWABLE (lu->layer), - 0, 0, - GIMP_DRAWABLE (lu->layer)->width, - GIMP_DRAWABLE (lu->layer)->height); - - if (gimp_container_num_children (gimage->layers) == 1 && - ! gimp_drawable_has_alpha (GIMP_LIST (gimage->layers)->list->data)) - { - accum->alpha_changed = TRUE; - } - } - else - { - /* restore layer */ - - /* record the active layer */ - lu->prev_layer = gimp_image_get_active_layer (gimage); - - /* hide the current selection--for all views */ - if (gimp_image_get_active_layer (gimage)) - gimp_layer_invalidate_boundary (gimp_image_get_active_layer (gimage)); - - /* if this is a floating selection, set the fs pointer */ - if (gimp_layer_is_floating_sel (lu->layer)) - gimage->floating_sel = lu->layer; - - if (gimp_container_num_children (gimage->layers) == 1 && - ! gimp_drawable_has_alpha (GIMP_LIST (gimage->layers)->list->data)) - { - accum->alpha_changed = TRUE; - } - - /* add the new layer */ - gimp_container_insert (gimage->layers, - GIMP_OBJECT (lu->layer), lu->prev_position); - gimp_image_set_active_layer (gimage, lu->layer); - - if (gimp_layer_is_floating_sel (lu->layer)) - gimp_image_floating_selection_changed (gimage); - - gimp_drawable_update (GIMP_DRAWABLE (lu->layer), - 0, 0, - GIMP_DRAWABLE (lu->layer)->width, - GIMP_DRAWABLE (lu->layer)->height); - } - - return TRUE; -} - -static void -undo_free_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - LayerUndo *lu; - - lu = (LayerUndo *) undo->data; - - g_object_unref (lu->layer); - g_free (lu); -} - - -/********************/ -/* Layer Mod Undo */ -/********************/ - -typedef struct _LayerModUndo LayerModUndo; - -struct _LayerModUndo -{ - GimpLayer *layer; - TileManager *tiles; - GimpImageType type; - gint offset_x; - gint offset_y; -}; - -static gboolean undo_pop_layer_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_layer_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_layer_mod (GimpImage *gimage, - GimpLayer *layer) -{ - GimpUndo *new; - TileManager *tiles; - gsize size; - - tiles = GIMP_DRAWABLE (layer)->tiles; - - size = sizeof (LayerModUndo) + tile_manager_get_memsize (tiles); - - if ((new = gimp_image_undo_push (gimage, - size, sizeof (LayerModUndo), - GIMP_UNDO_LAYER_MOD, NULL, - TRUE, - undo_pop_layer_mod, - undo_free_layer_mod))) - { - LayerModUndo *lmu; - - lmu = new->data; - - lmu->layer = layer; - lmu->tiles = tiles; - lmu->type = GIMP_DRAWABLE (layer)->type; - lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x; - lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y; - - return TRUE; - } - - tile_manager_destroy (tiles); - - return FALSE; -} - -static gboolean -undo_pop_layer_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - LayerModUndo *lmu; - GimpImageType layer_type; - gint offset_x, offset_y; - TileManager *tiles; - GimpLayer *layer; - - lmu = (LayerModUndo *) undo->data; - - layer = lmu->layer; - - /* Issue the first update */ - gimp_image_update (gimage, - GIMP_DRAWABLE (layer)->offset_x, - GIMP_DRAWABLE (layer)->offset_y, - GIMP_DRAWABLE (layer)->width, - GIMP_DRAWABLE (layer)->height); - - tiles = lmu->tiles; - layer_type = lmu->type; - offset_x = lmu->offset_x; - offset_y = lmu->offset_y; - - lmu->tiles = GIMP_DRAWABLE (layer)->tiles; - lmu->type = GIMP_DRAWABLE (layer)->type; - lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x; - lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y; - - GIMP_DRAWABLE (layer)->tiles = tiles; - GIMP_DRAWABLE (layer)->width = tile_manager_width (tiles); - GIMP_DRAWABLE (layer)->height = tile_manager_height (tiles); - GIMP_DRAWABLE (layer)->bytes = tile_manager_bpp (tiles); - GIMP_DRAWABLE (layer)->type = layer_type; - GIMP_DRAWABLE (layer)->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type); - GIMP_DRAWABLE (layer)->offset_x = offset_x; - GIMP_DRAWABLE (layer)->offset_y = offset_y; - - if (layer->mask) - { - GIMP_DRAWABLE (layer->mask)->offset_x = offset_x; - GIMP_DRAWABLE (layer->mask)->offset_y = offset_y; - } - - if (GIMP_IMAGE_TYPE_HAS_ALPHA (GIMP_DRAWABLE (layer)->type) != - GIMP_IMAGE_TYPE_HAS_ALPHA (lmu->type) && - GIMP_ITEM (layer)->gimage->layers->num_children == 1) - { - gimp_image_alpha_changed (GIMP_ITEM (layer)->gimage); - } - - if (GIMP_DRAWABLE (layer)->width != tile_manager_width (lmu->tiles) || - GIMP_DRAWABLE (layer)->height != tile_manager_height (lmu->tiles)) - { - gimp_viewable_size_changed (GIMP_VIEWABLE (layer)); - } - - /* Issue the second update */ - gimp_drawable_update (GIMP_DRAWABLE (layer), - 0, 0, - GIMP_DRAWABLE (layer)->width, - GIMP_DRAWABLE (layer)->height); - - return TRUE; -} - -static void -undo_free_layer_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - LayerModUndo *lmu; - - lmu = (LayerModUndo *) undo->data; - - tile_manager_destroy (lmu->tiles); - g_free (lmu); -} - - -/********************************/ -/* Layer Mask Add/Remove Undo */ -/********************************/ - -typedef struct _LayerMaskUndo LayerMaskUndo; - -struct _LayerMaskUndo -{ - GimpLayer *layer; /* the layer */ - GimpLayerMask *mask; /* the layer mask */ -}; - -static gboolean undo_push_layer_mask (GimpImage *gimage, - GimpUndoType type, - GimpLayer *layer, - GimpLayerMask *mask); -static gboolean undo_pop_layer_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_layer_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_layer_mask_add (GimpImage *gimage, - GimpLayer *layer, - GimpLayerMask *mask) -{ - return undo_push_layer_mask (gimage, GIMP_UNDO_LAYER_MASK_ADD, - layer, mask); -} - -gboolean -undo_push_layer_mask_remove (GimpImage *gimage, - GimpLayer *layer, - GimpLayerMask *mask) -{ - return undo_push_layer_mask (gimage, GIMP_UNDO_LAYER_MASK_REMOVE, - layer, mask); -} - -static gboolean -undo_push_layer_mask (GimpImage *gimage, - GimpUndoType type, - GimpLayer *layer, - GimpLayerMask *mask) -{ - GimpUndo *new; - gsize size; - - g_return_val_if_fail (type == GIMP_UNDO_LAYER_MASK_ADD || - type == GIMP_UNDO_LAYER_MASK_REMOVE, - FALSE); - - size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask)); - - if ((new = gimp_image_undo_push (gimage, - size, - sizeof (LayerMaskUndo), - type, NULL, - TRUE, - undo_pop_layer_mask, - undo_free_layer_mask))) - { - LayerMaskUndo *lmu; - - lmu = new->data; - - lmu->layer = g_object_ref (mask); - lmu->mask = mask; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_layer_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - LayerMaskUndo *lmu; - - lmu = (LayerMaskUndo *) undo->data; - - if ((undo_mode == GIMP_UNDO_MODE_UNDO && - undo->undo_type == GIMP_UNDO_LAYER_MASK_ADD) || - (undo_mode == GIMP_UNDO_MODE_REDO && - undo->undo_type == GIMP_UNDO_LAYER_MASK_REMOVE)) - { - /* remove layer mask */ - - gimp_layer_apply_mask (lmu->layer, GIMP_MASK_DISCARD, FALSE); - } - else - { - /* restore layer */ - - gimp_layer_add_mask (lmu->layer, lmu->mask, FALSE); - } - - return TRUE; -} - -static void -undo_free_layer_mask (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - LayerMaskUndo *lmu; - - lmu = (LayerMaskUndo *) undo->data; - - g_object_unref (lmu->mask); - g_free (lmu); -} - - -/***************************/ -/* Layer re-position Undo */ -/***************************/ - -typedef struct _LayerRepositionUndo LayerRepositionUndo; - -struct _LayerRepositionUndo -{ - GimpLayer *layer; - gint old_position; -}; - -static gboolean undo_pop_layer_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_layer_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_layer_reposition (GimpImage *gimage, - GimpLayer *layer) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (LayerRepositionUndo), - sizeof (LayerRepositionUndo), - GIMP_UNDO_LAYER_REPOSITION, NULL, - TRUE, - undo_pop_layer_reposition, - undo_free_layer_reposition))) - { - LayerRepositionUndo *lru; - - lru = new->data; - - lru->layer = layer; - lru->old_position = gimp_image_get_layer_index (gimage, layer); - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_layer_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - LayerRepositionUndo *lru; - gint pos; - - lru = (LayerRepositionUndo *) undo->data; - - /* what's the layer's current index? */ - pos = gimp_image_get_layer_index (gimage, lru->layer); - gimp_image_position_layer (gimage, lru->layer, lru->old_position, FALSE); - - lru->old_position = pos; - - return TRUE; -} - -static void -undo_free_layer_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/*****************************/ -/* Layer displacement Undo */ -/*****************************/ - -typedef struct _LayerDisplaceUndo LayerDisplaceUndo; - -struct _LayerDisplaceUndo -{ - GimpLayer *layer; - gint offset_x; - gint offset_y; - GSList *path_undo; -}; - -static gboolean undo_pop_layer_displace (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_layer_displace (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_layer_displace (GimpImage *gimage, - GimpLayer *layer) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (LayerDisplaceUndo), - sizeof (LayerDisplaceUndo), - GIMP_UNDO_LAYER_DISPLACE, NULL, - TRUE, - undo_pop_layer_displace, - undo_free_layer_displace))) - { - LayerDisplaceUndo *ldu; - - ldu = new->data; - - ldu->layer = g_object_ref (layer); - ldu->offset_x = GIMP_DRAWABLE (layer)->offset_x; - ldu->offset_y = GIMP_DRAWABLE (layer)->offset_y; - ldu->path_undo = path_transform_start_undo (gimage); - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_layer_displace (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - LayerDisplaceUndo *ldu; - GimpLayer *layer; - gint old_offset_x; - gint old_offset_y; - - ldu = (LayerDisplaceUndo *) undo->data; - - layer = ldu->layer; - - old_offset_x = GIMP_DRAWABLE (layer)->offset_x; - old_offset_y = GIMP_DRAWABLE (layer)->offset_y; - gimp_drawable_update (GIMP_DRAWABLE (layer), - 0, 0, - GIMP_DRAWABLE (layer)->width, - GIMP_DRAWABLE (layer)->height); - - GIMP_DRAWABLE (layer)->offset_x = ldu->offset_x; - GIMP_DRAWABLE (layer)->offset_y = ldu->offset_y; - gimp_drawable_update (GIMP_DRAWABLE (layer), - 0, 0, - GIMP_DRAWABLE (layer)->width, - GIMP_DRAWABLE (layer)->height); - - if (layer->mask) - { - GIMP_DRAWABLE (layer->mask)->offset_x = ldu->offset_x; - GIMP_DRAWABLE (layer->mask)->offset_y = ldu->offset_y; - gimp_drawable_update (GIMP_DRAWABLE (layer->mask), - 0, 0, - GIMP_DRAWABLE (layer->mask)->width, - GIMP_DRAWABLE (layer->mask)->height); - } - - /* invalidate the selection boundary because of a layer modification */ - gimp_layer_invalidate_boundary (layer); - - ldu->offset_x = old_offset_x; - ldu->offset_y = old_offset_y; - - /* Now undo paths bits */ - if (ldu->path_undo) - path_transform_do_undo (gimage, ldu->path_undo); - - return TRUE; -} - -static void -undo_free_layer_displace (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - LayerDisplaceUndo *ldu; - - ldu = (LayerDisplaceUndo *) undo->data; - - g_object_unref (ldu->layer); - - if (ldu->path_undo) - path_transform_free_undo (ldu->path_undo); - - g_free (ldu); -} - - -/*****************************/ -/* Add/Remove Channel Undo */ -/*****************************/ - -typedef struct _ChannelUndo ChannelUndo; - -struct _ChannelUndo -{ - GimpChannel *channel; /* the actual channel */ - gint prev_position; /* former position in list */ - GimpChannel *prev_channel; /* previous active channel */ -}; - -static gboolean undo_push_channel (GimpImage *gimage, - GimpUndoType type, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel); -static gboolean undo_pop_channel (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_channel (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_channel_add (GimpImage *gimage, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel) -{ - return undo_push_channel (gimage, GIMP_UNDO_CHANNEL_ADD, - channel, prev_position, prev_channel); -} - -gboolean -undo_push_channel_remove (GimpImage *gimage, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel) -{ - return undo_push_channel (gimage, GIMP_UNDO_CHANNEL_REMOVE, - channel, prev_position, prev_channel); -} - -static gboolean -undo_push_channel (GimpImage *gimage, - GimpUndoType type, - GimpChannel *channel, - gint prev_position, - GimpChannel *prev_channel) -{ - GimpUndo *new; - gsize size; - - g_return_val_if_fail (type == GIMP_UNDO_CHANNEL_ADD || - type == GIMP_UNDO_CHANNEL_REMOVE, - FALSE); - - size = sizeof (ChannelUndo) + gimp_object_get_memsize (GIMP_OBJECT (channel)); - - if ((new = gimp_image_undo_push (gimage, - size, - sizeof (ChannelUndo), - type, NULL, - TRUE, - undo_pop_channel, - undo_free_channel))) - { - ChannelUndo *cu; - - cu = new->data; - - cu->channel = g_object_ref (channel); - cu->prev_position = prev_position; - cu->prev_channel = prev_channel; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_channel (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ChannelUndo *cu; - - cu = (ChannelUndo *) undo->data; - - if ((undo_mode == GIMP_UNDO_MODE_UNDO && - undo->undo_type == GIMP_UNDO_CHANNEL_ADD) || - (undo_mode == GIMP_UNDO_MODE_REDO && - undo->undo_type == GIMP_UNDO_CHANNEL_REMOVE)) - { - /* remove channel */ - - /* record the current position */ - cu->prev_position = gimp_image_get_channel_index (gimage, cu->channel); - - /* remove the channel */ - gimp_container_remove (gimage->channels, GIMP_OBJECT (cu->channel)); - - /* if exists, set the previous channel */ - if (cu->prev_channel) - gimp_image_set_active_channel (gimage, cu->prev_channel); - - /* update the area */ - gimp_drawable_update (GIMP_DRAWABLE (cu->channel), - 0, 0, - GIMP_DRAWABLE (cu->channel)->width, - GIMP_DRAWABLE (cu->channel)->height); - } - else - { - /* restore channel */ - - /* record the active channel */ - cu->prev_channel = gimp_image_get_active_channel (gimage); - - /* add the new channel */ - gimp_container_insert (gimage->channels, - GIMP_OBJECT (cu->channel), cu->prev_position); - - /* set the new channel */ - gimp_image_set_active_channel (gimage, cu->channel); - - /* update the area */ - gimp_drawable_update (GIMP_DRAWABLE (cu->channel), - 0, 0, - GIMP_DRAWABLE (cu->channel)->width, - GIMP_DRAWABLE (cu->channel)->height); - } - - return TRUE; -} - -static void -undo_free_channel (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - ChannelUndo *cu; - - cu = (ChannelUndo *) undo->data; - - g_object_unref (cu->channel); - - g_free (cu); -} - - -/**********************/ -/* Channel Mod Undo */ -/**********************/ - -typedef struct _ChannelModUndo ChannelModUndo; - -struct _ChannelModUndo -{ - GimpChannel *channel; - TileManager *tiles; -}; - -static gboolean undo_pop_channel_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_channel_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_channel_mod (GimpImage *gimage, - GimpChannel *channel) -{ - TileManager *tiles; - GimpUndo *new; - gsize size; - - tiles = GIMP_DRAWABLE (channel)->tiles; - - size = sizeof (ChannelModUndo) + tile_manager_get_memsize (tiles); - - if ((new = gimp_image_undo_push (gimage, - size, - sizeof (ChannelModUndo), - GIMP_UNDO_CHANNEL_MOD, NULL, - TRUE, - undo_pop_channel_mod, - undo_free_channel_mod))) - { - ChannelModUndo *cmu; - - cmu = new->data; - - cmu->channel = channel; - cmu->tiles = tiles; - - return TRUE; - } - - tile_manager_destroy (tiles); - - return FALSE; -} - -static gboolean -undo_pop_channel_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ChannelModUndo *cmu; - TileManager *tiles; - GimpChannel *channel; - - cmu = (ChannelModUndo *) undo->data; - - channel = cmu->channel; - - /* Issue the first update */ - gimp_drawable_update (GIMP_DRAWABLE (channel), - 0, 0, - GIMP_DRAWABLE (channel)->width, - GIMP_DRAWABLE (channel)->height); - - tiles = cmu->tiles; - - cmu->tiles = GIMP_DRAWABLE (channel)->tiles; - - GIMP_DRAWABLE (channel)->tiles = tiles; - GIMP_DRAWABLE (channel)->width = tile_manager_width (tiles); - GIMP_DRAWABLE (channel)->height = tile_manager_height (tiles); - GIMP_CHANNEL (channel)->bounds_known = FALSE; - - if (GIMP_DRAWABLE (channel)->width != tile_manager_width (cmu->tiles) || - GIMP_DRAWABLE (channel)->height != tile_manager_height (cmu->tiles)) - { - gimp_viewable_size_changed (GIMP_VIEWABLE (channel)); - } - - /* Issue the second update */ - gimp_drawable_update (GIMP_DRAWABLE (channel), - 0, 0, - GIMP_DRAWABLE (channel)->width, - GIMP_DRAWABLE (channel)->height); - - return TRUE; -} - -static void -undo_free_channel_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - ChannelModUndo *cmu; - - cmu = (ChannelModUndo *) undo->data; - - tile_manager_destroy (cmu->tiles); - - g_free (cmu); -} - - -/******************************/ -/* Channel re-position Undo */ -/******************************/ - -typedef struct _ChannelRepositionUndo ChannelRepositionUndo; - -struct _ChannelRepositionUndo -{ - GimpChannel *channel; - gint old_position; -}; - -static gboolean undo_pop_channel_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_channel_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_channel_reposition (GimpImage *gimage, - GimpChannel *channel) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ChannelRepositionUndo), - sizeof (ChannelRepositionUndo), - GIMP_UNDO_CHANNEL_REPOSITION, NULL, - TRUE, - undo_pop_channel_reposition, - undo_free_channel_reposition))) - { - ChannelRepositionUndo *cru; - - cru = new->data; - - cru->channel = channel; - cru->old_position = gimp_image_get_channel_index (gimage, channel); - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_channel_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ChannelRepositionUndo *cru; - gint pos; - - cru = (ChannelRepositionUndo *) undo->data; - - /* what's the channel's current index? */ - pos = gimp_image_get_channel_index (gimage, cru->channel); - gimp_image_position_channel (gimage, cru->channel, cru->old_position, FALSE); - - cru->old_position = pos; - - return TRUE; -} - -static void -undo_free_channel_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/*****************************/ -/* Add/Remove Vectors Undo */ -/*****************************/ - -typedef struct _VectorsUndo VectorsUndo; - -struct _VectorsUndo -{ - GimpVectors *vectors; /* the actual vectors */ - gint prev_position; /* former position in list */ - GimpVectors *prev_vectors; /* previous active vectors */ -}; - -static gboolean undo_push_vectors (GimpImage *gimage, - GimpUndoType type, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors); -static gboolean undo_pop_vectors (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_vectors (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_vectors_add (GimpImage *gimage, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors) -{ - return undo_push_vectors (gimage, GIMP_UNDO_VECTORS_ADD, - vectors, prev_position, prev_vectors); -} - -gboolean -undo_push_vectors_remove (GimpImage *gimage, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors) -{ - return undo_push_vectors (gimage, GIMP_UNDO_VECTORS_REMOVE, - vectors, prev_position, prev_vectors); -} - -static gboolean -undo_push_vectors (GimpImage *gimage, - GimpUndoType type, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors) -{ - GimpUndo *new; - gsize size; - - g_return_val_if_fail (type == GIMP_UNDO_VECTORS_ADD || - type == GIMP_UNDO_VECTORS_REMOVE, - FALSE); - - size = sizeof (VectorsUndo) + gimp_object_get_memsize (GIMP_OBJECT (vectors)); - - if ((new = gimp_image_undo_push (gimage, - size, - sizeof (VectorsUndo), - type, NULL, - TRUE, - undo_pop_vectors, - undo_free_vectors))) - { - VectorsUndo *vu; - - vu = new->data; - - vu->vectors = g_object_ref (vectors); - vu->prev_position = prev_position; - vu->prev_vectors = prev_vectors; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_vectors (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - VectorsUndo *vu; - - vu = (VectorsUndo *) undo->data; - - if ((undo_mode == GIMP_UNDO_MODE_UNDO && - undo->undo_type == GIMP_UNDO_VECTORS_ADD) || - (undo_mode == GIMP_UNDO_MODE_REDO && - undo->undo_type == GIMP_UNDO_VECTORS_REMOVE)) - { - /* remove vectors */ - - /* record the current position */ - vu->prev_position = gimp_image_get_vectors_index (gimage, vu->vectors); - - /* remove the vectors */ - gimp_container_remove (gimage->vectors, GIMP_OBJECT (vu->vectors)); - - /* if exists, set the previous vectors */ - if (vu->prev_vectors) - gimp_image_set_active_vectors (gimage, vu->prev_vectors); - } - else - { - /* restore vectors */ - - /* record the active vectors */ - vu->prev_vectors = gimp_image_get_active_vectors (gimage); - - /* add the new vectors */ - gimp_container_insert (gimage->vectors, - GIMP_OBJECT (vu->vectors), vu->prev_position); - - /* set the new vectors */ - gimp_image_set_active_vectors (gimage, vu->vectors); - } - - return TRUE; -} - -static void -undo_free_vectors (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - VectorsUndo *vu; - - vu = (VectorsUndo *) undo->data; - - g_object_unref (vu->vectors); - - g_free (vu); -} - - -/**********************/ -/* Vectors Mod Undo */ -/**********************/ - -typedef struct _VectorsModUndo VectorsModUndo; - -struct _VectorsModUndo -{ - GimpVectors *vectors; - GimpVectors *undo_vectors; -}; - -static gboolean undo_pop_vectors_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_vectors_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_vectors_mod (GimpImage *gimage, - GimpVectors *vectors) -{ - GimpUndo *new; - gsize size; - - size = (sizeof (VectorsModUndo) + - gimp_object_get_memsize (GIMP_OBJECT (vectors))); - - if ((new = gimp_image_undo_push (gimage, - size, - sizeof (VectorsModUndo), - GIMP_UNDO_VECTORS_MOD, NULL, - TRUE, - undo_pop_vectors_mod, - undo_free_vectors_mod))) - { - VectorsModUndo *vmu; - - vmu = new->data; - - vmu->vectors = vectors; - vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors), - G_TYPE_FROM_INSTANCE (vectors), - FALSE)); - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_vectors_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - VectorsModUndo *vmu; - GimpVectors *temp; - - vmu = (VectorsModUndo *) undo->data; - - temp = vmu->undo_vectors; - - vmu->undo_vectors = - GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vmu->vectors), - G_TYPE_FROM_INSTANCE (vmu->vectors), - FALSE)); - - gimp_vectors_copy_strokes (temp, vmu->vectors); - - g_object_unref (temp); - - return TRUE; -} - -static void -undo_free_vectors_mod (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - VectorsModUndo *vmu; - - vmu = (VectorsModUndo *) undo->data; - - g_object_unref (vmu->undo_vectors); - - g_free (vmu); -} - - -/******************************/ -/* Vectors re-position Undo */ -/******************************/ - -typedef struct _VectorsRepositionUndo VectorsRepositionUndo; - -struct _VectorsRepositionUndo -{ - GimpVectors *vectors; - gint old_position; -}; - -static gboolean undo_pop_vectors_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_vectors_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_vectors_reposition (GimpImage *gimage, - GimpVectors *vectors) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (VectorsRepositionUndo), - sizeof (VectorsRepositionUndo), - GIMP_UNDO_VECTORS_REPOSITION, NULL, - TRUE, - undo_pop_vectors_reposition, - undo_free_vectors_reposition))) - { - VectorsRepositionUndo *vru; - - vru = new->data; - - vru->vectors = vectors; - vru->old_position = gimp_image_get_vectors_index (gimage, vectors); - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_vectors_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - VectorsRepositionUndo *vru; - gint pos; - - vru = (VectorsRepositionUndo *) undo->data; - - /* what's the vectors's current index? */ - pos = gimp_image_get_vectors_index (gimage, vru->vectors); - gimp_image_position_vectors (gimage, vru->vectors, vru->old_position, FALSE); - - vru->old_position = pos; - - return TRUE; -} - -static void -undo_free_vectors_reposition (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/**************************************/ -/* Floating Selection to Layer Undo */ -/**************************************/ - -typedef struct _FStoLayerUndo FStoLayerUndo; - -struct _FStoLayerUndo -{ - GimpLayer *floating_layer; /* the floating layer */ - GimpDrawable *drawable; /* drawable of floating sel */ -}; - -static gboolean undo_pop_fs_to_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_fs_to_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_fs_to_layer (GimpImage *gimage, - GimpLayer *floating_layer, - GimpDrawable *drawable) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (FStoLayerUndo), - sizeof (FStoLayerUndo), - GIMP_UNDO_FS_TO_LAYER, NULL, - TRUE, - undo_pop_fs_to_layer, - undo_free_fs_to_layer))) - { - FStoLayerUndo *fsu; - - fsu = new->data; - - fsu->floating_layer = floating_layer; - fsu->drawable = drawable; - - return TRUE; - } - - tile_manager_destroy (floating_layer->fs.backing_store); - floating_layer->fs.backing_store = NULL; - - return FALSE; -} - -static gboolean -undo_pop_fs_to_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - FStoLayerUndo *fsu; - - fsu = (FStoLayerUndo *) undo->data; - - switch (undo_mode) - { - case GIMP_UNDO_MODE_UNDO: - /* Update the preview for the floating sel */ - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer)); - - fsu->floating_layer->fs.drawable = fsu->drawable; - gimp_image_set_active_layer (gimage, fsu->floating_layer); - gimage->floating_sel = fsu->floating_layer; - - /* restore the contents of the drawable */ - floating_sel_store (fsu->floating_layer, - GIMP_DRAWABLE (fsu->floating_layer)->offset_x, - GIMP_DRAWABLE (fsu->floating_layer)->offset_y, - GIMP_DRAWABLE (fsu->floating_layer)->width, - GIMP_DRAWABLE (fsu->floating_layer)->height); - fsu->floating_layer->fs.initial = TRUE; - - /* clear the selection */ - gimp_layer_invalidate_boundary (fsu->floating_layer); - - /* Update the preview for the gimage and underlying drawable */ - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer)); - break; - - case GIMP_UNDO_MODE_REDO: - /* restore the contents of the drawable */ - floating_sel_restore (fsu->floating_layer, - GIMP_DRAWABLE (fsu->floating_layer)->offset_x, - GIMP_DRAWABLE (fsu->floating_layer)->offset_y, - GIMP_DRAWABLE (fsu->floating_layer)->width, - GIMP_DRAWABLE (fsu->floating_layer)->height); - - /* Update the preview for the gimage and underlying drawable */ - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer)); - - /* clear the selection */ - gimp_layer_invalidate_boundary (fsu->floating_layer); - - /* update the pointers */ - fsu->floating_layer->fs.drawable = NULL; - gimage->floating_sel = NULL; - - /* Update the fs drawable */ - gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer)); - break; - } - - gimp_image_floating_selection_changed (gimage); - - return TRUE; -} - -static void -undo_free_fs_to_layer (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - FStoLayerUndo *fsu; - - fsu = (FStoLayerUndo *) undo->data; - - if (undo_mode == GIMP_UNDO_MODE_UNDO) - { - tile_manager_destroy (fsu->floating_layer->fs.backing_store); - fsu->floating_layer->fs.backing_store = NULL; - } - - g_free (fsu); -} - - -/***********************************/ -/* Floating Selection Rigor Undo */ -/***********************************/ - -static gboolean undo_pop_fs_rigor (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_fs_rigor (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_fs_rigor (GimpImage *gimage, - gint layer_ID) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (gint32), - sizeof (gint32), - GIMP_UNDO_FS_RIGOR, NULL, - FALSE, - undo_pop_fs_rigor, - undo_free_fs_rigor))) - { - gint32 *id; - - id = new->data; - - *id = layer_ID; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_fs_rigor (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - gint32 layer_ID; - GimpLayer *floating_layer; - - layer_ID = *((gint32 *) undo->data); - - if ((floating_layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, layer_ID)) == NULL) - return FALSE; - - if (! gimp_layer_is_floating_sel (floating_layer)) - return FALSE; - - switch (undo_mode) - { - case GIMP_UNDO_MODE_UNDO: - /* restore the contents of drawable the floating layer is attached to */ - if (floating_layer->fs.initial == FALSE) - floating_sel_restore (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; - break; - - case GIMP_UNDO_MODE_REDO: - /* store the affected area from the drawable in the backing store */ - floating_sel_store (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; - break; - } - - gimp_image_floating_selection_changed (gimage); - - return TRUE; -} - -static void -undo_free_fs_rigor (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/***********************************/ -/* Floating Selection Relax Undo */ -/***********************************/ - -static gboolean undo_pop_fs_relax (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_fs_relax (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_fs_relax (GimpImage *gimage, - gint32 layer_ID) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (gint32), - sizeof (gint32), - GIMP_UNDO_FS_RELAX, NULL, - FALSE, - undo_pop_fs_relax, - undo_free_fs_relax))) - { - gint32 *id; - - id = new->data; - - *id = layer_ID; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_fs_relax (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - gint32 layer_ID; - GimpLayer *floating_layer; - - layer_ID = *((gint32 *) undo->data); - - if ((floating_layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, layer_ID)) == NULL) - return FALSE; - - if (! gimp_layer_is_floating_sel (floating_layer)) - return FALSE; - - switch (undo_mode) - { - case GIMP_UNDO_MODE_UNDO: - /* store the affected area from the drawable in the backing store */ - floating_sel_store (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; - break; - - case GIMP_UNDO_MODE_REDO: - /* restore the contents of drawable the floating layer is attached to */ - if (floating_layer->fs.initial == FALSE) - floating_sel_restore (floating_layer, - GIMP_DRAWABLE (floating_layer)->offset_x, - GIMP_DRAWABLE (floating_layer)->offset_y, - GIMP_DRAWABLE (floating_layer)->width, - GIMP_DRAWABLE (floating_layer)->height); - floating_layer->fs.initial = TRUE; - break; - } - - gimp_image_floating_selection_changed (gimage); - - return TRUE; -} - -static void -undo_free_fs_relax (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - g_free (undo->data); -} - - -/********************/ -/* Transform Undo */ -/********************/ - -typedef struct _TransformUndo TransformUndo; - -struct _TransformUndo -{ - gint tool_ID; - GType tool_type; - - TransInfo trans_info; - TileManager *original; - gpointer path_undo; -}; - -static gboolean undo_pop_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_transform (GimpImage *gimage, - gint tool_ID, - GType tool_type, - gdouble *trans_info, - TileManager *original, - GSList *path_undo) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (TransformUndo), - sizeof (TransformUndo), - GIMP_UNDO_TRANSFORM, NULL, - FALSE, - undo_pop_transform, - undo_free_transform))) - { - TransformUndo *tu; - gint i; - - tu = new->data; - - tu->tool_ID = tool_ID; - tu->tool_type = tool_type; - - for (i = 0; i < TRAN_INFO_SIZE; i++) - tu->trans_info[i] = trans_info[i]; - - tu->original = original; - tu->path_undo = path_undo; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - GimpTool *active_tool; - - active_tool = tool_manager_get_active (gimage->gimp); - - if (GIMP_IS_TRANSFORM_TOOL (active_tool)) - { - GimpTransformTool *tt; - TransformUndo *tu; - - tt = GIMP_TRANSFORM_TOOL (active_tool); - tu = (TransformUndo *) undo->data; - - path_transform_do_undo (gimage, tu->path_undo); - - /* only pop if the active tool is the tool that pushed this undo */ - if (tu->tool_ID == active_tool->ID) - { - TileManager *temp; - gdouble d; - gint i; - - /* swap the transformation information arrays */ - for (i = 0; i < TRAN_INFO_SIZE; i++) - { - d = tu->trans_info[i]; - tu->trans_info[i] = tt->trans_info[i]; - tt->trans_info[i] = d; - } - - /* swap the original buffer--the source buffer for repeated transforms - */ - temp = tu->original; - tu->original = tt->original; - tt->original = temp; - - /* If we're re-implementing the first transform, reactivate tool */ - if (undo_mode == GIMP_UNDO_MODE_REDO && tt->original) - { - gimp_tool_control_activate (active_tool->control); - - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt)); - } - } - } - - return TRUE; -} - -static void -undo_free_transform (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - TransformUndo * tu; - - tu = (TransformUndo *) undo->data; - - if (tu->original) - tile_manager_destroy (tu->original); - path_transform_free_undo (tu->path_undo); - g_free (tu); -} - - -/****************/ -/* Paint Undo */ -/****************/ - -typedef struct _PaintUndo PaintUndo; - -struct _PaintUndo -{ - gint core_ID; - GType core_type; - - GimpCoords last_coords; -}; - -static gboolean undo_pop_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_paint (GimpImage *gimage, - gint core_ID, - GType core_type, - GimpCoords *last_coords) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (PaintUndo), - sizeof (PaintUndo), - GIMP_UNDO_PAINT, NULL, - FALSE, - undo_pop_paint, - undo_free_paint))) - { - PaintUndo *pu; - - pu = new->data; - - pu->core_ID = core_ID; - pu->core_type = core_type; - pu->last_coords = *last_coords; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - GimpTool *active_tool; - - active_tool = tool_manager_get_active (gimage->gimp); - - if (GIMP_IS_PAINT_TOOL (active_tool)) - { - GimpPaintTool *pt; - PaintUndo *pu; - - pt = GIMP_PAINT_TOOL (active_tool); - pu = (PaintUndo *) undo->data; - - /* only pop if the active paint core is the one that pushed this undo */ - if (pu->core_ID == pt->core->ID) - { - GimpCoords tmp_coords; - - /* swap the paint core information */ - tmp_coords = pt->core->last_coords; - pt->core->last_coords = pu->last_coords; - pu->last_coords = tmp_coords; - } - } - - return TRUE; -} - -static void -undo_free_paint (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - PaintUndo *pu; - - pu = (PaintUndo *) undo->data; - - g_free (pu); -} - - -/*******************/ -/* Parasite Undo */ -/*******************/ - -typedef struct _ParasiteUndo ParasiteUndo; - -struct _ParasiteUndo -{ - GimpImage *gimage; - GimpItem *item; - GimpParasite *parasite; - gchar *name; -}; - -static gboolean undo_pop_parasite (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); -static void undo_free_parasite (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode); - -gboolean -undo_push_image_parasite (GimpImage *gimage, - gpointer parasite) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ParasiteUndo), - sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_ATTACH, NULL, - TRUE, - undo_pop_parasite, - undo_free_parasite))) - { - ParasiteUndo *pu; - - pu = new->data; - - pu->gimage = gimage; - pu->item = NULL; - pu->name = g_strdup (gimp_parasite_name (parasite)); - pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage, - pu->name)); - - return TRUE; - } - - return FALSE; -} - -gboolean -undo_push_image_parasite_remove (GimpImage *gimage, - const gchar *name) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ParasiteUndo), - sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_REMOVE, NULL, - TRUE, - undo_pop_parasite, - undo_free_parasite))) - { - ParasiteUndo *pu; - - pu = new->data; - - pu->gimage = gimage; - pu->item = NULL; - pu->name = g_strdup (name); - pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage, - pu->name)); - - return TRUE; - } - - return FALSE; -} - -gboolean -undo_push_item_parasite (GimpImage *gimage, - GimpItem *item, - gpointer parasite) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ParasiteUndo), - sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_ATTACH, NULL, - TRUE, - undo_pop_parasite, - undo_free_parasite))) - { - ParasiteUndo *pu; - - pu = new->data; - - pu->gimage = NULL; - pu->item = item; - pu->name = g_strdup (gimp_parasite_name (parasite)); - pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (item, - pu->name)); - return TRUE; - } - - return FALSE; -} - -gboolean -undo_push_item_parasite_remove (GimpImage *gimage, - GimpItem *item, - const gchar *name) -{ - GimpUndo *new; - - if ((new = gimp_image_undo_push (gimage, - sizeof (ParasiteUndo), - sizeof (ParasiteUndo), - GIMP_UNDO_PARASITE_REMOVE, NULL, - TRUE, - undo_pop_parasite, - undo_free_parasite))) - { - ParasiteUndo *pu; - - pu = new->data; - - pu->gimage = NULL; - pu->item = item; - pu->name = g_strdup (name); - pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (item, - pu->name)); - return TRUE; - } - - return FALSE; -} - - -static gboolean -undo_pop_parasite (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - ParasiteUndo *data; - GimpParasite *tmp; - - data = (ParasiteUndo *) undo->data; - - tmp = data->parasite; - - if (data->gimage) - { - data->parasite = - gimp_parasite_copy (gimp_image_parasite_find (gimage, data->name)); - - if (tmp) - gimp_parasite_list_add (data->gimage->parasites, tmp); - else - gimp_parasite_list_remove (data->gimage->parasites, data->name); - } - else if (data->item) - { - data->parasite = - gimp_parasite_copy (gimp_item_parasite_find (data->item, - data->name)); - if (tmp) - gimp_parasite_list_add (data->item->parasites, tmp); - else - gimp_parasite_list_remove (data->item->parasites, data->name); - } - else - { - data->parasite = gimp_parasite_copy (gimp_parasite_find (gimage->gimp, - data->name)); - if (tmp) - gimp_parasite_attach (gimage->gimp, tmp); - else - gimp_parasite_detach (gimage->gimp, data->name); - } - - if (tmp) - gimp_parasite_free (tmp); - - return TRUE; -} - - -static void -undo_free_parasite (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode) -{ - ParasiteUndo *pu; - - pu = (ParasiteUndo *) undo->data; - - if (pu->parasite) - gimp_parasite_free (pu->parasite); - if (pu->name) - g_free (pu->name); - - g_free (pu); -} - - -/******************************************************************************/ -/* Something for which programmer is too lazy to write an undo function for */ -/******************************************************************************/ - -static gboolean undo_pop_cantundo (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum); - -gboolean -undo_push_cantundo (GimpImage *gimage, - const gchar *action) -{ - GimpUndo *new; - - /* This is the sole purpose of this type of undo: the ability to - * mark an image as having been mutated, without really providing - * any adequate undo facility. - */ - - if ((new = gimp_image_undo_push (gimage, - 0, 0, - GIMP_UNDO_CANT, NULL, - TRUE, - undo_pop_cantundo, - NULL))) - { - new->data = (gpointer) action; - - return TRUE; - } - - return FALSE; -} - -static gboolean -undo_pop_cantundo (GimpUndo *undo, - GimpImage *gimage, - GimpUndoMode undo_mode, - GimpUndoAccumulator *accum) -{ - gchar *action = undo->data; - - switch (undo_mode) - { - case GIMP_UNDO_MODE_UNDO: - g_message (_("Can't undo %s"), action); - break; - - case GIMP_UNDO_MODE_REDO: - break; - } - - return TRUE; -} diff --git a/app/undo.h b/app/undo.h deleted file mode 100644 index ce3da3d1f5..0000000000 --- a/app/undo.h +++ /dev/null @@ -1,161 +0,0 @@ -/* 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 __UNDO_H__ -#define __UNDO_H__ - - -/* 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_type (GimpImage *gimage); -gboolean undo_push_image_size (GimpImage *gimage); -gboolean undo_push_image_resolution (GimpImage *gimage); -gboolean undo_push_image_qmask (GimpImage *gimage); -gboolean undo_push_image_guide (GimpImage *gimage, - GimpGuide *guide); - - -/* mask undo */ - -gboolean undo_push_mask (GimpImage *gimage, - GimpChannel *mask); - - -/* item undos */ - -gboolean undo_push_item_rename (GimpImage *gimage, - GimpItem *item); - - -/* 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_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); - - -/* vectors undos */ - -gboolean undo_push_vectors_add (GimpImage *gimage, - GimpVectors *vectors, - gint prev_position, - GimpVectors *prev_vectors); -gboolean undo_push_vectors_remove (GimpImage *gimage, - GimpVectors *channel, - gint prev_position, - GimpVectors *prev_vectors); -gboolean undo_push_vectors_mod (GimpImage *gimage, - GimpVectors *vectors); -gboolean undo_push_vectors_reposition (GimpImage *gimage, - GimpVectors *vectors); - - -/* 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_item_parasite (GimpImage *gimage, - GimpItem *item, - gpointer parasite); -gboolean undo_push_item_parasite_remove (GimpImage *gimage, - GimpItem *item, - const gchar *name); - - -/* EEK undo */ - -gboolean undo_push_cantundo (GimpImage *gimage, - const gchar *action); - - -#endif /* __UNDO_H__ */ diff --git a/app/undo_history.c b/app/undo_history.c index 702c197a33..423cc07ce7 100644 --- a/app/undo_history.c +++ b/app/undo_history.c @@ -74,8 +74,6 @@ #include "widgets/gimpviewabledialog.h" -#include "undo.h" - #include "libgimp/gimpintl.h" #include "pixmaps/yes.xpm" diff --git a/app/widgets/gimpchannellistview.c b/app/widgets/gimpchannellistview.c index 4d84f55fa1..e22c3767dc 100644 --- a/app/widgets/gimpchannellistview.c +++ b/app/widgets/gimpchannellistview.c @@ -325,6 +325,7 @@ gimp_channel_list_view_toselection_extended_clicked (GtkWidget *widget gimage = gimp_item_get_image (GIMP_ITEM (viewable)); gimp_image_mask_select_channel (gimage, + _("Channel to Selection"), GIMP_CHANNEL (viewable), 0, 0, operation, diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c index 4d84f55fa1..e22c3767dc 100644 --- a/app/widgets/gimpchanneltreeview.c +++ b/app/widgets/gimpchanneltreeview.c @@ -325,6 +325,7 @@ gimp_channel_list_view_toselection_extended_clicked (GtkWidget *widget gimage = gimp_item_get_image (GIMP_ITEM (viewable)); gimp_image_mask_select_channel (gimage, + _("Channel to Selection"), GIMP_CHANNEL (viewable), 0, 0, operation, diff --git a/app/widgets/gimpdrawablelistview.c b/app/widgets/gimpdrawablelistview.c index 18479a575e..6bbabf2724 100644 --- a/app/widgets/gimpdrawablelistview.c +++ b/app/widgets/gimpdrawablelistview.c @@ -49,8 +49,6 @@ #include "gimplistitem.h" #include "gimppreview.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c index 18479a575e..6bbabf2724 100644 --- a/app/widgets/gimpdrawabletreeview.c +++ b/app/widgets/gimpdrawabletreeview.c @@ -49,8 +49,6 @@ #include "gimplistitem.h" #include "gimppreview.h" -#include "undo.h" - #include "libgimp/gimpintl.h" diff --git a/app/widgets/gimpselectioneditor.c b/app/widgets/gimpselectioneditor.c index 387d79db74..e7ef4c5a8a 100644 --- a/app/widgets/gimpselectioneditor.c +++ b/app/widgets/gimpselectioneditor.c @@ -345,7 +345,7 @@ gimp_selection_editor_none_clicked (GtkWidget *widget, { if (editor->gimage) { - gimp_image_mask_clear (editor->gimage); + gimp_image_mask_clear (editor->gimage, NULL); gimp_image_flush (editor->gimage); } } diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 7b9535b798..36702d4dd6 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -74,7 +74,7 @@ HELP &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -157,7 +157,7 @@ HELP &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Levels")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -207,7 +207,7 @@ HELP &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -365,7 +365,7 @@ HELP &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -431,7 +431,7 @@ HELP &srcPR, &destPR); gimp_lut_free (lut); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Curves")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -505,7 +505,7 @@ HELP color_balance (&srcPR, &destPR, &cb); } - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -677,7 +677,7 @@ HELP hue_saturation (&srcPR, &destPR, &hs); } - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -728,7 +728,7 @@ HELP pixel_regions_process_parallel ((p_func) threshold_2, &tr, 2, &srcPR, &destPR); - gimp_drawable_merge_shadow (drawable, TRUE); + gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold")); gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1)); } } @@ -738,7 +738,8 @@ CODE @headers = qw("base/gimphistogram.h" "base/gimplut.h" "base/lut-funcs.h" "base/pixel-region.h" "base/pixel-processor.h" - "core/gimpdrawable.h" "core/gimpimage.h"); + "core/gimpdrawable.h" "core/gimpimage.h" + "libgimp/gimpintl.h"); @procs = qw(brightness_contrast levels posterize desaturate equalize invert curves_spline curves_explicit color_balance histogram diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb index 004c85cb19..4b1f100388 100644 --- a/tools/pdbgen/pdb/drawable.pdb +++ b/tools/pdbgen/pdb/drawable.pdb @@ -103,7 +103,7 @@ HELP desc => 'Push merge to undo stack?' } ); - %invoke = ( code => 'gimp_drawable_merge_shadow (drawable, undo);' ); + %invoke = ( code => 'gimp_drawable_merge_shadow (drawable, undo, _("Plug-In"));' ); } sub drawable_fill { @@ -541,7 +541,8 @@ CODE @headers = qw("core/gimp.h" "core/gimplayermask.h" "core/gimpchannel.h" "core/gimpdrawable.h" "core/gimpdrawable-offset.h" - "base/tile.h" "base/tile-manager.h" "base/temp-buf.h"); + "base/tile.h" "base/tile-manager.h" "base/temp-buf.h" + "libgimp/gimpintl.h"); @procs = qw(drawable_merge_shadow drawable_fill drawable_update drawable_mask_bounds drawable_image drawable_type diff --git a/tools/pdbgen/pdb/guides.pdb b/tools/pdbgen/pdb/guides.pdb index 9a7cee4678..4ed70219af 100644 --- a/tools/pdbgen/pdb/guides.pdb +++ b/tools/pdbgen/pdb/guides.pdb @@ -23,7 +23,7 @@ sub pdb_misc { } sub image_add_guide { - my ($desc, $type, $max, $pos) = @_; + my ($desc, $help_desc, $type, $max, $pos) = @_; $blurb = "Add a $desc guide to an image."; @@ -55,7 +55,7 @@ HELP if (offset < gimage->$max) { guide = gimp_image_add_${func}guide (gimage); - undo_push_image_guide (gimage, guide); + gimp_image_undo_push_image_guide (gimage, _("${help_desc}"), guide); guide->position = offset; guide_ID = guide->guide_ID; } @@ -69,11 +69,11 @@ CODE # The defs sub image_add_hguide { - &image_add_guide('horizontal', 'y', 'height', 'top'); + &image_add_guide('horizontal', 'Add Horizontal Guide', 'y', 'height', 'top'); } sub image_add_vguide { - &image_add_guide('vertical', 'x', 'width', 'left'); + &image_add_guide('vertical', 'Add Vertical Guide', 'x', 'width', 'left'); } sub image_delete_guide { @@ -93,31 +93,23 @@ HELP ); %invoke = ( - headers => [ qw("undo.h") ], vars => [ 'GList *guides' ], code => <<'CODE' { success = FALSE; - guides = gimage->guides; - - while (guides) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) + GimpGuide *g = (GimpGuide *) guides->data; + + if ((g->guide_ID == guide) && (g->position >= 0)) { - GList *tmp_next; + gimp_image_undo_push_image_guide (gimage, _("Remove Guide"), g); + gimp_image_delete_guide (gimage, g); success = TRUE; - - tmp_next = guides->next; - - undo_push_image_guide (gimage, ((GimpGuide *) guides->data)); - gimp_image_delete_guide (gimage, (GimpGuide *) guides->data); - guides = tmp_next; + break; } - else - guides = guides->next; } } CODE @@ -148,50 +140,38 @@ HELP ); %invoke = ( - vars => [ 'GList *guides' ], + vars => [ 'GList *guides', 'gboolean guide_found' ], code => <<'CODE' { - guides = gimage->guides; + success = FALSE; + guide_found = FALSE; - if (guides != NULL) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if (guide == 0) /* init - Return first guide ID in list */ - { - while (guides && (((GimpGuide *) guides->data)->position < 0)) - guides = guides->next; - - if (guides) /* didn't just come to end of list */ - next_guide = ((GimpGuide *) guides->data)->guide_ID; - } - else - { - success = FALSE; - - while (guides) - { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) - { - GList* tmplist; - - success = TRUE; + GimpGuide *g = (GimpGuide *) guides->data; - tmplist = guides->next; - - while (tmplist && (((GimpGuide *) tmplist->data)->position < 0)) - tmplist = tmplist->next; + if (g->position < 0) + continue; - if (tmplist) - next_guide = ((GimpGuide *) tmplist->data)->guide_ID; - else - next_guide = 0; + if (guide == 0) /* init - Return first guide ID in list */ + { + next_guide = g->guide_ID; - break; - } + success = TRUE; + break; + } - guides = guides->next; - } + if (! guide_found) + { + if (g->guide_ID == guide) + guide_found = TRUE; + } + else + { + next_guide = g->guide_ID; + success = TRUE; + break; } } } @@ -225,21 +205,19 @@ HELP vars => [ 'GList *guides' ], code => <<'CODE' { - guides = gimage->guides; - success = FALSE; - while (guides) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) + GimpGuide *g = (GimpGuide *) guides->data; + + if ((g->guide_ID == guide) && (g->position >= 0)) { - orientation = ((GimpGuide *) guides->data)->orientation; + orientation = g->orientation; + success = TRUE; break; } - - guides = guides->next; } } CODE @@ -271,28 +249,27 @@ HELP vars => [ 'GList *guides' ], code => <<'CODE' { - guides = gimage->guides; - success = FALSE; - while (guides) + for (guides = gimage->guides; guides; guides = g_list_next (guides)) { - if ((((GimpGuide *) guides->data)->guide_ID == guide) && - (((GimpGuide *) guides->data)->position >= 0)) + GimpGuide *g = (GimpGuide *) guides->data; + + if ((g->guide_ID == guide) && (g->position >= 0)) { - position = ((GimpGuide *) guides->data)->position; + position = g->position; + success = TRUE; break; } - - guides = guides->next; } } CODE ); } -@headers = qw("core/gimpimage-guides.h"); +@headers = qw("core/gimpimage-guides.h" "core/gimpimage-undo-push.h" + "libgimp/gimpintl.h"); @procs = qw(image_add_hguide image_add_vguide image_delete_guide image_find_next_guide image_get_guide_orientation diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index f66e32e100..7b5be44864 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -41,7 +41,7 @@ sub layer_change_invoke { while ($code =~ /^\t* {8}/m) { $code =~ s/^(\t*) {8}/$1\t/mg } %invoke = ( - headers => [ qw("undo.h" "core/gimplayer-floating-sel.h") ], + headers => [ qw("core/gimplayer-floating-sel.h") ], vars => [ 'GimpImage *gimage', 'GimpLayer *floating_layer' ], code => < "gimp_image_mask_clear (gimage, NULL);" ); } sub selection_invert { @@ -243,14 +247,18 @@ HELP } sub selection_none { - &selection_simple_proc('clear'); - $blurb = 'Deselect the entire image.'; $help = <<'HELP'; This procedure deselects the entire image. Every pixel in the selection channel is set to 0. HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => "gimp_image_mask_clear (gimage, NULL);" ); } sub selection_feather { diff --git a/tools/pdbgen/pdb/selection_tools.pdb b/tools/pdbgen/pdb/selection_tools.pdb index 59707fa8b1..6c60e25165 100644 --- a/tools/pdbgen/pdb/selection_tools.pdb +++ b/tools/pdbgen/pdb/selection_tools.pdb @@ -195,6 +195,7 @@ HELP %invoke = ( code => <<'CODE' gimp_image_mask_select_polygon (gimage, + _("Free Select"), num_segs, (GimpVector2 *) segs, operation, @@ -309,7 +310,7 @@ CODE ); } -@headers = qw("core/gimpimage-mask-select.h"); +@headers = qw("core/gimpimage-mask-select.h" "libgimp/gimpintl.h"); @procs = qw(by_color_select ellipse_select free_select fuzzy_select rect_select); -- GitLab