GIMP Chat
http://gimpchat.com/

How to find a list of enums?
http://gimpchat.com/viewtopic.php?f=9&t=18376
Page 1 of 1

Author:  berater [ Sun May 24, 2020 10:34 am ]
Post subject:  How to find a list of enums?

Hello everybody,
I am new to GIMP and to GIMP scripting and am trying to write a Scheme script for changing the mode of all visible layers at once to a particular value (LAYER-MODE-LIGHTEN-ONLY), because I want to combine a series of 200 full moon images with a foreground taken at dawn (the moon alone in black night is boring). Unfortunately, GIMP does not offer that functionalty by itself.
I am stuck at the stage where I want to register my new function with one of the parameters being an SF-ENUM offering all the available layer modes with a default of LAYER-MODE-LIGHTEN-ONLY. My parameter declaration in script-fu-register so far is
SF-ENUM "The Layer Mode" '("LayerMode" "LAYER-MODE-LIGHTEN-ONLY")
This is syntactically accepted but not executed with respect to the default. The default remains at the entry with the lowest value. I could live with it but I'd like to have it pretty.
The documentation says "This has to be the name of a registered enum, without the 'Gimp' prefix. The second parameter speficies the default value, using the enum value's nick".
Wonderful! How about a link to a list of those enums with the corresponding nicks?
Has anbody a hint for me where I can look-up the available enum declarations? I even found such a declaration in developer gimp org (I newbie am not allowed to post weblinks), but that's outdated.
Do I really need to study the source code of GIMP? Hm... Is GIMP open source at all...? :puzzled

Author:  rich2005 [ Sun May 24, 2020 12:22 pm ]
Post subject:  Re: How to find a list of enums?

Certainly been done before.
For script-fu there is an old one, so just legacy layer modes, ra-mode-settings.scm from http://www.silent9.com/incoming/scripts/
For python one of ofnuts plugins ofn-layer-modes.py from http://sourceforge.net/projects/gimp-to ... s/scripts/

Should be something in the code to give you a hint for writing your script.

Author:  berater [ Sun May 24, 2020 3:08 pm ]
Post subject:  Re: How to find a list of enums?

rich2005 wrote:
For script-fu there is an old one, so just legacy layer modes, ra-mode-settings.scm from http www silent9 com incoming scripts

Excellent! :coolthup
While it does not point me to the enum list, it even solves my original problem! :bigthup The legacy modes will do so far. Main thing I can merge my moon images with the dawn foreground.
Thank you very much! :cheers

(The enum list would be appreciated anyway, just for information or for future projects, in case anybody knows...) (The python list seems not to apply to script-fu)

Author:  Pocholo [ Sun May 24, 2020 9:26 pm ]
Post subject:  Re: How to find a list of enums?

berater wrote:
rich2005 wrote:
For script-fu there is an old one, so just legacy layer modes, ra-mode-settings.scm from http www silent9 com incoming scripts

Excellent! :coolthup
While it does not point me to the enum list, it even solves my original problem! :bigthup The legacy modes will do so far. Main thing I can merge my moon images with the dawn foreground.
Thank you very much! :cheers

(The enum list would be appreciated anyway, just for information or for future projects, in case anybody knows...) (The python list seems not to apply to script-fu)



I wonder if this is the list you're looking for?
Go to the link and go down about half of the way.
https://developer.gimp.org/api/2.0/app/ ... enums.html

Author:  berater [ Mon May 25, 2020 3:23 am ]
Post subject:  Re: How to find a list of enums?

Pocholo wrote:
I wonder if this is the list you're looking for?
Go to the link and go down about half of the way.
https developer gimp org api 2.0 app app-base-enums html

Thank you very much! Obviously, I missed this one scarcely. What I found was
https developer gimp org api 2.0 libgimpbase libgimpbase-gimpbaseenums html which seems outdated to me.

Author:  ofnuts [ Mon May 25, 2020 5:24 am ]
Post subject:  Re: How to find a list of enums?

Otherwise, see my ofn-layer-modes script.

Using the enums is quite touchy if you want to support 2.8 and 2.10, because the names don't change but their values do (so that LAYER_MODE_NORMAL is the new NORMAL mode in 2.10 (28) and not the legacy LAYER_MODE_NORMAL mode (0), which in 2.10 is LAYER_MODE_NORMAL_LEGACY.

So the Right Thing to do is to use enums instead of hardcoded values, but at the same time new layer modes can appear with new releases, but using them blindly makes the script unusable even with recent versions. In my script above used Python introspection to enable choices only if the running Gimp release allows it.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/