Commit e4b08205 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh

Vector object wrapper API.

2006-10-24  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/pygimp-vectors.c: Vector object wrapper API.

        * plug-ins/pygimp/Makefile.am: add above file.

        * plug-ins/pygimp/gimpshelf.py
        * plug-ins/pygimp/pygimp.h
        * plug-ins/pygimp/gimpmodule.c: hook the new objects in.

        * plug-ins/pygimp/pygimp-image.c: get_vectors accessor.
parent 96c0a5eb
2006-10-24 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/pygimp-vectors.c: Vector object wrapper API.
* plug-ins/pygimp/Makefile.am: add above file.
* plug-ins/pygimp/gimpshelf.py
* plug-ins/pygimp/pygimp.h
* plug-ins/pygimp/gimpmodule.c: hook the new objects in.
* plug-ins/pygimp/pygimp-image.c: get_vectors accessor.
2006-10-24 Manish Singh <yosh@gimp.org>
* tools/pdbgen/pdb/vectors.pdb: fix spelling of "precision", and
......
......@@ -37,6 +37,7 @@ gimp_la_SOURCES = \
pygimp-parasite.c \
pygimp-pdb.c \
pygimp-tile.c \
pygimp-vectors.c \
pygimp.h \
pygimp-api.h \
pygimp-intl.h \
......
......@@ -1495,6 +1495,21 @@ id2display(PyObject *self, PyObject *args)
return Py_None;
}
static PyObject *
id2vectors(PyObject *self, PyObject *args)
{
int id;
if (!PyArg_ParseTuple(args, "i:_id2vectors", &id))
return NULL;
if (id >= 0)
return pygimp_vectors_new(id);
Py_INCREF(Py_None);
return Py_None;
}
/* List of methods defined in the module */
static struct PyMethodDef gimp_methods[] = {
......@@ -1564,6 +1579,7 @@ static struct PyMethodDef gimp_methods[] = {
{"_id2image", (PyCFunction)id2image, METH_VARARGS},
{"_id2drawable", (PyCFunction)id2drawable, METH_VARARGS},
{"_id2display", (PyCFunction)id2display, METH_VARARGS},
{"_id2vectors", (PyCFunction)id2vectors, METH_VARARGS},
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
};
......@@ -1647,6 +1663,24 @@ initgimp(void)
if (PyType_Ready(&PyGimpParasite_Type) < 0)
return;
PyGimpVectorsStroke_Type.ob_type = &PyType_Type;
PyGimpVectorsStroke_Type.tp_alloc = PyType_GenericAlloc;
PyGimpVectorsStroke_Type.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyGimpVectorsStroke_Type) < 0)
return;
PyGimpVectorsBezierStroke_Type.ob_type = &PyType_Type;
PyGimpVectorsBezierStroke_Type.tp_alloc = PyType_GenericAlloc;
PyGimpVectorsBezierStroke_Type.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyGimpVectorsBezierStroke_Type) < 0)
return;
PyGimpVectors_Type.ob_type = &PyType_Type;
PyGimpVectors_Type.tp_alloc = PyType_GenericAlloc;
PyGimpVectors_Type.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyGimpVectors_Type) < 0)
return;
pygimp_init_pygobject();
init_pygimpcolor();
......@@ -1680,6 +1714,7 @@ initgimp(void)
PyDict_SetItemString(d, "Tile", (PyObject *)&PyGimpTile_Type);
PyDict_SetItemString(d, "PixelRgn", (PyObject *)&PyGimpPixelRgn_Type);
PyDict_SetItemString(d, "Parasite", (PyObject *)&PyGimpParasite_Type);
PyDict_SetItemString(d, "Vectors", (PyObject *)&PyGimpVectors_Type);
/* for other modules */
PyDict_SetItemString(d, "_PyGimp_API",
......
......@@ -51,12 +51,16 @@ def _drawable_id(obj):
def _display_id(obj):
return gimp._id2display, int(obj)
def _vectors_id(obj):
return gimp._id2vectors, int(obj.ID)
copy_reg.pickle(gimp.Image, _image_id, gimp._id2image)
copy_reg.pickle(gimp.Layer, _drawable_id, gimp._id2drawable)
copy_reg.pickle(gimp.Channel, _drawable_id, gimp._id2drawable)
copy_reg.pickle(gimp.Display, _display_id, gimp._id2display)
copy_reg.pickle(gimp.Vectors, _vectors_id, gimp._id2vectors)
del copy_reg, _image_id, _drawable_id, _display_id
del copy_reg, _image_id, _drawable_id, _display_id, _vectors_id
class Gimpshelf:
def has_key(self, key):
......
......@@ -1155,6 +1155,25 @@ img_set_unit(PyGimpImage *self, PyObject *value, void *closure)
return 0;
}
static PyObject *
img_get_vectors(PyGimpImage *self, void *closure)
{
int *vectors;
int i, num_vectors;
PyObject *ret;
vectors = gimp_image_get_vectors(self->ID, &num_vectors);
ret = PyList_New(num_vectors);
for (i = 0; i < num_vectors; i++)
PyList_SetItem(ret, i, pygimp_vectors_new(vectors[i]));
g_free(vectors);
return ret;
}
static PyGetSetDef img_getsets[] = {
{ "ID", (getter)img_get_ID, (setter)0 },
{ "active_channel", (getter)img_get_active_channel,
......@@ -1178,6 +1197,7 @@ static PyGetSetDef img_getsets[] = {
{ "tattoo_state", (getter)img_get_tattoo_state,
(setter)img_set_tattoo_state },
{ "unit", (getter)img_get_unit, (setter)img_set_unit },
{ "vectors", (getter)img_get_vectors, (setter)0 },
{ "width", (getter)img_get_width, (setter)0 },
{ NULL, (getter)0, (setter)0 }
};
......
This diff is collapsed.
......@@ -115,9 +115,21 @@ typedef struct {
} PyGimpParasite;
extern PyTypeObject PyGimpParasite_Type;
#define pygimp_parasite_check(v) (PyObject_TypeCheck(v, &Paratype))
#define pygimp_parasite_check(v) (PyObject_TypeCheck(v, &PyGimpParasite_Type))
PyObject *pygimp_parasite_new(GimpParasite *para);
typedef struct {
PyObject_HEAD
gint32 ID;
} PyGimpVectors;
extern PyTypeObject PyGimpVectors_Type;
#define pygimp_vectors_check(v) (PyObject_TypeCheck(v, &PyGimpVectors_Type))
PyObject *pygimp_vectors_new(gint32 vectors_ID);
extern PyTypeObject PyGimpVectorsStroke_Type;
extern PyTypeObject PyGimpVectorsBezierStroke_Type;
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment