[gimp/gtk3-port: 315/457] app: allow setting parent for dialogs created by GimpDialogFactory.
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 315/457] app: allow setting parent for dialogs created by GimpDialogFactory.
- Date: Sat, 19 May 2018 18:30:08 +0000 (UTC)
commit 57192406b51981f7c88b752159483064a1793cd5
Author: Jehan <jehan girinstud io>
Date: Thu May 3 00:55:44 2018 +0200
app: allow setting parent for dialogs created by GimpDialogFactory.
Fixes a bunch of:
> Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
app/actions/dialogs-commands.c | 1 +
app/actions/file-commands.c | 5 +++++
app/actions/image-commands.c | 1 +
app/actions/palettes-commands.c | 1 +
app/dialogs/dialogs.c | 8 ++++++--
app/dialogs/preferences-dialog.c | 2 ++
app/display/gimpmultiwindowstrategy.c | 2 +-
app/display/gimpsinglewindowstrategy.c | 2 ++
app/gui/gimpuiconfigurer.c | 1 +
app/gui/gui-message.c | 2 ++
app/gui/gui.c | 15 +++++++++++----
app/tests/gimp-app-test-utils.c | 1 +
app/tests/test-ui.c | 1 +
app/widgets/gimpdialogfactory.c | 23 +++++++++++++++++++++++
app/widgets/gimpdialogfactory.h | 2 ++
app/widgets/gimpsessioninfo-dock.c | 1 +
app/widgets/gimpwidgets-utils.c | 2 ++
17 files changed, 63 insertions(+), 7 deletions(-)
---
diff --git a/app/actions/dialogs-commands.c b/app/actions/dialogs-commands.c
index 4a0fe0c..b45222d 100644
--- a/app/actions/dialogs-commands.c
+++ b/app/actions/dialogs-commands.c
@@ -48,6 +48,7 @@ dialogs_create_toplevel_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
+ widget,
value, -1, TRUE);
}
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index d691438..2eadfe2 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -150,6 +150,7 @@ file_open_location_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
+ widget,
"gimp-file-open-location-dialog", -1, TRUE);
}
@@ -463,6 +464,7 @@ file_close_all_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
+ widget,
"gimp-close-all-dialog", -1);
}
}
@@ -556,6 +558,7 @@ file_open_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
+ parent,
"gimp-file-open-dialog", -1, FALSE);
if (dialog)
@@ -609,6 +612,7 @@ file_save_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
+ parent,
"gimp-file-save-dialog",
-1, FALSE);
@@ -690,6 +694,7 @@ file_export_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
+ parent,
"gimp-file-export-dialog",
-1, FALSE);
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 694c462..eb85b90 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -190,6 +190,7 @@ image_new_cmd_callback (GtkAction *action,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
+ widget,
"gimp-image-new-dialog", -1, FALSE);
if (dialog)
diff --git a/app/actions/palettes-commands.c b/app/actions/palettes-commands.c
index b203108..f50c0d0 100644
--- a/app/actions/palettes-commands.c
+++ b/app/actions/palettes-commands.c
@@ -63,6 +63,7 @@ palettes_import_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
+ widget,
"gimp-palette-import-dialog", -1, TRUE);
}
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index 077f2af..c3c2707 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -459,8 +459,11 @@ dialogs_restore_dialog (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpSessionInfo *info)
{
- GtkWidget *dialog;
- GimpCoreConfig *config = gimp_dialog_factory_get_context (factory)->gimp->config;
+ GtkWidget *dialog;
+ Gimp *gimp = gimp_dialog_factory_get_context (factory)->gimp;
+ GimpCoreConfig *config = gimp->config;
+ GimpDisplay *display = GIMP_DISPLAY (gimp_get_empty_display (gimp));
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
GIMP_LOG (DIALOG_FACTORY, "restoring toplevel \"%s\" (info %p)",
gimp_session_info_get_factory_entry (info)->identifier,
@@ -469,6 +472,7 @@ dialogs_restore_dialog (GimpDialogFactory *factory,
dialog =
gimp_dialog_factory_dialog_new (factory, monitor,
NULL /*ui_manager*/,
+ GTK_WIDGET (gimp_display_shell_get_window (shell)),
gimp_session_info_get_factory_entry (info)->identifier,
gimp_session_info_get_factory_entry (info)->view_size,
! GIMP_GUI_CONFIG (config)->hide_docks);
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 051bfe5..1095237 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -571,6 +571,7 @@ prefs_input_devices_dialog (GtkWidget *widget,
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
+ widget,
"gimp-input-devices-dialog", 0);
}
@@ -580,6 +581,7 @@ prefs_keyboard_shortcuts_dialog (GtkWidget *widget,
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gimp_widget_get_monitor (widget),
+ widget,
"gimp-keyboard-shortcuts-dialog", 0);
}
diff --git a/app/display/gimpmultiwindowstrategy.c b/app/display/gimpmultiwindowstrategy.c
index 2897b9f..c48e248 100644
--- a/app/display/gimpmultiwindowstrategy.c
+++ b/app/display/gimpmultiwindowstrategy.c
@@ -71,7 +71,7 @@ gimp_multi_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
GdkMonitor *monitor,
const gchar *identifiers)
{
- return gimp_dialog_factory_dialog_raise (factory, monitor,
+ return gimp_dialog_factory_dialog_raise (factory, monitor, NULL,
identifiers, -1);
}
diff --git a/app/display/gimpsinglewindowstrategy.c b/app/display/gimpsinglewindowstrategy.c
index 06deb62..cfe2932 100644
--- a/app/display/gimpsinglewindowstrategy.c
+++ b/app/display/gimpsinglewindowstrategy.c
@@ -96,6 +96,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
widget = gimp_dialog_factory_dialog_new (factory, monitor,
ui_manager,
+ GTK_WIDGET (window),
"gimp-toolbox",
-1 /*view_size*/,
FALSE /*present*/);
@@ -111,6 +112,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
{
/* if the dialog is already open, simply raise it */
return gimp_dialog_factory_dialog_raise (factory, monitor,
+ GTK_WIDGET (window),
identifiers, -1);
}
else
diff --git a/app/gui/gimpuiconfigurer.c b/app/gui/gimpuiconfigurer.c
index ac5fd53..4119079 100644
--- a/app/gui/gimpuiconfigurer.c
+++ b/app/gui/gimpuiconfigurer.c
@@ -374,6 +374,7 @@ gimp_ui_configurer_move_docks_to_window (GimpUIConfigurer *ui_configurer,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
monitor,
NULL /*ui_manager*/,
+ GTK_WIDGET (dock_columns),
(contains_toolbox ?
"gimp-toolbox-window" :
"gimp-dock-window"),
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index 2644f4d..c9eec1a 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -457,6 +457,7 @@ global_error_dialog (void)
return gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
monitor,
NULL /*ui_manager*/,
+ NULL,
"gimp-error-dialog", -1,
FALSE);
}
@@ -470,6 +471,7 @@ global_critical_dialog (void)
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
monitor,
NULL /*ui_manager*/,
+ NULL,
"gimp-critical-dialog", -1,
FALSE);
g_signal_handlers_disconnect_by_func (dialog,
diff --git a/app/gui/gui.c b/app/gui/gui.c
index 05642b0..1de5a6c 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -718,13 +718,20 @@ gui_exit_callback (Gimp *gimp,
if (! force && gimp_displays_dirty (gimp))
{
- GdkMonitor *monitor;
+ GimpContext *context = gimp_get_user_context (gimp);
+ GimpDisplay *display = gimp_context_get_display (context);
+ GdkMonitor *monitor = gimp_get_monitor_at_pointer ();
+ GtkWidget *parent = NULL;
- monitor = gimp_get_monitor_at_pointer ();
+ if (display)
+ {
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
+
+ parent = GTK_WIDGET (gimp_display_shell_get_window (shell));
+ }
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
- monitor,
- "gimp-quit-dialog", -1);
+ monitor, parent, "gimp-quit-dialog", -1);
return TRUE; /* stop exit for now */
}
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index bb9d756..a5617e3 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -307,6 +307,7 @@ gimp_test_utils_create_image_from_dialog (Gimp *gimp)
new_image_dialog =
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gdk_display_get_monitor (gdk_display_get_default (), 0),
+ NULL,
"gimp-image-new-dialog",
-1 /*view_size*/);
diff --git a/app/tests/test-ui.c b/app/tests/test-ui.c
index 6384d6f..774d3e0 100644
--- a/app/tests/test-ui.c
+++ b/app/tests/test-ui.c
@@ -117,6 +117,7 @@ tool_options_editor_updates (gconstpointer data)
gtk_widget_get_screen (toplevel),
gimp_widget_get_monitor (toplevel),
NULL /*ui_manager*/,
+ toplevel,
"gimp-tool-options",
-1 /*view_size*/,
FALSE /*present*/);
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index bc57a73..c506f31 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -423,6 +423,7 @@ gimp_dialog_factory_dialog_sane (GimpDialogFactory *factory,
* @monitor:
* @context:
* @ui_manager:
+ * @parent:
* @identifier:
* @view_size:
* @return_existing: If %TRUE, (or if the dialog is a singleton),
@@ -443,6 +444,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpContext *context,
GimpUIManager *ui_manager,
+ GtkWidget *parent,
const gchar *identifier,
gint view_size,
gboolean return_existing,
@@ -514,6 +516,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
dock_window = gimp_dialog_factory_dialog_new (factory,
monitor,
NULL /*ui_manager*/,
+ parent,
"gimp-toolbox-window",
-1 /*view_size*/,
FALSE /*present*/);
@@ -631,6 +634,17 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
gtk_window_set_screen (GTK_WINDOW (dialog),
gdk_display_get_default_screen (gdk_monitor_get_display (monitor)));
+ if (parent)
+ {
+ GtkWidget *parent_toplevel = gtk_widget_get_toplevel (parent);
+
+ if (GTK_IS_WINDOW (parent_toplevel))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (parent_toplevel));
+ }
+ }
+
toplevel = dialog;
}
else if (GIMP_IS_DOCK (dialog))
@@ -676,6 +690,8 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
* @factory: a #GimpDialogFactory
* @monitor the #GdkMonitor the dialog should appear on
* @ui_manager: A #GimpUIManager, if applicable.
+ * @parent: The parent widget, from which the call originated, if
+ * applicable, NULL otherwise.
* @identifier: the identifier of the dialog as registered with
* gimp_dialog_factory_register_entry()
* @view_size: the initial preview size
@@ -691,6 +707,7 @@ GtkWidget *
gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpUIManager *ui_manager,
+ GtkWidget *parent,
const gchar *identifier,
gint view_size,
gboolean present)
@@ -703,6 +720,7 @@ gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
monitor,
factory->p->context,
ui_manager,
+ parent,
identifier,
view_size,
FALSE /*return_existing*/,
@@ -760,6 +778,8 @@ gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
* gimp_dialog_factory_dialog_raise:
* @factory: a #GimpDialogFactory
* @monitor: the #GdkMonitor the dialog should appear on
+ * @parent: the #GtkWidget from which the raised dialog
+ * originated, if applicable, #NULL otherwise.
* @identifiers: a '|' separated list of identifiers of dialogs as
* registered with gimp_dialog_factory_register_entry()
* @view_size: the initial preview size if a dialog needs to be created
@@ -775,6 +795,7 @@ gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
GtkWidget *
gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkMonitor *monitor,
+ GtkWidget *parent,
const gchar *identifiers,
gint view_size)
{
@@ -803,6 +824,7 @@ gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
monitor,
NULL,
NULL,
+ parent,
ids[i] ? ids[i] : ids[0],
view_size,
TRUE /*return_existing*/,
@@ -845,6 +867,7 @@ gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
gimp_widget_get_monitor (GTK_WIDGET (dock)),
gimp_dock_get_context (dock),
gimp_dock_get_ui_manager (dock),
+ NULL,
identifier,
view_size,
FALSE /*return_existing*/,
diff --git a/app/widgets/gimpdialogfactory.h b/app/widgets/gimpdialogfactory.h
index e636163..39fa344 100644
--- a/app/widgets/gimpdialogfactory.h
+++ b/app/widgets/gimpdialogfactory.h
@@ -140,6 +140,7 @@ GtkWidget * gimp_dialog_factory_find_widget (GimpDialogFactory
GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkMonitor *monitor,
GimpUIManager *ui_manager,
+ GtkWidget *parent,
const gchar *identifier,
gint view_size,
gboolean present);
@@ -151,6 +152,7 @@ void gimp_dialog_factory_add_session_info (GimpDialogFactory
GimpSessionInfo *info);
GtkWidget * gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkMonitor *monitor,
+ GtkWidget *parent,
const gchar *identifiers,
gint view_size);
GtkWidget * gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
diff --git a/app/widgets/gimpsessioninfo-dock.c b/app/widgets/gimpsessioninfo-dock.c
index 6788cba..9d13bd3 100644
--- a/app/widgets/gimpsessioninfo-dock.c
+++ b/app/widgets/gimpsessioninfo-dock.c
@@ -290,6 +290,7 @@ gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
dock = gimp_dialog_factory_dialog_new (factory, monitor,
ui_manager,
+ NULL,
dock_info->dock_type,
-1 /*view_size*/,
FALSE /*present*/);
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 14f001f..0de4dfb 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1364,6 +1364,7 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
*/
dock_window = gimp_dialog_factory_dialog_new (factory, monitor,
NULL /*ui_manager*/,
+ NULL,
(toolbox ?
"gimp-toolbox-window" :
"gimp-dock-window"),
@@ -1374,6 +1375,7 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
dock = gimp_dialog_factory_dialog_new (factory, monitor,
ui_manager,
+ dock_window,
(toolbox ?
"gimp-toolbox" :
"gimp-dock"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]