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 670897 - Phython-fu does not return parent layer (pdb.gimp_item_get_parent(item))
Phython-fu does not return parent layer (pdb.gimp_item_get_parent(item))
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Gimp-Python
git master
Other All
: Normal minor
: 2.8
Assigned To: Manish Singh
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2012-02-27 15:32 UTC by Hartmut Kuhse
Modified: 2012-03-07 22:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
simple testscript giving out tdrawable and parent (532 bytes, text/plain)
2012-02-27 15:32 UTC, Hartmut Kuhse
  Details
Proposed patch (1.50 KB, patch)
2012-02-28 07:35 UTC, Massimo
none Details | Review
Extended patch (2.40 KB, patch)
2012-02-28 09:13 UTC, Massimo
accepted-commit_now Details | Review

Description Hartmut Kuhse 2012-02-27 15:32:37 UTC
Created attachment 208497 [details]
simple testscript giving out tdrawable and parent

There is a layergroup with some layers in it.
selecting a layer within the group
calling a python-fu plugin (parameters: timg, tdrawable)

parentlayer = pdb..gimp_item_get_parent(tdrawable)

is tdrawable the selected (active) layer.
parentlayer should be the layer group.

But parentlayer seems to be just a layer-ID for the layergroup.

If the layergroup is selected, then tdrawable returns the layergroup, which is correct.

Without the correct layergroup, functions

pdb.gimp_image_insert_layer

and

pdb.gimp_image_reorder_item

are not functional.

Test script as attachment
Comment 1 Massimo 2012-02-28 07:35:43 UTC
Created attachment 208550 [details] [review]
Proposed patch

This is a patch that converts params of type GIMP_PDB_ITEM to
the correct Python type, and implements the NYI 'parent' getter
of the class gimp.Item, it returns None if the item is at root level.

In the test-case attached to the previous comment it is then possible
to write

    parentlayer = tdrawable.parent
 
instead of

    parentlayer = pdb.gimp_item_get_parent(tdrawable)

and both now return a Python Object or None.

Please review since I'm not a Python expert.
Comment 2 Michael Natterer 2012-02-28 08:17:05 UTC
Neither am I, but it surely looks more correct than before, please push.
Comment 3 Massimo 2012-02-28 09:13:51 UTC
Created attachment 208558 [details] [review]
Extended patch

Extended the patch to also deal with the problem reported in

https://mail.gnome.org/archives/gimp-user-list/2012-February/msg00017.html

pygimp now treats params of type GIMP_PDB_VECTORS like all the
other item derived types.

and added a 'children' getter to the class gimp.Item, this automates
the conversion of the list of integer to a list of PyObjects, it 
returns an empty list if the item doesn't have children, it is basically
a copy of 'img_get_layers'.
Comment 4 Hartmut Kuhse 2012-02-28 13:15:49 UTC
Review of attachment 208558 [details] [review]:

Yes, now its acting as expected.
Thank you.

Hartmut
Comment 5 Massimo 2012-02-28 17:23:56 UTC
pushed:


commit c2f68b59a3f3097df185d42b9337c09e6f73decf
Author: Massimo Valentini <mvalentini@src.gnome.org>
Date:   Tue Feb 28 18:20:10 2012 +0100

    Bug 670897: Phython-fu does not return parent layer...
    
    (pdb.gimp_item_get_parent(item))
    
    Adjust param conversions when wrapping pdb functions
    and implement 'children' and 'parent' getter for
    GimpItem Python Object.
Comment 6 Michael Natterer 2012-03-07 22:42:42 UTC
Comment on attachment 208558 [details] [review]
Extended patch

Please push
Comment 7 Michael Natterer 2012-03-07 22:43:59 UTC
Argh, please ignore.