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.
This commit is contained in:
Jehan 2023-08-15 00:12:16 +02:00
parent d6a2deb305
commit 6aeb456e17
29 changed files with 173 additions and 41 deletions

View File

@ -404,6 +404,7 @@ gimp_pdb_dialog_new (Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
GimpContainer *container, GimpContainer *container,
GBytes *parent_handle,
const gchar *title, const gchar *title,
const gchar *callback_name, const gchar *callback_name,
const gchar *object_name, const gchar *object_name,
@ -425,7 +426,7 @@ gimp_pdb_dialog_new (Gimp *gimp,
va_start (args, object_name); va_start (args, object_name);
retval = gimp->gui.pdb_dialog_new (gimp, context, progress, retval = gimp->gui.pdb_dialog_new (gimp, context, progress,
container, title, container, parent_handle, title,
callback_name, object_name, callback_name, object_name,
args); args);

View File

@ -74,6 +74,7 @@ struct _GimpGui
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
GimpContainer *container, GimpContainer *container,
GBytes *parent_handle,
const gchar *title, const gchar *title,
const gchar *callback_name, const gchar *callback_name,
const gchar *object_name, const gchar *object_name,
@ -172,6 +173,7 @@ gboolean gimp_pdb_dialog_new (Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
GimpContainer *container, GimpContainer *container,
GBytes *parent_handle,
const gchar *title, const gchar *title,
const gchar *callback_name, const gchar *callback_name,
const gchar *object_name, const gchar *object_name,

View File

@ -153,6 +153,7 @@ static gboolean gui_pdb_dialog_new (Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
GimpContainer *container, GimpContainer *container,
GBytes *parent_handle,
const gchar *title, const gchar *title,
const gchar *callback_name, const gchar *callback_name,
const gchar *object_name, const gchar *object_name,
@ -611,6 +612,7 @@ gui_pdb_dialog_new (Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
GimpContainer *container, GimpContainer *container,
GBytes *parent_handle,
const gchar *title, const gchar *title,
const gchar *callback_name, const gchar *callback_name,
const gchar *object_name, const gchar *object_name,
@ -706,17 +708,20 @@ gui_pdb_dialog_new (Gimp *gimp,
gtk_widget_show (dialog); gtk_widget_show (dialog);
/* workaround for bug #360106 */ /* workaround for bug #360106 */
{ {
GSource *source = g_timeout_source_new (100); GSource *source = g_timeout_source_new (100);
GClosure *closure; GClosure *closure;
closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present), closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present),
G_OBJECT (dialog)); G_OBJECT (dialog));
g_source_set_closure (source, closure); g_source_set_closure (source, closure);
g_source_attach (source, NULL); g_source_attach (source, NULL);
g_source_unref (source); g_source_unref (source);
} }
if (parent_handle != NULL)
gimp_window_set_transient_for_handle (GTK_WINDOW (dialog), parent_handle);
return TRUE; return TRUE;
} }

View File

