RSS/Atom feed Twitter
Site is read-only, email is disabled

User Friendly Plug-In Browser (Sven Neumann): Python plugin defaults accessible

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

User Friendly Plug-In Browser (Sven Neumann): Python plugin defaults accessible lloyd konneker 15 Apr 15:15
  User Friendly Plug-In Browser (Sven Neumann): Python plugin defaults accessible Avgoustinos Kadis 16 Apr 21:10
lloyd konneker
2010-04-15 15:15:20 UTC (over 14 years ago)

User Friendly Plug-In Browser (Sven Neumann): Python plugin defaults accessible

On Mon, 2010-04-12 at 23:20 +0200, Avgoustinos Kadis wrote:

Thanks Sven, very important to know that! How feasible are these options?

1. Randomly pick a value for each parameter. From what you said (that it depends a lot on the parameters) this wont give us the best results but at least we will have a preview.

2. Modify PDB so it can store default parameters and enter their values in the plug-ins (maintained in one place only)?

Sven wrote:

The latter is the only reasonable solution and it has been on the TODO for quite a while already. But IMO it goes way beyond the scope of a GSoC project.

Lloyd responds:

If the GSoC project was just to be a proof of concept, then you could get the defaults for a subset of plugins, namely some Python plugins, as follows:

1) make the patch to pygimp that allows Gimp to reimport plugins (small patch proposed earlier on this list, search under "gimp_env_init".)

2) Python pseudo code snippet:

for each python plugin filename in the standard directories: __import__( filename )
for procname in gimpfu._registered_plugins_.keys() params = gimpfu._registered_plugins_[procname][8] for param in params:
default = param[3]

In other words, reimporting a plugin sometimes calls its register() which creates a "private" structure in gimpfu that gives the registration parameters, including the defaults (and a range of reasonable values for some types of parameters.)

Sometimes means: unless the call to register() is guarded by if __name__ = "__main__" !!! The call to register() is a declaration: the convention should be that it NOT be guarded. The call to register() doesn't interact with Gimp. (This is more discussion about the proposed patch.)

Not the way you would ultimately want to have defaults accessible, but it might help enable a transition to a more general solution.

Avgoustinos Kadis
2010-04-16 21:10:54 UTC (over 14 years ago)

User Friendly Plug-In Browser (Sven Neumann): Python plugin defaults accessible

Hi Lloyd,
Sorry for answering so late. I'm studying for exams these days.. Thanks for your idea! Sounds like a good way to get some default values. Doesn't sound very painful either .. For proof of concept, a more painless way is to hard-code the default parameters for 10-20 plugins. That's how I was thinking of starting with it. After that, your way sounds the next step to go for (no better choice for now).
Thanks again,
Avgoustinos

On Thu, Apr 15, 2010 at 3:15 PM, lloyd konneker wrote:

On Mon, 2010-04-12 at 23:20 +0200, Avgoustinos Kadis wrote:

Thanks Sven, very important to know that! How feasible are these options?

1. Randomly pick a value for each parameter. From what you said (that it depends a lot on the parameters) this wont give us the best results but at least we will have a preview.

2. Modify PDB so it can store default parameters and enter their values in the plug-ins (maintained in one place only)?

Sven wrote:

The latter is the only reasonable solution and it has been on the TODO for quite a while already. But IMO it goes way beyond the scope of a GSoC project.

Lloyd responds:

If the GSoC project was just to be a proof of concept, then you could get the defaults for a subset of plugins, namely some Python plugins, as follows:

1) make the patch to pygimp that allows Gimp to reimport plugins (small patch proposed earlier on this list, search under "gimp_env_init".)

2) Python pseudo code snippet:

for each python plugin filename in the standard directories:    __import__( filename )
   for procname in gimpfu._registered_plugins_.keys()         params = gimpfu._registered_plugins_[procname][8]         for param in params:
           default = param[3]

In other words, reimporting a plugin sometimes calls its register() which creates a "private" structure in gimpfu that gives the registration parameters, including the defaults (and a range of reasonable values for some types of parameters.)

Sometimes means: unless the call to register() is guarded by if __name__ = "__main__" !!!  The call to register() is a declaration: the convention should be that it NOT be guarded.  The call to register() doesn't interact with Gimp.  (This is more discussion about the proposed patch.)

Not the way you would ultimately want to have defaults accessible, but it might help enable a transition to a more general solution.