[gimp] Bug 643155 - Tool dialogs don't stay on top of the image window
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 643155 - Tool dialogs don't stay on top of the image window
- Date: Sun, 20 Mar 2011 17:19:25 +0000 (UTC)
commit 4149452279b1f6cdff4ef77c59f24dc90ed87a89
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 20 18:15:42 2011 +0100
Bug 643155 - Tool dialogs don't stay on top of the image window
Change the "GtkWidget *parent" parameter of GimpToolDialog to
"GimpDisplayShell". Also add API gimp_tool_dialog_set_shell() so an
existing dialog can be used on different images. Make sure the dialog
closes when the shell is unmapped (like when switching tabs in SWM),
and make the dialog transient for the toplevel GimpImageWindow.
Change all tool dialog users accordingly.
app/display/gimptooldialog.c | 82 ++++++++++++++++++++++++++++++++++++++---
app/display/gimptooldialog.h | 11 +++--
app/tools/gimpimagemaptool.c | 12 ++++--
app/tools/gimpmeasuretool.c | 11 +++--
app/tools/gimptransformtool.c | 4 +-
5 files changed, 101 insertions(+), 19 deletions(-)
---
diff --git a/app/display/gimptooldialog.c b/app/display/gimptooldialog.c
index c90de21..71181ea 100644
--- a/app/display/gimptooldialog.c
+++ b/app/display/gimptooldialog.c
@@ -31,15 +31,33 @@
#include "widgets/gimpdialogfactory.h"
+#include "gimpdisplayshell.h"
#include "gimptooldialog.h"
+typedef struct _GimpToolDialogPrivate GimpToolDialogPrivate;
+
+struct _GimpToolDialogPrivate
+{
+ GimpDisplayShell *shell;
+};
+
+#define GET_PRIVATE(dialog) G_TYPE_INSTANCE_GET_PRIVATE (dialog, \
+ GIMP_TYPE_TOOL_DIALOG, \
+ GimpToolDialogPrivate)
+
+
+static void gimp_tool_dialog_shell_unmap (GimpDisplayShell *shell,
+ GimpToolDialog *dialog);
+
+
G_DEFINE_TYPE (GimpToolDialog, gimp_tool_dialog, GIMP_TYPE_VIEWABLE_DIALOG)
static void
gimp_tool_dialog_class_init (GimpToolDialogClass *klass)
{
+ g_type_class_add_private (klass, sizeof (GimpToolDialogPrivate));
}
static void
@@ -51,7 +69,7 @@ gimp_tool_dialog_init (GimpToolDialog *dialog)
/**
* gimp_tool_dialog_new:
* @tool_info: a #GimpToolInfo
- * @parent: the parent widget of this dialog or %NULL
+ * @shell: the parent display shell this dialog
* @desc: a string to use in the dialog header or %NULL to use the help
* field from #GimpToolInfo
* @...: a %NULL-terminated valist of button parameters as described in
@@ -64,9 +82,9 @@ gimp_tool_dialog_init (GimpToolDialog *dialog)
* Return value: a new #GimpViewableDialog
**/
GtkWidget *
-gimp_tool_dialog_new (GimpToolInfo *tool_info,
- GtkWidget *parent,
- const gchar *desc,
+gimp_tool_dialog_new (GimpToolInfo *tool_info,
+ GimpDisplayShell *shell,
+ const gchar *desc,
...)
{
GtkWidget *dialog;
@@ -75,7 +93,7 @@ gimp_tool_dialog_new (GimpToolInfo *tool_info,
va_list args;
g_return_val_if_fail (GIMP_IS_TOOL_INFO (tool_info), NULL);
- g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
+ g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
@@ -86,9 +104,10 @@ gimp_tool_dialog_new (GimpToolInfo *tool_info,
"help-id", tool_info->help_id,
"stock-id", stock_id,
"description", desc ? desc : tool_info->help,
- "parent", parent,
NULL);
+ gimp_tool_dialog_set_shell (GIMP_TOOL_DIALOG (dialog), shell);
+
va_start (args, desc);
gimp_dialog_add_buttons_valist (GIMP_DIALOG (dialog), args);
va_end (args);
@@ -103,3 +122,54 @@ gimp_tool_dialog_new (GimpToolInfo *tool_info,
return dialog;
}
+
+void
+gimp_tool_dialog_set_shell (GimpToolDialog *tool_dialog,
+ GimpDisplayShell *shell)
+{
+ GimpToolDialogPrivate *private = GET_PRIVATE (tool_dialog);
+
+ g_return_if_fail (GIMP_IS_TOOL_DIALOG (tool_dialog));
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+ if (shell == private->shell)
+ return;
+
+ if (private->shell)
+ {
+ g_signal_handlers_disconnect_by_func (private->shell,
+ gimp_tool_dialog_shell_unmap,
+ tool_dialog);
+ private->shell = NULL;
+ }
+
+ private->shell = shell;
+
+ if (private->shell)
+ {
+ GtkWidget *toplevel;
+
+ g_signal_connect_object (private->shell, "unmap",
+ G_CALLBACK (gimp_tool_dialog_shell_unmap),
+ tool_dialog, 0);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
+
+ gtk_window_set_transient_for (GTK_WINDOW (tool_dialog),
+ GTK_WINDOW (toplevel));
+ }
+}
+
+
+/* private functions */
+
+static void
+gimp_tool_dialog_shell_unmap (GimpDisplayShell *shell,
+ GimpToolDialog *dialog)
+{
+ /* the dialog being mapped while the shell is being unmapped
+ * happens when switching images in GimpImageWindow
+ */
+ if (gtk_widget_get_mapped (GTK_WIDGET (dialog)))
+ g_signal_emit_by_name (dialog, "close");
+}
diff --git a/app/display/gimptooldialog.h b/app/display/gimptooldialog.h
index d3c5ae4..ae3baaa 100644
--- a/app/display/gimptooldialog.h
+++ b/app/display/gimptooldialog.h
@@ -42,10 +42,13 @@ struct _GimpToolDialog
GType gimp_tool_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_tool_dialog_new (GimpToolInfo *tool_info,
- GtkWidget *parent,
- const gchar *desc,
- ...) G_GNUC_NULL_TERMINATED;
+GtkWidget * gimp_tool_dialog_new (GimpToolInfo *tool_info,
+ GimpDisplayShell *shell,
+ const gchar *desc,
+ ...) G_GNUC_NULL_TERMINATED;
+
+void gimp_tool_dialog_set_shell (GimpToolDialog *tool_dialog,
+ GimpDisplayShell *shell);
#endif /* __GIMP_TOOL_DIALOG_H__ */
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index 1de335f..3430ba0 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -334,7 +334,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
{
image_map_tool->shell = shell =
gimp_tool_dialog_new (tool_info,
- GTK_WIDGET (display_shell),
+ display_shell,
klass->shell_desc,
GIMP_STOCK_RESET, RESPONSE_RESET,
@@ -390,9 +390,13 @@ gimp_image_map_tool_initialize (GimpTool *tool,
}
if (! image_map_tool->overlay)
- gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (image_map_tool->shell),
- GIMP_VIEWABLE (drawable),
- GIMP_CONTEXT (tool_info->tool_options));
+ {
+ gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (image_map_tool->shell),
+ GIMP_VIEWABLE (drawable),
+ GIMP_CONTEXT (tool_info->tool_options));
+ gimp_tool_dialog_set_shell (GIMP_TOOL_DIALOG (image_map_tool->shell),
+ display_shell);
+ }
gtk_widget_show (image_map_tool->shell);
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index f183c2a..5623e78 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -336,9 +336,12 @@ gimp_measure_tool_button_press (GimpTool *tool,
}
if (measure->dialog)
- gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (measure->dialog),
- GIMP_VIEWABLE (image),
- GIMP_CONTEXT (options));
+ {
+ gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (measure->dialog),
+ GIMP_VIEWABLE (image),
+ GIMP_CONTEXT (options));
+ gimp_tool_dialog_set_shell (GIMP_TOOL_DIALOG (measure->dialog), shell);
+ }
}
static void
@@ -995,7 +998,7 @@ gimp_measure_tool_dialog_new (GimpMeasureTool *measure)
GtkWidget *label;
dialog = gimp_tool_dialog_new (tool->tool_info,
- NULL /* tool->display->shell */,
+ gimp_display_get_shell (tool->display),
_("Measure Distances and Angles"),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index d7742ad..40e4a6f 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -1766,7 +1766,7 @@ gimp_transform_tool_dialog (GimpTransformTool *tr_tool)
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
tr_tool->dialog = gimp_tool_dialog_new (tool_info,
- NULL /* tool->display->shell */,
+ gimp_display_get_shell (tool->display),
tool_info->blurb,
GIMP_STOCK_RESET, RESPONSE_RESET,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -1811,6 +1811,8 @@ gimp_transform_tool_prepare (GimpTransformTool *tr_tool,
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (tr_tool->dialog),
GIMP_VIEWABLE (drawable),
GIMP_CONTEXT (options));
+ gimp_tool_dialog_set_shell (GIMP_TOOL_DIALOG (tr_tool->dialog),
+ gimp_display_get_shell (display));
gtk_widget_set_sensitive (tr_tool->dialog, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]