GNOME Bugzilla – Bug 670897
Phython-fu does not return parent layer (pdb.gimp_item_get_parent(item))
Last modified: 2012-03-07 22:43:59 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
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.
Neither am I, but it surely looks more correct than before, please push.
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'.
Review of attachment 208558 [details] [review]: Yes, now its acting as expected. Thank you. Hartmut
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 on attachment 208558 [details] [review] Extended patch Please push
Argh, please ignore.