From 6aeb456e17646a6e90be73817f0fc3784fb53863 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 15 Aug 2023 00:12:16 +0200 Subject: [PATCH] app, libgimp, pdb: add a parent_window parameter to gimp_*_popup() PDB calls. Brush, font, gradient, palette and pattern choices are currently chosen through a dialog created by the core, which then returns the user choice to the calling plug-in. This has the unfortunate consequence of having a pile of likely at least 3 windows (main GIMP window by core process, plug-in window by plug-in process, then the choice popup by the core process) shared in 2 processes, which often end up under each other and that's messy. Even more as the choice popup is kinda expected to be like a sub-part of the plug-in dialog. So anyway, now the plug-in can send its window handle to the core so that the resource choice dialog ends up always above the plug-in dialog. Of course, it will always work only on platforms where we have working inter-process transient support. --- app/core/gimp-gui.c | 3 +- app/core/gimp-gui.h | 2 ++ app/gui/gui-vtable.c | 23 ++++++++------ app/pdb/brush-select-cmds.c | 9 ++++++ app/pdb/font-select-cmds.c | 9 ++++++ app/pdb/gradient-select-cmds.c | 9 ++++++ app/pdb/palette-select-cmds.c | 9 ++++++ app/pdb/pattern-select-cmds.c | 9 ++++++ app/widgets/gimpwidgets-utils.c | 49 ++++++++++++++++++++++++------ app/widgets/gimpwidgets-utils.h | 2 ++ libgimp/gimpbrushselect_pdb.c | 5 ++- libgimp/gimpbrushselect_pdb.h | 3 +- libgimp/gimpbrushselectbutton.c | 2 ++ libgimp/gimpfontselect_pdb.c | 5 ++- libgimp/gimpfontselect_pdb.h | 3 +- libgimp/gimpgradientselect_pdb.c | 5 ++- libgimp/gimpgradientselect_pdb.h | 3 +- libgimp/gimppaletteselect_pdb.c | 5 ++- libgimp/gimppaletteselect_pdb.h | 3 +- libgimp/gimppatternselect_pdb.c | 5 ++- libgimp/gimppatternselect_pdb.h | 3 +- libgimp/gimpresourceselect.c | 15 ++++----- libgimp/gimpresourceselect.h | 1 + libgimp/gimpresourceselectbutton.c | 7 +++++ pdb/groups/brush_select.pdb | 5 ++- pdb/groups/font_select.pdb | 5 ++- pdb/groups/gradient_select.pdb | 5 ++- pdb/groups/palette_select.pdb | 5 ++- pdb/groups/pattern_select.pdb | 5 ++- 29 files changed, 173 insertions(+), 41 deletions(-) diff --git a/app/core/gimp-gui.c b/app/core/gimp-gui.c index bbfc862551..0eeaa31cac 100644 --- a/app/core/gimp-gui.c +++ b/app/core/gimp-gui.c @@ -404,6 +404,7 @@ gimp_pdb_dialog_new (Gimp *gimp, GimpContext *context, GimpProgress *progress, GimpContainer *container, + GBytes *parent_handle, const gchar *title, const gchar *callback_name, const gchar *object_name, @@ -425,7 +426,7 @@ gimp_pdb_dialog_new (Gimp *gimp, va_start (args, object_name); retval = gimp->gui.pdb_dialog_new (gimp, context, progress, - container, title, + container, parent_handle, title, callback_name, object_name, args); diff --git a/app/core/gimp-gui.h b/app/core/gimp-gui.h index d5daf1f21c..14219aa95e 100644 --- a/app/core/gimp-gui.h +++ b/app/core/gimp-gui.h @@ -74,6 +74,7 @@ struct _GimpGui GimpContext *context, GimpProgress *progress, GimpContainer *container, + GBytes *parent_handle, const gchar *title, const gchar *callback_name, const gchar *object_name, @@ -172,6 +173,7 @@ gboolean gimp_pdb_dialog_new (Gimp *gimp, GimpContext *context, GimpProgress *progress, GimpContainer *container, + GBytes *parent_handle, const gchar *title, const gchar *callback_name, const gchar *object_name, diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c index f83293b1c2..85a98af82f 100644 --- a/app/gui/gui-vtable.c +++ b/app/gui/gui-vtable.c @@ -153,6 +153,7 @@ static gboolean gui_pdb_dialog_new (Gimp *gimp, GimpContext *context, GimpProgress *progress, GimpContainer *container, + GBytes *parent_handle, const gchar *title, const gchar *callback_name, const gchar *object_name, @@ -611,6 +612,7 @@ gui_pdb_dialog_new (Gimp *gimp, GimpContext *context, GimpProgress *progress, GimpContainer *container, + GBytes *parent_handle, const gchar *title, const gchar *callback_name, const gchar *object_name, @@ -706,17 +708,20 @@ gui_pdb_dialog_new (Gimp *gimp, gtk_widget_show (dialog); /* workaround for bug #360106 */ - { - GSource *source = g_timeout_source_new (100); - GClosure *closure; + { + GSource *source = g_timeout_source_new (100); + GClosure *closure; - closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present), - G_OBJECT (dialog)); + closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present), + G_OBJECT (dialog)); - g_source_set_closure (source, closure); - g_source_attach (source, NULL); - g_source_unref (source); - } + g_source_set_closure (source, closure); + g_source_attach (source, NULL); + g_source_unref (source); + } + + if (parent_handle != NULL) + gimp_window_set_transient_for_handle (GTK_WINDOW (dialog), parent_handle); return TRUE; } diff --git a/app/pdb/brush-select-cmds.c b/app/pdb/brush-select-cmds.c index 554504ccab..612944f4e3 100644 --- a/app/pdb/brush-select-cmds.c +++ b/app/pdb/brush-select-cmds.c @@ -50,10 +50,12 @@ brushes_popup_invoker (GimpProcedure *procedure, const gchar *brush_callback; const gchar *popup_title; const gchar *initial_brush_name; + GBytes *parent_window; brush_callback = g_value_get_string (gimp_value_array_index (args, 0)); popup_title = g_value_get_string (gimp_value_array_index (args, 1)); initial_brush_name = g_value_get_string (gimp_value_array_index (args, 2)); + parent_window = g_value_get_boxed (gimp_value_array_index (args, 3)); if (success) { @@ -61,6 +63,7 @@ brushes_popup_invoker (GimpProcedure *procedure, ! gimp_pdb_lookup_procedure (gimp->pdb, brush_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->brush_factory), + parent_window, popup_title, brush_callback, initial_brush_name, NULL)) success = FALSE; @@ -165,6 +168,12 @@ register_brush_select_procs (GimpPDB *pdb) FALSE, TRUE, FALSE, NULL, GIMP_PARAM_READWRITE)); + gimp_procedure_add_argument (procedure, + g_param_spec_boxed ("parent-window", + "parent window", + "An optional parent window handle for the popup to be set transient to", + G_TYPE_BYTES, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); diff --git a/app/pdb/font-select-cmds.c b/app/pdb/font-select-cmds.c index bca497e57a..07573ee151 100644 --- a/app/pdb/font-select-cmds.c +++ b/app/pdb/font-select-cmds.c @@ -50,10 +50,12 @@ fonts_popup_invoker (GimpProcedure *procedure, const gchar *font_callback; const gchar *popup_title; const gchar *initial_font_name; + GBytes *parent_window; font_callback = g_value_get_string (gimp_value_array_index (args, 0)); popup_title = g_value_get_string (gimp_value_array_index (args, 1)); initial_font_name = g_value_get_string (gimp_value_array_index (args, 2)); + parent_window = g_value_get_boxed (gimp_value_array_index (args, 3)); if (success) { @@ -62,6 +64,7 @@ fonts_popup_invoker (GimpProcedure *procedure, ! gimp_data_factory_data_wait (gimp->font_factory) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->font_factory), + parent_window, popup_title, font_callback, initial_font_name, NULL)) success = FALSE; @@ -169,6 +172,12 @@ register_font_select_procs (GimpPDB *pdb) FALSE, TRUE, FALSE, NULL, GIMP_PARAM_READWRITE)); + gimp_procedure_add_argument (procedure, + g_param_spec_boxed ("parent-window", + "parent window", + "An optional parent window handle for the popup to be set transient to", + G_TYPE_BYTES, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); diff --git a/app/pdb/gradient-select-cmds.c b/app/pdb/gradient-select-cmds.c index 9e5880a0c8..9a32f99beb 100644 --- a/app/pdb/gradient-select-cmds.c +++ b/app/pdb/gradient-select-cmds.c @@ -51,10 +51,12 @@ gradients_popup_invoker (GimpProcedure *procedure, const gchar *gradient_callback; const gchar *popup_title; const gchar *initial_gradient_name; + GBytes *parent_window; gradient_callback = g_value_get_string (gimp_value_array_index (args, 0)); popup_title = g_value_get_string (gimp_value_array_index (args, 1)); initial_gradient_name = g_value_get_string (gimp_value_array_index (args, 2)); + parent_window = g_value_get_boxed (gimp_value_array_index (args, 3)); if (success) { @@ -68,6 +70,7 @@ gradients_popup_invoker (GimpProcedure *procedure, ! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->gradient_factory), + parent_window, popup_title, gradient_callback, initial_gradient_name, NULL)) success = FALSE; @@ -172,6 +175,12 @@ register_gradient_select_procs (GimpPDB *pdb) FALSE, TRUE, FALSE, NULL, GIMP_PARAM_READWRITE)); + gimp_procedure_add_argument (procedure, + g_param_spec_boxed ("parent-window", + "parent window", + "An optional parent window handle for the popup to be set transient to", + G_TYPE_BYTES, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); diff --git a/app/pdb/palette-select-cmds.c b/app/pdb/palette-select-cmds.c index 6e4b68a2f4..a4e2495e09 100644 --- a/app/pdb/palette-select-cmds.c +++ b/app/pdb/palette-select-cmds.c @@ -50,10 +50,12 @@ palettes_popup_invoker (GimpProcedure *procedure, const gchar *palette_callback; const gchar *popup_title; const gchar *initial_palette_name; + GBytes *parent_window; palette_callback = g_value_get_string (gimp_value_array_index (args, 0)); popup_title = g_value_get_string (gimp_value_array_index (args, 1)); initial_palette_name = g_value_get_string (gimp_value_array_index (args, 2)); + parent_window = g_value_get_boxed (gimp_value_array_index (args, 3)); if (success) { @@ -61,6 +63,7 @@ palettes_popup_invoker (GimpProcedure *procedure, ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->palette_factory), + parent_window, popup_title, palette_callback, initial_palette_name, NULL)) success = FALSE; @@ -165,6 +168,12 @@ register_palette_select_procs (GimpPDB *pdb) FALSE, TRUE, FALSE, NULL, GIMP_PARAM_READWRITE)); + gimp_procedure_add_argument (procedure, + g_param_spec_boxed ("parent-window", + "parent window", + "An optional parent window handle for the popup to be set transient to", + G_TYPE_BYTES, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); diff --git a/app/pdb/pattern-select-cmds.c b/app/pdb/pattern-select-cmds.c index 7790d3ac1a..e75778d7bd 100644 --- a/app/pdb/pattern-select-cmds.c +++ b/app/pdb/pattern-select-cmds.c @@ -50,10 +50,12 @@ patterns_popup_invoker (GimpProcedure *procedure, const gchar *pattern_callback; const gchar *popup_title; const gchar *initial_pattern_name; + GBytes *parent_window; pattern_callback = g_value_get_string (gimp_value_array_index (args, 0)); popup_title = g_value_get_string (gimp_value_array_index (args, 1)); initial_pattern_name = g_value_get_string (gimp_value_array_index (args, 2)); + parent_window = g_value_get_boxed (gimp_value_array_index (args, 3)); if (success) { @@ -61,6 +63,7 @@ patterns_popup_invoker (GimpProcedure *procedure, ! gimp_pdb_lookup_procedure (gimp->pdb, pattern_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->pattern_factory), + parent_window, popup_title, pattern_callback, initial_pattern_name, NULL)) success = FALSE; @@ -165,6 +168,12 @@ register_pattern_select_procs (GimpPDB *pdb) FALSE, TRUE, FALSE, NULL, GIMP_PARAM_READWRITE)); + gimp_procedure_add_argument (procedure, + g_param_spec_boxed ("parent-window", + "parent window", + "An optional parent window handle for the popup to be set transient to", + G_TYPE_BYTES, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c index 77e7a844e3..b66a6d63e1 100644 --- a/app/widgets/gimpwidgets-utils.c +++ b/app/widgets/gimpwidgets-utils.c @@ -97,6 +97,9 @@ static void gimp_blink_free_script (GList *blink_sce static gboolean gimp_window_transient_on_mapped (GtkWidget *widget, GdkEventAny *event, GimpProgress *progress); +static void gimp_window_set_transient_cb (GtkWidget *window, + GdkEventAny *event, + GBytes *handle); GtkWidget * @@ -940,6 +943,23 @@ gimp_window_set_transient_for (GtkWindow *window, gimp_window_transient_on_mapped (GTK_WIDGET (window), NULL, parent); } +void +gimp_window_set_transient_for_handle (GtkWindow *window, + GBytes *handle) +{ + g_return_if_fail (GTK_IS_WINDOW (window)); + g_return_if_fail (handle != NULL); + + g_signal_connect_data (window, "map-event", + G_CALLBACK (gimp_window_set_transient_cb), + g_bytes_ref (handle), + (GClosureNotify) g_bytes_unref, + G_CONNECT_AFTER); + + if (gtk_widget_get_mapped (GTK_WIDGET (window))) + gimp_window_set_transient_cb (GTK_WIDGET (window), NULL, handle); +} + static void gimp_widget_accels_changed (GimpAction *action, const gchar **accels, @@ -2507,17 +2527,32 @@ gimp_utils_are_menu_path_identical (const gchar *path1, static gboolean gimp_window_transient_on_mapped (GtkWidget *window, - GdkEventAny *event, + GdkEventAny *event G_GNUC_UNUSED, GimpProgress *progress) { - GBytes *handle; - gboolean transient_set = FALSE; + GBytes *handle; handle = gimp_progress_get_window_id (progress); if (handle == NULL) return FALSE; + gimp_window_set_transient_cb (window, NULL, handle); + + g_bytes_unref (handle); + + return FALSE; +} + +static void +gimp_window_set_transient_cb (GtkWidget *window, + GdkEventAny *event G_GNUC_UNUSED, + GBytes *handle) +{ + gboolean transient_set = FALSE; + + g_return_if_fail (handle != NULL); + #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) { @@ -2539,7 +2574,7 @@ gimp_window_transient_on_mapped (GtkWidget *window, gsize handle_size; handle_data = (Window *) g_bytes_get_data (handle, &handle_size); - g_return_val_if_fail (handle_size == sizeof (Window), FALSE); + g_return_if_fail (handle_size == sizeof (Window)); parent_ID = *handle_data; parent = gimp_get_foreign_window ((gpointer) parent_ID); @@ -2559,7 +2594,7 @@ gimp_window_transient_on_mapped (GtkWidget *window, gsize handle_size; handle_data = (HANDLE *) g_bytes_get_data (handle, &handle_size); - g_return_val_if_fail (handle_size == sizeof (HANDLE), FALSE); + g_return_if_fail (handle_size == sizeof (HANDLE)); parent_ID = *handle_data; parent = gimp_get_foreign_window ((gpointer) parent_ID); @@ -2570,8 +2605,4 @@ gimp_window_transient_on_mapped (GtkWidget *window, transient_set = TRUE; } #endif - - g_bytes_unref (handle); - - return FALSE; } diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h index 89f5562527..114bb11146 100644 --- a/app/widgets/gimpwidgets-utils.h +++ b/app/widgets/gimpwidgets-utils.h @@ -73,6 +73,8 @@ void gimp_window_set_hint (GtkWindow *window GimpWindowHint hint); void gimp_window_set_transient_for (GtkWindow *window, GimpProgress *progress); +void gimp_window_set_transient_for_handle (GtkWindow *window, + GBytes *handle); void gimp_widget_set_accel_help (GtkWidget *widget, GimpAction *action); diff --git a/libgimp/gimpbrushselect_pdb.c b/libgimp/gimpbrushselect_pdb.c index 8719854f11..2f65ef5263 100644 --- a/libgimp/gimpbrushselect_pdb.c +++ b/libgimp/gimpbrushselect_pdb.c @@ -42,6 +42,7 @@ * @brush_callback: The callback PDB proc to call when user chooses a brush. * @popup_title: Title of the brush selection dialog. * @initial_brush_name: The name of the brush to set as the initial choice. + * @parent_window: An optional parent window handle for the popup to be set transient to. * * Invokes the GIMP brush selection dialog. * @@ -52,7 +53,8 @@ gboolean gimp_brushes_popup (const gchar *brush_callback, const gchar *popup_title, - const gchar *initial_brush_name) + const gchar *initial_brush_name, + GBytes *parent_window) { GimpValueArray *args; GimpValueArray *return_vals; @@ -62,6 +64,7 @@ gimp_brushes_popup (const gchar *brush_callback, G_TYPE_STRING, brush_callback, G_TYPE_STRING, popup_title, G_TYPE_STRING, initial_brush_name, + G_TYPE_BYTES, parent_window, G_TYPE_NONE); return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), diff --git a/libgimp/gimpbrushselect_pdb.h b/libgimp/gimpbrushselect_pdb.h index f47165bdf0..8a7b9970ac 100644 --- a/libgimp/gimpbrushselect_pdb.h +++ b/libgimp/gimpbrushselect_pdb.h @@ -34,7 +34,8 @@ G_BEGIN_DECLS gboolean gimp_brushes_popup (const gchar *brush_callback, const gchar *popup_title, - const gchar *initial_brush_name); + const gchar *initial_brush_name, + GBytes *parent_window); gboolean gimp_brushes_close_popup (const gchar *brush_callback); gboolean gimp_brushes_set_popup (const gchar *brush_callback, const gchar *brush_name); diff --git a/libgimp/gimpbrushselectbutton.c b/libgimp/gimpbrushselectbutton.c index 2dde1c1941..fd5801b19e 100644 --- a/libgimp/gimpbrushselectbutton.c +++ b/libgimp/gimpbrushselectbutton.c @@ -420,6 +420,8 @@ gimp_brush_select_button_open_popup (GimpBrushSelectButton *self, mask, mask.width); g_free (mask.mask_data); + gdk_window_set_transient_for (gtk_widget_get_window (self->popup), + gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (self)))); } static void diff --git a/libgimp/gimpfontselect_pdb.c b/libgimp/gimpfontselect_pdb.c index 65c9a11a55..729a385533 100644 --- a/libgimp/gimpfontselect_pdb.c +++ b/libgimp/gimpfontselect_pdb.c @@ -50,6 +50,7 @@ * @font_callback: The callback PDB proc to call when user chooses a font. * @popup_title: Title of the font selection dialog. * @initial_font_name: The name of the initial font choice. + * @parent_window: An optional parent window handle for the popup to be set transient to. * * Invokes the Gimp font selection dialog. * @@ -60,7 +61,8 @@ gboolean gimp_fonts_popup (const gchar *font_callback, const gchar *popup_title, - const gchar *initial_font_name) + const gchar *initial_font_name, + GBytes *parent_window) { GimpValueArray *args; GimpValueArray *return_vals; @@ -70,6 +72,7 @@ gimp_fonts_popup (const gchar *font_callback, G_TYPE_STRING, font_callback, G_TYPE_STRING, popup_title, G_TYPE_STRING, initial_font_name, + G_TYPE_BYTES, parent_window, G_TYPE_NONE); return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), diff --git a/libgimp/gimpfontselect_pdb.h b/libgimp/gimpfontselect_pdb.h index c0456c632f..b3d4ece18c 100644 --- a/libgimp/gimpfontselect_pdb.h +++ b/libgimp/gimpfontselect_pdb.h @@ -34,7 +34,8 @@ G_BEGIN_DECLS gboolean gimp_fonts_popup (const gchar *font_callback, const gchar *popup_title, - const gchar *initial_font_name); + const gchar *initial_font_name, + GBytes *parent_window); gboolean gimp_fonts_close_popup (const gchar *font_callback); gboolean gimp_fonts_set_popup (const gchar *font_callback, const gchar *font_name); diff --git a/libgimp/gimpgradientselect_pdb.c b/libgimp/gimpgradientselect_pdb.c index 67a47d217a..2f0241c83a 100644 --- a/libgimp/gimpgradientselect_pdb.c +++ b/libgimp/gimpgradientselect_pdb.c @@ -42,6 +42,7 @@ * @gradient_callback: The callback PDB proc to call when user chooses a gradient. * @popup_title: Title of the gradient selection dialog. * @initial_gradient_name: The name of the initial gradient choice. + * @parent_window: An optional parent window handle for the popup to be set transient to. * * Invokes the Gimp gradients selection dialog. * @@ -52,7 +53,8 @@ gboolean gimp_gradients_popup (const gchar *gradient_callback, const gchar *popup_title, - const gchar *initial_gradient_name) + const gchar *initial_gradient_name, + GBytes *parent_window) { GimpValueArray *args; GimpValueArray *return_vals; @@ -62,6 +64,7 @@ gimp_gradients_popup (const gchar *gradient_callback, G_TYPE_STRING, gradient_callback, G_TYPE_STRING, popup_title, G_TYPE_STRING, initial_gradient_name, + G_TYPE_BYTES, parent_window, G_TYPE_NONE); return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), diff --git a/libgimp/gimpgradientselect_pdb.h b/libgimp/gimpgradientselect_pdb.h index c283ac5aeb..243a9edd7e 100644 --- a/libgimp/gimpgradientselect_pdb.h +++ b/libgimp/gimpgradientselect_pdb.h @@ -34,7 +34,8 @@ G_BEGIN_DECLS gboolean gimp_gradients_popup (const gchar *gradient_callback, const gchar *popup_title, - const gchar *initial_gradient_name); + const gchar *initial_gradient_name, + GBytes *parent_window); gboolean gimp_gradients_close_popup (const gchar *gradient_callback); gboolean gimp_gradients_set_popup (const gchar *gradient_callback, const gchar *gradient_name); diff --git a/libgimp/gimppaletteselect_pdb.c b/libgimp/gimppaletteselect_pdb.c index 39cb534f16..318ea2816d 100644 --- a/libgimp/gimppaletteselect_pdb.c +++ b/libgimp/gimppaletteselect_pdb.c @@ -42,6 +42,7 @@ * @palette_callback: The callback PDB proc to call when user chooses a palette. * @popup_title: Title of the palette selection dialog. * @initial_palette_name: The name of the palette to set as the initial choice. + * @parent_window: An optional parent window handle for the popup to be set transient to. * * Invokes the Gimp palette selection dialog. * @@ -52,7 +53,8 @@ gboolean gimp_palettes_popup (const gchar *palette_callback, const gchar *popup_title, - const gchar *initial_palette_name) + const gchar *initial_palette_name, + GBytes *parent_window) { GimpValueArray *args; GimpValueArray *return_vals; @@ -62,6 +64,7 @@ gimp_palettes_popup (const gchar *palette_callback, G_TYPE_STRING, palette_callback, G_TYPE_STRING, popup_title, G_TYPE_STRING, initial_palette_name, + G_TYPE_BYTES, parent_window, G_TYPE_NONE); return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), diff --git a/libgimp/gimppaletteselect_pdb.h b/libgimp/gimppaletteselect_pdb.h index 840108db9d..f11aeb0abe 100644 --- a/libgimp/gimppaletteselect_pdb.h +++ b/libgimp/gimppaletteselect_pdb.h @@ -34,7 +34,8 @@ G_BEGIN_DECLS gboolean gimp_palettes_popup (const gchar *palette_callback, const gchar *popup_title, - const gchar *initial_palette_name); + const gchar *initial_palette_name, + GBytes *parent_window); gboolean gimp_palettes_close_popup (const gchar *palette_callback); gboolean gimp_palettes_set_popup (const gchar *palette_callback, const gchar *palette_name); diff --git a/libgimp/gimppatternselect_pdb.c b/libgimp/gimppatternselect_pdb.c index 02657e28f8..9699372963 100644 --- a/libgimp/gimppatternselect_pdb.c +++ b/libgimp/gimppatternselect_pdb.c @@ -42,6 +42,7 @@ * @pattern_callback: The callback PDB proc to call when the user chooses a pattern. * @popup_title: Title of the pattern selection dialog. * @initial_pattern_name: The name of the pattern to set as the initial choice. + * @parent_window: An optional parent window handle for the popup to be set transient to. * * Invokes the Gimp pattern selection. * @@ -52,7 +53,8 @@ gboolean gimp_patterns_popup (const gchar *pattern_callback, const gchar *popup_title, - const gchar *initial_pattern_name) + const gchar *initial_pattern_name, + GBytes *parent_window) { GimpValueArray *args; GimpValueArray *return_vals; @@ -62,6 +64,7 @@ gimp_patterns_popup (const gchar *pattern_callback, G_TYPE_STRING, pattern_callback, G_TYPE_STRING, popup_title, G_TYPE_STRING, initial_pattern_name, + G_TYPE_BYTES, parent_window, G_TYPE_NONE); return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), diff --git a/libgimp/gimppatternselect_pdb.h b/libgimp/gimppatternselect_pdb.h index b56f4be488..979189f09c 100644 --- a/libgimp/gimppatternselect_pdb.h +++ b/libgimp/gimppatternselect_pdb.h @@ -34,7 +34,8 @@ G_BEGIN_DECLS gboolean gimp_patterns_popup (const gchar *pattern_callback, const gchar *popup_title, - const gchar *initial_pattern_name); + const gchar *initial_pattern_name, + GBytes *parent_window); gboolean gimp_patterns_close_popup (const gchar *pattern_callback); gboolean gimp_patterns_set_popup (const gchar *pattern_callback, const gchar *pattern_name); diff --git a/libgimp/gimpresourceselect.c b/libgimp/gimpresourceselect.c index 6b189b4b33..9bc1d02dcf 100644 --- a/libgimp/gimpresourceselect.c +++ b/libgimp/gimpresourceselect.c @@ -245,6 +245,7 @@ create_callback_PDB_procedure_params (GimpProcedure *procedure, */ static gboolean popup_remote_chooser (const gchar *title, + GBytes *parent_handle, GimpResource *resource, gchar *temp_PDB_callback_name, GType resource_type) @@ -257,23 +258,23 @@ popup_remote_chooser (const gchar *title, if (g_type_is_a (resource_type, GIMP_TYPE_BRUSH)) { - result = gimp_brushes_popup (temp_PDB_callback_name, title, resource_name); + result = gimp_brushes_popup (temp_PDB_callback_name, title, resource_name, parent_handle); } else if (g_type_is_a (resource_type, GIMP_TYPE_FONT)) { - result = gimp_fonts_popup (temp_PDB_callback_name, title, resource_name); + result = gimp_fonts_popup (temp_PDB_callback_name, title, resource_name, parent_handle); } else if (g_type_is_a (resource_type, GIMP_TYPE_GRADIENT)) { - result = gimp_gradients_popup (temp_PDB_callback_name, title, resource_name); + result = gimp_gradients_popup (temp_PDB_callback_name, title, resource_name, parent_handle); } else if (g_type_is_a (resource_type, GIMP_TYPE_PALETTE)) { - result = gimp_palettes_popup (temp_PDB_callback_name, title, resource_name); + result = gimp_palettes_popup (temp_PDB_callback_name, title, resource_name, parent_handle); } else if (g_type_is_a (resource_type, GIMP_TYPE_PATTERN)) { - result = gimp_patterns_popup (temp_PDB_callback_name, title, resource_name); + result = gimp_patterns_popup (temp_PDB_callback_name, title, resource_name, parent_handle); } else { @@ -336,6 +337,7 @@ close_remote_chooser (gchar *temp_PDB_callback_name, **/ const gchar * gimp_resource_select_new (const gchar *title, + GBytes *parent_handle, GimpResource *resource, GType resource_type, GimpResourceChoosedCallback callback, @@ -377,8 +379,7 @@ gimp_resource_select_new (const gchar *title, gimp_plug_in_add_temp_procedure (plug_in, procedure); g_object_unref (procedure); - if (popup_remote_chooser (title, resource, temp_PDB_callback_name, - resource_type)) + if (popup_remote_chooser (title, parent_handle, resource, temp_PDB_callback_name, resource_type)) { /* Allow callbacks to be watched */ gimp_plug_in_extension_enable (plug_in); diff --git a/libgimp/gimpresourceselect.h b/libgimp/gimpresourceselect.h index 8ad8fe47a6..64ad251a18 100644 --- a/libgimp/gimpresourceselect.h +++ b/libgimp/gimpresourceselect.h @@ -38,6 +38,7 @@ typedef void (* GimpResourceChoosedCallback) (GimpResource *resource, gpointer owner_data); const gchar * gimp_resource_select_new (const gchar *title, + GBytes *parent_handle, GimpResource *resource, GType resource_type, GimpResourceChoosedCallback callback, diff --git a/libgimp/gimpresourceselectbutton.c b/libgimp/gimpresourceselectbutton.c index feb2fc9fb3..21a65637fd 100644 --- a/libgimp/gimpresourceselectbutton.c +++ b/libgimp/gimpresourceselectbutton.c @@ -506,9 +506,16 @@ gimp_resource_select_button_clicked (GimpResourceSelectButton *self) } else { + GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self)); + GBytes *handle = NULL; + + if (GIMP_IS_DIALOG (toplevel)) + handle = gimp_dialog_get_native_handle (GIMP_DIALOG (toplevel)); + /* Call GimpResourceSelect which dispatches on resource_type. */ priv->temp_callback_from_remote_dialog = gimp_resource_select_new (priv->title, + handle, priv->resource, klass->resource_type, gimp_resource_select_button_callback, diff --git a/pdb/groups/brush_select.pdb b/pdb/groups/brush_select.pdb index b61bbfefef..0a0e882d08 100644 --- a/pdb/groups/brush_select.pdb +++ b/pdb/groups/brush_select.pdb @@ -28,7 +28,9 @@ sub brushes_popup { { name => 'popup_title', type => 'string', desc => 'Title of the brush selection dialog' }, { name => 'initial_brush_name', type => 'string', null_ok => 1, - desc => 'The name of the brush to set as the initial choice' } + desc => 'The name of the brush to set as the initial choice' }, + { name => 'parent_window', type => 'bytes', null_ok => 1, + desc => 'An optional parent window handle for the popup to be set transient to' } ); %invoke = ( @@ -38,6 +40,7 @@ sub brushes_popup { ! gimp_pdb_lookup_procedure (gimp->pdb, brush_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->brush_factory), + parent_window, popup_title, brush_callback, initial_brush_name, NULL)) success = FALSE; diff --git a/pdb/groups/font_select.pdb b/pdb/groups/font_select.pdb index 8f680d2d22..0e7d048315 100644 --- a/pdb/groups/font_select.pdb +++ b/pdb/groups/font_select.pdb @@ -29,7 +29,9 @@ sub fonts_popup { { name => 'popup_title', type => 'string', desc => 'Title of the font selection dialog' }, { name => 'initial_font_name', type => 'string', null_ok => 1, - desc => 'The name of the initial font choice.' } + desc => 'The name of the initial font choice.' }, + { name => 'parent_window', type => 'bytes', null_ok => 1, + desc => 'An optional parent window handle for the popup to be set transient to' } ); %invoke = ( @@ -40,6 +42,7 @@ sub fonts_popup { ! gimp_data_factory_data_wait (gimp->font_factory) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->font_factory), + parent_window, popup_title, font_callback, initial_font_name, NULL)) success = FALSE; diff --git a/pdb/groups/gradient_select.pdb b/pdb/groups/gradient_select.pdb index 80aade519d..935eab089d 100644 --- a/pdb/groups/gradient_select.pdb +++ b/pdb/groups/gradient_select.pdb @@ -29,7 +29,9 @@ sub gradients_popup { { name => 'popup_title', type => 'string', desc => 'Title of the gradient selection dialog' }, { name => 'initial_gradient_name', type => 'string', null_ok => 1, - desc => 'The name of the initial gradient choice' } + desc => 'The name of the initial gradient choice' }, + { name => 'parent_window', type => 'bytes', null_ok => 1, + desc => 'An optional parent window handle for the popup to be set transient to' } ); %invoke = ( @@ -45,6 +47,7 @@ sub gradients_popup { ! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->gradient_factory), + parent_window, popup_title, gradient_callback, initial_gradient_name, NULL)) success = FALSE; diff --git a/pdb/groups/palette_select.pdb b/pdb/groups/palette_select.pdb index 84d0832bae..f41344997b 100644 --- a/pdb/groups/palette_select.pdb +++ b/pdb/groups/palette_select.pdb @@ -28,7 +28,9 @@ sub palettes_popup { { name => 'popup_title', type => 'string', desc => 'Title of the palette selection dialog' }, { name => 'initial_palette_name', type => 'string', null_ok => 1, - desc => 'The name of the palette to set as the initial choice.' } + desc => 'The name of the palette to set as the initial choice.' }, + { name => 'parent_window', type => 'bytes', null_ok => 1, + desc => 'An optional parent window handle for the popup to be set transient to' } ); %invoke = ( @@ -38,6 +40,7 @@ sub palettes_popup { ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->palette_factory), + parent_window, popup_title, palette_callback, initial_palette_name, NULL)) success = FALSE; diff --git a/pdb/groups/pattern_select.pdb b/pdb/groups/pattern_select.pdb index 8c334f9947..c513ba12bd 100644 --- a/pdb/groups/pattern_select.pdb +++ b/pdb/groups/pattern_select.pdb @@ -28,7 +28,9 @@ sub patterns_popup { { name => 'popup_title', type => 'string', desc => 'Title of the pattern selection dialog' }, { name => 'initial_pattern_name', type => 'string', null_ok => 1, - desc => 'The name of the pattern to set as the initial choice' } + desc => 'The name of the pattern to set as the initial choice' }, + { name => 'parent_window', type => 'bytes', null_ok => 1, + desc => 'An optional parent window handle for the popup to be set transient to' } ); %invoke = ( @@ -38,6 +40,7 @@ sub patterns_popup { ! gimp_pdb_lookup_procedure (gimp->pdb, pattern_callback) || ! gimp_pdb_dialog_new (gimp, context, progress, gimp_data_factory_get_container (gimp->pattern_factory), + parent_window, popup_title, pattern_callback, initial_pattern_name, NULL)) success = FALSE;