1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-06-08 06:51:23 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
#include "tools/tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
#include "base/tile.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2002-05-15 19:05:32 +08:00
|
|
|
#include "core/gimp-parasites.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimpcoreconfig.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
#include "core/gimpimage-guides.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage-mask.h"
|
2001-11-28 11:08:03 +08:00
|
|
|
#include "core/gimpimage-projection.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "core/gimplayer-floating-sel.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayermask.h"
|
2002-08-28 22:09:14 +08:00
|
|
|
#include "core/gimplist.h"
|
2001-07-10 03:48:30 +08:00
|
|
|
#include "core/gimpparasitelist.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint/gimppaintcore.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "tools/gimpbycolorselecttool.h"
|
|
|
|
#include "tools/gimppainttool.h"
|
|
|
|
#include "tools/gimptransformtool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2000-02-16 21:52:33 +08:00
|
|
|
#include "path_transform.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "undo.h"
|
2002-02-24 01:29:19 +08:00
|
|
|
#include "undo_types.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1999-04-23 14:07:09 +08:00
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
1999-11-04 06:34:32 +08:00
|
|
|
/*#define DEBUG*/
|
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
#ifdef DEBUG
|
|
|
|
#define TRC(x) printf x
|
|
|
|
#else
|
|
|
|
#define TRC(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
UNDO = 0,
|
|
|
|
REDO = 1
|
1999-09-24 07:42:38 +08:00
|
|
|
} UndoState;
|
1998-01-22 15:02:57 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef gboolean (* UndoPopFunc) (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data);
|
|
|
|
typedef void (* UndoFreeFunc) (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
typedef struct _Undo Undo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
struct _Undo
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
UndoType type; /* undo type */
|
2000-05-27 06:28:40 +08:00
|
|
|
gpointer data; /* data to implement the undo, NULL for group */
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize bytes; /* size of undo item */
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean dirties_image; /* TRUE if undo mutates image */
|
|
|
|
gboolean group_boundary; /* TRUE if this is the start/end of a group */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
UndoPopFunc pop_func; /* function pointer to undo pop proc */
|
|
|
|
UndoFreeFunc free_func; /* function with specifics for freeing */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
|
2001-01-29 10:45:02 +08:00
|
|
|
static const gchar * undo_type_to_name (UndoType undo_type);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-29 10:45:02 +08:00
|
|
|
static Undo * undo_new (UndoType undo_type,
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize size,
|
2001-01-29 10:45:02 +08:00
|
|
|
gboolean dirties_image);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
static gboolean mode_changed = FALSE;
|
|
|
|
static gboolean size_changed = FALSE;
|
|
|
|
static gboolean resolution_changed = FALSE;
|
|
|
|
static gboolean unit_changed = FALSE;
|
2002-08-22 18:40:11 +08:00
|
|
|
static gboolean mask_changed = FALSE;
|
|
|
|
static gboolean qmask_changed = FALSE;
|
2002-08-28 22:09:14 +08:00
|
|
|
static gboolean alpha_changed = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_free_list (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
GSList *list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
GSList *orig;
|
|
|
|
Undo *undo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
orig = list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
undo = (Undo *) list->data;
|
|
|
|
if (undo)
|
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
if (undo->free_func)
|
|
|
|
(*undo->free_func) (state, undo->type, undo->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->undo_bytes -= undo->bytes;
|
|
|
|
g_free (undo);
|
|
|
|
}
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
g_slist_free (orig);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
static GSList *
|
2001-01-29 00:44:22 +08:00
|
|
|
remove_stack_bottom (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
GSList *list;
|
|
|
|
GSList *last;
|
|
|
|
Undo *object;
|
|
|
|
gboolean in_group = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
list = gimage->undo_stack;
|
|
|
|
|
|
|
|
last = NULL;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
if (list->next == NULL)
|
|
|
|
{
|
|
|
|
if (last)
|
|
|
|
undo_free_list (gimage, UNDO, last->next);
|
|
|
|
else
|
|
|
|
undo_free_list (gimage, UNDO, list);
|
|
|
|
|
|
|
|
gimage->undo_levels --;
|
|
|
|
if (last)
|
|
|
|
last->next = NULL;
|
|
|
|
list = NULL;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
|
|
|
gimp_image_undo_event (gimage, UNDO_EXPIRED);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
object = (Undo *) list->data;
|
|
|
|
if (object->group_boundary)
|
2000-05-27 06:28:40 +08:00
|
|
|
in_group = (in_group) ? FALSE : TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Make sure last points to only a single item, or the
|
|
|
|
* tail of an aggregate undo item
|
|
|
|
*/
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
if (!in_group)
|
2000-05-27 06:28:40 +08:00
|
|
|
last = list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (last)
|
|
|
|
return gimage->undo_stack;
|
|
|
|
else
|
|
|
|
return NULL;
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/* Allocate and initialise a new Undo. Leaves data and function
|
|
|
|
* pointers zeroed ready to be filled in by caller.
|
|
|
|
*/
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
static Undo *
|
2002-02-26 08:04:55 +08:00
|
|
|
undo_new (UndoType type,
|
|
|
|
gsize size,
|
|
|
|
gboolean dirties_image)
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
Undo *new;
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
new = g_new0 (Undo, 1);
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
new->type = type;
|
|
|
|
new->bytes = size;
|
|
|
|
new->dirties_image = dirties_image;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
return new;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_free_up_space (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
/* If there are 0 levels of undo return FALSE. */
|
2001-07-11 20:39:49 +08:00
|
|
|
if (gimage->gimp->config->levels_of_undo == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Delete the item on the bottom of the stack if we have the maximum
|
|
|
|
* levels of undo already
|
|
|
|
*/
|
2001-07-11 20:39:49 +08:00
|
|
|
while (gimage->undo_levels >= gimage->gimp->config->levels_of_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->undo_stack = remove_stack_bottom (gimage);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Undo *
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push (GimpImage *gimage,
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize size,
|
2001-01-29 00:44:22 +08:00
|
|
|
UndoType type,
|
|
|
|
gboolean dirties_image)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
Undo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-25 02:31:48 +08:00
|
|
|
g_return_val_if_fail (type > LAST_UNDO_GROUP, NULL);
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
/* Does this undo dirty the image? If so, we always want to mark
|
2002-02-25 02:31:48 +08:00
|
|
|
* image dirty, even if we can't actually push the undo.
|
|
|
|
*/
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
if (dirties_image)
|
2002-02-25 02:31:48 +08:00
|
|
|
gimp_image_dirty (gimage);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (! gimage->undo_on)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
size += sizeof (Undo);
|
|
|
|
|
|
|
|
if (gimage->redo_stack)
|
|
|
|
{
|
|
|
|
undo_free_list (gimage, REDO, gimage->redo_stack);
|
|
|
|
gimage->redo_stack = NULL;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
|
|
|
/* If the image was dirty, but could become clean by redo-ing
|
|
|
|
* some actions, then it should now become 'infinitely' dirty.
|
|
|
|
* This is because we've just nuked the actions that would allow
|
|
|
|
* the image to become clean again. The only hope for salvation
|
|
|
|
* is to save the image now! -- austin */
|
|
|
|
if (gimage->dirty < 0)
|
2000-05-27 06:28:40 +08:00
|
|
|
gimage->dirty = 10000;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if (gimage->pushing_undo_group == NO_UNDO_GROUP)
|
1997-11-25 06:05:25 +08:00
|
|
|
if (! undo_free_up_space (gimage))
|
|
|
|
return NULL;
|
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
new = undo_new (type, size, dirties_image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gimage->undo_bytes += size;
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
|
|
|
/* only increment levels if not in a group */
|
2002-02-24 01:29:19 +08:00
|
|
|
if (gimage->pushing_undo_group == NO_UNDO_GROUP)
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->undo_levels ++;
|
|
|
|
|
2000-06-08 06:51:23 +08:00
|
|
|
gimage->undo_stack = g_slist_prepend (gimage->undo_stack, (gpointer) new);
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
TRC (("undo_push: %s\n", undo_type_to_name (type)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
/* lastly, tell people about the newly pushed undo (must come after
|
|
|
|
* modification of undo_stack). */
|
2002-02-24 01:29:19 +08:00
|
|
|
if (gimage->pushing_undo_group == NO_UNDO_GROUP)
|
|
|
|
gimp_image_undo_event (gimage, UNDO_PUSHED);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
pop_stack (GimpImage *gimage,
|
2000-05-27 06:28:40 +08:00
|
|
|
GSList **stack_ptr,
|
|
|
|
GSList **unstack_ptr,
|
|
|
|
UndoState state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-02 17:31:21 +08:00
|
|
|
Undo *object;
|
|
|
|
GSList *stack;
|
|
|
|
GSList *tmp;
|
|
|
|
gboolean status = FALSE;
|
|
|
|
gboolean in_group = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Keep popping until we pop a valid object
|
|
|
|
* or get to the end of a group if we're in one
|
|
|
|
*/
|
|
|
|
while (*stack_ptr)
|
|
|
|
{
|
|
|
|
stack = *stack_ptr;
|
|
|
|
|
|
|
|
object = (Undo *) stack->data;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
if (object->group_boundary)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-02 17:31:21 +08:00
|
|
|
in_group = ! in_group;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (in_group)
|
|
|
|
gimage->undo_levels += (state == UNDO) ? -1 : 1;
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
if (status && ! in_group)
|
|
|
|
status = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-11-02 17:31:21 +08:00
|
|
|
status = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
TRC (("undo_pop: %s\n", undo_type_to_name (object->type)));
|
2001-11-02 17:31:21 +08:00
|
|
|
|
|
|
|
status = (* object->pop_func) (gimage,
|
|
|
|
state,
|
|
|
|
object->type,
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
object->data);
|
|
|
|
|
|
|
|
if (object->dirties_image)
|
2000-05-27 06:28:40 +08:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case UNDO:
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
gimp_image_clean (gimage);
|
|
|
|
break;
|
2000-05-27 06:28:40 +08:00
|
|
|
case REDO:
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
gimp_image_dirty (gimage);
|
|
|
|
break;
|
2000-05-27 06:28:40 +08:00
|
|
|
}
|
|
|
|
}
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
if (! in_group)
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->undo_levels += (state == UNDO) ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
*unstack_ptr = g_slist_prepend (*unstack_ptr, object);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tmp = stack;
|
1998-01-29 16:03:27 +08:00
|
|
|
*stack_ptr = g_slist_next (*stack_ptr);
|
1997-11-25 06:05:25 +08:00
|
|
|
tmp->next = NULL;
|
1998-01-29 16:03:27 +08:00
|
|
|
g_slist_free (tmp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
if (status && ! in_group)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-07 00:14:34 +08:00
|
|
|
/* If the mode_changed flag was set */
|
|
|
|
if (mode_changed)
|
|
|
|
{
|
|
|
|
gimp_image_mode_changed (gimage);
|
|
|
|
|
|
|
|
mode_changed = FALSE;
|
|
|
|
}
|
|
|
|
|
2001-05-07 01:56:10 +08:00
|
|
|
/* If the size_changed flag was set */
|
|
|
|
if (size_changed)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
2001-05-07 00:14:34 +08:00
|
|
|
|
2001-05-07 01:56:10 +08:00
|
|
|
size_changed = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
/* If the resolution_changed flag was set */
|
|
|
|
if (resolution_changed)
|
|
|
|
{
|
|
|
|
gimp_image_resolution_changed (gimage);
|
|
|
|
|
|
|
|
resolution_changed = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the unit_changed flag was set */
|
|
|
|
if (unit_changed)
|
|
|
|
{
|
|
|
|
gimp_image_unit_changed (gimage);
|
|
|
|
|
|
|
|
unit_changed = FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-22 18:40:11 +08:00
|
|
|
/* If the mask_changed flag was set */
|
|
|
|
if (mask_changed)
|
|
|
|
{
|
|
|
|
gimp_image_mask_changed (gimage);
|
|
|
|
|
|
|
|
mask_changed = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the qmask_changed flag was set */
|
|
|
|
if (qmask_changed)
|
|
|
|
{
|
|
|
|
gimp_image_qmask_changed (gimage);
|
|
|
|
|
|
|
|
qmask_changed = FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-28 22:09:14 +08:00
|
|
|
/* If the alpha_changed flag was set */
|
|
|
|
if (alpha_changed)
|
|
|
|
{
|
|
|
|
gimp_image_alpha_changed (gimage);
|
|
|
|
|
|
|
|
alpha_changed = FALSE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
/* let others know that we just popped an action */
|
|
|
|
gimp_image_undo_event (gimage,
|
|
|
|
(state == UNDO)? UNDO_POPPED : UNDO_REDO);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
/* Very bad idea to pop an action off the undo stack if we're in the
|
|
|
|
* middle of a group, since the whole group won't be popped. Might
|
|
|
|
* leave unbalanced group start marker earlier in the stack too,
|
|
|
|
* causing much confusion when it's later reached and
|
|
|
|
* mis-interpreted as a group start.
|
|
|
|
*/
|
|
|
|
g_return_val_if_fail (gimage->pushing_undo_group == NO_UNDO_GROUP, FALSE);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return pop_stack (gimage, &gimage->undo_stack, &gimage->redo_stack, UNDO);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_redo (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
/* ditto for redo stack */
|
2002-02-24 01:29:19 +08:00
|
|
|
g_return_val_if_fail (gimage->pushing_undo_group == NO_UNDO_GROUP, FALSE);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return pop_stack (gimage, &gimage->redo_stack, &gimage->undo_stack, REDO);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
|
|
|
/* Return the name of the action that would be used if undo_pop or
|
|
|
|
* undo_redo is called, or NULL if there are no actions pushed on the
|
2002-02-24 01:29:19 +08:00
|
|
|
* stack.
|
|
|
|
*/
|
2000-05-27 06:28:40 +08:00
|
|
|
static const gchar *
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
undo_get_topitem_name (GSList *stack)
|
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
Undo *object;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (!stack)
|
|
|
|
return NULL;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
object = stack->data;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* For group boundaries, the type of the boundary marker is the
|
|
|
|
* type of the whole group (but each individual action in the
|
|
|
|
* group retains its own type so layer/channel unrefs work
|
|
|
|
* correctly).
|
|
|
|
*/
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
return undo_type_to_name (object->type);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
1999-11-03 07:05:55 +08:00
|
|
|
/* Return the type of the top undo action */
|
|
|
|
static UndoType
|
|
|
|
undo_get_topitem_type (GSList *stack)
|
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
Undo *object;
|
1999-11-03 07:05:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (!stack)
|
2002-02-24 01:29:19 +08:00
|
|
|
return NO_UNDO_GROUP;
|
1999-11-03 07:05:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
object = stack->data;
|
1999-11-03 07:05:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* For group boundaries, the type of the boundary marker is the
|
|
|
|
* type of the whole group (but each individual action in the
|
|
|
|
* group retains its own type so layer/channel unrefs work
|
|
|
|
* correctly).
|
|
|
|
*/
|
1999-11-03 07:05:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
return object->type;
|
1999-11-03 07:05:55 +08:00
|
|
|
}
|
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
const gchar *
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_get_undo_name (GimpImage *gimage)
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, NULL);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* don't want to encourage undo while a group is open */
|
2002-02-24 01:29:19 +08:00
|
|
|
if (gimage->pushing_undo_group != NO_UNDO_GROUP)
|
2000-05-27 06:28:40 +08:00
|
|
|
return NULL;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
return undo_get_topitem_name (gimage->undo_stack);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
1999-11-03 07:05:55 +08:00
|
|
|
UndoType
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_get_undo_top_type (GimpImage *gimage)
|
1999-11-03 07:05:55 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, NO_UNDO_GROUP);
|
1999-11-03 07:05:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* don't want to encourage undo while a group is open */
|
2002-02-24 01:29:19 +08:00
|
|
|
if (gimage->pushing_undo_group != NO_UNDO_GROUP)
|
|
|
|
return NO_UNDO_GROUP;
|
1999-11-03 07:05:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
return undo_get_topitem_type (gimage->undo_stack);
|
1999-11-03 07:05:55 +08:00
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
const gchar *
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_get_redo_name (GimpImage *gimage)
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, NULL);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* don't want to encourage redo while a group is open */
|
2002-02-24 01:29:19 +08:00
|
|
|
if (gimage->pushing_undo_group != NO_UNDO_GROUP)
|
2000-05-27 06:28:40 +08:00
|
|
|
return NULL;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
return undo_get_topitem_name (gimage->redo_stack);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static void
|
|
|
|
undo_map_over_stack (GSList *stack,
|
|
|
|
undo_map_fn fn,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data)
|
2000-05-27 06:28:40 +08:00
|
|
|
{
|
|
|
|
gboolean in_group = FALSE;
|
|
|
|
gint count = 0;
|
|
|
|
Undo *object;
|
|
|
|
|
|
|
|
while (stack)
|
|
|
|
{
|
|
|
|
object = (Undo *) stack->data;
|
|
|
|
if (object->group_boundary)
|
|
|
|
in_group = !in_group;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* Keep track of group length. 0 means not in group (or group
|
|
|
|
* end marker), 1 is group start marker, >= 2 are group
|
|
|
|
* members.
|
|
|
|
*/
|
|
|
|
if (in_group)
|
|
|
|
count++;
|
|
|
|
else
|
|
|
|
count = 0;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
/* Is this a group end marker or non-grouped action? */
|
|
|
|
if (count == 0)
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
if (fn (undo_type_to_name (object->type), data))
|
|
|
|
return; /* early termination option exercised */
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
stack = g_slist_next (stack);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_map_over_undo_stack (GimpImage *gimage,
|
2000-05-27 06:28:40 +08:00
|
|
|
undo_map_fn fn,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data)
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
/* shouldn't have group open */
|
2002-02-24 01:29:19 +08:00
|
|
|
g_return_if_fail (gimage->pushing_undo_group == NO_UNDO_GROUP);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
undo_map_over_stack (gimage->undo_stack, fn, data);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_map_over_redo_stack (GimpImage *gimage,
|
2000-05-27 06:28:40 +08:00
|
|
|
undo_map_fn fn,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data)
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
/* shouldn't have group open */
|
2002-02-24 01:29:19 +08:00
|
|
|
g_return_if_fail (gimage->pushing_undo_group == NO_UNDO_GROUP);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
undo_map_over_stack (gimage->redo_stack, fn, data);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_free (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
undo_free_list (gimage, UNDO, gimage->undo_stack);
|
|
|
|
undo_free_list (gimage, REDO, gimage->redo_stack);
|
2000-06-08 06:51:23 +08:00
|
|
|
|
|
|
|
gimage->undo_stack = NULL;
|
|
|
|
gimage->redo_stack = NULL;
|
|
|
|
gimage->undo_bytes = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->undo_levels = 0;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
|
|
|
/* If the image was dirty, but could become clean by redo-ing
|
|
|
|
* some actions, then it should now become 'infinitely' dirty.
|
|
|
|
* This is because we've just nuked the actions that would allow
|
|
|
|
* the image to become clean again. The only hope for salvation
|
2000-05-27 06:28:40 +08:00
|
|
|
* is to save the image now! -- austin
|
|
|
|
*/
|
1999-08-23 22:34:58 +08:00
|
|
|
if (gimage->dirty < 0)
|
2000-05-27 06:28:40 +08:00
|
|
|
gimage->dirty = 10000;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
|
|
|
/* The same applies to the case where the image would become clean
|
|
|
|
* due to undo actions, but since user can't undo without an undo
|
2000-05-27 06:28:40 +08:00
|
|
|
* stack, that's not so much a problem.
|
|
|
|
*/
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
gimp_image_undo_event (gimage, UNDO_FREE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************/
|
|
|
|
/* group Undo funcs */
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_group_start (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoType type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
Undo *boundary_marker;
|
|
|
|
|
2002-02-25 02:31:48 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-25 02:31:48 +08:00
|
|
|
/* Bad idea to push NO_UNDO_GROUP as the group type, since that
|
|
|
|
* won't be recognized as the start of the group later.
|
2000-05-27 06:28:40 +08:00
|
|
|
*/
|
2002-02-25 02:31:48 +08:00
|
|
|
g_return_val_if_fail (type > FIRST_UNDO_GROUP &&
|
|
|
|
type <= LAST_UNDO_GROUP, FALSE);
|
|
|
|
|
|
|
|
if (! gimage->undo_on)
|
|
|
|
return FALSE;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
gimage->group_count ++;
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
TRC (("group_start (%s)\n", undo_type_to_name (type)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* If we're already in a group...ignore */
|
1999-08-23 22:34:58 +08:00
|
|
|
if (gimage->group_count > 1)
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (gimage->redo_stack)
|
|
|
|
{
|
|
|
|
undo_free_list (gimage, REDO, gimage->redo_stack);
|
|
|
|
gimage->redo_stack = NULL;
|
1999-08-23 22:34:58 +08:00
|
|
|
/* If the image was dirty, but could become clean by redo-ing
|
|
|
|
* some actions, then it should now become 'infinitely' dirty.
|
|
|
|
* This is because we've just nuked the actions that would allow
|
|
|
|
* the image to become clean again. The only hope for salvation
|
2000-05-27 06:28:40 +08:00
|
|
|
* is to save the image now! -- austin
|
|
|
|
*/
|
1999-08-23 22:34:58 +08:00
|
|
|
if (gimage->dirty < 0)
|
2000-05-27 06:28:40 +08:00
|
|
|
gimage->dirty = 10000;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! undo_free_up_space (gimage))
|
|
|
|
return FALSE;
|
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
boundary_marker = undo_new (type, sizeof (Undo), FALSE);
|
|
|
|
gimage->undo_bytes += boundary_marker->bytes;
|
|
|
|
boundary_marker->group_boundary = TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->pushing_undo_group = type;
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
gimage->undo_stack = g_slist_prepend (gimage->undo_stack, boundary_marker);
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage->undo_levels++;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_group_end (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
Undo *boundary_marker;
|
|
|
|
|
2002-02-25 02:31:48 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (! gimage->undo_on)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
gimage->group_count --;
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
TRC (("group end\n"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
if (gimage->group_count == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
boundary_marker = undo_new (gimage->pushing_undo_group,
|
|
|
|
sizeof (Undo), FALSE);
|
|
|
|
boundary_marker->group_boundary = TRUE;
|
|
|
|
gimage->undo_stack = g_slist_prepend (gimage->undo_stack,
|
|
|
|
boundary_marker);
|
|
|
|
gimage->undo_bytes += boundary_marker->bytes;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gimage->pushing_undo_group = NO_UNDO_GROUP;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
|
|
|
/* Do it here, since undo_push doesn't emit this event while in the
|
|
|
|
* middle of a group */
|
|
|
|
gimp_image_undo_event (gimage, UNDO_PUSHED);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/****************/
|
|
|
|
/* Image Undo */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
typedef struct _ImageUndo ImageUndo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
struct _ImageUndo
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
TileManager *tiles;
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable;
|
2000-05-27 06:28:40 +08:00
|
|
|
gint x1, y1, x2, y2;
|
2000-06-08 06:51:23 +08:00
|
|
|
gboolean sparse;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_image (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_image (UndoState, UndoType, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_image (GimpImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable,
|
2000-05-27 06:28:40 +08:00
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2)
|
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
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));
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ImageUndo) + ((x2 - x1) * (y2 - y1) *
|
|
|
|
gimp_drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
if ((new = undo_push (gimage, size, IMAGE_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ImageUndo *image_undo;
|
|
|
|
TileManager *tiles;
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
|
|
|
|
image_undo = g_new0 (ImageUndo, 1);
|
|
|
|
|
|
|
|
new->data = image_undo;
|
|
|
|
new->pop_func = undo_pop_image;
|
|
|
|
new->free_func = undo_free_image;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* If we cannot create a new temp buf--either because our parameters are
|
|
|
|
* degenerate or something else failed, simply return an unsuccessful push.
|
|
|
|
*/
|
2001-01-15 05:11:52 +08:00
|
|
|
tiles = tile_manager_new ((x2 - x1), (y2 - y1),
|
|
|
|
gimp_drawable_bytes (drawable));
|
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
2000-05-27 06:28:40 +08:00
|
|
|
x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
|
|
|
pixel_region_init (&destPR, tiles,
|
|
|
|
0, 0, (x2 - x1), (y2 - y1), TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
|
|
|
|
/* set the image undo structure */
|
2002-02-24 01:29:19 +08:00
|
|
|
image_undo->tiles = tiles;
|
1998-01-22 15:02:57 +08:00
|
|
|
image_undo->drawable = drawable;
|
2002-02-24 01:29:19 +08:00
|
|
|
image_undo->x1 = x1;
|
|
|
|
image_undo->y1 = y1;
|
|
|
|
image_undo->x2 = x2;
|
|
|
|
image_undo->y2 = y2;
|
|
|
|
image_undo->sparse = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_image_mod (GimpImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable,
|
2000-05-27 06:28:40 +08:00
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
2002-02-24 01:29:19 +08:00
|
|
|
TileManager *tiles,
|
2000-06-08 06:51:23 +08:00
|
|
|
gboolean sparse)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
Undo *new;
|
|
|
|
gsize size;
|
|
|
|
gint dwidth, dheight;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if (! tiles)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
dwidth = gimp_drawable_width (drawable);
|
|
|
|
dheight = gimp_drawable_height (drawable);
|
1998-07-25 02:52:03 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
x1 = CLAMP (x1, 0, dwidth);
|
|
|
|
y1 = CLAMP (y1, 0, dheight);
|
|
|
|
x2 = CLAMP (x2, 0, dwidth);
|
|
|
|
y2 = CLAMP (y2, 0, dheight);
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ImageUndo) + tile_manager_get_memsize (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
if ((new = undo_push (gimage, size, IMAGE_MOD_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ImageUndo *image_undo;
|
|
|
|
|
|
|
|
image_undo = g_new0 (ImageUndo, 1);
|
|
|
|
|
|
|
|
new->data = image_undo;
|
|
|
|
new->pop_func = undo_pop_image;
|
|
|
|
new->free_func = undo_free_image;
|
|
|
|
|
2000-06-08 06:51:23 +08:00
|
|
|
image_undo->tiles = tiles;
|
1998-01-22 15:02:57 +08:00
|
|
|
image_undo->drawable = drawable;
|
2000-06-08 06:51:23 +08:00
|
|
|
image_undo->x1 = x1;
|
|
|
|
image_undo->y1 = y1;
|
|
|
|
image_undo->x2 = x2;
|
|
|
|
image_undo->y2 = y2;
|
|
|
|
image_undo->sparse = sparse;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_image (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer image_undo_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
ImageUndo *image_undo;
|
1997-11-25 06:05:25 +08:00
|
|
|
TileManager *tiles;
|
2000-05-27 06:28:40 +08:00
|
|
|
PixelRegion PR1, PR2;
|
|
|
|
gint x, y;
|
|
|
|
gint w, h;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
image_undo = (ImageUndo *) image_undo_ptr;
|
|
|
|
tiles = image_undo->tiles;
|
|
|
|
|
|
|
|
/* some useful values */
|
|
|
|
x = image_undo->x1;
|
|
|
|
y = image_undo->y1;
|
|
|
|
|
|
|
|
if (image_undo->sparse == FALSE)
|
|
|
|
{
|
2001-01-23 21:01:48 +08:00
|
|
|
w = tile_manager_width (tiles);
|
|
|
|
h = tile_manager_height (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
pixel_region_init (&PR1, tiles,
|
|
|
|
0, 0, w, h, TRUE);
|
2001-01-15 05:11:52 +08:00
|
|
|
pixel_region_init (&PR2, gimp_drawable_data (image_undo->drawable),
|
2000-05-27 06:28:40 +08:00
|
|
|
x, y, w, h, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* 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)))
|
|
|
|
{
|
1998-08-16 03:17:36 +08:00
|
|
|
src_tile = tile_manager_get_tile (tiles, j, i, FALSE, FALSE);
|
1998-08-12 01:35:34 +08:00
|
|
|
if (tile_is_valid (src_tile) == TRUE)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-08-12 01:35:34 +08:00
|
|
|
/* swap tiles, not pixels! */
|
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
src_tile = tile_manager_get_tile (tiles, j, i, TRUE, FALSE /* TRUE */);
|
2001-01-15 05:11:52 +08:00
|
|
|
dest_tile = tile_manager_get_tile (gimp_drawable_data (image_undo->drawable), j, i, TRUE, FALSE /* TRUE */);
|
1998-08-12 01:35:34 +08:00
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
tile_manager_map_tile (tiles, j, i, dest_tile);
|
2001-01-15 05:11:52 +08:00
|
|
|
tile_manager_map_tile (gimp_drawable_data (image_undo->drawable), j, i, src_tile);
|
1998-08-12 01:35:34 +08:00
|
|
|
#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 */);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (image_undo->drawable, x, y, w, h);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-09-24 07:42:38 +08:00
|
|
|
undo_free_image (UndoState state,
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer image_undo_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ImageUndo *image_undo;
|
|
|
|
|
|
|
|
image_undo = (ImageUndo *) image_undo_ptr;
|
|
|
|
|
|
|
|
tile_manager_destroy (image_undo->tiles);
|
|
|
|
g_free (image_undo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
/*********************/
|
|
|
|
/* Image Type Undo */
|
|
|
|
|
|
|
|
typedef struct _ImageTypeUndo ImageTypeUndo;
|
|
|
|
|
|
|
|
struct _ImageTypeUndo
|
|
|
|
{
|
|
|
|
GimpImageBaseType base_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_image_type (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_image_type (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_image_type (GimpImage *gimage)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (ImageTypeUndo),
|
|
|
|
IMAGE_TYPE_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
ImageTypeUndo *itu;
|
|
|
|
|
|
|
|
itu = g_new0 (ImageTypeUndo, 1);
|
|
|
|
|
|
|
|
new->data = itu;
|
|
|
|
new->pop_func = undo_pop_image_type;
|
|
|
|
new->free_func = undo_free_image_type;
|
|
|
|
|
|
|
|
itu->base_type = gimage->base_type;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_image_type (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
|
|
|
ImageTypeUndo *itu;
|
|
|
|
GimpImageBaseType tmp;
|
|
|
|
|
|
|
|
itu = (ImageTypeUndo *) data_ptr;
|
|
|
|
|
|
|
|
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)
|
|
|
|
mode_changed = TRUE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_image_type (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
|
|
|
g_free (data_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/*********************/
|
|
|
|
/* Image Size Undo */
|
|
|
|
|
|
|
|
typedef struct _ImageSizeUndo ImageSizeUndo;
|
|
|
|
|
|
|
|
struct _ImageSizeUndo
|
|
|
|
{
|
2002-02-24 02:29:07 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
2002-02-24 01:29:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_image_size (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_image_size (UndoState, UndoType, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_push_image_size (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (ImageSizeUndo),
|
|
|
|
IMAGE_SIZE_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
ImageSizeUndo *isu;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
isu = g_new0 (ImageSizeUndo, 1);
|
|
|
|
|
|
|
|
new->data = isu;
|
|
|
|
new->pop_func = undo_pop_image_size;
|
|
|
|
new->free_func = undo_free_image_size;
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
isu->width = gimage->width;
|
|
|
|
isu->height = gimage->height;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_image_size (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
2002-02-24 02:29:07 +08:00
|
|
|
ImageSizeUndo *isu;
|
2002-02-24 01:29:19 +08:00
|
|
|
gint tmp;
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
isu = (ImageSizeUndo *) data_ptr;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
tmp = isu->width;
|
|
|
|
isu->width = gimage->width;
|
2002-02-24 01:29:19 +08:00
|
|
|
gimage->width = tmp;
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
tmp = isu->height;
|
|
|
|
isu->height = gimage->height;
|
2002-02-24 01:29:19 +08:00
|
|
|
gimage->height = tmp;
|
|
|
|
|
|
|
|
gimp_image_projection_allocate (gimage);
|
|
|
|
|
|
|
|
gimp_image_mask_invalidate (gimage);
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
if (gimage->width != isu->width ||
|
|
|
|
gimage->height != isu->height)
|
2002-02-24 01:29:19 +08:00
|
|
|
size_changed = TRUE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_image_size (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
|
|
|
g_free (data_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* Image Resolution Undo */
|
|
|
|
|
|
|
|
typedef struct _ResolutionUndo ResolutionUndo;
|
|
|
|
|
|
|
|
struct _ResolutionUndo
|
|
|
|
{
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
GimpUnit unit;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_image_resolution (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_image_resolution (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_image_resolution (GimpImage *gimage)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (ResolutionUndo),
|
|
|
|
IMAGE_RESOLUTION_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
ResolutionUndo *ru;
|
|
|
|
|
|
|
|
ru = g_new (ResolutionUndo, 1);
|
|
|
|
|
|
|
|
new->data = ru;
|
|
|
|
new->pop_func = undo_pop_image_resolution;
|
|
|
|
new->free_func = undo_free_image_resolution;
|
|
|
|
|
|
|
|
ru->xres = gimage->xresolution;
|
|
|
|
ru->yres = gimage->yresolution;
|
|
|
|
ru->unit = gimage->unit;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_image_resolution (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
|
|
|
ResolutionUndo *ru;
|
|
|
|
|
|
|
|
ru = data_ptr;
|
|
|
|
|
|
|
|
if (ABS (ru->xres - gimage->xresolution) >= 1e-5 ||
|
|
|
|
ABS (ru->yres - gimage->yresolution) >= 1e-5)
|
|
|
|
{
|
|
|
|
gdouble old_xres;
|
|
|
|
gdouble old_yres;
|
|
|
|
|
|
|
|
old_xres = gimage->xresolution;
|
|
|
|
old_yres = gimage->yresolution;
|
|
|
|
|
|
|
|
gimage->xresolution = ru->xres;
|
|
|
|
gimage->yresolution = ru->yres;
|
|
|
|
|
|
|
|
ru->xres = old_xres;
|
|
|
|
ru->yres = old_yres;
|
|
|
|
|
|
|
|
resolution_changed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ru->unit != gimage->unit)
|
|
|
|
{
|
|
|
|
GimpUnit old_unit;
|
|
|
|
|
|
|
|
old_unit = gimage->unit;
|
|
|
|
gimage->unit = ru->unit;
|
|
|
|
ru->unit = old_unit;
|
|
|
|
|
|
|
|
unit_changed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_image_resolution (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
|
|
|
g_free (data_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************/
|
|
|
|
/* Qmask Undo */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _QmaskUndo QmaskUndo;
|
1999-10-19 04:55:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _QmaskUndo
|
1999-10-19 04:55:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
gboolean qmask;
|
1999-10-19 04:55:25 +08:00
|
|
|
};
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_image_qmask (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_image_qmask (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_push_image_qmask (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (QmaskUndo),
|
|
|
|
IMAGE_QMASK_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
QmaskUndo *qu;
|
|
|
|
|
|
|
|
qu = g_new (QmaskUndo, 1);
|
|
|
|
|
|
|
|
new->data = qu;
|
|
|
|
new->pop_func = undo_pop_image_qmask;
|
|
|
|
new->free_func = undo_free_image_qmask;
|
|
|
|
|
|
|
|
qu->gimage = gimage;
|
|
|
|
qu->qmask = gimage->qmask_state;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_pop_image_qmask (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
QmaskUndo *data;
|
2002-08-20 18:22:23 +08:00
|
|
|
gboolean tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
data = (QmaskUndo *) data_ptr;
|
|
|
|
|
2002-08-20 18:22:23 +08:00
|
|
|
tmp = gimage->qmask_state;
|
2002-02-24 01:29:19 +08:00
|
|
|
gimage->qmask_state = data->qmask;
|
2002-08-20 18:22:23 +08:00
|
|
|
data->qmask = tmp;
|
2000-05-27 06:28:40 +08:00
|
|
|
|
2002-08-22 18:40:11 +08:00
|
|
|
qmask_changed = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_free_image_qmask (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
g_free (data_ptr);
|
|
|
|
}
|
1999-10-19 04:55:25 +08:00
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/****************/
|
|
|
|
/* Guide Undo */
|
1999-10-19 04:55:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _GuideUndo GuideUndo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _GuideUndo
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpGuide *guide;
|
|
|
|
GimpGuide orig;
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_image_guide (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_image_guide (UndoState, UndoType, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_push_image_guide (GimpImage *gimage,
|
|
|
|
GimpGuide *guide)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
Undo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (GuideUndo),
|
|
|
|
IMAGE_GUIDE_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GuideUndo *gu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gu = g_new (GuideUndo, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
new->data = gu;
|
|
|
|
new->pop_func = undo_pop_image_guide;
|
|
|
|
new->free_func = undo_free_image_guide;
|
2001-02-14 12:55:21 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
guide->ref_count++;
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gu->gimage = gimage;
|
|
|
|
gu->guide = guide;
|
|
|
|
gu->orig = *guide;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean
|
|
|
|
undo_pop_image_guide (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
|
|
|
{
|
|
|
|
GuideUndo *data;
|
|
|
|
GimpGuide tmp;
|
|
|
|
gint tmp_ref;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
data = data_ptr;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_image_update_guide (gimage, data->guide);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tmp_ref = data->guide->ref_count;
|
|
|
|
tmp = *(data->guide);
|
|
|
|
*(data->guide) = data->orig;
|
|
|
|
data->guide->ref_count = tmp_ref;
|
|
|
|
data->orig = tmp;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_image_update_guide (gimage, data->guide);
|
2001-03-31 22:47:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2002-02-26 08:04:55 +08:00
|
|
|
undo_free_image_guide (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer data_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GuideUndo *data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
data = (GuideUndo *) data_ptr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
data->guide->ref_count--;
|
|
|
|
if (data->guide->position < 0 && data->guide->ref_count <= 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_image_remove_guide (data->gimage, data->guide);
|
|
|
|
g_free (data->guide);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-02-24 01:29:19 +08:00
|
|
|
g_free (data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2002-08-20 18:22:23 +08:00
|
|
|
/***************/
|
|
|
|
/* 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 (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_mask (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_mask (GimpImage *gimage,
|
|
|
|
GimpChannel *mask)
|
|
|
|
{
|
|
|
|
TileManager *undo_tiles;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
Undo *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 = undo_push (gimage, size, MASK_UNDO, FALSE)))
|
|
|
|
{
|
|
|
|
MaskUndo *mask_undo;
|
|
|
|
|
|
|
|
mask_undo = g_new0 (MaskUndo, 1);
|
|
|
|
|
|
|
|
new->data = mask_undo;
|
|
|
|
new->pop_func = undo_pop_mask;
|
|
|
|
new->free_func = undo_free_mask;
|
|
|
|
|
|
|
|
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 (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer mask_ptr)
|
|
|
|
{
|
|
|
|
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 *) mask_ptr;
|
|
|
|
|
|
|
|
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;
|
2002-08-22 18:40:11 +08:00
|
|
|
GIMP_DRAWABLE (mask_undo->channel)->preview_valid = FALSE;
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
{
|
2002-08-22 18:40:11 +08:00
|
|
|
mask_changed = TRUE;
|
2002-08-20 18:22:23 +08:00
|
|
|
}
|
|
|
|
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 (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer mask_ptr)
|
|
|
|
{
|
|
|
|
MaskUndo *mask_undo;
|
|
|
|
|
|
|
|
mask_undo = (MaskUndo *) mask_ptr;
|
|
|
|
if (mask_undo->tiles)
|
|
|
|
tile_manager_destroy (mask_undo->tiles);
|
|
|
|
g_free (mask_undo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/**********************/
|
|
|
|
/* Item Rename Undo */
|
|
|
|
|
|
|
|
typedef struct _ItemRenameUndo ItemRenameUndo;
|
|
|
|
|
|
|
|
struct _ItemRenameUndo
|
|
|
|
{
|
|
|
|
GimpItem *item;
|
|
|
|
gchar *old_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_item_rename (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_item_rename (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_item_rename (GimpImage *gimage,
|
|
|
|
GimpItem *item)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (ItemRenameUndo),
|
|
|
|
ITEM_RENAME_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
ItemRenameUndo *iru;
|
|
|
|
|
|
|
|
iru = g_new0 (ItemRenameUndo, 1);
|
|
|
|
|
|
|
|
new->data = iru;
|
|
|
|
new->pop_func = undo_pop_item_rename;
|
|
|
|
new->free_func = undo_free_item_rename;
|
|
|
|
|
|
|
|
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 (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer iru_ptr)
|
|
|
|
{
|
|
|
|
ItemRenameUndo *iru;
|
|
|
|
gchar *tmp;
|
|
|
|
|
|
|
|
iru = (ItemRenameUndo *) iru_ptr;
|
|
|
|
|
|
|
|
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 (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer iru_ptr)
|
|
|
|
{
|
|
|
|
ItemRenameUndo *iru;
|
|
|
|
|
|
|
|
iru = (ItemRenameUndo *) iru_ptr;
|
|
|
|
|
|
|
|
g_free (iru->old_name);
|
|
|
|
g_free (iru);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/***************************/
|
|
|
|
/* Layer Add/Remove Undo */
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _LayerUndo LayerUndo;
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _LayerUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer; /* the actual layer */
|
|
|
|
gint prev_position; /* former position in list */
|
|
|
|
GimpLayer *prev_layer; /* previous active layer */
|
|
|
|
};
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_push_layer (GimpImage *gimage,
|
|
|
|
UndoType type,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer);
|
|
|
|
static gboolean undo_pop_layer (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_layer (UndoState, UndoType, gpointer);
|
1998-06-06 11:49:01 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
|
|
|
undo_push_layer_add (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer)
|
|
|
|
{
|
|
|
|
return undo_push_layer (gimage, LAYER_ADD_UNDO,
|
|
|
|
layer, prev_position, prev_layer);
|
2001-03-11 21:15:41 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
|
|
|
undo_push_layer_remove (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
return undo_push_layer (gimage, LAYER_REMOVE_UNDO,
|
|
|
|
layer, prev_position, prev_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_layer (GimpImage *gimage,
|
|
|
|
UndoType type,
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpLayer *layer,
|
|
|
|
gint prev_position,
|
|
|
|
GimpLayer *prev_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
Undo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
g_return_val_if_fail (type == LAYER_ADD_UNDO ||
|
|
|
|
type == LAYER_REMOVE_UNDO,
|
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
if ((new = undo_push (gimage, size, type, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
LayerUndo *lu;
|
|
|
|
|
|
|
|
lu = g_new0 (LayerUndo, 1);
|
2001-02-19 21:06:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
new->data = lu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_layer;
|
|
|
|
new->free_func = undo_free_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
g_object_ref (G_OBJECT (layer));
|
|
|
|
|
|
|
|
lu->layer = layer;
|
|
|
|
lu->prev_position = prev_position;
|
|
|
|
lu->prev_layer = prev_layer;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-29 08:46:04 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_layer (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer lu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerUndo *lu;
|
|
|
|
|
|
|
|
lu = (LayerUndo *) lu_ptr;
|
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
if ((state == UNDO && type == LAYER_ADD_UNDO) ||
|
|
|
|
(state == REDO && type == LAYER_REMOVE_UNDO))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* remove layer */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the current position */
|
2000-12-29 23:22:01 +08:00
|
|
|
lu->prev_position = gimp_image_get_layer_index (gimage, lu->layer);
|
2002-02-26 08:04:55 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* set the previous layer */
|
2000-12-29 23:22:01 +08:00
|
|
|
gimp_image_set_active_layer (gimage, lu->prev_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* remove the layer */
|
2001-02-19 21:06:09 +08:00
|
|
|
gimp_container_remove (gimage->layers, GIMP_OBJECT (lu->layer));
|
1998-01-29 16:03:27 +08:00
|
|
|
gimage->layer_stack = g_slist_remove (gimage->layer_stack, lu->layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* reset the gimage values */
|
2001-01-29 07:25:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (lu->layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-01-22 15:02:57 +08:00
|
|
|
gimage->floating_sel = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
/* reset the old drawable */
|
|
|
|
floating_sel_reset (lu->layer);
|
2001-05-08 09:32:25 +08:00
|
|
|
|
|
|
|
gimp_image_floating_selection_changed (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (lu->layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->width,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->height);
|
2002-08-28 22:09:14 +08:00
|
|
|
|
|
|
|
if (gimp_container_num_children (gimage->layers) == 1 &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_LIST (gimage->layers)->list->data))
|
|
|
|
{
|
|
|
|
alpha_changed = TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* restore layer */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the active layer */
|
2001-02-25 22:37:12 +08:00
|
|
|
lu->prev_layer = gimp_image_get_active_layer (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* hide the current selection--for all views */
|
2001-02-25 22:37:12 +08:00
|
|
|
if (gimp_image_get_active_layer (gimage))
|
|
|
|
gimp_layer_invalidate_boundary (gimp_image_get_active_layer (gimage));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* if this is a floating selection, set the fs pointer */
|
2001-01-29 07:25:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (lu->layer))
|
1998-01-22 15:02:57 +08:00
|
|
|
gimage->floating_sel = lu->layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-28 22:09:14 +08:00
|
|
|
if (gimp_container_num_children (gimage->layers) == 1 &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_LIST (gimage->layers)->list->data))
|
|
|
|
{
|
|
|
|
alpha_changed = TRUE;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* add the new layer */
|
2001-02-19 21:06:09 +08:00
|
|
|
gimp_container_insert (gimage->layers,
|
|
|
|
GIMP_OBJECT (lu->layer), lu->prev_position);
|
2001-02-25 22:37:12 +08:00
|
|
|
gimp_image_set_active_layer (gimage, lu->layer);
|
1998-09-27 04:07:46 +08:00
|
|
|
|
2001-05-08 09:32:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (lu->layer))
|
|
|
|
gimp_image_floating_selection_changed (gimage);
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (lu->layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->width,
|
|
|
|
GIMP_DRAWABLE (lu->layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_layer (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer lu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerUndo *lu;
|
|
|
|
|
|
|
|
lu = (LayerUndo *) lu_ptr;
|
|
|
|
|
2001-07-25 09:03:43 +08:00
|
|
|
g_object_unref (G_OBJECT (lu->layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (lu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/********************/
|
|
|
|
/* Layer Mod Undo */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-29 00:54:11 +08:00
|
|
|
typedef struct _LayerModUndo LayerModUndo;
|
|
|
|
|
|
|
|
struct _LayerModUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
TileManager *tiles;
|
|
|
|
GimpImageType type;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
};
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_layer_mod (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_layer_mod (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_layer_mod (GimpImage *gimage,
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-29 00:54:11 +08:00
|
|
|
Undo *new;
|
|
|
|
TileManager *tiles;
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-23 21:01:48 +08:00
|
|
|
tiles = GIMP_DRAWABLE (layer)->tiles;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (LayerModUndo) + tile_manager_get_memsize (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
if ((new = undo_push (gimage, size, LAYER_MOD_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
LayerModUndo *lmu;
|
|
|
|
|
|
|
|
lmu = g_new0 (LayerModUndo, 1);
|
|
|
|
|
|
|
|
new->data = lmu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_layer_mod;
|
|
|
|
new->free_func = undo_free_layer_mod;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
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;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_layer_mod (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2002-02-26 08:04:55 +08:00
|
|
|
gpointer lmu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
LayerModUndo *lmu;
|
2001-11-29 00:54:11 +08:00
|
|
|
gint layer_type;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
TileManager *tiles;
|
|
|
|
TileManager *temp;
|
|
|
|
GimpLayer *layer;
|
|
|
|
gboolean old_has_alpha;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
lmu = (LayerModUndo *) lmu_ptr;
|
|
|
|
|
|
|
|
layer = lmu->layer;
|
|
|
|
tiles = lmu->tiles;
|
|
|
|
offset_x = lmu->offset_x;
|
|
|
|
offset_y = lmu->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the first update */
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_image_update (gimage,
|
|
|
|
GIMP_DRAWABLE (layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (layer)->width,
|
|
|
|
GIMP_DRAWABLE (layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create a tile manager to store the current layer contents */
|
2000-05-27 06:28:40 +08:00
|
|
|
temp = GIMP_DRAWABLE (layer)->tiles;
|
2001-11-29 00:54:11 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
lmu->offset_x = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
lmu->offset_y = GIMP_DRAWABLE (layer)->offset_y;
|
2001-11-29 00:54:11 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
layer_type = lmu->type;
|
|
|
|
lmu->type = GIMP_DRAWABLE (layer)->type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
old_has_alpha = GIMP_DRAWABLE (layer)->has_alpha;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* restore the layer's data */
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (layer)->tiles = tiles;
|
2001-01-23 21:01:48 +08:00
|
|
|
GIMP_DRAWABLE (layer)->width = tile_manager_width (tiles);
|
|
|
|
GIMP_DRAWABLE (layer)->height = tile_manager_height (tiles);
|
|
|
|
GIMP_DRAWABLE (layer)->bytes = tile_manager_bpp (tiles);
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (layer)->type = layer_type;
|
2000-12-14 02:53:35 +08:00
|
|
|
GIMP_DRAWABLE (layer)->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type);
|
2001-11-29 00:54:11 +08:00
|
|
|
GIMP_DRAWABLE (layer)->offset_x = offset_x;
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y = offset_y;
|
1998-01-22 15:02:57 +08:00
|
|
|
if (layer->mask)
|
|
|
|
{
|
2002-08-20 18:22:23 +08:00
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_x = offset_x;
|
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_y = offset_y;
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
if (GIMP_DRAWABLE (layer)->has_alpha != old_has_alpha &&
|
2002-02-26 01:58:50 +08:00
|
|
|
GIMP_ITEM (layer)->gimage->layers->num_children == 1)
|
2001-11-01 05:18:57 +08:00
|
|
|
{
|
2002-02-26 01:58:50 +08:00
|
|
|
gimp_image_alpha_changed (GIMP_ITEM (layer)->gimage);
|
2001-11-01 05:18:57 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Set the new tile manager */
|
2002-02-26 08:04:55 +08:00
|
|
|
lmu->tiles = temp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the second update */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (layer)->width,
|
2001-11-01 05:18:57 +08:00
|
|
|
GIMP_DRAWABLE (layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_layer_mod (UndoState state,
|
|
|
|
UndoType type,
|
2002-02-26 08:04:55 +08:00
|
|
|
gpointer lmu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
LayerModUndo *lmu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
lmu = (LayerModUndo *) lmu_ptr;
|
|
|
|
|
|
|
|
tile_manager_destroy (lmu->tiles);
|
|
|
|
g_free (lmu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/********************************/
|
|
|
|
/* Layer Mask Add/Remove Undo */
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
typedef struct _LayerMaskUndo LayerMaskUndo;
|
|
|
|
|
|
|
|
struct _LayerMaskUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer; /* the layer */
|
|
|
|
GimpLayerMask *mask; /* the layer mask */
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_push_layer_mask (GimpImage *gimage,
|
|
|
|
UndoType type,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask);
|
|
|
|
static gboolean undo_pop_layer_mask (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_layer_mask (UndoState, UndoType, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_push_layer_mask_add (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask)
|
|
|
|
{
|
|
|
|
return undo_push_layer_mask (gimage, LAYER_MASK_ADD_UNDO,
|
|
|
|
layer, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_layer_mask_remove (GimpImage *gimage,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask)
|
|
|
|
{
|
|
|
|
return undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO,
|
|
|
|
layer, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_push_layer_mask (GimpImage *gimage,
|
|
|
|
UndoType type,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpLayerMask *mask)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
Undo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
g_return_val_if_fail (type == LAYER_MASK_ADD_UNDO ||
|
|
|
|
type == LAYER_MASK_REMOVE_UNDO,
|
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
if ((new = undo_push (gimage, size, type, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
LayerMaskUndo *lmu;
|
|
|
|
|
|
|
|
lmu = g_new0 (LayerMaskUndo, 1);
|
|
|
|
|
|
|
|
new->data = lmu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_layer_mask;
|
|
|
|
new->free_func = undo_free_layer_mask;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
g_object_ref (G_OBJECT (mask));
|
|
|
|
|
|
|
|
lmu->layer = layer;
|
|
|
|
lmu->mask = mask;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-29 00:44:22 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_layer_mask (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer lmu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerMaskUndo *lmu;
|
|
|
|
|
|
|
|
lmu = (LayerMaskUndo *) lmu_ptr;
|
|
|
|
|
1999-12-11 04:55:57 +08:00
|
|
|
if ((state == UNDO && type == LAYER_MASK_ADD_UNDO) ||
|
|
|
|
(state == REDO && type == LAYER_MASK_REMOVE_UNDO))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
/* remove layer mask */
|
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
gimp_layer_apply_mask (lmu->layer, GIMP_MASK_DISCARD, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
/* restore layer */
|
|
|
|
|
2002-08-20 18:22:23 +08:00
|
|
|
gimp_layer_add_mask (lmu->layer, lmu->mask, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_layer_mask (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer lmu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
LayerMaskUndo *lmu;
|
|
|
|
|
|
|
|
lmu = (LayerMaskUndo *) lmu_ptr;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
g_object_unref (G_OBJECT (lmu->mask));
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (lmu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/***************************/
|
|
|
|
/* Layer re-position Undo */
|
|
|
|
|
|
|
|
typedef struct _LayerRepositionUndo LayerRepositionUndo;
|
|
|
|
|
|
|
|
struct _LayerRepositionUndo
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
gint old_position;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_layer_reposition (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_layer_reposition (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_layer_reposition (GimpImage *gimage,
|
|
|
|
GimpLayer *layer)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (LayerRepositionUndo),
|
|
|
|
LAYER_REPOSITION_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
LayerRepositionUndo *lru;
|
|
|
|
|
|
|
|
lru = g_new0 (LayerRepositionUndo, 1);
|
|
|
|
|
|
|
|
new->data = lru;
|
|
|
|
new->pop_func = undo_pop_layer_reposition;
|
|
|
|
new->free_func = undo_free_layer_reposition;
|
|
|
|
|
|
|
|
lru->layer = layer;
|
|
|
|
lru->old_position = gimp_image_get_layer_index (gimage, layer);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_layer_reposition (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
void *data_ptr)
|
|
|
|
{
|
|
|
|
LayerRepositionUndo *data = data_ptr;
|
|
|
|
gint pos;
|
|
|
|
|
|
|
|
/* what's the layer's current index? */
|
|
|
|
pos = gimp_image_get_layer_index (gimage, data->layer);
|
|
|
|
gimp_image_position_layer (gimage, data->layer, data->old_position, FALSE);
|
|
|
|
|
|
|
|
data->old_position = pos;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_layer_reposition (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
void *data_ptr)
|
|
|
|
{
|
|
|
|
g_free (data_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Layer displacement Undo */
|
|
|
|
|
|
|
|
typedef struct _LayerDisplaceUndo LayerDisplaceUndo;
|
|
|
|
|
|
|
|
struct _LayerDisplaceUndo
|
|
|
|
{
|
|
|
|
gint info[3];
|
|
|
|
GSList *path_undo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_layer_displace (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_layer_displace (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_layer_displace (GimpImage *gimage,
|
|
|
|
GimpLayer *layer)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (LayerDisplaceUndo),
|
|
|
|
LAYER_DISPLACE_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
LayerDisplaceUndo *ldu;
|
|
|
|
|
|
|
|
ldu = g_new (LayerDisplaceUndo, 1);
|
|
|
|
|
|
|
|
new->data = ldu;
|
|
|
|
new->pop_func = undo_pop_layer_displace;
|
|
|
|
new->free_func = undo_free_layer_displace;
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
ldu->info[0] = gimp_item_get_ID (GIMP_ITEM (layer));
|
2002-02-24 01:29:19 +08:00
|
|
|
ldu->info[1] = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
ldu->info[2] = GIMP_DRAWABLE (layer)->offset_y;
|
|
|
|
ldu->path_undo = path_transform_start_undo (gimage);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_layer_displace (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer info_ptr)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
gint old_offsets[2];
|
|
|
|
LayerDisplaceUndo *ldu;
|
|
|
|
|
|
|
|
ldu = (LayerDisplaceUndo *) info_ptr;
|
2002-02-26 01:58:50 +08:00
|
|
|
layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, ldu->info[0]);
|
2002-02-24 01:29:19 +08:00
|
|
|
if (layer)
|
|
|
|
{
|
|
|
|
old_offsets[0] = GIMP_DRAWABLE (layer)->offset_x;
|
|
|
|
old_offsets[1] = 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->info[1];
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y = ldu->info[2];
|
|
|
|
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->info[1];
|
|
|
|
GIMP_DRAWABLE (layer->mask)->offset_y = ldu->info[2];
|
|
|
|
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->info[1] = old_offsets[0];
|
|
|
|
ldu->info[2] = old_offsets[1];
|
|
|
|
|
|
|
|
/* Now undo paths bits */
|
|
|
|
if (ldu->path_undo)
|
|
|
|
path_transform_do_undo (gimage, ldu->path_undo);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_layer_displace (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer info_ptr)
|
|
|
|
{
|
|
|
|
LayerDisplaceUndo * ldu;
|
|
|
|
|
|
|
|
ldu = (LayerDisplaceUndo *) info_ptr;
|
|
|
|
|
|
|
|
/* Free mem held for paths undo stuff */
|
|
|
|
if (ldu->path_undo)
|
|
|
|
path_transform_free_undo (ldu->path_undo);
|
|
|
|
|
|
|
|
g_free (info_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* 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,
|
|
|
|
UndoType type,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel);
|
|
|
|
static gboolean undo_pop_channel (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_channel (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_channel_add (GimpImage *gimage,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel)
|
|
|
|
{
|
|
|
|
return undo_push_channel (gimage, CHANNEL_ADD_UNDO,
|
|
|
|
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, CHANNEL_REMOVE_UNDO,
|
|
|
|
channel, prev_position, prev_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_push_channel (GimpImage *gimage,
|
|
|
|
UndoType type,
|
|
|
|
GimpChannel *channel,
|
|
|
|
gint prev_position,
|
|
|
|
GimpChannel *prev_channel)
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
Undo *new;
|
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-02 03:26:56 +08:00
|
|
|
g_return_val_if_fail (type == CHANNEL_ADD_UNDO ||
|
|
|
|
type == CHANNEL_REMOVE_UNDO,
|
|
|
|
FALSE);
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ChannelUndo) + gimp_object_get_memsize (GIMP_OBJECT (channel));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-02 03:26:56 +08:00
|
|
|
if ((new = undo_push (gimage, size, type, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ChannelUndo *cu;
|
2001-02-19 21:06:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
cu = g_new0 (ChannelUndo, 1);
|
|
|
|
|
|
|
|
new->data = cu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_channel;
|
|
|
|
new->free_func = undo_free_channel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
g_object_ref (G_OBJECT (channel));
|
|
|
|
|
|
|
|
cu->channel = channel;
|
|
|
|
cu->prev_position = prev_position;
|
|
|
|
cu->prev_channel = prev_channel;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-02-19 21:06:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_channel (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer cu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ChannelUndo *cu;
|
|
|
|
|
|
|
|
cu = (ChannelUndo *) cu_ptr;
|
|
|
|
|
1999-10-02 03:26:56 +08:00
|
|
|
if ((state == UNDO && type == CHANNEL_ADD_UNDO) ||
|
|
|
|
(state == REDO && type == CHANNEL_REMOVE_UNDO))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* remove channel */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the current position */
|
2000-12-29 23:22:01 +08:00
|
|
|
cu->prev_position = gimp_image_get_channel_index (gimage, cu->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* remove the channel */
|
2001-02-19 21:06:09 +08:00
|
|
|
gimp_container_remove (gimage->channels, GIMP_OBJECT (cu->channel));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if (cu->prev_channel)
|
|
|
|
{
|
|
|
|
/* set the previous channel */
|
|
|
|
gimp_image_set_active_channel (gimage, cu->prev_channel);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the area */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (cu->channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->width,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
/* restore channel */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* record the active channel */
|
2001-02-25 22:37:12 +08:00
|
|
|
cu->prev_channel = gimp_image_get_active_channel (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* add the new channel */
|
2001-02-19 21:06:09 +08:00
|
|
|
gimp_container_insert (gimage->channels,
|
|
|
|
GIMP_OBJECT (cu->channel), cu->prev_position);
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/* set the new channel */
|
|
|
|
gimp_image_set_active_channel (gimage, cu->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the area */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (cu->channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->width,
|
|
|
|
GIMP_DRAWABLE (cu->channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_channel (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer cu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ChannelUndo *cu;
|
|
|
|
|
|
|
|
cu = (ChannelUndo *) cu_ptr;
|
|
|
|
|
2001-07-25 09:03:43 +08:00
|
|
|
g_object_unref (G_OBJECT (cu->channel));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (cu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/**********************/
|
|
|
|
/* Channel Mod Undo */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
typedef struct _ChannelModUndo ChannelModUndo;
|
|
|
|
|
|
|
|
struct _ChannelModUndo
|
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpChannel *channel;
|
|
|
|
TileManager *tiles;
|
2001-11-29 09:06:44 +08:00
|
|
|
};
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_channel_mod (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_channel_mod (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_push_channel_mod (GimpImage *gimage,
|
|
|
|
GimpChannel *channel)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
TileManager *tiles;
|
|
|
|
Undo *new;
|
2002-02-26 08:04:55 +08:00
|
|
|
gsize size;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
tiles = GIMP_DRAWABLE (channel)->tiles;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
size = sizeof (ChannelModUndo) + tile_manager_get_memsize (tiles);
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
if ((new = undo_push (gimage, size, CHANNEL_MOD_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ChannelModUndo *cmu;
|
|
|
|
|
|
|
|
cmu = g_new0 (ChannelModUndo, 1);
|
|
|
|
|
|
|
|
new->data = cmu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_channel_mod;
|
|
|
|
new->free_func = undo_free_channel_mod;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
cmu->channel = channel;
|
|
|
|
cmu->tiles = tiles;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (tiles);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_channel_mod (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2002-02-25 05:00:58 +08:00
|
|
|
gpointer cmu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
ChannelModUndo *cmu;
|
2001-11-29 09:06:44 +08:00
|
|
|
TileManager *tiles;
|
|
|
|
TileManager *temp;
|
|
|
|
GimpChannel *channel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
cmu = (ChannelModUndo *) cmu_ptr;
|
|
|
|
|
|
|
|
channel = cmu->channel;
|
|
|
|
tiles = cmu->tiles;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the first update */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (channel)->width,
|
|
|
|
GIMP_DRAWABLE (channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
temp = GIMP_DRAWABLE (channel)->tiles;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
GIMP_DRAWABLE (channel)->tiles = tiles;
|
|
|
|
GIMP_DRAWABLE (channel)->width = tile_manager_width (tiles);
|
|
|
|
GIMP_DRAWABLE (channel)->height = tile_manager_height (tiles);
|
2001-01-23 21:01:48 +08:00
|
|
|
GIMP_CHANNEL (channel)->bounds_known = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Set the new buffer */
|
2002-02-25 05:00:58 +08:00
|
|
|
cmu->tiles = temp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Issue the second update */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (channel),
|
|
|
|
0, 0,
|
|
|
|
GIMP_DRAWABLE (channel)->width,
|
|
|
|
GIMP_DRAWABLE (channel)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2002-02-25 05:00:58 +08:00
|
|
|
undo_free_channel_mod (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer cmu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
ChannelModUndo *cmu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
cmu = (ChannelModUndo *) cmu_ptr;
|
|
|
|
|
|
|
|
tile_manager_destroy (cmu->tiles);
|
|
|
|
|
|
|
|
g_free (cmu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/******************************/
|
|
|
|
/* Channel re-position Undo */
|
|
|
|
|
|
|
|
typedef struct _ChannelRepositionUndo ChannelRepositionUndo;
|
|
|
|
|
|
|
|
struct _ChannelRepositionUndo
|
|
|
|
{
|
|
|
|
GimpChannel *channel;
|
|
|
|
gint old_position;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean undo_pop_channel_reposition (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_channel_reposition (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_channel_reposition (GimpImage *gimage,
|
|
|
|
GimpChannel *channel)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (ChannelRepositionUndo),
|
|
|
|
CHANNEL_REPOSITION_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
ChannelRepositionUndo *cru;
|
|
|
|
|
|
|
|
cru = g_new0 (ChannelRepositionUndo, 1);
|
|
|
|
|
|
|
|
new->data = cru;
|
|
|
|
new->pop_func = undo_pop_channel_reposition;
|
|
|
|
new->free_func = undo_free_channel_reposition;
|
|
|
|
|
|
|
|
cru->channel = channel;
|
|
|
|
cru->old_position = gimp_image_get_channel_index (gimage, channel);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_channel_reposition (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2002-02-25 05:00:58 +08:00
|
|
|
gpointer cru_ptr)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
ChannelRepositionUndo *cru;
|
2002-02-24 01:29:19 +08:00
|
|
|
gint pos;
|
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
cru = (ChannelRepositionUndo *) cru_ptr;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* what's the channel's current index? */
|
2002-02-25 05:00:58 +08:00
|
|
|
pos = gimp_image_get_channel_index (gimage, cru->channel);
|
|
|
|
gimp_image_position_channel (gimage, cru->channel, cru->old_position, FALSE);
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2002-02-25 05:00:58 +08:00
|
|
|
cru->old_position = pos;
|
2002-02-24 01:29:19 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_channel_reposition (UndoState state,
|
|
|
|
UndoType type,
|
2002-02-25 05:00:58 +08:00
|
|
|
gpointer cru_ptr)
|
2002-02-24 01:29:19 +08:00
|
|
|
{
|
2002-02-25 05:00:58 +08:00
|
|
|
g_free (cru_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* 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,
|
|
|
|
UndoType type,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors);
|
|
|
|
static gboolean undo_pop_vectors (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_vectors (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_vectors_add (GimpImage *gimage,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors)
|
|
|
|
{
|
|
|
|
return undo_push_vectors (gimage, VECTORS_ADD_UNDO,
|
|
|
|
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, VECTORS_REMOVE_UNDO,
|
|
|
|
vectors, prev_position, prev_vectors);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_push_vectors (GimpImage *gimage,
|
|
|
|
UndoType type,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gint prev_position,
|
|
|
|
GimpVectors *prev_vectors)
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
Undo *new;
|
|
|
|
gsize size;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (type == VECTORS_ADD_UNDO ||
|
|
|
|
type == VECTORS_REMOVE_UNDO,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
size = sizeof (VectorsUndo) + gimp_object_get_memsize (GIMP_OBJECT (vectors));
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, size, type, TRUE)))
|
|
|
|
{
|
|
|
|
VectorsUndo *vu;
|
|
|
|
|
|
|
|
vu = g_new0 (VectorsUndo, 1);
|
|
|
|
|
|
|
|
new->data = vu;
|
|
|
|
new->pop_func = undo_pop_vectors;
|
|
|
|
new->free_func = undo_free_vectors;
|
|
|
|
|
|
|
|
g_object_ref (G_OBJECT (vectors));
|
|
|
|
|
|
|
|
vu->vectors = vectors;
|
|
|
|
vu->prev_position = prev_position;
|
|
|
|
vu->prev_vectors = prev_vectors;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_vectors (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer vu_ptr)
|
|
|
|
{
|
|
|
|
VectorsUndo *vu;
|
|
|
|
|
|
|
|
vu = (VectorsUndo *) vu_ptr;
|
|
|
|
|
|
|
|
if ((state == UNDO && type == VECTORS_ADD_UNDO) ||
|
|
|
|
(state == REDO && type == VECTORS_REMOVE_UNDO))
|
|
|
|
{
|
|
|
|
/* 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));
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if (vu->prev_vectors)
|
|
|
|
{
|
|
|
|
/* set the previous vectors */
|
|
|
|
gimp_image_set_active_vectors (gimage, vu->prev_vectors);
|
|
|
|
}
|
2002-02-25 05:00:58 +08:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
/* set the new vectors */
|
|
|
|
gimp_image_set_active_vectors (gimage, vu->vectors);
|
2002-02-25 05:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_vectors (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer vu_ptr)
|
|
|
|
{
|
|
|
|
VectorsUndo *vu;
|
|
|
|
|
|
|
|
vu = (VectorsUndo *) vu_ptr;
|
|
|
|
|
|
|
|
g_object_unref (G_OBJECT (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 (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_vectors_mod (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_vectors_mod (GimpImage *gimage,
|
|
|
|
GimpVectors *vectors)
|
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
Undo *new;
|
|
|
|
gsize size;
|
2002-02-25 05:00:58 +08:00
|
|
|
|
|
|
|
size = (sizeof (VectorsModUndo) +
|
|
|
|
gimp_object_get_memsize (GIMP_OBJECT (vectors)));
|
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
if ((new = undo_push (gimage, size, VECTORS_MOD_UNDO, TRUE)))
|
2002-02-25 05:00:58 +08:00
|
|
|
{
|
|
|
|
VectorsModUndo *vmu;
|
|
|
|
|
|
|
|
vmu = g_new0 (VectorsModUndo, 1);
|
|
|
|
|
|
|
|
new->data = vmu;
|
|
|
|
new->pop_func = undo_pop_vectors_mod;
|
|
|
|
new->free_func = undo_free_vectors_mod;
|
|
|
|
|
|
|
|
vmu->vectors = vectors;
|
|
|
|
vmu->undo_vectors = NULL; /* gimp_vectors_duplicate (vectors); */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_vectors_mod (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer vmu_ptr)
|
|
|
|
{
|
|
|
|
VectorsModUndo *vmu;
|
|
|
|
GimpVectors *temp;
|
|
|
|
|
|
|
|
vmu = (VectorsModUndo *) vmu_ptr;
|
|
|
|
|
|
|
|
temp = vmu->undo_vectors;
|
|
|
|
|
|
|
|
vmu->undo_vectors = NULL; /* gimp_vectors_duplicate (vmu->vectors); */
|
|
|
|
|
|
|
|
/* gimp_vectors_copy_strokes (temp, vmu->vectors); */
|
|
|
|
|
|
|
|
/* g_object_unref (G_OBJECT (temp)); */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
undo_free_vectors_mod (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer vmu_ptr)
|
|
|
|
{
|
|
|
|
VectorsModUndo *vmu;
|
|
|
|
|
|
|
|
vmu = (VectorsModUndo *) vmu_ptr;
|
|
|
|
|
|
|
|
/* g_object_unref (G_OBJECT (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 (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_vectors_reposition (UndoState, UndoType, gpointer);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
undo_push_vectors_reposition (GimpImage *gimage,
|
|
|
|
GimpVectors *vectors)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (VectorsRepositionUndo),
|
|
|
|
VECTORS_REPOSITION_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
VectorsRepositionUndo *vru;
|
|
|
|
|
|
|
|
vru = g_new0 (VectorsRepositionUndo, 1);
|
|
|
|
|
|
|
|
new->data = vru;
|
|
|
|
new->pop_func = undo_pop_vectors_reposition;
|
|
|
|
new->free_func = undo_free_vectors_reposition;
|
|
|
|
|
|
|
|
vru->vectors = vectors;
|
|
|
|
vru->old_position = gimp_image_get_vectors_index (gimage, vectors);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
undo_pop_vectors_reposition (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer vru_ptr)
|
|
|
|
{
|
|
|
|
VectorsRepositionUndo *vru;
|
|
|
|
gint pos;
|
|
|
|
|
|
|
|
vru = (VectorsRepositionUndo *) vru_ptr;
|
|
|
|
|
|
|
|
/* 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 (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer vru_ptr)
|
|
|
|
{
|
|
|
|
g_free (vru_ptr);
|
2002-02-24 01:29:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/**************************************/
|
|
|
|
/* Floating Selection to Layer Undo */
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _FStoLayerUndo FStoLayerUndo;
|
|
|
|
|
|
|
|
struct _FStoLayerUndo
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpLayer *floating_layer; /* the floating layer */
|
|
|
|
GimpDrawable *drawable; /* drawable of floating sel */
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_fs_to_layer (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_fs_to_layer (UndoState, UndoType, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
|
|
|
undo_push_fs_to_layer (GimpImage *gimage,
|
|
|
|
GimpLayer *floating_layer,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
|
|
|
if ((new = undo_push (gimage, sizeof (FStoLayerUndo),
|
|
|
|
FS_TO_LAYER_UNDO, TRUE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
FStoLayerUndo *fsu;
|
|
|
|
|
|
|
|
fsu = g_new0 (FStoLayerUndo, 1);
|
|
|
|
|
|
|
|
new->data = fsu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_fs_to_layer;
|
|
|
|
new->free_func = undo_free_fs_to_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
fsu->floating_layer = floating_layer;
|
|
|
|
fsu->drawable = drawable;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (floating_layer->fs.backing_store);
|
|
|
|
floating_layer->fs.backing_store = NULL;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_fs_to_layer (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer fsu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FStoLayerUndo *fsu;
|
|
|
|
|
|
|
|
fsu = (FStoLayerUndo *) fsu_ptr;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case UNDO:
|
|
|
|
/* Update the preview for the floating sel */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
fsu->floating_layer->fs.drawable = fsu->drawable;
|
|
|
|
gimp_image_set_active_layer (gimage, fsu->floating_layer);
|
|
|
|
gimage->floating_sel = fsu->floating_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* restore the contents of the drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
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;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* clear the selection */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_layer_invalidate_boundary (fsu->floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the preview for the gimage and underlying drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case REDO:
|
|
|
|
/* restore the contents of the drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
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);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the preview for the gimage and underlying drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* clear the selection */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_layer_invalidate_boundary (fsu->floating_layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the pointers */
|
2002-02-24 01:29:19 +08:00
|
|
|
fsu->floating_layer->fs.drawable = NULL;
|
1998-01-22 15:02:57 +08:00
|
|
|
gimage->floating_sel = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the fs drawable */
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (fsu->floating_layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-08 09:32:25 +08:00
|
|
|
gimp_image_floating_selection_changed (gimage);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_fs_to_layer (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer fsu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FStoLayerUndo *fsu;
|
|
|
|
|
|
|
|
fsu = (FStoLayerUndo *) fsu_ptr;
|
|
|
|
|
|
|
|
if (state == UNDO)
|
2001-11-10 00:54:56 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
tile_manager_destroy (fsu->floating_layer->fs.backing_store);
|
|
|
|
fsu->floating_layer->fs.backing_store = NULL;
|
2001-11-10 00:54:56 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (fsu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
/* Floating Selection Rigor Undo */
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_fs_rigor (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_fs_rigor (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_fs_rigor (GimpImage *gimage,
|
|
|
|
gint layer_ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (gint32),
|
|
|
|
FS_RIGOR_UNDO, FALSE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 06:51:23 +08:00
|
|
|
new->data = g_new (gint32, 1);
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_fs_rigor;
|
|
|
|
new->free_func = undo_free_fs_rigor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-06-08 06:51:23 +08:00
|
|
|
*((gint32 *) new->data) = layer_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_fs_rigor (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer layer_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 07:25:25 +08:00
|
|
|
gint32 layer_ID;
|
|
|
|
GimpLayer *floating_layer;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
|
|
|
layer_ID = *((gint32 *) layer_ptr);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if ((floating_layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, layer_ID)) == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2001-01-29 07:25:25 +08:00
|
|
|
if (! gimp_layer_is_floating_sel (floating_layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case UNDO:
|
|
|
|
/* restore the contents of drawable the floating layer is attached to */
|
|
|
|
if (floating_layer->fs.initial == FALSE)
|
|
|
|
floating_sel_restore (floating_layer,
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->width,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
floating_layer->fs.initial = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REDO:
|
|
|
|
/* store the affected area from the drawable in the backing store */
|
|
|
|
floating_sel_store (floating_layer,
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->width,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
floating_layer->fs.initial = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-08 09:32:25 +08:00
|
|
|
gimp_image_floating_selection_changed (gimage);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_fs_rigor (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer layer_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
g_free (layer_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
/* Floating Selection Relax Undo */
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_fs_relax (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_fs_relax (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_fs_relax (GimpImage *gimage,
|
|
|
|
gint32 layer_ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Undo *new;
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (gint32),
|
|
|
|
FS_RELAX_UNDO, FALSE)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 06:51:23 +08:00
|
|
|
new->data = g_new (gint32, 1);
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_fs_relax;
|
|
|
|
new->free_func = undo_free_fs_relax;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-06-08 06:51:23 +08:00
|
|
|
*((gint32 *) new->data) = layer_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_fs_relax (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer layer_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 07:25:25 +08:00
|
|
|
gint32 layer_ID;
|
|
|
|
GimpLayer *floating_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-06-08 06:51:23 +08:00
|
|
|
layer_ID = *((gint32 *) layer_ptr);
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if ((floating_layer = (GimpLayer *) gimp_item_get_by_ID (gimage->gimp, layer_ID)) == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
2000-06-08 06:51:23 +08:00
|
|
|
|
2001-01-29 07:25:25 +08:00
|
|
|
if (! gimp_layer_is_floating_sel (floating_layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case UNDO:
|
|
|
|
/* store the affected area from the drawable in the backing store */
|
|
|
|
floating_sel_store (floating_layer,
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->width,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
floating_layer->fs.initial = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REDO:
|
|
|
|
/* restore the contents of drawable the floating layer is attached to */
|
|
|
|
if (floating_layer->fs.initial == FALSE)
|
|
|
|
floating_sel_restore (floating_layer,
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_x,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->offset_y,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->width,
|
|
|
|
GIMP_DRAWABLE (floating_layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
floating_layer->fs.initial = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-08 09:32:25 +08:00
|
|
|
gimp_image_floating_selection_changed (gimage);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_fs_relax (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer layer_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
g_free (layer_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/********************/
|
|
|
|
/* Transform Undo */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _TransformUndo TransformUndo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _TransformUndo
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
gint tool_ID;
|
|
|
|
GType tool_type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
TransInfo trans_info;
|
|
|
|
TileManager *original;
|
|
|
|
gpointer path_undo;
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_transform (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_transform (UndoState, UndoType, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gboolean
|
|
|
|
undo_push_transform (GimpImage *gimage,
|
|
|
|
gint tool_ID,
|
|
|
|
GType tool_type,
|
|
|
|
gdouble *trans_info,
|
|
|
|
TileManager *original,
|
|
|
|
GSList *path_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (TransformUndo),
|
|
|
|
TRANSFORM_UNDO, FALSE)))
|
|
|
|
{
|
|
|
|
TransformUndo *tu;
|
|
|
|
gint i;
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tu = g_new0 (TransformUndo, 1);
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
new->data = tu;
|
|
|
|
new->pop_func = undo_pop_transform;
|
|
|
|
new->free_func = undo_free_transform;
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tu->tool_ID = tool_ID;
|
|
|
|
tu->tool_type = tool_type;
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
for (i = 0; i < TRAN_INFO_SIZE; i++)
|
|
|
|
tu->trans_info[i] = trans_info[i];
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tu->original = original;
|
|
|
|
tu->path_undo = path_undo;
|
1999-07-07 11:18:54 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_pop_transform (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer tu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpTool *active_tool;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpTransformTool *tt;
|
|
|
|
TransformUndo *tu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tt = GIMP_TRANSFORM_TOOL (active_tool);
|
|
|
|
tu = (TransformUndo *) tu_ptr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
path_transform_do_undo (gimage, tu->path_undo);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* 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;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* 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;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* swap the original buffer--the source buffer for repeated transforms
|
|
|
|
*/
|
|
|
|
temp = tu->original;
|
|
|
|
tu->original = tt->original;
|
|
|
|
tt->original = temp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* If we're re-implementing the first transform, reactivate tool */
|
|
|
|
if (state == REDO && tt->original)
|
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_tool_control_activate(active_tool->control);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-14 07:07:45 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_free_transform (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer tu_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
TransformUndo * tu;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
tu = (TransformUndo *) tu_ptr;
|
|
|
|
if (tu->original)
|
|
|
|
tile_manager_destroy (tu->original);
|
|
|
|
path_transform_free_undo (tu->path_undo);
|
|
|
|
g_free (tu);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
|
1999-09-30 00:44:52 +08:00
|
|
|
/****************/
|
2002-02-24 01:29:19 +08:00
|
|
|
/* Paint Undo */
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
typedef struct _PaintUndo PaintUndo;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
struct _PaintUndo
|
1999-09-30 00:44:52 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
gint core_ID;
|
|
|
|
GType core_type;
|
|
|
|
|
|
|
|
GimpCoords last_coords;
|
1999-09-30 00:44:52 +08:00
|
|
|
};
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_paint (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_paint (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_push_paint (GimpImage *gimage,
|
|
|
|
gint core_ID,
|
|
|
|
GType core_type,
|
|
|
|
GimpCoords *last_coords)
|
1999-09-30 00:44:52 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (PaintUndo),
|
|
|
|
PAINT_UNDO, FALSE)))
|
1999-09-30 00:44:52 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
PaintUndo *pu;
|
|
|
|
|
|
|
|
pu = g_new0 (PaintUndo, 1);
|
|
|
|
|
|
|
|
new->data = pu;
|
|
|
|
new->pop_func = undo_pop_paint;
|
|
|
|
new->free_func = undo_free_paint;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->core_ID = core_ID;
|
|
|
|
pu->core_type = core_type;
|
|
|
|
pu->last_coords = *last_coords;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_pop_paint (GimpImage *gimage,
|
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer pu_ptr)
|
1999-09-30 00:44:52 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpTool *active_tool;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if (GIMP_IS_PAINT_TOOL (active_tool))
|
2001-11-01 05:18:57 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
GimpPaintTool *pt;
|
|
|
|
PaintUndo *pu;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pt = GIMP_PAINT_TOOL (active_tool);
|
|
|
|
pu = (PaintUndo *) pu_ptr;
|
2001-11-01 05:18:57 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* only pop if the active paint core is the one that pushed this undo */
|
|
|
|
if (pu->core_ID == pt->core->ID)
|
|
|
|
{
|
|
|
|
GimpCoords tmp_coords;
|
1999-09-30 00:44:52 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/* swap the paint core information */
|
|
|
|
tmp_coords = pt->core->last_coords;
|
|
|
|
pt->core->last_coords = pu->last_coords;
|
|
|
|
pu->last_coords = tmp_coords;
|
|
|
|
}
|
2001-11-01 05:18:57 +08:00
|
|
|
}
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
|
1999-09-30 00:44:52 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-02-24 01:29:19 +08:00
|
|
|
undo_free_paint (UndoState state,
|
|
|
|
UndoType type,
|
|
|
|
gpointer pu_ptr)
|
1999-09-30 00:44:52 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
PaintUndo *pu;
|
|
|
|
|
|
|
|
pu = (PaintUndo *) pu_ptr;
|
|
|
|
g_free (pu);
|
1999-09-30 00:44:52 +08:00
|
|
|
}
|
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/*******************/
|
|
|
|
/* Parasite Undo */
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
typedef struct _ParasiteUndo ParasiteUndo;
|
|
|
|
|
|
|
|
struct _ParasiteUndo
|
|
|
|
{
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpImage *gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpItem *item;
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *parasite;
|
|
|
|
gchar *name;
|
1999-04-23 14:07:09 +08:00
|
|
|
};
|
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_parasite (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_parasite (UndoState, UndoType, gpointer);
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_image_parasite (GimpImage *gimage,
|
|
|
|
gpointer parasite)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (ParasiteUndo),
|
|
|
|
PARASITE_ATTACH_UNDO, TRUE)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
|
|
|
pu = g_new0 (ParasiteUndo, 1);
|
|
|
|
|
|
|
|
new->data = pu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_parasite;
|
|
|
|
new->free_func = undo_free_parasite;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = NULL;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (gimp_parasite_name (parasite));
|
|
|
|
pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_image_parasite_remove (GimpImage *gimage,
|
2000-05-27 06:28:40 +08:00
|
|
|
const gchar *name)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (ParasiteUndo),
|
|
|
|
PARASITE_REMOVE_UNDO, TRUE)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
|
|
|
pu = g_new0 (ParasiteUndo, 1);
|
|
|
|
|
|
|
|
new->data = pu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_parasite;
|
|
|
|
new->free_func = undo_free_parasite;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = NULL;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (name);
|
|
|
|
pu->parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-26 01:58:50 +08:00
|
|
|
undo_push_item_parasite (GimpImage *gimage,
|
|
|
|
GimpItem *item,
|
|
|
|
gpointer parasite)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (ParasiteUndo),
|
|
|
|
PARASITE_ATTACH_UNDO, TRUE)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
|
|
|
pu = g_new0 (ParasiteUndo, 1);
|
|
|
|
|
|
|
|
new->data = pu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_parasite;
|
|
|
|
new->free_func = undo_free_parasite;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = NULL;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = item;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (gimp_parasite_name (parasite));
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (item,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2002-02-26 01:58:50 +08:00
|
|
|
undo_push_item_parasite_remove (GimpImage *gimage,
|
|
|
|
GimpItem *item,
|
|
|
|
const gchar *name)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
Undo *new;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
if ((new = undo_push (gimage, sizeof (ParasiteUndo),
|
|
|
|
PARASITE_REMOVE_UNDO, TRUE)))
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
ParasiteUndo *pu;
|
|
|
|
|
|
|
|
pu = g_new0 (ParasiteUndo, 1);
|
|
|
|
|
|
|
|
new->data = pu;
|
2000-05-27 06:28:40 +08:00
|
|
|
new->pop_func = undo_pop_parasite;
|
|
|
|
new->free_func = undo_free_parasite;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->gimage = NULL;
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->item = item;
|
2002-02-24 01:29:19 +08:00
|
|
|
pu->name = g_strdup (name);
|
2002-02-26 01:58:50 +08:00
|
|
|
pu->parasite = gimp_parasite_copy (gimp_item_parasite_find (item,
|
|
|
|
pu->name));
|
1999-04-23 14:07:09 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_parasite (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data_ptr)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
|
|
|
ParasiteUndo *data;
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *tmp;
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
data = data_ptr;
|
|
|
|
|
|
|
|
tmp = data->parasite;
|
|
|
|
|
|
|
|
if (data->gimage)
|
2000-01-26 07:06:12 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
data->parasite =
|
|
|
|
gimp_parasite_copy (gimp_image_parasite_find (gimage, data->name));
|
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
if (tmp)
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list_add (data->gimage->parasites, tmp);
|
2000-01-26 07:06:12 +08:00
|
|
|
else
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list_remove (data->gimage->parasites, data->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
else if (data->item)
|
2000-01-26 07:06:12 +08:00
|
|
|
{
|
|
|
|
data->parasite =
|
2002-02-26 01:58:50 +08:00
|
|
|
gimp_parasite_copy (gimp_item_parasite_find (data->item,
|
|
|
|
data->name));
|
2000-01-26 07:06:12 +08:00
|
|
|
if (tmp)
|
2002-02-26 01:58:50 +08:00
|
|
|
gimp_parasite_list_add (data->item->parasites, tmp);
|
2000-01-26 07:06:12 +08:00
|
|
|
else
|
2002-02-26 01:58:50 +08:00
|
|
|
gimp_parasite_list_remove (data->item->parasites, data->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
}
|
1999-04-23 14:07:09 +08:00
|
|
|
else
|
2000-01-26 07:06:12 +08:00
|
|
|
{
|
2001-07-05 06:59:25 +08:00
|
|
|
data->parasite = gimp_parasite_copy (gimp_parasite_find (gimage->gimp,
|
|
|
|
data->name));
|
2000-01-26 07:06:12 +08:00
|
|
|
if (tmp)
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_attach (gimage->gimp, tmp);
|
2000-01-26 07:06:12 +08:00
|
|
|
else
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_detach (gimage->gimp, data->name);
|
2000-01-26 07:06:12 +08:00
|
|
|
}
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
if (tmp)
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_free (tmp);
|
1999-04-23 14:07:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_parasite (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data_ptr)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
|
|
|
ParasiteUndo *data;
|
|
|
|
|
|
|
|
data = data_ptr;
|
|
|
|
|
|
|
|
if (data->parasite)
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_free (data->parasite);
|
1999-04-23 14:07:09 +08:00
|
|
|
if (data->name)
|
|
|
|
g_free (data->name);
|
|
|
|
|
|
|
|
g_free (data_ptr);
|
|
|
|
}
|
|
|
|
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
/******************************************************************************/
|
|
|
|
/* Something for which programmer is too lazy to write an undo function for */
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-24 01:29:19 +08:00
|
|
|
static gboolean undo_pop_cantundo (GimpImage *,
|
|
|
|
UndoState, UndoType, gpointer);
|
|
|
|
static void undo_free_cantundo (UndoState, UndoType, gpointer);
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_push_cantundo (GimpImage *gimage,
|
2000-06-08 06:51:23 +08:00
|
|
|
const gchar *action)
|
1999-08-23 22:34:58 +08:00
|
|
|
{
|
2000-01-26 07:06:12 +08:00
|
|
|
Undo *new;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
/* This is the sole purpose of this type of undo: the ability to
|
|
|
|
* mark an image as having been mutated, without really providing
|
2002-02-24 01:29:19 +08:00
|
|
|
* any adequate undo facility.
|
|
|
|
*/
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
if ((new = undo_push (gimage, 0, CANT_UNDO, TRUE)))
|
|
|
|
{
|
|
|
|
new->data = (gpointer) action;
|
|
|
|
new->pop_func = undo_pop_cantundo;
|
|
|
|
new->free_func = undo_free_cantundo;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2002-02-26 08:04:55 +08:00
|
|
|
return FALSE;
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static gboolean
|
2001-01-29 00:44:22 +08:00
|
|
|
undo_pop_cantundo (GimpImage *gimage,
|
1999-10-14 07:07:45 +08:00
|
|
|
UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data_ptr)
|
1999-08-23 22:34:58 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar *action = data_ptr;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
1999-08-23 22:34:58 +08:00
|
|
|
case UNDO:
|
2000-01-26 07:06:12 +08:00
|
|
|
g_message (_("Can't undo %s"), action);
|
|
|
|
break;
|
1999-08-23 22:34:58 +08:00
|
|
|
|
|
|
|
case REDO:
|
2000-01-26 07:06:12 +08:00
|
|
|
break;
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
return TRUE;
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
undo_free_cantundo (UndoState state,
|
|
|
|
UndoType type,
|
2000-06-08 06:51:23 +08:00
|
|
|
gpointer data_ptr)
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
{
|
2000-01-26 07:06:12 +08:00
|
|
|
/* nothing to free */
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
static struct undo_name_t
|
|
|
|
{
|
|
|
|
UndoType type;
|
|
|
|
const gchar *name;
|
|
|
|
}
|
|
|
|
undo_name[] =
|
|
|
|
{
|
2002-02-24 01:29:19 +08:00
|
|
|
{ NO_UNDO_GROUP, N_("<<invalid>>") },
|
|
|
|
{ IMAGE_SCALE_UNDO_GROUP, N_("Scale Image") },
|
|
|
|
{ IMAGE_RESIZE_UNDO_GROUP, N_("Resize Image") },
|
|
|
|
{ IMAGE_CONVERT_UNDO_GROUP, N_("Convert Image") },
|
|
|
|
{ IMAGE_CROP_UNDO_GROUP, N_("Crop Image") },
|
|
|
|
{ IMAGE_LAYERS_MERGE_UNDO_GROUP, N_("Merge Layers") },
|
|
|
|
{ IMAGE_QMASK_UNDO_GROUP, N_("QuickMask") },
|
|
|
|
{ IMAGE_GUIDE_UNDO_GROUP, N_("Guide") },
|
2002-02-26 08:04:55 +08:00
|
|
|
{ LAYER_PROPERTIES_UNDO_GROUP, N_("Layer Properties") },
|
2002-02-24 01:29:19 +08:00
|
|
|
{ LAYER_SCALE_UNDO_GROUP, N_("Scale Layer") },
|
|
|
|
{ LAYER_RESIZE_UNDO_GROUP, N_("Resize Layer") },
|
|
|
|
{ LAYER_DISPLACE_UNDO_GROUP, N_("Move Layer") },
|
|
|
|
{ LAYER_APPLY_MASK_UNDO_GROUP, N_("Apply Layer Mask") },
|
|
|
|
{ LAYER_LINKED_UNDO_GROUP, N_("Linked Layer") },
|
|
|
|
{ FS_FLOAT_UNDO_GROUP, N_("Float Selection") },
|
|
|
|
{ FS_ANCHOR_UNDO_GROUP, N_("Anchor Floating Selection") },
|
|
|
|
{ EDIT_PASTE_UNDO_GROUP, N_("Paste") },
|
|
|
|
{ EDIT_CUT_UNDO_GROUP, N_("Cut") },
|
|
|
|
{ TEXT_UNDO_GROUP, N_("Text") },
|
|
|
|
{ TRANSFORM_UNDO_GROUP, N_("Transform") },
|
|
|
|
{ PAINT_UNDO_GROUP, N_("Paint") },
|
2002-02-25 02:31:48 +08:00
|
|
|
{ PARASITE_ATTACH_UNDO_GROUP, N_("Attach Parasite") },
|
|
|
|
{ PARASITE_REMOVE_UNDO_GROUP, N_("Remove Parasite") },
|
2002-02-24 01:29:19 +08:00
|
|
|
{ MISC_UNDO_GROUP, N_("Plug-In") },
|
|
|
|
|
2002-02-24 02:29:07 +08:00
|
|
|
{ IMAGE_UNDO, N_("Image") },
|
|
|
|
{ IMAGE_MOD_UNDO, N_("Image Mod") },
|
|
|
|
{ IMAGE_TYPE_UNDO, N_("Image Type") },
|
|
|
|
{ IMAGE_SIZE_UNDO, N_("Image Size") },
|
|
|
|
{ IMAGE_RESOLUTION_UNDO, N_("Resolution Change") },
|
|
|
|
{ IMAGE_QMASK_UNDO, N_("QuickMask") },
|
|
|
|
{ IMAGE_GUIDE_UNDO, N_("Guide") },
|
2002-08-20 18:22:23 +08:00
|
|
|
{ MASK_UNDO, N_("Selection Mask") },
|
2002-02-26 08:04:55 +08:00
|
|
|
{ ITEM_RENAME_UNDO, N_("Rename Item") },
|
2002-02-24 02:29:07 +08:00
|
|
|
{ LAYER_ADD_UNDO, N_("New Layer") },
|
|
|
|
{ LAYER_REMOVE_UNDO, N_("Delete Layer") },
|
|
|
|
{ LAYER_MOD_UNDO, N_("Layer Mod") },
|
|
|
|
{ LAYER_MASK_ADD_UNDO, N_("Add Layer Mask") },
|
|
|
|
{ LAYER_MASK_REMOVE_UNDO, N_("Delete Layer Mask") },
|
|
|
|
{ LAYER_REPOSITION_UNDO, N_("Layer Reposition") },
|
|
|
|
{ LAYER_DISPLACE_UNDO, N_("Layer Move") },
|
|
|
|
{ CHANNEL_ADD_UNDO, N_("New Channel") },
|
|
|
|
{ CHANNEL_REMOVE_UNDO, N_("Delete Channel") },
|
|
|
|
{ CHANNEL_MOD_UNDO, N_("Channel Mod") },
|
|
|
|
{ CHANNEL_REPOSITION_UNDO, N_("Channel Reposition") },
|
2002-02-25 05:00:58 +08:00
|
|
|
{ VECTORS_ADD_UNDO, N_("New Vectors") },
|
|
|
|
{ VECTORS_REMOVE_UNDO, N_("Delete Vectors") },
|
|
|
|
{ VECTORS_MOD_UNDO, N_("Vectors Mod") },
|
|
|
|
{ VECTORS_REPOSITION_UNDO, N_("Vectors Reposition") },
|
2002-02-24 02:29:07 +08:00
|
|
|
{ FS_TO_LAYER_UNDO, N_("FS to Layer") },
|
|
|
|
{ FS_RIGOR_UNDO, N_("FS Rigor") },
|
|
|
|
{ FS_RELAX_UNDO, N_("FS Relax") },
|
|
|
|
{ TRANSFORM_UNDO, N_("Transform") },
|
|
|
|
{ PAINT_UNDO, N_("Paint") },
|
|
|
|
{ PARASITE_ATTACH_UNDO, N_("Attach Parasite") },
|
|
|
|
{ PARASITE_REMOVE_UNDO, N_("Remove Parasite") },
|
2002-02-24 01:29:19 +08:00
|
|
|
|
2002-06-09 20:53:42 +08:00
|
|
|
{ CANT_UNDO, "EEK: can't undo" }
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
};
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
static const gchar *
|
1999-09-24 07:42:38 +08:00
|
|
|
undo_type_to_name (UndoType type)
|
1999-08-23 22:34:58 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gint i;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2001-08-07 20:42:23 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (undo_name); i++)
|
2000-01-26 07:06:12 +08:00
|
|
|
if (undo_name[i].type == type)
|
|
|
|
return gettext (undo_name[i].name);
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
/* no name found */
|
|
|
|
return "";
|
1999-08-23 22:34:58 +08:00
|
|
|
}
|