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.
This commit is contained in:
Massimo Valentini 2012-02-28 18:20:10 +01:00
parent bebcebd1ca
commit c2f68b59a3
2 changed files with 33 additions and 3 deletions

View File

@ -48,12 +48,38 @@ static PyMethodDef item_methods[] = {
static PyObject *
item_get_parent(PyGimpLayer *self, void *closure)
{
/* Not implemented yet */
return NULL;
gint32 id = gimp_item_get_parent(self->ID);
if (id == -1) {
Py_INCREF(Py_None);
return Py_None;
}
return pygimp_item_new(id);
}
static PyObject *
item_get_children(PyGimpLayer *self, void *closure)
{
gint32 *children;
gint n_children, i;
PyObject *ret;
children = gimp_item_get_children(self->ID, &n_children);
ret = PyList_New(n_children);
for (i = 0; i < n_children; i++)
PyList_SetItem(ret, i, pygimp_item_new(children[i]));
g_free(children);
return ret;
}
static PyGetSetDef item_getsets[] = {
{ "parent", (getter)item_get_parent, (setter)0 },
{ "children", (getter) item_get_children, (setter)0 },
{ NULL, (getter)0, (setter)0 }
};

View File

@ -291,7 +291,7 @@ pygimp_param_to_tuple(int nparams, const GimpParam *params)
value = pygimp_channel_new(params[i].data.d_channel);
break;
case GIMP_PDB_ITEM:
value = PyInt_FromLong(params[i].data.d_item);
value = pygimp_item_new(params[i].data.d_item);
break;
case GIMP_PDB_DRAWABLE:
value = pygimp_drawable_new(NULL, params[i].data.d_drawable);
@ -590,6 +590,10 @@ pygimp_param_from_tuple(PyObject *args, const GimpParamDef *ptype, int nparams)
}
break;
case GIMP_PDB_VECTORS:
if (item == Py_None) {
ret[i].data.d_vectors = -1;
break;
}
check(!pygimp_vectors_check(item));
ret[i].data.d_vectors = ((PyGimpVectors *)item)->ID;
break;