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.
This commit is contained in:
25
ChangeLog
25
ChangeLog
@ -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
|
||||
|
@ -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"),
|
||||
@ -261,9 +273,11 @@ edit_actions_update (GimpActionGroup *group,
|
||||
SET_LABEL ("edit-undo", undo_name ? undo_name : _("_Undo"));
|
||||
SET_LABEL ("edit-redo", redo_name ? redo_name : _("_Redo"));
|
||||
|
||||
SET_SENSITIVE ("edit-undo", undo_enabled && undo_name);
|
||||
SET_SENSITIVE ("edit-redo", undo_enabled && redo_name);
|
||||
SET_SENSITIVE ("edit-undo-clear", undo_enabled && (undo_name || redo_name));
|
||||
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);
|
||||
g_free (redo_name);
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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"
|
||||
|
@ -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 />
|
||||
|
Reference in New Issue
Block a user