From 55cc42339b85a40975f954602fbbe3a8e7402511 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 7 Jan 2006 17:47:24 +0000 Subject: [PATCH] implement GtkWidget::hide() and set the the focus widget to NULL, so a 2006-01-07 Michael Natterer * libgimpwidgets/gimpdialog.c: implement GtkWidget::hide() and set the the focus widget to NULL, so a focussed entry emits focus_out and its callbacks are invoked immediately (before the call to gtk_widget_hide() returns). Fixes crashes and warnings in tool dialogs when hitting escape while a spinbutton is being edited. * app/tools/gimptransformtool.c (gimp_transform_tool_force_expose_preview): return silently instead of warning when being called while the draw tool is not active (same scenario as above). --- ChangeLog | 13 +++++++++++++ app/tools/gimptransformtool.c | 7 ++++++- libgimpwidgets/gimpdialog.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index afb3f28c1b..adb0602948 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-01-07 Michael Natterer + + * libgimpwidgets/gimpdialog.c: implement GtkWidget::hide() and set + the the focus widget to NULL, so a focussed entry emits focus_out + and its callbacks are invoked immediately (before the call to + gtk_widget_hide() returns). Fixes crashes and warnings in tool + dialogs when hitting escape while a spinbutton is being edited. + + * app/tools/gimptransformtool.c + (gimp_transform_tool_force_expose_preview): return silently + instead of warning when being called while the draw tool is not + active (same scenario as above). + 2006-01-07 Sven Neumann * app/base/siox.c: applied patch from Tobias Lenz that plugs a diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 26a3e712a3..4c7c50129a 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -1144,7 +1144,12 @@ gimp_transform_tool_force_expose_preview (GimpTransformTool *tr_tool) if (! tr_tool->use_grid) return; - g_return_if_fail (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tr_tool))); + /* we might be called as the result of cancelling the transform + * tool dialog, return silently because the draw tool may have + * already been stopped by gimp_transform_tool_halt() + */ + if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tr_tool))) + return; shell = GIMP_DISPLAY_SHELL (GIMP_DRAW_TOOL (tr_tool)->gdisp->shell); diff --git a/libgimpwidgets/gimpdialog.c b/libgimpwidgets/gimpdialog.c index dd53ed03a0..c510e76a39 100644 --- a/libgimpwidgets/gimpdialog.c +++ b/libgimpwidgets/gimpdialog.c @@ -51,6 +51,7 @@ static void gimp_dialog_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static void gimp_dialog_hide (GtkWidget *widget); static gboolean gimp_dialog_delete_event (GtkWidget *widget, GdkEventAny *event); static void gimp_dialog_close (GtkDialog *dialog); @@ -79,6 +80,7 @@ gimp_dialog_class_init (GimpDialogClass *klass) object_class->set_property = gimp_dialog_set_property; object_class->get_property = gimp_dialog_get_property; + widget_class->hide = gimp_dialog_hide; widget_class->delete_event = gimp_dialog_delete_event; dialog_class->close = gimp_dialog_close; @@ -217,6 +219,15 @@ gimp_dialog_get_property (GObject *object, } } +static void +gimp_dialog_hide (GtkWidget *widget) +{ + /* set focus to NULL so focus_out callbacks are invoked synchronously */ + gtk_window_set_focus (GTK_WINDOW (widget), NULL); + + GTK_WIDGET_CLASS (parent_class)->hide (widget); +} + static gboolean gimp_dialog_delete_event (GtkWidget *widget, GdkEventAny *event)