app, libgimp, pdb, plug-ins: fix failure to set plug-in as transient.

While setting a plug-in as transient usually worked, it was failing in
cases the plug-in's progress bar was not initialized (i.e. if
progress_init() was not called before setting the dialog transient).

This commit stores the calling display, core side too (libgimp side, the
plug-in already had the calling display ID information), and we use this
when a GimpProgress has not been created yet.
This commit is contained in:
Jehan 2024-06-08 21:46:19 +02:00
parent e710457b4c
commit cca637135b
8 changed files with 26 additions and 20 deletions

View file

@ -414,8 +414,8 @@ register_progress_procs (GimpPDB *pdb)
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-progress-get-window-handle");
gimp_procedure_set_static_help (procedure,
"Returns the native handle of the toplevel window this plug-in's progress is displayed in.",
"This function returns the native handle allowing to identify the toplevel window this plug-in's progress is displayed in.\n"
"Returns the native handle of the toplevel window this plug-in's progress is or would be displayed in.",
"This function returns the native handle allowing to identify the toplevel window this plug-in's progress is displayed in. It should still work even if the progress bar has not been initialized yet, unless the plug-in wasn't called from a GUI.\n"
"This handle can be of various types (integer, string, etc.) depending on the platform you are running on which is why it returns a GBytes. There are usually no reasons to call this directly.",
NULL);
gimp_procedure_set_static_attribution (procedure,

View file

@ -244,6 +244,8 @@ gimp_plug_in_progress_get_window_id (GimpPlugIn *plug_in)
if (proc_frame->progress)
return gimp_progress_get_window_id (proc_frame->progress);
else if (plug_in->display)
return gimp_get_display_window_id (plug_in->manager->gimp, plug_in->display);
return 0;
}

View file

@ -75,6 +75,7 @@
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpdisplay.h"
#include "core/gimp-spawn.h"
#include "core/gimpprogress.h"
@ -142,6 +143,7 @@ gimp_plug_in_init (GimpPlugIn *plug_in)
{
plug_in->manager = NULL;
plug_in->file = NULL;
plug_in->display = NULL;
plug_in->call_mode = GIMP_PLUG_IN_CALL_NONE;
plug_in->open = FALSE;
@ -171,6 +173,7 @@ gimp_plug_in_finalize (GObject *object)
GimpPlugIn *plug_in = GIMP_PLUG_IN (object);
g_clear_object (&plug_in->file);
g_clear_weak_pointer (&plug_in->display);
gimp_plug_in_proc_frame_dispose (&plug_in->main_proc_frame, plug_in);
@ -396,7 +399,8 @@ gimp_plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure,
GFile *file)
GFile *file,
GimpDisplay *display)
{
GimpPlugIn *plug_in;
@ -406,6 +410,7 @@ gimp_plug_in_new (GimpPlugInManager *manager,
g_return_val_if_fail (procedure == NULL ||
GIMP_IS_PLUG_IN_PROCEDURE (procedure), NULL);
g_return_val_if_fail (file == NULL || G_IS_FILE (file), NULL);
g_return_val_if_fail (display == NULL || GIMP_IS_DISPLAY (display), NULL);
g_return_val_if_fail ((procedure != NULL || file != NULL) &&
! (procedure != NULL && file != NULL), NULL);
@ -419,6 +424,7 @@ gimp_plug_in_new (GimpPlugInManager *manager,
plug_in->manager = manager;
plug_in->file = g_object_ref (file);
g_set_weak_pointer (&plug_in->display, display);
gimp_plug_in_proc_frame_init (&plug_in->main_proc_frame,
context, progress, procedure);

View file

@ -44,6 +44,7 @@ struct _GimpPlugIn
GimpPlugInManager *manager;
GFile *file; /* Plug-in's full path name */
GimpDisplay *display; /* The display this plug-in was called from. */
GimpPlugInCallMode call_mode; /* QUERY, INIT or RUN */
guint open : 1; /* Is the plug-in open? */
guint hup : 1; /* Did we receive a G_IO_HUP */
@ -82,7 +83,8 @@ GimpPlugIn * gimp_plug_in_new (GimpPlugInManager *manager,
GimpContext *context,
GimpProgress *progress,
GimpPlugInProcedure *procedure,
GFile *file);
GFile *file,
GimpDisplay *display);
gboolean gimp_plug_in_open (GimpPlugIn *plug_in,
GimpPlugInCallMode call_mode,

View file

@ -78,7 +78,7 @@ gimp_plug_in_manager_call_query (GimpPlugInManager *manager,
g_return_if_fail (GIMP_IS_PLUG_IN_DEF (plug_in_def));
plug_in = gimp_plug_in_new (manager, context, NULL,
NULL, plug_in_def->file);
NULL, plug_in_def->file, NULL);
if (plug_in)
{
@ -118,7 +118,7 @@ gimp_plug_in_manager_call_init (GimpPlugInManager *manager,
g_return_if_fail (GIMP_IS_PLUG_IN_DEF (plug_in_def));
plug_in = gimp_plug_in_new (manager, context, NULL,
NULL, plug_in_def->file);
NULL, plug_in_def->file, NULL);
if (plug_in)
{
@ -165,7 +165,10 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
g_return_val_if_fail (args != NULL, NULL);
g_return_val_if_fail (display == NULL || GIMP_IS_DISPLAY (display), NULL);
plug_in = gimp_plug_in_new (manager, context, progress, procedure, NULL);
if (! display)
display = gimp_context_get_display (context);
plug_in = gimp_plug_in_new (manager, context, progress, procedure, NULL, display);
if (plug_in)
{
@ -199,9 +202,6 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
return return_vals;
}
if (! display)
display = gimp_context_get_display (context);
display_id = display ? gimp_display_get_id (display) : -1;
icon_theme_dir = gimp_get_icon_theme_dir (manager->gimp);

View file

@ -220,10 +220,12 @@ gimp_progress_end (void)
* gimp_progress_get_window_handle:
*
* Returns the native handle of the toplevel window this plug-in's
* progress is displayed in.
* progress is or would be displayed in.
*
* This function returns the native handle allowing to identify the
* toplevel window this plug-in's progress is displayed in.
* toplevel window this plug-in's progress is displayed in. It should
* still work even if the progress bar has not been initialized yet,
* unless the plug-in wasn't called from a GUI.
* This handle can be of various types (integer, string, etc.)
* depending on the platform you are running on which is why it returns
* a GBytes. There are usually no reasons to call this directly.

View file

@ -180,10 +180,11 @@ CODE
}
sub progress_get_window_handle {
$blurb = 'Returns the native handle of the toplevel window this plug-in\'s progress is displayed in.';
$blurb = 'Returns the native handle of the toplevel window this plug-in\'s progress is or would be displayed in.';
$help = <<'HELP';
This function returns the native handle allowing to identify the toplevel window this plug-in's progress is displayed in.
It should still work even if the progress bar has not been initialized yet, unless the plug-in wasn't called from a GUI.
This handle can be of various types (integer, string, etc.) depending on the platform you are running on which is why it
returns a GBytes. There are usually no reasons to call this directly.

View file

@ -3790,13 +3790,6 @@ load_dialog (GFile *file,
GIMP_PROCEDURE_CONFIG (config),
&extracted_data, NULL);
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gimp_window_set_transient (GTK_WINDOW (dialog));
if (page_count > 1)
{
selector = gimp_page_selector_new ();