[gimp/gimp-2-8] Bug 678890 - Selection box handles do not respond after changing layer
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Bug 678890 - Selection box handles do not respond after changing layer
- Date: Thu, 26 Jul 2012 16:21:51 +0000 (UTC)
commit d6091dbce6f1b60ec606db1e59be7cb069a87477
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 26 18:17:01 2012 +0200
Bug 678890 - Selection box handles do not respond after changing layer
Make sure that temporarily setting/unsetting tool->control's "preserve
tool across image changes" does not mess up the default value:
Introduce gimp_tool_control_push/pop_preserve() which restores the old
state automatically, and use it in all tools, instead of saying
set_preserve(TRUE/FALSE) around image changes.
(cherry picked from commit 078128bb09dbca458b4f2f98cbf6d4140b357b29)
app/tools/gimpcagetool.c | 8 ++++----
app/tools/gimpimagemaptool.c | 24 ++++++++++++------------
app/tools/gimprectangleselecttool.c | 24 ++++++++++++------------
app/tools/gimptoolcontrol.c | 27 +++++++++++++++++++++++++++
app/tools/gimptoolcontrol.h | 6 ++++++
app/tools/gimptransformtool.c | 4 ++--
6 files changed, 63 insertions(+), 30 deletions(-)
---
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 7880e59..fe0e1a9 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -237,13 +237,13 @@ gimp_cage_tool_control (GimpTool *tool,
if (ct->image_map)
{
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_abort (ct->image_map);
g_object_unref (ct->image_map);
ct->image_map = NULL;
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
gimp_image_flush (gimp_display_get_image (tool->display));
}
@@ -426,13 +426,13 @@ gimp_cage_tool_key_press (GimpTool *tool,
}
else if (ct->tool_state == DEFORM_STATE_WAIT)
{
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_commit (ct->image_map);
g_object_unref (ct->image_map);
ct->image_map = NULL;
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
gimp_image_flush (gimp_display_get_image (display));
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index fd42b6e..c168dfc 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -421,13 +421,13 @@ gimp_image_map_tool_control (GimpTool *tool,
{
GimpImage *image;
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_abort (image_map_tool->image_map);
g_object_unref (image_map_tool->image_map);
image_map_tool->image_map = NULL;
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
/* don't call gimp_image_flush() here, because the tool
* might be cancelled from some other place opening an undo
@@ -501,19 +501,19 @@ gimp_image_map_tool_options_notify (GimpTool *tool,
if (im_options->preview)
{
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_tool_map (image_map_tool);
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
}
else
{
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_clear (image_map_tool->image_map);
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
gimp_image_map_tool_flush (image_map_tool->image_map,
image_map_tool);
@@ -667,7 +667,7 @@ gimp_image_map_tool_response (GtkWidget *widget,
{
GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
if (! options->preview)
gimp_image_map_tool_map (image_map_tool);
@@ -676,7 +676,7 @@ gimp_image_map_tool_response (GtkWidget *widget,
g_object_unref (image_map_tool->image_map);
image_map_tool->image_map = NULL;
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
gimp_image_flush (gimp_display_get_image (tool->display));
@@ -740,11 +740,11 @@ gimp_image_map_tool_preview (GimpImageMapTool *image_map_tool)
if (image_map_tool->image_map && options->preview)
{
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_tool_map (image_map_tool);
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
}
}
@@ -755,11 +755,11 @@ gimp_image_map_tool_gegl_notify (GObject *config,
{
if (im_tool->image_map)
{
- gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, TRUE);
+ gimp_tool_control_push_preserve (GIMP_TOOL (im_tool)->control, TRUE);
gimp_image_map_tool_create_map (im_tool);
- gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, FALSE);
+ gimp_tool_control_pop_preserve (GIMP_TOOL (im_tool)->control);
gimp_image_map_tool_preview (im_tool);
}
diff --git a/app/tools/gimprectangleselecttool.c b/app/tools/gimprectangleselecttool.c
index a7bc9bc..50d9852 100644
--- a/app/tools/gimprectangleselecttool.c
+++ b/app/tools/gimprectangleselecttool.c
@@ -421,11 +421,11 @@ gimp_rectangle_select_tool_button_press (GimpTool *tool,
if (undo && priv->undo == undo)
{
/* prevent this change from halting the tool */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_undo (image);
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
/* we will need to redo if the user cancels or executes */
priv->redo = gimp_undo_stack_peek (redo_stack);
@@ -477,12 +477,12 @@ gimp_rectangle_select_tool_button_release (GimpTool *tool,
if (redo && priv->redo == redo)
{
/* prevent this from halting the tool */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_redo (image);
priv->redo = NULL;
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
}
}
@@ -494,11 +494,11 @@ gimp_rectangle_select_tool_button_release (GimpTool *tool,
if (priv->redo)
{
/* prevent this from halting the tool */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_redo (image);
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
}
priv->use_saved_op = TRUE; /* is this correct? */
@@ -784,7 +784,7 @@ gimp_rectangle_select_tool_execute (GimpRectangleTool *rectangle,
GimpChannelOps operation;
/* prevent this change from halting the tool */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
/* We can conceptually think of a click outside of the
* selection as adding a 0px selection. Behave intuitivly
@@ -806,7 +806,7 @@ gimp_rectangle_select_tool_execute (GimpRectangleTool *rectangle,
break;
}
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
}
}
@@ -843,12 +843,12 @@ gimp_rectangle_select_tool_cancel (GimpRectangleTool *rectangle)
if (undo && priv->undo == undo)
{
/* prevent this change from halting the tool */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_undo (image);
gimp_image_flush (image);
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
}
}
@@ -870,7 +870,7 @@ gimp_rectangle_select_tool_rectangle_change_complete (GimpRectangleTool *rectang
priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool);
/* prevent change in selection from halting the tool */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
if (tool->display && ! gimp_tool_control_is_active (tool->control))
{
@@ -919,7 +919,7 @@ gimp_rectangle_select_tool_rectangle_change_complete (GimpRectangleTool *rectang
gimp_image_flush (image);
}
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
gimp_rectangle_select_tool_update_option_defaults (rect_sel_tool, FALSE);
diff --git a/app/tools/gimptoolcontrol.c b/app/tools/gimptoolcontrol.c
index 58c29f2..c7e939e 100644
--- a/app/tools/gimptoolcontrol.c
+++ b/app/tools/gimptoolcontrol.c
@@ -90,6 +90,8 @@ gimp_tool_control_finalize (GObject *object)
{
GimpToolControl *control = GIMP_TOOL_CONTROL (object);
+ g_slist_free (control->preserve_stack);
+
g_free (control->action_value_1);
g_free (control->action_value_2);
g_free (control->action_value_3);
@@ -172,6 +174,31 @@ gimp_tool_control_get_preserve (GimpToolControl *control)
}
void
+gimp_tool_control_push_preserve (GimpToolControl *control,
+ gboolean preserve)
+{
+ g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
+
+ control->preserve_stack =
+ g_slist_prepend (control->preserve_stack,
+ GINT_TO_POINTER (control->preserve));
+
+ control->preserve = preserve ? TRUE : FALSE;
+}
+
+void
+gimp_tool_control_pop_preserve (GimpToolControl *control)
+{
+ g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
+ g_return_if_fail (control->preserve_stack != NULL);
+
+ control->preserve = GPOINTER_TO_INT (control->preserve_stack->data);
+
+ control->preserve_stack = g_slist_delete_link (control->preserve_stack,
+ control->preserve_stack);
+}
+
+void
gimp_tool_control_set_scroll_lock (GimpToolControl *control,
gboolean scroll_lock)
{
diff --git a/app/tools/gimptoolcontrol.h b/app/tools/gimptoolcontrol.h
index 2ed3348..398a8b7 100644
--- a/app/tools/gimptoolcontrol.h
+++ b/app/tools/gimptoolcontrol.h
@@ -42,6 +42,8 @@ struct _GimpToolControl
gboolean preserve; /* Preserve this tool across *
* drawable changes */
+ GSList *preserve_stack; /* for push/pop preserve */
+
gboolean scroll_lock; /* allow scrolling or not */
gboolean handle_empty_image; /* invoke the tool on images *
* without active drawable */
@@ -100,6 +102,10 @@ void gimp_tool_control_set_preserve (GimpToolControl *control,
gboolean preserve);
gboolean gimp_tool_control_get_preserve (GimpToolControl *control);
+void gimp_tool_control_push_preserve (GimpToolControl *control,
+ gboolean preserve);
+void gimp_tool_control_pop_preserve (GimpToolControl *control);
+
void gimp_tool_control_set_scroll_lock (GimpToolControl *control,
gboolean scroll_lock);
gboolean gimp_tool_control_get_scroll_lock (GimpToolControl *control);
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index b5fad86..4c41232 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -1103,7 +1103,7 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tr_tool));
/* We're going to dirty this image, but we want to keep the tool around */
- gimp_tool_control_set_preserve (tool->control, TRUE);
+ gimp_tool_control_push_preserve (tool->control, TRUE);
undo_desc = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_undo_desc (tr_tool);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM, undo_desc);
@@ -1190,7 +1190,7 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
/* We're done dirtying the image, and would like to be restarted if
* the image gets dirty while the tool exists
*/
- gimp_tool_control_set_preserve (tool->control, FALSE);
+ gimp_tool_control_pop_preserve (tool->control);
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]