GNOME Bugzilla – Bug 71200
PDB should be changed to use named parameters
Last modified: 2018-05-24 10:40:05 UTC
The following is a proposal that I sent in years ago, just prior to the release of 1.0. Unfortunately it was turned down because of the huge breakage that would be the result of it. The current PDB has parameters that are position dependent. This is a very inflexible and tedious interface. E.g. gimp_text has 17 parameters. A user that would like to use this interface has to fill in a lot of parameters, most of which she would be happy to use the default values of. Of course there is no way to remember these parameters when writing scripts, and instead one must resort to tedious copy and paste, and a result the signal to noise ratio in the code is high. A much better approach is to use "named parameters", or key/value pairs as they are sometimes known. When these are used all parameters have default values, and only those values that should be changed are given in the PDB call. E.g. instead of doing the call gimp_bucket_fill(drawable, FG_BUCKET_FILL, NORMAL_MODE, 0.1, 13, 1, 100, 100) where one must reference the manual to understand the parameters, the following call would be made: gimp_bucket_fill("drawable", drawable, "x", 100, "y", 100) Most paramaters have default values and only the values that are overridden are listed. This is a much clearer interface. It would probably be possible to create an implementation that is backwards compatible, e.g. by checking if the first parameter is a string, and only then interprete the rest of the parameters as a key, value pair list. Key/values is really the natural interface to commands and interfaces, and a future Gimp should support it.
Not actually a new idea and discussed several times. At the moment scheduled for GIMP-2.0.
Could probably benefit from gimp_set_last_values() - a function to be called after a plug-in finished - too. see bug #51937
Just a quick note that we have come one step closer to this noble goal. Mitch has cleaned up the PDB internals as well as the perl code used to generate the PDB code. Internally the PDB now uses GParamSpec and GValue. These changes are not exposed to libgimp though. We plan to introduce an alternative PDB API in the next development cycle (after 2.4).
Just a question: Will this feature come with GEGL?
No it's completely unrelated. Comment 3 stays true, except we redefine "next development cycle" all the time :)
Michael Natterer, thank you very much for explaining.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gimp/issues/18.