Enhance GimpProcedureDialog to show widgets for GimpItem, GimpImage properties
Summary
Supports a rare use case for third-party plugins: dialog widgets for choosing images or items not already selected in the context.
Needed if we want to eliminate GUI code from ScriptFu and absolutely don't regress on what plugin dialogs could do before. Also needed if we want to let Python plugins dialog show such widgets.
Discussion
Re SF-IMAGE, SF-LAYER, SF-CHANNEL, SF-VECTORS etc. in ScriptFu and PF_IMAGE etc in v2 PyGimp.
These were used to declare arguments of a plugin procedure that are supplemental images or layers. Where supplemental means: in addition to the standard "image, drawables" arguments from the context. They should display in the a plugin's dialog with GIMP's stock chooser widgets.
Currently, in GIMP 3 these don't work for ScriptFu or Python plugins that use GimpProcedureDialog. (But ScriptFu still implements the widgets on its own for old-style scripts.)
Importance
One use case is rare: a plugin that performs say a binary operation, and lets the user choose an existing supplemental item that is not in the context (items the user selected before invoking the plugin.) (The use case is not "choose a name for a new image", that is supported.)
A more compelling use case might be a plugin user choosing a Channel or Path (Vectors.) It is not as friendly to require a user to choose all the argument items before invoking a plugin (and let the plugin get the active items to operate on.)
Apparently no Python or ScriptFu plugins in the GIMP repo use these cases. Its not even clear that plugins relegated to non-supported repo gimp-data-extras use this case. So only third party plugins might embody this use case.
The long existing plugin scripts/test-sphere.scm tests this use case. And it still shows a widget because ScriptFu still implements its own GUI. The new plugin scripts/test-sphere-v3.scm tests this use case, and fails, because it uses GimpProcedureDialog. These are only test plugins.
Alternatives
We can just say: interactive plugins cannot declare args for supplemental items (say Channel)
We can leave ScriptFu implementing its own interface.
- third party plugins can use script-fu-register and use say SF-CHANNEL,
- ScriptFu plugins can't use the new script-fu-register-filter
(which uses GimpProcedureDialog) and also declare args say SF-CHANNEL.
- Python plugins can't declare args of type GimpChannel
(and expect GimpProcedureDialog to show them.)
Extent
The enhancement entails adding cases to GimpProcedureDialog.
Also adding a property widget, since GimpProcedureDialog uses prop widgets. A prop widget is a widget bound to (editing) a property of a config. A prop widget wraps a more primitive widget.
The prop widget can be generic, and cover GimpImage and GimpItems. All those objects have the same trait of being identified by int ID's, and they all have existing chooser widgets returning int ID's. GimpImage and GimpItems are things identified by ID's, that belong to each other in an item tree.
See a forthcoming draft MR. Its a few hundred lines of code.
Args declared this way have say type GimpImage in the PDB Browser. These args are represented in a GimpConfig with a Gimp type say GimpImage. The plugin for a GI bound language (say Python) should receive an actual GimpImage instance. ScriptFu plugins (they don't use GI) receive an int ID.
Related
This is a step towards Python and ScriptFu plugins using GimpProcedureDialog instead of building their own GUI.
This is item 3 of #8495.