Finally implemented the suggestion in bug #144854, of
	"strong" undo/redo commands that continue undoing so long
	as they only encounter visibility changes.

	* app/actions/edit-actions.c
	* app/actions/edit-commands.c
	* app/actions/edit-commands.h: added "strong undo"
	and "strong redo" commands/actions.

	* app/core/gimpimage-undo.[ch]: added functions
	gimp_image_strong_undo() and gimp_image_strong_redo().

	* app/core/gimpundo.[ch]: added utility function
	gimp_undo_is_weak().

	* app/widgets/gimphelp-ids.h:added id's.

	* menus/image-menu.xml.in: added to edit menu,
	bound to C-S-z and C-S-y.

	This will no doubt need tweaking, but I will consider it
	to fix bug #144854.
This commit is contained in:
William Skaggs
2006-06-13 02:03:44 +00:00
parent cd9811b321
commit 701b7b31d7
10 changed files with 163 additions and 4 deletions

View File

@ -1,3 +1,28 @@
2006-06-12 Bill Skaggs <weskaggs@primate.ucdavis.edu>
Finally implemented the suggestion in bug #144854, of
"strong" undo/redo commands that continue undoing so long
as they only encounter visibility changes.
* app/actions/edit-actions.c
* app/actions/edit-commands.c
* app/actions/edit-commands.h: added "strong undo"
and "strong redo" commands/actions.
* app/core/gimpimage-undo.[ch]: added functions
gimp_image_strong_undo() and gimp_image_strong_redo().
* app/core/gimpundo.[ch]: added utility function
gimp_undo_is_weak().
* app/widgets/gimphelp-ids.h:added id's.
* menus/image-menu.xml.in: added to edit menu,
bound to C-S-z and C-S-y.
This will no doubt need tweaking, but I will consider it
to fix bug #144854.
2006-06-12 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* plug-ins/common/gnomeprint.c: try not to distort

View File

@ -78,6 +78,18 @@ static const GimpActionEntry edit_actions[] =
G_CALLBACK (edit_redo_cmd_callback),
GIMP_HELP_EDIT_REDO },
{ "edit-strong-undo", GTK_STOCK_UNDO,
N_("Strong Undo"), "<control><shift>Z",
N_("Undo the last operation, skipping over some types"),
G_CALLBACK (edit_strong_undo_cmd_callback),
GIMP_HELP_EDIT_STRONG_UNDO },
{ "edit-strong-redo", GTK_STOCK_REDO,
N_("Strong Redo"), "<control><shift>Y",
N_("Redo the last operation that was undone, skipping over some types"),
G_CALLBACK (edit_strong_redo_cmd_callback),
GIMP_HELP_EDIT_STRONG_REDO },
{ "edit-undo-clear", GTK_STOCK_CLEAR,
N_("_Clear Undo History"), "",
N_("Remove all operations from the undo history"),
@ -263,6 +275,8 @@ edit_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("edit-undo", undo_enabled && undo_name);
SET_SENSITIVE ("edit-redo", undo_enabled && redo_name);
SET_SENSITIVE ("edit-strong-undo", undo_enabled && undo_name);
SET_SENSITIVE ("edit-strong-redo", undo_enabled && redo_name);
SET_SENSITIVE ("edit-undo-clear", undo_enabled && (undo_name || redo_name));
g_free (undo_name);

View File

@ -94,6 +94,28 @@ edit_redo_cmd_callback (GtkAction *action,
gimp_image_flush (image);
}
void
edit_strong_undo_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
return_if_no_image (image, data);
if (gimp_image_strong_undo (image))
gimp_image_flush (image);
}
void
edit_strong_redo_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
return_if_no_image (image, data);
if (gimp_image_strong_redo (image))
gimp_image_flush (image);
}
void
edit_undo_clear_cmd_callback (GtkAction *action,
gpointer data)

View File

