From c16484b71cafc81498ec51ee069a0647a91a7dcc Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 14 Mar 2007 21:33:09 +0000 Subject: [PATCH] Fix stuck statusbar messages when changing tools (bug #398913): 2007-03-14 Michael Natterer Fix stuck statusbar messages when changing tools (bug #398913): * app/tools/gimptool.[ch]: keep a list of status_displays around. Update the list in all status push, replace and pop functions. Added gimp_tool_clear_status() which removes the status messages from all displays in the list. Call the function from gimp_tool_real_control(HALT). * app/tools/tool_manager.c (tool_manager_control_active): if we can't call gimp_tool_control() because we have no display to pass, still call gimp_tool_clear_status() so the messages go away from displays the tool was only hovering. svn path=/trunk/; revision=22123 --- ChangeLog | 15 ++++++++++++ app/tools/gimptool.c | 51 ++++++++++++++++++++++++++++++++++++++++ app/tools/gimptool.h | 5 ++++ app/tools/tool_manager.c | 2 ++ 4 files changed, 73 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7803190ddb..f75a17bcae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-03-14 Michael Natterer + + Fix stuck statusbar messages when changing tools (bug #398913): + + * app/tools/gimptool.[ch]: keep a list of status_displays around. + Update the list in all status push, replace and pop functions. + Added gimp_tool_clear_status() which removes the status messages + from all displays in the list. Call the function from + gimp_tool_real_control(HALT). + + * app/tools/tool_manager.c (tool_manager_control_active): if we + can't call gimp_tool_control() because we have no display to pass, + still call gimp_tool_clear_status() so the messages go away from + displays the tool was only hovering. + 2007-03-14 Michael Natterer * app/plug-in/gimpplugin.c (gimp_plug_in_new): require either diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c index c40ddf681d..67fca7aff3 100644 --- a/app/tools/gimptool.c +++ b/app/tools/gimptool.c @@ -25,6 +25,7 @@ #include "tools-types.h" #include "core/gimp.h" +#include "core/gimpcontainer.h" #include "core/gimpimage.h" #include "core/gimptoolinfo.h" @@ -172,6 +173,12 @@ gimp_tool_finalize (GObject *object) tool->control = NULL; } + if (tool->status_displays) + { + g_list_free (tool->status_displays); + tool->status_displays = NULL; + } + G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -263,6 +270,7 @@ gimp_tool_real_control (GimpTool *tool, case GIMP_TOOL_ACTION_HALT: tool->display = NULL; + gimp_tool_clear_status (tool); break; } } @@ -819,6 +827,9 @@ gimp_tool_push_status (GimpTool *tool, format, args); va_end (args); + + tool->status_displays = g_list_remove (tool->status_displays, display); + tool->status_displays = g_list_prepend (tool->status_displays, display); } void @@ -840,6 +851,9 @@ gimp_tool_push_status_coords (GimpTool *tool, gimp_statusbar_push_coords (GIMP_STATUSBAR (shell->statusbar), G_OBJECT_TYPE_NAME (tool), title, x, separator, y, help); + + tool->status_displays = g_list_remove (tool->status_displays, display); + tool->status_displays = g_list_prepend (tool->status_displays, display); } void @@ -860,6 +874,9 @@ gimp_tool_push_status_length (GimpTool *tool, gimp_statusbar_push_length (GIMP_STATUSBAR (shell->statusbar), G_OBJECT_TYPE_NAME (tool), title, axis, value, help); + + tool->status_displays = g_list_remove (tool->status_displays, display); + tool->status_displays = g_list_prepend (tool->status_displays, display); } void @@ -884,6 +901,9 @@ gimp_tool_replace_status (GimpTool *tool, format, args); va_end (args); + + tool->status_displays = g_list_remove (tool->status_displays, display); + tool->status_displays = g_list_prepend (tool->status_displays, display); } void @@ -899,6 +919,37 @@ gimp_tool_pop_status (GimpTool *tool, gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), G_OBJECT_TYPE_NAME (tool)); + + tool->status_displays = g_list_remove (tool->status_displays, display); +} + +void +gimp_tool_clear_status (GimpTool *tool) +{ + GList *list; + + g_return_if_fail (GIMP_IS_TOOL (tool)); + + list = tool->status_displays; + while (list) + { + GimpDisplay *display = list->data; + + /* get next element early because we modify the list */ + list = g_list_next (list); + + if (gimp_container_have (tool->tool_info->gimp->displays, + (GimpObject *) display)) + { + gimp_tool_pop_status (tool, display); + } + else + { + tool->status_displays = g_list_remove (tool->status_displays, + display); + } + + } } void diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h index 7d0bc3b5f6..42cee0c4e3 100644 --- a/app/tools/gimptool.h +++ b/app/tools/gimptool.h @@ -62,6 +62,10 @@ struct _GimpTool gboolean got_motion_event; GimpCoords button_press_coords; guint32 button_press_time; + + /* private list of displays which have a status message from this tool + */ + GList *status_displays; }; struct _GimpToolClass @@ -202,6 +206,7 @@ void gimp_tool_replace_status (GimpTool *tool, ...) G_GNUC_PRINTF(3,4); void gimp_tool_pop_status (GimpTool *tool, GimpDisplay *display); +void gimp_tool_clear_status (GimpTool *tool); void gimp_tool_message (GimpTool *tool, GimpDisplay *display, diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c index f705285ff3..e53c5e9d90 100644 --- a/app/tools/tool_manager.c +++ b/app/tools/tool_manager.c @@ -267,6 +267,8 @@ tool_manager_control_active (Gimp *gimp, { if (gimp_tool_control_is_active (tool->control)) gimp_tool_control_halt (tool->control); + + gimp_tool_clear_status (tool); } } }