Discussion about API to advertize what your plug-in handles
@Wormnest @mitch A small thread for discussion.
So lately I've added gimp_procedure_set_sensitivity_mask() which sets some flags to tell the core if your plug-in can only handle a single layer only, several layers, or even doesn't care about selected layers (it may work on images, etc.). It can even tell that it doesn't actually care if there is an image at all (some plug-ins may create their own images or whatnot, and don't work on opened images). Right now, this is only used to set plug-in sensitivity (in menus, etc.) though maybe it could even be extended as a check before calling a PDB procedure. Like if we know we are in an unsupported case, why even bother calling the plug-in and return a good global error message from the start.
Now gimp_procedure_set_image_types()
also already existed, except that I believe that it should be renamed gimp_procedure_set_drawable_types()
because we can actually set RGBA
if we want to work only on RGB drawables with alpha channel, etc. Moreover something which was discussed some time ago was some day the ability to have mix color models in a single image (like grayscale layers next to RGB layers, etc.). I don't know if it will ever happen, but it might (who knows), so why not be future-proof.
Last, we were discussing with @Wormnest the other day that it would be nice if a plug-in could also advertize a type of drawables: like do I want only layers? Channels? Layer masks? Any drawable? Maybe a plug-in could also advertize it works on other types of data rather than drawables, like a selection (so the plug-in should be inactive if no selection) or existing vectors, etc.
So we could either rename a bit and add more functions, or I was thinking if we could merge all these functions in one like gimp_procedure_handles()
, and the argument would be a string with a format more flexible than mask values (for instance, with masks, we can say "I handle one layer" or "I handle multiple layer", but not "I handle exactly 2 layers", which could typically be a plug-in pre-requisite).
For instance: gimp_procedure_handles (procedure, "layers:2:RGB*,GRAY*");
for a procedure which handles exactly 2 layers of any RGB or grayscale type or gimp_procedure_handles (procedure, "*:1+:RGBA");
for a procedure which handles one or more drawables, but only RGBA. And so on. Of course, more syntax must be specified, for instance maybe ;
as a separator between cases, etc.
Wouldn't such an API make sense? It would replace both gimp_procedure_set_image_types()
and gimp_procedure_set_sensitivity_mask()
and more.