[gimp] plugins/pygimp: use (PF|PDB)_ITEM instead of _REGION so pygimp works again.



commit cebbde5da936600aeb4740f3d7d8b53bb2c12b24
Author: David Gowers <00ai99 gmail com>
Date:   Wed Jul 14 16:59:21 2010 +0930

    plugins/pygimp: use (PF|PDB)_ITEM instead of _REGION so pygimp works again.
    
    Also update vectors and drawable code to use the new GimpItem API.

 plug-ins/pygimp/gimpfu.py         |    8 ++--
 plug-ins/pygimp/pygimp-drawable.c |   57 ++++++++++++++++++++----------------
 plug-ins/pygimp/pygimp-tile.c     |    6 ++--
 plug-ins/pygimp/pygimp-vectors.c  |   34 +++++++++++-----------
 4 files changed, 56 insertions(+), 49 deletions(-)
---
diff --git a/plug-ins/pygimp/gimpfu.py b/plug-ins/pygimp/gimpfu.py
index 8756bb4..aa2b09a 100644
--- a/plug-ins/pygimp/gimpfu.py
+++ b/plug-ins/pygimp/gimpfu.py
@@ -100,7 +100,7 @@ PF_VALUE       = PF_STRING
 #PF_STRINGARRAY = PDB_STRINGARRAY
 PF_COLOR       = PDB_COLOR
 PF_COLOUR      = PF_COLOR
-PF_REGION      = PDB_REGION
+PF_ITEM        = PDB_ITEM
 PF_DISPLAY     = PDB_DISPLAY
 PF_IMAGE       = PDB_IMAGE
 PF_LAYER       = PDB_LAYER
@@ -142,7 +142,7 @@ _type_mapping = {
     #PF_FLOATARRAY  : PDB_FLOATARRAY,
     #PF_STRINGARRAY : PDB_STRINGARRAY,
     PF_COLOR       : PDB_COLOR,
-    PF_REGION      : PDB_REGION,
+    PF_ITEM        : PDB_ITEM,
     PF_DISPLAY     : PDB_DISPLAY,
     PF_IMAGE       : PDB_IMAGE,
     PF_LAYER       : PDB_LAYER,
@@ -179,7 +179,7 @@ _obj_mapping = {
     #PF_FLOATARRAY  : list,
     #PF_STRINGARRAY : list,
     PF_COLOR       : gimpcolor.RGB,
-    PF_REGION      : int,
+    PF_ITEM        : int,
     PF_DISPLAY     : gimp.Display,
     PF_IMAGE       : gimp.Image,
     PF_LAYER       : gimp.Layer,
@@ -624,7 +624,7 @@ def _interact(proc_name, start_params):
             #PF_FLOATARRAY  : ArrayEntry,
             #PF_STRINGARRAY : ArrayEntry,
             PF_COLOR       : gimpui.ColorSelector,
-            PF_REGION      : IntEntry,  # should handle differently ...
+            PF_ITEM        : IntEntry,  # should handle differently ...
             PF_IMAGE       : gimpui.ImageSelector,
             PF_LAYER       : gimpui.LayerSelector,
             PF_CHANNEL     : gimpui.ChannelSelector,
diff --git a/plug-ins/pygimp/pygimp-drawable.c b/plug-ins/pygimp/pygimp-drawable.c
index 1a04470..a849f93 100644
--- a/plug-ins/pygimp/pygimp-drawable.c
+++ b/plug-ins/pygimp/pygimp-drawable.c
@@ -229,7 +229,7 @@ drw_parasite_find(PyGimpDrawable *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
 	return NULL;
 
-    return pygimp_parasite_new(gimp_drawable_parasite_find(self->ID, name));
+    return pygimp_parasite_new(gimp_item_parasite_find(self->ID, name));
 }
 
 static PyObject *
@@ -241,7 +241,7 @@ drw_parasite_attach(PyGimpDrawable *self, PyObject *args)
 			  &parasite))
 	return NULL;
 