@ -24,6 +24,10 @@ void edit_undo_cmd_callback (GtkAction *action,
gpointer data);
void edit_redo_cmd_callback (GtkAction *action,
gpointer data);
void edit_strong_undo_cmd_callback (GtkAction *action,
gpointer data);
void edit_strong_redo_cmd_callback (GtkAction *action,
gpointer data);
void edit_undo_clear_cmd_callback (GtkAction *action,
gpointer data);
void edit_cut_cmd_callback (GtkAction *action,

View File

@ -32,6 +32,7 @@
#include "gimpitemundo.h"
#include "gimplist.h"
#include "gimpundostack.h"
#include "gimpundo.h"
/* local function prototypes */
@ -63,6 +64,33 @@ gimp_image_undo (GimpImage *image)
return TRUE;
}
/*
* this function continues to undo as long as it only sees certain
* undo types, in particular visibility changes.
*/
gboolean
gimp_image_strong_undo (GimpImage *image)
{
GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
FALSE);
undo = gimp_undo_stack_peek (image->undo_stack);
gimp_image_undo (image);
while (gimp_undo_is_weak (undo))
{
undo = gimp_undo_stack_peek (image->undo_stack);
if (gimp_undo_is_weak (undo))
gimp_image_undo (image);
}
return TRUE;
}
gboolean
gimp_image_redo (GimpImage *image)
{
@ -78,6 +106,35 @@ gimp_image_redo (GimpImage *image)
return TRUE;
}
/*
* this function continues to redo as long as it only sees certain
* undo types, in particular visibility changes. Note that the
* order of events is set up to make it exactly reverse
* gimp_image_strong_undo().
*/
gboolean
gimp_image_strong_redo (GimpImage *image)
{
GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (image->pushing_undo_group == GIMP_UNDO_GROUP_NONE,
FALSE);
undo = gimp_undo_stack_peek (image->redo_stack);
gimp_image_redo (image);
while (gimp_undo_is_weak (undo))
{
undo = gimp_undo_stack_peek (image->redo_stack);
if (gimp_undo_is_weak (undo))
gimp_image_redo (image);
}
return TRUE;
}
void
gimp_image_undo_free (GimpImage *image)
{

View File

@ -23,6 +23,9 @@
gboolean gimp_image_undo (GimpImage *image);
gboolean gimp_image_redo (GimpImage *image);
gboolean gimp_image_strong_undo (GimpImage *image);
gboolean gimp_image_strong_redo (GimpImage *image);
void gimp_image_undo_free (GimpImage *image);
gboolean gimp_image_undo_group_start (GimpImage *image,

View File

@ -530,3 +530,33 @@ gimp_undo_type_to_name (GimpUndoType type)
else
return "";
}
gboolean
gimp_undo_is_weak (GimpUndo *undo)
{
GimpUndoType type;
if (! undo)
return FALSE;
type = undo->undo_type;
switch (undo->undo_type)
{
case GIMP_UNDO_GROUP_ITEM_VISIBILITY:
case GIMP_UNDO_GROUP_ITEM_PROPERTIES:
case GIMP_UNDO_GROUP_LAYER_APPLY_MASK:
case GIMP_UNDO_ITEM_VISIBILITY:
case GIMP_UNDO_LAYER_MODE:
case GIMP_UNDO_LAYER_OPACITY:
case GIMP_UNDO_LAYER_MASK_APPLY:
case GIMP_UNDO_LAYER_MASK_SHOW:
return TRUE;
break;
default:
break;
}
return FALSE;
}

View File

@ -89,6 +89,6 @@ void gimp_undo_refresh_preview (GimpUndo *undo);
const gchar * gimp_undo_type_to_name (GimpUndoType type);
gboolean gimp_undo_is_weak (GimpUndo *undo);
#endif /* __GIMP_UNDO_H__ */

View File

@ -43,6 +43,8 @@
#define GIMP_HELP_EDIT_UNDO "gimp-edit-undo"
#define GIMP_HELP_EDIT_REDO "gimp-edit-redo"
#define GIMP_HELP_EDIT_STRONG_UNDO "gimp-edit-strong-undo"
#define GIMP_HELP_EDIT_STRONG_REDO "gimp-edit-strong-redo"
#define GIMP_HELP_EDIT_UNDO_CLEAR "gimp-edit-undo-clear"
#define GIMP_HELP_EDIT_CUT "gimp-edit-cut"
#define GIMP_HELP_EDIT_COPY "gimp-edit-copy"

View File

@ -149,6 +149,8 @@
<placeholder name="Undo">
<menuitem action="edit-undo" />
<menuitem action="edit-redo" />
<menuitem action="edit-strong-undo" />
<menuitem action="edit-strong-redo" />
<menuitem action="dialogs-undo-history" />
</placeholder>
<separator />