GNOME Bugzilla – Bug 376102
gimp-python comboboxes don't provide python objects
Last modified: 2006-11-28 09:48:39 UTC
When a script uses the PF_LAYER argument type to get a layer combo box the script gets a wrong parameter. Instead of (as in gimp 2.2) a python layer object it gets the index of the entry of the option menu (not even the layer ID), which is basically totally useless. A sample script is attached. With gimp 2.2 this scripts prints "<gimp.Layer 'Background'>", for gimp 2.3 it prints "0". The same probably holds for the PF_DRAWABLE, PF_CHANNEL types, although I did not test this explicitely. In 2.3 it behaves the same for the PF_VECTORS I am about to commit, but I don't undestand enough of the code to actually fix this properly.
Created attachment 76733 [details] Sample script that exposes the problem.
2006-11-17 Sven Neumann <sven@gimp.org> * plug-ins/pygimp/gimpui.override: override the wrapper for gimp_int_combo_box_get_active() and let it return the selected integer instead of the index in the combo (bug #376102). This only addresses one part of the problem. But at least the correct IDs are returned now (and a PyNone object if nothing is selected). It's now up to the derived classes to return the associated object.
Created attachment 76756 [details] [review] patch to address the problem in gimpui.py The attached patch changes the Selector classes to return objects instead of IDs. There is still some inconsistency then for palettes, patterns, etc. Probably those should be python objects as well, perhaps derived from a PyGimpItem class that would then also be the base class of PyGimpVectors. The other problem is that the test script now does the right thing on the first call: <gimp.Layer 'Background'> ... but fails on subsequent calls: Traceback (most recent call last):
+ Trace 87209
res = _interact(proc_name, start_params)
wid = _edit_mapping[pf_type](def_val)
if default is not None:
2006-11-28 Manish Singh <yosh@gimp.org> * plug-ins/pygimp/pygimp-api.h * plug-ins/pygimp/pygimp.h * plug-ins/pygimp/gimpmodule.c: export common object types via _PyGimp_API, and remove the PDBFunction_Type hack. Also define the common object structures here. * plug-ins/pygimp/pygimp.h: remove hack for Python < 2.3, since we require Python 2.3 now. * plug-ins/pygimp/gimpui.override * plug-ins/pygimp/gimpui.py: create and use specialized wrappers for get/set_active methods for GimpIntComboBox and derived types. Fixes #376102.
The test script here has an error, the default for the layer argument should be None, not -1.