-    if (!gimp_drawable_parasite_attach(self->ID, parasite->para)) {
+    if (!gimp_item_parasite_attach(self->ID, parasite->para)) {
 	PyErr_Format(pygimp_error,
 		     "could not attach parasite '%s' on drawable (ID %d)",
 		     gimp_parasite_name(parasite->para), self->ID);
@@ -255,9 +255,11 @@ drw_parasite_attach(PyGimpDrawable *self, PyObject *args)
 static PyObject *
 drw_attach_new_parasite(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
 {
-    char *name;
-    int flags, size;
-    guint8 *data;
+    char         *name;
+    int           flags, size;
+    guint8       *data;
+    GimpParasite *parasite;
+    gboolean      success;
 
     static char *kwlist[] = { "name", "flags", "data", NULL };
 
@@ -266,7 +268,12 @@ drw_attach_new_parasite(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
 				     &name, &flags, &data, &size))
 	return NULL;
 
-    if (!gimp_drawable_attach_new_parasite(self->ID, name, flags, size, data)) {
+    parasite = gimp_parasite_new (name,
+                                  flags, size + 1, data);
+    success = gimp_image_parasite_attach (self->ID, parasite);
+    gimp_parasite_free (parasite);
+
+    if (!success) {
 	PyErr_Format(pygimp_error,
 		     "could not attach new parasite '%s' to drawable (ID %d)",
 		     name, self->ID);
@@ -284,7 +291,7 @@ drw_parasite_detach(PyGimpDrawable *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "s:detach_parasite", &name))
 	return NULL;
 
-    if (!gimp_drawable_parasite_detach(self->ID, name)) {
+    if (!gimp_item_parasite_detach(self->ID, name)) {
 	PyErr_Format(pygimp_error,
 		     "could not detach parasite '%s' from drawable (ID %d)",
 		     name, self->ID);
@@ -301,7 +308,7 @@ drw_parasite_list(PyGimpDrawable *self)
     gint num_parasites;
     gchar **parasites;
 
-    if (gimp_drawable_parasite_list(self->ID, &num_parasites, &parasites)) {
+    if (gimp_item_parasite_list(self->ID, &num_parasites, &parasites)) {
 	PyObject *ret;
 	gint i;
 
@@ -943,7 +950,7 @@ drw_get_ID(PyGimpDrawable *self, void *closure)
 static PyObject *
 drw_get_name(PyGimpDrawable *self, void *closure)
 {
-    return PyString_FromString(gimp_drawable_get_name(self->ID));
+    return PyString_FromString(gimp_item_get_name(self->ID));
 }
 
 static int
@@ -959,7 +966,7 @@ drw_set_name(PyGimpDrawable *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_drawable_set_name(self->ID, PyString_AsString(value));
+    gimp_item_set_name(self->ID, PyString_AsString(value));
 
     return 0;
 }
@@ -985,7 +992,7 @@ drw_get_height(PyGimpDrawable *self, void *closure)
 static PyObject *
 drw_get_image(PyGimpDrawable *self, void *closure)
 {
-    return pygimp_image_new(gimp_drawable_get_image(self->ID));
+    return pygimp_image_new(gimp_item_get_image(self->ID));
 }
 
 static PyObject *
@@ -1009,7 +1016,7 @@ drw_get_is_indexed(PyGimpDrawable *self, void *closure)
 static PyObject *
 drw_get_is_layer_mask(PyGimpDrawable *self, void *closure)
 {
-    return PyBool_FromLong(gimp_drawable_is_layer_mask(self->ID));
+    return PyBool_FromLong(gimp_item_is_layer_mask(self->ID));
 }
 
 static PyObject *
@@ -1052,7 +1059,7 @@ drw_get_width(PyGimpDrawable *self, void *closure)
 static PyObject *
 drw_get_linked(PyGimpDrawable *self, void *closure)
 {
-    return PyBool_FromLong(gimp_drawable_get_linked(self->ID));
+    return PyBool_FromLong(gimp_item_get_linked(self->ID));
 }
 
 static int
@@ -1068,7 +1075,7 @@ drw_set_linked(PyGimpDrawable *self, PyObject *value, void *closure)
 	return -1;
     }
 
-    gimp_drawable_set_linked(self->ID, PyInt_AsLong(value));
+    gimp_item_set_linked(self->ID, PyInt_AsLong(value));
 
     return 0;
 }
@@ -1076,7 +1083,7 @@ drw_set_linked(PyGimpDrawable *self, PyObject *value, void *closure)
 static PyObject *
 drw_get_tattoo(PyGimpDrawable *self, void *closure)
 {
-    return PyInt_FromLong(gimp_drawable_get_tattoo(self->ID));
+    return PyInt_FromLong(gimp_item_get_tattoo(self->ID));
 }
 
 static int
@@ -1092,7 +1099,7 @@ drw_set_tattoo(PyGimpDrawable *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_drawable_set_tattoo(self->ID, PyInt_AsLong(value));
+    gimp_item_set_tattoo(self->ID, PyInt_AsLong(value));
 
     return 0;
 }
@@ -1100,7 +1107,7 @@ drw_set_tattoo(PyGimpDrawable *self, PyObject *value, void *closure)
 static PyObject *
 drw_get_visible(PyGimpDrawable *self, void *closure)
 {
-    return PyBool_FromLong(gimp_drawable_get_visible(self->ID));
+    return PyBool_FromLong(gimp_item_get_visible(self->ID));
 }
 
 static int
@@ -1116,7 +1123,7 @@ drw_set_visible(PyGimpDrawable *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_drawable_set_visible(self->ID, PyInt_AsLong(value));
+    gimp_item_set_visible(self->ID, PyInt_AsLong(value));
 
     return 0;
 }
@@ -1159,7 +1166,7 @@ drw_repr(PyGimpDrawable *self)
     PyObject *s;
     gchar *name;
 
-    name = gimp_drawable_get_name(self->ID);
+    name = gimp_item_get_name(self->ID);
     s = PyString_FromFormat("<gimp.Drawable '%s'>", name ? name : "(null)");
     g_free(name);
 
@@ -1228,13 +1235,13 @@ pygimp_drawable_new(GimpDrawable *drawable, gint32 ID)
     if (drawable != NULL)
     ID = drawable->drawable_id;
 
-    if (!gimp_drawable_is_valid(ID)) {
+    if (!gimp_item_is_valid(ID)) {
 	Py_INCREF(Py_None);
 	return Py_None;
     }
 
     /* create the appropriate object type */
-    if (gimp_drawable_is_layer(ID))
+    if (gimp_item_is_layer(ID))
 	self = pygimp_layer_new(ID);
     else
 	self = pygimp_channel_new(ID);
@@ -1724,7 +1731,7 @@ lay_repr(PyGimpLayer *self)
     PyObject *s;
     gchar *name;
 
-    name = gimp_drawable_get_name(self->ID);
+    name = gimp_item_get_name(self->ID);
     s = PyString_FromFormat("<gimp.Layer '%s'>", name ? name : "(null)");
     g_free(name);
 
@@ -1811,7 +1818,7 @@ pygimp_layer_new(gint32 ID)
 {
     PyGimpLayer *self;
 
-    if (!gimp_drawable_is_valid(ID) || !gimp_drawable_is_layer(ID)) {
+    if (!gimp_item_is_valid(ID) || !gimp_item_is_layer(ID)) {
 	Py_INCREF(Py_None);
 	return Py_None;
     }
@@ -2003,7 +2010,7 @@ chn_repr(PyGimpChannel *self)
     PyObject *s;
     gchar *name;
 
-    name = gimp_drawable_get_name(self->ID);
+    name = gimp_item_get_name(self->ID);
     s = PyString_FromFormat("<gimp.Channel '%s'>", name ? name : "(null)");
     g_free(name);
 
@@ -2099,7 +2106,7 @@ pygimp_channel_new(gint32 ID)
 {
     PyGimpChannel *self;
 
-    if (!gimp_drawable_is_valid(ID) || !gimp_drawable_is_channel(ID)) {
+    if (!gimp_item_is_valid(ID) || !gimp_item_is_channel(ID)) {
 	Py_INCREF(Py_None);
 	return Py_None;
     }
diff --git a/plug-ins/pygimp/pygimp-tile.c b/plug-ins/pygimp/pygimp-tile.c
index e395f12..36fbe12 100644
--- a/plug-ins/pygimp/pygimp-tile.c
+++ b/plug-ins/pygimp/pygimp-tile.c
@@ -130,7 +130,7 @@ tile_repr(PyGimpTile *self)
     PyObject *s;
     gchar *name;
 
-    name = gimp_drawable_get_name(self->tile->drawable->drawable_id);
+    name = gimp_item_get_name(self->tile->drawable->drawable_id);
 
     if (self->tile->shadow)
 	s = PyString_FromFormat("<gimp.Tile for drawable '%s' (shadow)>", name);
@@ -689,7 +689,7 @@ pr_repr(PyGimpPixelRgn *self)
     PyObject *s;
     gchar *name;
 
-    name = gimp_drawable_get_name(self->drawable->drawable->drawable_id);
+    name = gimp_item_get_name(self->drawable->drawable->drawable_id);
     s = PyString_FromFormat("<gimp.PixelRgn for drawable '%s'>", name);
     g_free(name);
 
@@ -950,7 +950,7 @@ pf_repr(PyGimpPixelFetcher *self)
     PyObject *s;
     char *name;
 
-    name = gimp_drawable_get_name(self->drawable->drawable->drawable_id);
+    name = gimp_item_get_name(self->drawable->drawable->drawable_id);
 
     if (self->shadow)
         s = PyString_FromFormat("<gimp.PixelFetcher for drawable '%s' (shadow)>", name);
diff --git a/plug-ins/pygimp/pygimp-vectors.c b/plug-ins/pygimp/pygimp-vectors.c
index 1b013de..ac9f330 100644
--- a/plug-ins/pygimp/pygimp-vectors.c
+++ b/plug-ins/pygimp/pygimp-vectors.c
@@ -290,7 +290,7 @@ vs_repr(PyGimpVectorsStroke *self)
     PyObject *s;
     char *name;
 
-    name = gimp_vectors_get_name(self->vectors_ID);
+    name = gimp_item_get_name(self->vectors_ID);
     s = PyString_FromFormat("<gimp.VectorsStroke %d of gimp.Vectors '%s'>",
                             self->stroke, name ? name : "(null)");
     g_free(name);
@@ -470,7 +470,7 @@ vbs_repr(PyGimpVectorsStroke *self)
     PyObject *s;
     char *name;
 
-    name = gimp_vectors_get_name(self->vectors_ID);
+    name = gimp_item_get_name(self->vectors_ID);
     s = PyString_FromFormat("<gimp.VectorsBezierStroke %d of gimp.Vectors '%s'>",
                             self->stroke, name ? name : "(null)");
     g_free(name);
@@ -646,7 +646,7 @@ vectors_parasite_find(PyGimpVectors *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
         return NULL;
 
-    return pygimp_parasite_new(gimp_vectors_parasite_find(self->ID, name));
+    return pygimp_parasite_new(gimp_item_parasite_find(self->ID, name));
 }
 
 static PyObject *
@@ -658,7 +658,7 @@ vectors_parasite_attach(PyGimpVectors *self, PyObject *args)
                           &parasite))
         return NULL;
 
-    if (!gimp_vectors_parasite_attach(self->ID, parasite->para)) {
+    if (!gimp_item_parasite_attach(self->ID, parasite->para)) {
         PyErr_Format(pygimp_error,
                      "could not attach parasite '%s' to vectors (ID %d)",
                      parasite->para->name, self->ID);
@@ -677,7 +677,7 @@ vectors_parasite_detach(PyGimpVectors *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "s:parasite_detach", &name))
         return NULL;
 
-    if (!gimp_vectors_parasite_detach(self->ID, name)) {
+    if (!gimp_item_parasite_detach(self->ID, name)) {
         PyErr_Format(pygimp_error,
                      "could not detach parasite '%s' from vectors (ID %d)",
                      name, self->ID);
@@ -694,7 +694,7 @@ vectors_parasite_list(PyGimpVectors *self)
     gint num_parasites;
     gchar **parasites;
 
-    if (gimp_vectors_parasite_list(self->ID, &num_parasites, &parasites)) {
+    if (gimp_item_parasite_list(self->ID, &num_parasites, &parasites)) {
         PyObject *ret;
         gint i;
 
@@ -739,7 +739,7 @@ static PyMethodDef vectors_methods[] = {
 static PyObject *
 vectors_get_image(PyGimpVectors *self, void *closure)
 {
-    return pygimp_image_new(gimp_vectors_get_image(self->ID));
+    return pygimp_image_new(gimp_item_get_image(self->ID));
 }
 
 static PyObject *
@@ -751,7 +751,7 @@ vectors_get_ID(PyGimpVectors *self, void *closure)
 static PyObject *
 vectors_get_name(PyGimpVectors *self, void *closure)
 {
-    return PyString_FromString(gimp_vectors_get_name(self->ID));
+    return PyString_FromString(gimp_item_get_name(self->ID));
 }
 
 static int
@@ -767,7 +767,7 @@ vectors_set_name(PyGimpVectors *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_vectors_set_name(self->ID, PyString_AsString(value));
+    gimp_item_set_name(self->ID, PyString_AsString(value));
 
     return 0;
 }
@@ -775,7 +775,7 @@ vectors_set_name(PyGimpVectors *self, PyObject *value, void *closure)
 static PyObject *
 vectors_get_visible(PyGimpVectors *self, void *closure)
 {
-    return PyBool_FromLong(gimp_vectors_get_visible(self->ID));
+    return PyBool_FromLong(gimp_item_get_visible(self->ID));
 }
 
 static int
@@ -791,7 +791,7 @@ vectors_set_visible(PyGimpVectors *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_vectors_set_visible(self->ID, PyInt_AsLong(value));
+    gimp_item_set_visible(self->ID, PyInt_AsLong(value));
 
     return 0;
 }
@@ -799,7 +799,7 @@ vectors_set_visible(PyGimpVectors *self, PyObject *value, void *closure)
 static PyObject *
 vectors_get_linked(PyGimpVectors *self, void *closure)
 {
-    return PyBool_FromLong(gimp_vectors_get_linked(self->ID));
+    return PyBool_FromLong(gimp_item_get_linked(self->ID));
 }
 
 static int
@@ -815,7 +815,7 @@ vectors_set_linked(PyGimpVectors *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_vectors_set_linked(self->ID, PyInt_AsLong(value));
+    gimp_item_set_linked(self->ID, PyInt_AsLong(value));
 
     return 0;
 }
@@ -823,7 +823,7 @@ vectors_set_linked(PyGimpVectors *self, PyObject *value, void *closure)
 static PyObject *
 vectors_get_tattoo(PyGimpVectors *self, void *closure)
 {
-    return PyInt_FromLong(gimp_vectors_get_tattoo(self->ID));
+    return PyInt_FromLong(gimp_item_get_tattoo(self->ID));
 }
 
 static int
@@ -839,7 +839,7 @@ vectors_set_tattoo(PyGimpVectors *self, PyObject *value, void *closure)
         return -1;
     }
 
-    gimp_vectors_set_tattoo(self->ID, PyInt_AsLong(value));
+    gimp_item_set_tattoo(self->ID, PyInt_AsLong(value));
 
     return 0;
 }
@@ -888,7 +888,7 @@ vectors_repr(PyGimpVectors *self)
     PyObject *s;
     char *name;
 
-    name = gimp_vectors_get_name(self->ID);
+    name = gimp_item_get_name(self->ID);
     s = PyString_FromFormat("<gimp.Vectors '%s'>", name ? name : "(null)");
     g_free(name);
 
@@ -979,7 +979,7 @@ pygimp_vectors_new(gint32 ID)
 {
     PyGimpVectors *self;
 
-    if (!gimp_vectors_is_valid(ID)) {
+    if (!gimp_item_is_valid(ID)) {
         Py_INCREF(Py_None);
         return Py_None;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]