@ -50,10 +50,12 @@ brushes_popup_invoker (GimpProcedure *procedure,
const gchar *brush_callback; const gchar *brush_callback;
const gchar *popup_title; const gchar *popup_title;
const gchar *initial_brush_name; const gchar *initial_brush_name;
GBytes *parent_window;
brush_callback = g_value_get_string (gimp_value_array_index (args, 0)); brush_callback = g_value_get_string (gimp_value_array_index (args, 0));
popup_title = g_value_get_string (gimp_value_array_index (args, 1)); 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)); 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) if (success)
{ {
@ -61,6 +63,7 @@ brushes_popup_invoker (GimpProcedure *procedure,
! gimp_pdb_lookup_procedure (gimp->pdb, brush_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, brush_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->brush_factory), gimp_data_factory_get_container (gimp->brush_factory),
parent_window,
popup_title, brush_callback, initial_brush_name, popup_title, brush_callback, initial_brush_name,
NULL)) NULL))
success = FALSE; success = FALSE;
@ -165,6 +168,12 @@ register_brush_select_procs (GimpPDB *pdb)
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
NULL, NULL,
GIMP_PARAM_READWRITE)); 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); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -50,10 +50,12 @@ fonts_popup_invoker (GimpProcedure *procedure,
const gchar *font_callback; const gchar *font_callback;
const gchar *popup_title; const gchar *popup_title;
const gchar *initial_font_name; const gchar *initial_font_name;
GBytes *parent_window;
font_callback = g_value_get_string (gimp_value_array_index (args, 0)); font_callback = g_value_get_string (gimp_value_array_index (args, 0));
popup_title = g_value_get_string (gimp_value_array_index (args, 1)); 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)); 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) if (success)
{ {
@ -62,6 +64,7 @@ fonts_popup_invoker (GimpProcedure *procedure,
! gimp_data_factory_data_wait (gimp->font_factory) || ! gimp_data_factory_data_wait (gimp->font_factory) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->font_factory), gimp_data_factory_get_container (gimp->font_factory),
parent_window,
popup_title, font_callback, initial_font_name, popup_title, font_callback, initial_font_name,
NULL)) NULL))
success = FALSE; success = FALSE;
@ -169,6 +172,12 @@ register_font_select_procs (GimpPDB *pdb)
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
NULL, NULL,
GIMP_PARAM_READWRITE)); 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); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -51,10 +51,12 @@ gradients_popup_invoker (GimpProcedure *procedure,
const gchar *gradient_callback; const gchar *gradient_callback;
const gchar *popup_title; const gchar *popup_title;
const gchar *initial_gradient_name; const gchar *initial_gradient_name;
GBytes *parent_window;
gradient_callback = g_value_get_string (gimp_value_array_index (args, 0)); gradient_callback = g_value_get_string (gimp_value_array_index (args, 0));
popup_title = g_value_get_string (gimp_value_array_index (args, 1)); 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)); 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) if (success)
{ {
@ -68,6 +70,7 @@ gradients_popup_invoker (GimpProcedure *procedure,
! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->gradient_factory), gimp_data_factory_get_container (gimp->gradient_factory),
parent_window,
popup_title, gradient_callback, initial_gradient_name, popup_title, gradient_callback, initial_gradient_name,
NULL)) NULL))
success = FALSE; success = FALSE;
@ -172,6 +175,12 @@ register_gradient_select_procs (GimpPDB *pdb)
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
NULL, NULL,
GIMP_PARAM_READWRITE)); 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); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -50,10 +50,12 @@ palettes_popup_invoker (GimpProcedure *procedure,
const gchar *palette_callback; const gchar *palette_callback;
const gchar *popup_title; const gchar *popup_title;
const gchar *initial_palette_name; const gchar *initial_palette_name;
GBytes *parent_window;
palette_callback = g_value_get_string (gimp_value_array_index (args, 0)); palette_callback = g_value_get_string (gimp_value_array_index (args, 0));
popup_title = g_value_get_string (gimp_value_array_index (args, 1)); 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)); 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) if (success)
{ {
@ -61,6 +63,7 @@ palettes_popup_invoker (GimpProcedure *procedure,
! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->palette_factory), gimp_data_factory_get_container (gimp->palette_factory),
parent_window,
popup_title, palette_callback, initial_palette_name, popup_title, palette_callback, initial_palette_name,
NULL)) NULL))
success = FALSE; success = FALSE;
@ -165,6 +168,12 @@ register_palette_select_procs (GimpPDB *pdb)
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
NULL, NULL,
GIMP_PARAM_READWRITE)); 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); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -50,10 +50,12 @@ patterns_popup_invoker (GimpProcedure *procedure,
const gchar *pattern_callback; const gchar *pattern_callback;
const gchar *popup_title; const gchar *popup_title;
const gchar *initial_pattern_name; const gchar *initial_pattern_name;
GBytes *parent_window;
pattern_callback = g_value_get_string (gimp_value_array_index (args, 0)); pattern_callback = g_value_get_string (gimp_value_array_index (args, 0));
popup_title = g_value_get_string (gimp_value_array_index (args, 1)); 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)); 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) if (success)
{ {
@ -61,6 +63,7 @@ patterns_popup_invoker (GimpProcedure *procedure,
! gimp_pdb_lookup_procedure (gimp->pdb, pattern_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, pattern_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->pattern_factory), gimp_data_factory_get_container (gimp->pattern_factory),
parent_window,
popup_title, pattern_callback, initial_pattern_name, popup_title, pattern_callback, initial_pattern_name,
NULL)) NULL))
success = FALSE; success = FALSE;
@ -165,6 +168,12 @@ register_pattern_select_procs (GimpPDB *pdb)
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE,
NULL, NULL,
GIMP_PARAM_READWRITE)); 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); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -97,6 +97,9 @@ static void gimp_blink_free_script (GList *blink_sce
static gboolean gimp_window_transient_on_mapped (GtkWidget *widget, static gboolean gimp_window_transient_on_mapped (GtkWidget *widget,
GdkEventAny *event, GdkEventAny *event,
GimpProgress *progress); GimpProgress *progress);
static void gimp_window_set_transient_cb (GtkWidget *window,
GdkEventAny *event,
GBytes *handle);
GtkWidget * GtkWidget *
@ -940,6 +943,23 @@ gimp_window_set_transient_for (GtkWindow *window,
gimp_window_transient_on_mapped (GTK_WIDGET (window), NULL, parent); 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 static void
gimp_widget_accels_changed (GimpAction *action, gimp_widget_accels_changed (GimpAction *action,
const gchar **accels, const gchar **accels,
@ -2507,17 +2527,32 @@ gimp_utils_are_menu_path_identical (const gchar *path1,
static gboolean static gboolean
gimp_window_transient_on_mapped (GtkWidget *window, gimp_window_transient_on_mapped (GtkWidget *window,
GdkEventAny *event, GdkEventAny *event G_GNUC_UNUSED,
GimpProgress *progress) GimpProgress *progress)
{ {
GBytes *handle; GBytes *handle;
gboolean transient_set = FALSE;
handle = gimp_progress_get_window_id (progress); handle = gimp_progress_get_window_id (progress);
if (handle == NULL) if (handle == NULL)
return FALSE; 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 #ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
{ {
@ -2539,7 +2574,7 @@ gimp_window_transient_on_mapped (GtkWidget *window,
gsize handle_size; gsize handle_size;
handle_data = (Window *) g_bytes_get_data (handle, &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_ID = *handle_data;
parent = gimp_get_foreign_window ((gpointer) parent_ID); parent = gimp_get_foreign_window ((gpointer) parent_ID);
@ -2559,7 +2594,7 @@ gimp_window_transient_on_mapped (GtkWidget *window,
gsize handle_size; gsize handle_size;
handle_data = (HANDLE *) g_bytes_get_data (handle, &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_ID = *handle_data;
parent = gimp_get_foreign_window ((gpointer) parent_ID); parent = gimp_get_foreign_window ((gpointer) parent_ID);
@ -2570,8 +2605,4 @@ gimp_window_transient_on_mapped (GtkWidget *window,
transient_set = TRUE; transient_set = TRUE;
} }
#endif #endif
g_bytes_unref (handle);
return FALSE;
} }

View File

@ -73,6 +73,8 @@ void gimp_window_set_hint (GtkWindow *window
GimpWindowHint hint); GimpWindowHint hint);
void gimp_window_set_transient_for (GtkWindow *window, void gimp_window_set_transient_for (GtkWindow *window,
GimpProgress *progress); GimpProgress *progress);
void gimp_window_set_transient_for_handle (GtkWindow *window,
GBytes *handle);
void gimp_widget_set_accel_help (GtkWidget *widget, void gimp_widget_set_accel_help (GtkWidget *widget,
GimpAction *action); GimpAction *action);

View File

@ -42,6 +42,7 @@
* @brush_callback: The callback PDB proc to call when user chooses a brush. * @brush_callback: The callback PDB proc to call when user chooses a brush.
* @popup_title: Title of the brush selection dialog. * @popup_title: Title of the brush selection dialog.
* @initial_brush_name: The name of the brush to set as the initial choice. * @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. * Invokes the GIMP brush selection dialog.
* *
@ -52,7 +53,8 @@
gboolean gboolean
gimp_brushes_popup (const gchar *brush_callback, gimp_brushes_popup (const gchar *brush_callback,
const gchar *popup_title, const gchar *popup_title,
const gchar *initial_brush_name) const gchar *initial_brush_name,
GBytes *parent_window)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -62,6 +64,7 @@ gimp_brushes_popup (const gchar *brush_callback,
G_TYPE_STRING, brush_callback, G_TYPE_STRING, brush_callback,
G_TYPE_STRING, popup_title, G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_brush_name, G_TYPE_STRING, initial_brush_name,
G_TYPE_BYTES, parent_window,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),

View File

@ -34,7 +34,8 @@ G_BEGIN_DECLS
gboolean gimp_brushes_popup (const gchar *brush_callback, gboolean gimp_brushes_popup (const gchar *brush_callback,
const gchar *popup_title, 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_close_popup (const gchar *brush_callback);
gboolean gimp_brushes_set_popup (const gchar *brush_callback, gboolean gimp_brushes_set_popup (const gchar *brush_callback,
const gchar *brush_name); const gchar *brush_name);

View File

@ -420,6 +420,8 @@ gimp_brush_select_button_open_popup (GimpBrushSelectButton *self,
mask, mask,
mask.width); mask.width);
g_free (mask.mask_data); 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 static void

View File

@ -50,6 +50,7 @@
* @font_callback: The callback PDB proc to call when user chooses a font. * @font_callback: The callback PDB proc to call when user chooses a font.
* @popup_title: Title of the font selection dialog. * @popup_title: Title of the font selection dialog.
* @initial_font_name: The name of the initial font choice. * @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. * Invokes the Gimp font selection dialog.
* *
@ -60,7 +61,8 @@
gboolean gboolean
gimp_fonts_popup (const gchar *font_callback, gimp_fonts_popup (const gchar *font_callback,
const gchar *popup_title, const gchar *popup_title,
const gchar *initial_font_name) const gchar *initial_font_name,
GBytes *parent_window)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -70,6 +72,7 @@ gimp_fonts_popup (const gchar *font_callback,
G_TYPE_STRING, font_callback, G_TYPE_STRING, font_callback,
G_TYPE_STRING, popup_title, G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_font_name, G_TYPE_STRING, initial_font_name,
G_TYPE_BYTES, parent_window,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),

View File

@ -34,7 +34,8 @@ G_BEGIN_DECLS
gboolean gimp_fonts_popup (const gchar *font_callback, gboolean gimp_fonts_popup (const gchar *font_callback,
const gchar *popup_title, 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_close_popup (const gchar *font_callback);
gboolean gimp_fonts_set_popup (const gchar *font_callback, gboolean gimp_fonts_set_popup (const gchar *font_callback,
const gchar *font_name); const gchar *font_name);

View File

@ -42,6 +42,7 @@
* @gradient_callback: The callback PDB proc to call when user chooses a gradient. * @gradient_callback: The callback PDB proc to call when user chooses a gradient.
* @popup_title: Title of the gradient selection dialog. * @popup_title: Title of the gradient selection dialog.
* @initial_gradient_name: The name of the initial gradient choice. * @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. * Invokes the Gimp gradients selection dialog.
* *
@ -52,7 +53,8 @@
gboolean gboolean
gimp_gradients_popup (const gchar *gradient_callback, gimp_gradients_popup (const gchar *gradient_callback,
const gchar *popup_title, const gchar *popup_title,
const gchar *initial_gradient_name) const gchar *initial_gradient_name,
GBytes *parent_window)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -62,6 +64,7 @@ gimp_gradients_popup (const gchar *gradient_callback,
G_TYPE_STRING, gradient_callback, G_TYPE_STRING, gradient_callback,
G_TYPE_STRING, popup_title, G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_gradient_name, G_TYPE_STRING, initial_gradient_name,
G_TYPE_BYTES, parent_window,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),

View File

@ -34,7 +34,8 @@ G_BEGIN_DECLS
gboolean gimp_gradients_popup (const gchar *gradient_callback, gboolean gimp_gradients_popup (const gchar *gradient_callback,
const gchar *popup_title, 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_close_popup (const gchar *gradient_callback);
gboolean gimp_gradients_set_popup (const gchar *gradient_callback, gboolean gimp_gradients_set_popup (const gchar *gradient_callback,
const gchar *gradient_name); const gchar *gradient_name);

View File

@ -42,6 +42,7 @@
* @palette_callback: The callback PDB proc to call when user chooses a palette. * @palette_callback: The callback PDB proc to call when user chooses a palette.
* @popup_title: Title of the palette selection dialog. * @popup_title: Title of the palette selection dialog.
* @initial_palette_name: The name of the palette to set as the initial choice. * @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. * Invokes the Gimp palette selection dialog.
* *
@ -52,7 +53,8 @@
gboolean gboolean
gimp_palettes_popup (const gchar *palette_callback, gimp_palettes_popup (const gchar *palette_callback,
const gchar *popup_title, const gchar *popup_title,
const gchar *initial_palette_name) const gchar *initial_palette_name,
GBytes *parent_window)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -62,6 +64,7 @@ gimp_palettes_popup (const gchar *palette_callback,
G_TYPE_STRING, palette_callback, G_TYPE_STRING, palette_callback,
G_TYPE_STRING, popup_title, G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_palette_name, G_TYPE_STRING, initial_palette_name,
G_TYPE_BYTES, parent_window,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),

View File

@ -34,7 +34,8 @@ G_BEGIN_DECLS
gboolean gimp_palettes_popup (const gchar *palette_callback, gboolean gimp_palettes_popup (const gchar *palette_callback,
const gchar *popup_title, 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_close_popup (const gchar *palette_callback);
gboolean gimp_palettes_set_popup (const gchar *palette_callback, gboolean gimp_palettes_set_popup (const gchar *palette_callback,
const gchar *palette_name); const gchar *palette_name);

View File

@ -42,6 +42,7 @@
* @pattern_callback: The callback PDB proc to call when the user chooses a pattern. * @pattern_callback: The callback PDB proc to call when the user chooses a pattern.
* @popup_title: Title of the pattern selection dialog. * @popup_title: Title of the pattern selection dialog.
* @initial_pattern_name: The name of the pattern to set as the initial choice. * @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. * Invokes the Gimp pattern selection.
* *
@ -52,7 +53,8 @@
gboolean gboolean
gimp_patterns_popup (const gchar *pattern_callback, gimp_patterns_popup (const gchar *pattern_callback,
const gchar *popup_title, const gchar *popup_title,
const gchar *initial_pattern_name) const gchar *initial_pattern_name,
GBytes *parent_window)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -62,6 +64,7 @@ gimp_patterns_popup (const gchar *pattern_callback,
G_TYPE_STRING, pattern_callback, G_TYPE_STRING, pattern_callback,
G_TYPE_STRING, popup_title, G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_pattern_name, G_TYPE_STRING, initial_pattern_name,
G_TYPE_BYTES, parent_window,
G_TYPE_NONE); G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),

View File

@ -34,7 +34,8 @@ G_BEGIN_DECLS
gboolean gimp_patterns_popup (const gchar *pattern_callback, gboolean gimp_patterns_popup (const gchar *pattern_callback,
const gchar *popup_title, 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_close_popup (const gchar *pattern_callback);
gboolean gimp_patterns_set_popup (const gchar *pattern_callback, gboolean gimp_patterns_set_popup (const gchar *pattern_callback,
const gchar *pattern_name); const gchar *pattern_name);

View File

@ -245,6 +245,7 @@ create_callback_PDB_procedure_params (GimpProcedure *procedure,
*/ */
static gboolean static gboolean
popup_remote_chooser (const gchar *title, popup_remote_chooser (const gchar *title,
GBytes *parent_handle,
GimpResource *resource, GimpResource *resource,
gchar *temp_PDB_callback_name, gchar *temp_PDB_callback_name,
GType resource_type) GType resource_type)
@ -257,23 +258,23 @@ popup_remote_chooser (const gchar *title,
if (g_type_is_a (resource_type, GIMP_TYPE_BRUSH)) 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)) 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)) 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)) 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)) 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 else
{ {
@ -336,6 +337,7 @@ close_remote_chooser (gchar *temp_PDB_callback_name,
**/ **/
const gchar * const gchar *
gimp_resource_select_new (const gchar *title, gimp_resource_select_new (const gchar *title,
GBytes *parent_handle,
GimpResource *resource, GimpResource *resource,
GType resource_type, GType resource_type,
GimpResourceChoosedCallback callback, GimpResourceChoosedCallback callback,
@ -377,8 +379,7 @@ gimp_resource_select_new (const gchar *title,
gimp_plug_in_add_temp_procedure (plug_in, procedure); gimp_plug_in_add_temp_procedure (plug_in, procedure);
g_object_unref (procedure); g_object_unref (procedure);
if (popup_remote_chooser (title, resource, temp_PDB_callback_name, if (popup_remote_chooser (title, parent_handle, resource, temp_PDB_callback_name, resource_type))
resource_type))
{ {
/* Allow callbacks to be watched */ /* Allow callbacks to be watched */
gimp_plug_in_extension_enable (plug_in); gimp_plug_in_extension_enable (plug_in);

View File

@ -38,6 +38,7 @@ typedef void (* GimpResourceChoosedCallback) (GimpResource *resource,
gpointer owner_data); gpointer owner_data);
const gchar * gimp_resource_select_new (const gchar *title, const gchar * gimp_resource_select_new (const gchar *title,
GBytes *parent_handle,
GimpResource *resource, GimpResource *resource,
GType resource_type, GType resource_type,
GimpResourceChoosedCallback callback, GimpResourceChoosedCallback callback,

View File

@ -506,9 +506,16 @@ gimp_resource_select_button_clicked (GimpResourceSelectButton *self)
} }
else 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. */ /* Call GimpResourceSelect which dispatches on resource_type. */
priv->temp_callback_from_remote_dialog = priv->temp_callback_from_remote_dialog =
gimp_resource_select_new (priv->title, gimp_resource_select_new (priv->title,
handle,
priv->resource, priv->resource,
klass->resource_type, klass->resource_type,
gimp_resource_select_button_callback, gimp_resource_select_button_callback,

View File

@ -28,7 +28,9 @@ sub brushes_popup {
{ name => 'popup_title', type => 'string', { name => 'popup_title', type => 'string',
desc => 'Title of the brush selection dialog' }, desc => 'Title of the brush selection dialog' },
{ name => 'initial_brush_name', type => 'string', null_ok => 1, { 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 = ( %invoke = (
@ -38,6 +40,7 @@ sub brushes_popup {
! gimp_pdb_lookup_procedure (gimp->pdb, brush_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, brush_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->brush_factory), gimp_data_factory_get_container (gimp->brush_factory),
parent_window,
popup_title, brush_callback, initial_brush_name, popup_title, brush_callback, initial_brush_name,
NULL)) NULL))
success = FALSE; success = FALSE;

View File

@ -29,7 +29,9 @@ sub fonts_popup {
{ name => 'popup_title', type => 'string', { name => 'popup_title', type => 'string',
desc => 'Title of the font selection dialog' }, desc => 'Title of the font selection dialog' },
{ name => 'initial_font_name', type => 'string', null_ok => 1, { 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 = ( %invoke = (
@ -40,6 +42,7 @@ sub fonts_popup {
! gimp_data_factory_data_wait (gimp->font_factory) || ! gimp_data_factory_data_wait (gimp->font_factory) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->font_factory), gimp_data_factory_get_container (gimp->font_factory),
parent_window,
popup_title, font_callback, initial_font_name, popup_title, font_callback, initial_font_name,
NULL)) NULL))
success = FALSE; success = FALSE;

View File

@ -29,7 +29,9 @@ sub gradients_popup {
{ name => 'popup_title', type => 'string', { name => 'popup_title', type => 'string',
desc => 'Title of the gradient selection dialog' }, desc => 'Title of the gradient selection dialog' },
{ name => 'initial_gradient_name', type => 'string', null_ok => 1, { 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 = ( %invoke = (
@ -45,6 +47,7 @@ sub gradients_popup {
! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->gradient_factory), gimp_data_factory_get_container (gimp->gradient_factory),
parent_window,
popup_title, gradient_callback, initial_gradient_name, popup_title, gradient_callback, initial_gradient_name,
NULL)) NULL))
success = FALSE; success = FALSE;

View File

@ -28,7 +28,9 @@ sub palettes_popup {
{ name => 'popup_title', type => 'string', { name => 'popup_title', type => 'string',
desc => 'Title of the palette selection dialog' }, desc => 'Title of the palette selection dialog' },
{ name => 'initial_palette_name', type => 'string', null_ok => 1, { 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 = ( %invoke = (
@ -38,6 +40,7 @@ sub palettes_popup {
! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->palette_factory), gimp_data_factory_get_container (gimp->palette_factory),
parent_window,
popup_title, palette_callback, initial_palette_name, popup_title, palette_callback, initial_palette_name,
NULL)) NULL))
success = FALSE; success = FALSE;

View File

@ -28,7 +28,9 @@ sub patterns_popup {
{ name => 'popup_title', type => 'string', { name => 'popup_title', type => 'string',
desc => 'Title of the pattern selection dialog' }, desc => 'Title of the pattern selection dialog' },
{ name => 'initial_pattern_name', type => 'string', null_ok => 1, { 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 = ( %invoke = (
@ -38,6 +40,7 @@ sub patterns_popup {
! gimp_pdb_lookup_procedure (gimp->pdb, pattern_callback) || ! gimp_pdb_lookup_procedure (gimp->pdb, pattern_callback) ||
! gimp_pdb_dialog_new (gimp, context, progress, ! gimp_pdb_dialog_new (gimp, context, progress,
gimp_data_factory_get_container (gimp->pattern_factory), gimp_data_factory_get_container (gimp->pattern_factory),
parent_window,
popup_title, pattern_callback, initial_pattern_name, popup_title, pattern_callback, initial_pattern_name,
NULL)) NULL))
success = FALSE; success = FALSE;