From b7940e1ebfebbb39f5bae66ddccdd8d780b0098a Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 28 Mar 2000 23:02:05 +0000 Subject: [PATCH] new function gimp_dialog_hide() that calls gdk_window_withdraw() after gtk_widget_hide() so dialogs actually go away even if the user iconified them before. Should fix bugs #2961, #5293, #6441 and #7849. --Sven --- ChangeLog | 19 +++++++++++++++++++ app/base/color-balance.c | 6 ++---- app/base/curves.c | 10 ++++------ app/base/hue-saturation.c | 6 ++---- app/base/threshold.c | 8 +++----- app/brightness_contrast.c | 6 ++---- app/by_color_select.c | 5 ++--- app/color_balance.c | 6 ++---- app/curves.c | 10 ++++------ app/fileops.c | 4 ++-- app/gimpui.c | 24 ++++++++++++++++++++++++ app/gimpui.h | 8 +++++--- app/histogram_tool.c | 5 ++--- app/hue_saturation.c | 6 ++---- app/levels.c | 11 ++++------- app/posterize.c | 6 ++---- app/text_tool.c | 14 ++++++-------- app/threshold.c | 8 +++----- app/tools/brightness_contrast.c | 6 ++---- app/tools/by_color_select.c | 5 ++--- app/tools/color_balance.c | 6 ++---- app/tools/curves.c | 10 ++++------ app/tools/gimpbrightnesscontrasttool.c | 6 ++---- app/tools/gimpbycolorselecttool.c | 5 ++--- app/tools/gimpcolorbalancetool.c | 6 ++---- app/tools/gimpcurvestool.c | 10 ++++------ app/tools/gimphistogramtool.c | 5 ++--- app/tools/gimphuesaturationtool.c | 6 ++---- app/tools/gimplevelstool.c | 11 ++++------- app/tools/gimpposterizetool.c | 6 ++---- app/tools/gimptexttool.c | 14 ++++++-------- app/tools/gimpthresholdtool.c | 8 +++----- app/tools/histogram_tool.c | 5 ++--- app/tools/hue_saturation.c | 6 ++---- app/tools/levels.c | 11 ++++------- app/tools/posterize.c | 6 ++---- app/tools/text_tool.c | 14 ++++++-------- app/tools/threshold.c | 8 +++----- app/widgets/gimpwidgets-utils.c | 24 ++++++++++++++++++++++++ app/widgets/gimpwidgets-utils.h | 8 +++++--- 40 files changed, 177 insertions(+), 171 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f2390be99..609e5f005b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2000-03-29 Sven Neumann + + * app/gimpui.[ch]: (gimp_dialog_hide) new function that calls + gdk_window_withdraw() after gtk_widget_hide() so dialogs actually + go away even if they have been iconified by the user before. + + * brightness_contrast.c + * by_color_select.c + * color_balance.c + * curves.c + * fileops.c + * histogram_tool.c + * hue_saturation.c + * levels.c + * posterize.c + * text_tool.c + * threshold.c: use gimp_dialog_hide() on all(?) tool dialogs and + file_selectors. This should fix bugs #2961, #5293, #6441 and #7849. + 2000-03-28 Sven Neumann * plugins/script-fu/Makefile.am: don't install test-sphere.scm diff --git a/app/base/color-balance.c b/app/base/color-balance.c index 9d91cf0b5b..ad5f86db2c 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -569,8 +569,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); active_tool->preserve = TRUE; @@ -596,8 +595,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); if (cbd->image_map) { diff --git a/app/base/curves.c b/app/base/curves.c index a2d69d5ffc..36e90f955b 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -1213,8 +1213,7 @@ curves_ok_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); active_tool->preserve = TRUE; /* We're about to dirty... */ @@ -1241,8 +1240,7 @@ curves_cancel_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); if (cd->image_map) { @@ -1637,14 +1635,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c index d0dd0c163c..4d4c5117ba 100644 --- a/app/base/hue-saturation.c +++ b/app/base/hue-saturation.c @@ -674,8 +674,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); active_tool->preserve = TRUE; @@ -701,8 +700,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); if (hsd->image_map) { diff --git a/app/base/threshold.c b/app/base/threshold.c index f691eeafc2..ba96d23bbc 100644 --- a/app/base/threshold.c +++ b/app/base/threshold.c @@ -421,9 +421,8 @@ threshold_ok_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); - + gimp_dialog_hide (td->shell); + active_tool->preserve = TRUE; if (!td->preview) @@ -448,8 +447,7 @@ threshold_cancel_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); + gimp_dialog_hide (td->shell); if (td->image_map) { diff --git a/app/brightness_contrast.c b/app/brightness_contrast.c index 0adc5c49d9..6ea8c90b4c 100644 --- a/app/brightness_contrast.c +++ b/app/brightness_contrast.c @@ -371,8 +371,7 @@ brightness_contrast_ok_callback (GtkWidget *widget, bcd = (BrightnessContrastDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); active_tool->preserve = TRUE; @@ -404,8 +403,7 @@ brightness_contrast_cancel_callback (GtkWidget *widget, bcd = (BrightnessContrastDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); if (bcd->image_map) { diff --git a/app/by_color_select.c b/app/by_color_select.c index 41d1c7574b..c7c49c955b 100644 --- a/app/by_color_select.c +++ b/app/by_color_select.c @@ -786,7 +786,7 @@ by_color_select_dialog_new (void) gtk_widget_show (bcd->shell); gtk_signal_connect_object (GTK_OBJECT (bcd->shell), "unmap_event", - GTK_SIGNAL_FUNC (gtk_widget_hide), + GTK_SIGNAL_FUNC (gimp_dialog_hide), (gpointer) bcd->shell); return bcd; @@ -978,8 +978,7 @@ by_color_select_close_callback (GtkWidget *widget, bcd = (ByColorDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); if (bcd->gimage && gimp_set_have (image_context, bcd->gimage)) { diff --git a/app/color_balance.c b/app/color_balance.c index 9d91cf0b5b..ad5f86db2c 100644 --- a/app/color_balance.c +++ b/app/color_balance.c @@ -569,8 +569,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); active_tool->preserve = TRUE; @@ -596,8 +595,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); if (cbd->image_map) { diff --git a/app/curves.c b/app/curves.c index a2d69d5ffc..36e90f955b 100644 --- a/app/curves.c +++ b/app/curves.c @@ -1213,8 +1213,7 @@ curves_ok_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); active_tool->preserve = TRUE; /* We're about to dirty... */ @@ -1241,8 +1240,7 @@ curves_cancel_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); if (cd->image_map) { @@ -1637,14 +1635,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/fileops.c b/app/fileops.c index ccb873042f..927a63b142 100644 --- a/app/fileops.c +++ b/app/fileops.c @@ -1648,8 +1648,8 @@ file_dialog_show (GtkWidget *filesel) static int file_dialog_hide (GtkWidget *filesel) { - gtk_widget_hide (filesel); - + gimp_dialog_hide (filesel); + menus_set_sensitive ("/File/Open...", TRUE); menus_set_sensitive ("/File/Open...", TRUE); diff --git a/app/gimpui.c b/app/gimpui.c index f5a309b040..87a331a2dd 100644 --- a/app/gimpui.c +++ b/app/gimpui.c @@ -165,3 +165,27 @@ gimp_message_box_close_callback (GtkWidget *widget, g_free (msg_box->message); g_free (msg_box); } + + +/* + * A workaround for what I think is a GTK+ bug: + * If a dialog is hidden using gtk_widget_hide(), + * and was iconified before, it is still present + * in the window_list and can be deiconified by + * the user later. All subsequent calls to + * gtk_widget_hide() will then fail since the state + * of the widget is still INVISIBLE. + * Calling gdk_window_withdraw() seems to solve this. + * --Sven + */ +void +gimp_dialog_hide (GtkWidget *dialog) +{ + g_return_if_fail (dialog != NULL && !GTK_WIDGET_NO_WINDOW (dialog)); + + gtk_widget_hide (dialog); + gdk_window_withdraw (dialog->window); +} + + + diff --git a/app/gimpui.h b/app/gimpui.h index d59dd9ed8b..6b38901bb8 100644 --- a/app/gimpui.h +++ b/app/gimpui.h @@ -36,8 +36,10 @@ /* a simple message box */ -void gimp_message_box (gchar *message, - GtkCallback callback, - gpointer data); +void gimp_message_box (gchar *message, + GtkCallback callback, + gpointer data); + +void gimp_dialog_hide (GtkWidget *dialog); #endif /* __GIMP_UI_H__ */ diff --git a/app/histogram_tool.c b/app/histogram_tool.c index f853ce7ad2..d3f2e9e6db 100644 --- a/app/histogram_tool.c +++ b/app/histogram_tool.c @@ -386,9 +386,8 @@ histogram_tool_close_callback (GtkWidget *widget, htd = (HistogramToolDialog *) data; - if (GTK_WIDGET_VISIBLE (htd->shell)) - gtk_widget_hide (htd->shell); - + gimp_dialog_hide (htd->shell); + active_tool->gdisp_ptr = NULL; active_tool->drawable = NULL; } diff --git a/app/hue_saturation.c b/app/hue_saturation.c index d0dd0c163c..4d4c5117ba 100644 --- a/app/hue_saturation.c +++ b/app/hue_saturation.c @@ -674,8 +674,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); active_tool->preserve = TRUE; @@ -701,8 +700,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); if (hsd->image_map) { diff --git a/app/levels.c b/app/levels.c index 6585bf49b1..97c4d95b0f 100644 --- a/app/levels.c +++ b/app/levels.c @@ -960,8 +960,7 @@ levels_ok_callback (GtkWidget *widget, ld = (LevelsDialog *) data; - if (GTK_WIDGET_VISIBLE (ld->shell)) - gtk_widget_hide (ld->shell); + gimp_dialog_hide (ld->shell); active_tool->preserve = TRUE; @@ -993,8 +992,7 @@ levels_cancel_callback (GtkWidget *widget, ld = (LevelsDialog *) data; - if (GTK_WIDGET_VISIBLE (ld->shell)) - gtk_widget_hide (ld->shell); + gimp_dialog_hide (ld->shell); if (ld->image_map) { @@ -1455,15 +1453,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/posterize.c b/app/posterize.c index 1a1f681558..e3dcdade6d 100644 --- a/app/posterize.c +++ b/app/posterize.c @@ -288,8 +288,7 @@ posterize_ok_callback (GtkWidget *widget, pd = (PosterizeDialog *) data; - if (GTK_WIDGET_VISIBLE (pd->shell)) - gtk_widget_hide (pd->shell); + gimp_dialog_hide (pd->shell); active_tool->preserve = TRUE; @@ -320,8 +319,7 @@ posterize_cancel_callback (GtkWidget *widget, pd = (PosterizeDialog *) data; - if (GTK_WIDGET_VISIBLE (pd->shell)) - gtk_widget_hide (pd->shell); + gimp_dialog_hide (pd->shell); if (pd->image_map) { diff --git a/app/text_tool.c b/app/text_tool.c index 96e4c03dc3..6e8bc1c509 100644 --- a/app/text_tool.c +++ b/app/text_tool.c @@ -256,8 +256,8 @@ tools_free_text (Tool *tool) g_free (tool->private); the_text_tool = NULL; - if (text_tool_shell && GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + if (text_tool_shell) + gimp_dialog_hide (text_tool_shell); } static void @@ -377,8 +377,8 @@ text_control (Tool *tool, break; case HALT: - if (text_tool_shell && GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + if (text_tool_shell) + gimp_dialog_hide (text_tool_shell); break; default: @@ -419,8 +419,7 @@ static void text_dialog_ok_callback (GtkWidget *widget, gpointer data) { - if (GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + gimp_dialog_hide (text_tool_shell); if (the_text_tool) text_init_render (the_text_tool); @@ -440,8 +439,7 @@ static void text_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - if (GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + gimp_dialog_hide (text_tool_shell); } static void diff --git a/app/threshold.c b/app/threshold.c index f691eeafc2..ba96d23bbc 100644 --- a/app/threshold.c +++ b/app/threshold.c @@ -421,9 +421,8 @@ threshold_ok_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); - + gimp_dialog_hide (td->shell); + active_tool->preserve = TRUE; if (!td->preview) @@ -448,8 +447,7 @@ threshold_cancel_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); + gimp_dialog_hide (td->shell); if (td->image_map) { diff --git a/app/tools/brightness_contrast.c b/app/tools/brightness_contrast.c index 0adc5c49d9..6ea8c90b4c 100644 --- a/app/tools/brightness_contrast.c +++ b/app/tools/brightness_contrast.c @@ -371,8 +371,7 @@ brightness_contrast_ok_callback (GtkWidget *widget, bcd = (BrightnessContrastDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); active_tool->preserve = TRUE; @@ -404,8 +403,7 @@ brightness_contrast_cancel_callback (GtkWidget *widget, bcd = (BrightnessContrastDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); if (bcd->image_map) { diff --git a/app/tools/by_color_select.c b/app/tools/by_color_select.c index 41d1c7574b..c7c49c955b 100644 --- a/app/tools/by_color_select.c +++ b/app/tools/by_color_select.c @@ -786,7 +786,7 @@ by_color_select_dialog_new (void) gtk_widget_show (bcd->shell); gtk_signal_connect_object (GTK_OBJECT (bcd->shell), "unmap_event", - GTK_SIGNAL_FUNC (gtk_widget_hide), + GTK_SIGNAL_FUNC (gimp_dialog_hide), (gpointer) bcd->shell); return bcd; @@ -978,8 +978,7 @@ by_color_select_close_callback (GtkWidget *widget, bcd = (ByColorDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); if (bcd->gimage && gimp_set_have (image_context, bcd->gimage)) { diff --git a/app/tools/color_balance.c b/app/tools/color_balance.c index 9d91cf0b5b..ad5f86db2c 100644 --- a/app/tools/color_balance.c +++ b/app/tools/color_balance.c @@ -569,8 +569,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); active_tool->preserve = TRUE; @@ -596,8 +595,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); if (cbd->image_map) { diff --git a/app/tools/curves.c b/app/tools/curves.c index a2d69d5ffc..36e90f955b 100644 --- a/app/tools/curves.c +++ b/app/tools/curves.c @@ -1213,8 +1213,7 @@ curves_ok_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); active_tool->preserve = TRUE; /* We're about to dirty... */ @@ -1241,8 +1240,7 @@ curves_cancel_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); if (cd->image_map) { @@ -1637,14 +1635,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index 0adc5c49d9..6ea8c90b4c 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -371,8 +371,7 @@ brightness_contrast_ok_callback (GtkWidget *widget, bcd = (BrightnessContrastDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); active_tool->preserve = TRUE; @@ -404,8 +403,7 @@ brightness_contrast_cancel_callback (GtkWidget *widget, bcd = (BrightnessContrastDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); if (bcd->image_map) { diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index 41d1c7574b..c7c49c955b 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -786,7 +786,7 @@ by_color_select_dialog_new (void) gtk_widget_show (bcd->shell); gtk_signal_connect_object (GTK_OBJECT (bcd->shell), "unmap_event", - GTK_SIGNAL_FUNC (gtk_widget_hide), + GTK_SIGNAL_FUNC (gimp_dialog_hide), (gpointer) bcd->shell); return bcd; @@ -978,8 +978,7 @@ by_color_select_close_callback (GtkWidget *widget, bcd = (ByColorDialog *) data; - if (GTK_WIDGET_VISIBLE (bcd->shell)) - gtk_widget_hide (bcd->shell); + gimp_dialog_hide (bcd->shell); if (bcd->gimage && gimp_set_have (image_context, bcd->gimage)) { diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index 9d91cf0b5b..ad5f86db2c 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -569,8 +569,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); active_tool->preserve = TRUE; @@ -596,8 +595,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd = (ColorBalanceDialog *) data; - if (GTK_WIDGET_VISIBLE (cbd->shell)) - gtk_widget_hide (cbd->shell); + gimp_dialog_hide (cbd->shell); if (cbd->image_map) { diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index a2d69d5ffc..36e90f955b 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -1213,8 +1213,7 @@ curves_ok_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); active_tool->preserve = TRUE; /* We're about to dirty... */ @@ -1241,8 +1240,7 @@ curves_cancel_callback (GtkWidget *widget, cd = (CurvesDialog *) data; - if (GTK_WIDGET_VISIBLE (cd->shell)) - gtk_widget_hide (cd->shell); + gimp_dialog_hide (cd->shell); if (cd->image_map) { @@ -1637,14 +1635,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/tools/gimphistogramtool.c b/app/tools/gimphistogramtool.c index f853ce7ad2..d3f2e9e6db 100644 --- a/app/tools/gimphistogramtool.c +++ b/app/tools/gimphistogramtool.c @@ -386,9 +386,8 @@ histogram_tool_close_callback (GtkWidget *widget, htd = (HistogramToolDialog *) data; - if (GTK_WIDGET_VISIBLE (htd->shell)) - gtk_widget_hide (htd->shell); - + gimp_dialog_hide (htd->shell); + active_tool->gdisp_ptr = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index d0dd0c163c..4d4c5117ba 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -674,8 +674,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); active_tool->preserve = TRUE; @@ -701,8 +700,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); if (hsd->image_map) { diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index 6585bf49b1..97c4d95b0f 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -960,8 +960,7 @@ levels_ok_callback (GtkWidget *widget, ld = (LevelsDialog *) data; - if (GTK_WIDGET_VISIBLE (ld->shell)) - gtk_widget_hide (ld->shell); + gimp_dialog_hide (ld->shell); active_tool->preserve = TRUE; @@ -993,8 +992,7 @@ levels_cancel_callback (GtkWidget *widget, ld = (LevelsDialog *) data; - if (GTK_WIDGET_VISIBLE (ld->shell)) - gtk_widget_hide (ld->shell); + gimp_dialog_hide (ld->shell); if (ld->image_map) { @@ -1455,15 +1453,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index 1a1f681558..e3dcdade6d 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -288,8 +288,7 @@ posterize_ok_callback (GtkWidget *widget, pd = (PosterizeDialog *) data; - if (GTK_WIDGET_VISIBLE (pd->shell)) - gtk_widget_hide (pd->shell); + gimp_dialog_hide (pd->shell); active_tool->preserve = TRUE; @@ -320,8 +319,7 @@ posterize_cancel_callback (GtkWidget *widget, pd = (PosterizeDialog *) data; - if (GTK_WIDGET_VISIBLE (pd->shell)) - gtk_widget_hide (pd->shell); + gimp_dialog_hide (pd->shell); if (pd->image_map) { diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index 96e4c03dc3..6e8bc1c509 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -256,8 +256,8 @@ tools_free_text (Tool *tool) g_free (tool->private); the_text_tool = NULL; - if (text_tool_shell && GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + if (text_tool_shell) + gimp_dialog_hide (text_tool_shell); } static void @@ -377,8 +377,8 @@ text_control (Tool *tool, break; case HALT: - if (text_tool_shell && GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + if (text_tool_shell) + gimp_dialog_hide (text_tool_shell); break; default: @@ -419,8 +419,7 @@ static void text_dialog_ok_callback (GtkWidget *widget, gpointer data) { - if (GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + gimp_dialog_hide (text_tool_shell); if (the_text_tool) text_init_render (the_text_tool); @@ -440,8 +439,7 @@ static void text_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - if (GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + gimp_dialog_hide (text_tool_shell); } static void diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c index f691eeafc2..ba96d23bbc 100644 --- a/app/tools/gimpthresholdtool.c +++ b/app/tools/gimpthresholdtool.c @@ -421,9 +421,8 @@ threshold_ok_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); - + gimp_dialog_hide (td->shell); + active_tool->preserve = TRUE; if (!td->preview) @@ -448,8 +447,7 @@ threshold_cancel_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); + gimp_dialog_hide (td->shell); if (td->image_map) { diff --git a/app/tools/histogram_tool.c b/app/tools/histogram_tool.c index f853ce7ad2..d3f2e9e6db 100644 --- a/app/tools/histogram_tool.c +++ b/app/tools/histogram_tool.c @@ -386,9 +386,8 @@ histogram_tool_close_callback (GtkWidget *widget, htd = (HistogramToolDialog *) data; - if (GTK_WIDGET_VISIBLE (htd->shell)) - gtk_widget_hide (htd->shell); - + gimp_dialog_hide (htd->shell); + active_tool->gdisp_ptr = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/hue_saturation.c b/app/tools/hue_saturation.c index d0dd0c163c..4d4c5117ba 100644 --- a/app/tools/hue_saturation.c +++ b/app/tools/hue_saturation.c @@ -674,8 +674,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); active_tool->preserve = TRUE; @@ -701,8 +700,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd = (HueSaturationDialog *) data; - if (GTK_WIDGET_VISIBLE (hsd->shell)) - gtk_widget_hide (hsd->shell); + gimp_dialog_hide (hsd->shell); if (hsd->image_map) { diff --git a/app/tools/levels.c b/app/tools/levels.c index 6585bf49b1..97c4d95b0f 100644 --- a/app/tools/levels.c +++ b/app/tools/levels.c @@ -960,8 +960,7 @@ levels_ok_callback (GtkWidget *widget, ld = (LevelsDialog *) data; - if (GTK_WIDGET_VISIBLE (ld->shell)) - gtk_widget_hide (ld->shell); + gimp_dialog_hide (ld->shell); active_tool->preserve = TRUE; @@ -993,8 +992,7 @@ levels_cancel_callback (GtkWidget *widget, ld = (LevelsDialog *) data; - if (GTK_WIDGET_VISIBLE (ld->shell)) - gtk_widget_hide (ld->shell); + gimp_dialog_hide (ld->shell); if (ld->image_map) { @@ -1455,15 +1453,14 @@ file_dialog_ok_callback (GtkWidget *widget, fclose (f); } - - gtk_widget_hide (file_dlg); + file_dialog_cancel_callback (file_dlg, NULL); } static void file_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_widget_hide (file_dlg); + gimp_dialog_hide (file_dlg); } static gboolean diff --git a/app/tools/posterize.c b/app/tools/posterize.c index 1a1f681558..e3dcdade6d 100644 --- a/app/tools/posterize.c +++ b/app/tools/posterize.c @@ -288,8 +288,7 @@ posterize_ok_callback (GtkWidget *widget, pd = (PosterizeDialog *) data; - if (GTK_WIDGET_VISIBLE (pd->shell)) - gtk_widget_hide (pd->shell); + gimp_dialog_hide (pd->shell); active_tool->preserve = TRUE; @@ -320,8 +319,7 @@ posterize_cancel_callback (GtkWidget *widget, pd = (PosterizeDialog *) data; - if (GTK_WIDGET_VISIBLE (pd->shell)) - gtk_widget_hide (pd->shell); + gimp_dialog_hide (pd->shell); if (pd->image_map) { diff --git a/app/tools/text_tool.c b/app/tools/text_tool.c index 96e4c03dc3..6e8bc1c509 100644 --- a/app/tools/text_tool.c +++ b/app/tools/text_tool.c @@ -256,8 +256,8 @@ tools_free_text (Tool *tool) g_free (tool->private); the_text_tool = NULL; - if (text_tool_shell && GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + if (text_tool_shell) + gimp_dialog_hide (text_tool_shell); } static void @@ -377,8 +377,8 @@ text_control (Tool *tool, break; case HALT: - if (text_tool_shell && GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + if (text_tool_shell) + gimp_dialog_hide (text_tool_shell); break; default: @@ -419,8 +419,7 @@ static void text_dialog_ok_callback (GtkWidget *widget, gpointer data) { - if (GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + gimp_dialog_hide (text_tool_shell); if (the_text_tool) text_init_render (the_text_tool); @@ -440,8 +439,7 @@ static void text_dialog_cancel_callback (GtkWidget *widget, gpointer data) { - if (GTK_WIDGET_VISIBLE (text_tool_shell)) - gtk_widget_hide (text_tool_shell); + gimp_dialog_hide (text_tool_shell); } static void diff --git a/app/tools/threshold.c b/app/tools/threshold.c index f691eeafc2..ba96d23bbc 100644 --- a/app/tools/threshold.c +++ b/app/tools/threshold.c @@ -421,9 +421,8 @@ threshold_ok_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); - + gimp_dialog_hide (td->shell); + active_tool->preserve = TRUE; if (!td->preview) @@ -448,8 +447,7 @@ threshold_cancel_callback (GtkWidget *widget, td = (ThresholdDialog *) data; - if (GTK_WIDGET_VISIBLE (td->shell)) - gtk_widget_hide (td->shell); + gimp_dialog_hide (td->shell); if (td->image_map) { diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c index f5a309b040..87a331a2dd 100644 --- a/app/widgets/gimpwidgets-utils.c +++ b/app/widgets/gimpwidgets-utils.c @@ -165,3 +165,27 @@ gimp_message_box_close_callback (GtkWidget *widget, g_free (msg_box->message); g_free (msg_box); } + + +/* + * A workaround for what I think is a GTK+ bug: + * If a dialog is hidden using gtk_widget_hide(), + * and was iconified before, it is still present + * in the window_list and can be deiconified by + * the user later. All subsequent calls to + * gtk_widget_hide() will then fail since the state + * of the widget is still INVISIBLE. + * Calling gdk_window_withdraw() seems to solve this. + * --Sven + */ +void +gimp_dialog_hide (GtkWidget *dialog) +{ + g_return_if_fail (dialog != NULL && !GTK_WIDGET_NO_WINDOW (dialog)); + + gtk_widget_hide (dialog); + gdk_window_withdraw (dialog->window); +} + + + diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h index d59dd9ed8b..6b38901bb8 100644 --- a/app/widgets/gimpwidgets-utils.h +++ b/app/widgets/gimpwidgets-utils.h @@ -36,8 +36,10 @@ /* a simple message box */ -void gimp_message_box (gchar *message, - GtkCallback callback, - gpointer data); +void gimp_message_box (gchar *message, + GtkCallback callback, + gpointer data); + +void gimp_dialog_hide (GtkWidget *dialog); #endif /* __GIMP_UI_H__ */