After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 376102 - gimp-python comboboxes don't provide python objects
gimp-python comboboxes don't provide python objects
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Gimp-Python
git master
Other Linux
: Normal normal
: 2.4
Assigned To: Manish Singh
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2006-11-16 21:13 UTC by Simon Budig
Modified: 2006-11-28 09:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample script that exposes the problem. (391 bytes, text/plain)
2006-11-16 21:15 UTC, Simon Budig
  Details
patch to address the problem in gimpui.py (1.88 KB, patch)
2006-11-17 13:06 UTC, Sven Neumann
none Details | Review

Description Simon Budig 2006-11-16 21:13:41 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.
Comment 1 Simon Budig 2006-11-16 21:15:26 UTC
Created attachment 76733 [details]
Sample script that exposes the problem.
Comment 2 Sven Neumann 2006-11-17 12:03:42 UTC
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.
Comment 3 Sven Neumann 2006-11-17 13:06:37 UTC
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):
  • File "/usr/local/lib/gimp/2.0/python/gimpfu.py", line 713 in _run
    res = _interact(proc_name, start_params)
  • File "/usr/local/lib/gimp/2.0/python/gimpfu.py", line 647 in _interact
    wid = _edit_mapping[pf_type](def_val)
  • File "/usr/local/lib/gimp/2.0/python/gimpui.py", line 140 in __init__
    if default is not None:
TypeError: an integer is required

Comment 4 Manish Singh 2006-11-28 09:46:29 UTC
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.
Comment 5 Manish Singh 2006-11-28 09:48:39 UTC
The test script here has an error, the default for the layer argument should be None, not -1.