Index: plug-ins/pygimp/gimpfu.py =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/gimpfu.py,v retrieving revision 1.55 diff -u -p -w -r1.55 gimpfu.py --- plug-ins/pygimp/gimpfu.py 7 Oct 2006 21:07:04 -0000 1.55 +++ plug-ins/pygimp/gimpfu.py 16 Nov 2006 17:47:53 -0000 @@ -101,6 +101,7 @@ PF_IMAGE = PDB_IMAGE PF_LAYER = PDB_LAYER PF_CHANNEL = PDB_CHANNEL PF_DRAWABLE = PDB_DRAWABLE +PF_VECTORS = PDB_VECTORS #PF_SELECTION = PDB_SELECTION #PF_BOUNDARY = PDB_BOUNDARY #PF_PATH = PDB_PATH @@ -140,6 +141,7 @@ _type_mapping = { PF_LAYER : PDB_LAYER, PF_CHANNEL : PDB_CHANNEL, PF_DRAWABLE : PDB_DRAWABLE, + PF_VECTORS : PDB_VECTORS, PF_TOGGLE : PDB_INT32, PF_SLIDER : PDB_FLOAT, @@ -548,6 +550,7 @@ def _interact(proc_name, start_params): PF_LAYER : gimpui.LayerSelector, PF_CHANNEL : gimpui.ChannelSelector, PF_DRAWABLE : gimpui.DrawableSelector, + PF_VECTORS : gimpui.VectorsSelector, PF_TOGGLE : ToggleEntry, PF_SLIDER : SliderEntry, Index: plug-ins/pygimp/gimpmodule.c =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/gimpmodule.c,v retrieving revision 1.50 diff -u -p -w -r1.50 gimpmodule.c --- plug-ins/pygimp/gimpmodule.c 7 Nov 2006 17:57:44 -0000 1.50 +++ plug-ins/pygimp/gimpmodule.c 16 Nov 2006 17:47:53 -0000 @@ -1716,6 +1716,7 @@ static struct _PyGimp_Functions pygimp_a pygimp_drawable_new, pygimp_layer_new, pygimp_channel_new, + pygimp_vectors_new, &PyGimpPDBFunction_Type, pygimp_pdb_function_new Index: plug-ins/pygimp/gimpui.defs =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/gimpui.defs,v retrieving revision 1.7 diff -u -p -w -r1.7 gimpui.defs --- plug-ins/pygimp/gimpui.defs 20 Oct 2006 18:03:04 -0000 1.7 +++ plug-ins/pygimp/gimpui.defs 16 Nov 2006 17:47:53 -0000 @@ -336,6 +336,13 @@ (gtype-id "GIMP_TYPE_LAYER_COMBO_BOX") ) +(define-object VectorsComboBox + (in-module "Gimp") + (parent "GimpIntComboBox") + (c-name "GimpVectorsComboBox") + (gtype-id "GIMP_TYPE_VECTORS_COMBO_BOX") +) + (define-object ImageComboBox (in-module "Gimp") (parent "GimpIntComboBox") @@ -3660,6 +3667,11 @@ (return-type "GType") ) +(define-function gimp_vectors_combo_box_get_type + (c-name "gimp_vectors_combo_box_get_type") + (return-type "GType") +) + (define-function gimp_drawable_combo_box_new (c-name "gimp_drawable_combo_box_new") (is-constructor-of "GimpDrawableComboBox") @@ -3686,6 +3698,16 @@ (return-type "GtkWidget*") (parameters '("GimpDrawableConstraintFunc" "constraint") + '("gpointer" "data") + ) +) + +(define-function gimp_vectors_combo_box_new + (c-name "gimp_vectors_combo_box_new") + (is-constructor-of "GimpVectorsComboBox") + (return-type "GtkWidget*") + (parameters + '("GimpVectorsConstraintFunc" "constraint") '("gpointer" "data") ) ) Index: plug-ins/pygimp/gimpui.override =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/gimpui.override,v retrieving revision 1.8 diff -u -p -w -r1.8 gimpui.override --- plug-ins/pygimp/gimpui.override 20 Oct 2006 18:03:06 -0000 1.8 +++ plug-ins/pygimp/gimpui.override 16 Nov 2006 17:47:53 -0000 @@ -330,6 +330,97 @@ _wrap_gimp_layer_combo_box_new(PyGObject return 0; } %% +override gimp_vectors_combo_box_new kwargs +static gboolean +pygimp_vectors_constraint_marshal(gint32 image_id, gint32 vectors_id, + gpointer user_data) +{ + PyObject *img, *vect, *ret; + gboolean res; + PyGimpConstraintData *data = user_data; + + img = pygimp_image_new(image_id); + if (!img) { + PyErr_Print(); + return FALSE; + } + + vect = pygimp_vectors_new(vectors_id); + if (!vect) { + PyErr_Print(); + Py_DECREF(img); + return FALSE; + } + + if (data->user_data && data->user_data != Py_None) + ret = PyObject_CallFunctionObjArgs(data->constraint, img, vect, + data->user_data, NULL); + else + ret = PyObject_CallFunctionObjArgs(data->constraint, img, vect, NULL); + + if (!ret) { + PyErr_Print(); + res = FALSE; + } else { + res = PyObject_IsTrue(ret); + Py_DECREF(ret); + } + + Py_DECREF(vect); + Py_DECREF(img); + + return res; +} + +static int +_wrap_gimp_vectors_combo_box_new(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + PyObject *constraint = NULL, *user_data = NULL; + GimpVectorsConstraintFunc func = NULL; + PyGimpConstraintData *data = NULL; + + static char *kwlist[] = { "constraint", "data", NULL }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|OO:gimpui.VectorsComboBox.__init__", + kwlist, + &constraint, &user_data)) + return -1; + + if (constraint && constraint != Py_None) { + if (!PyCallable_Check(constraint)) { + PyErr_SetString(PyExc_TypeError, "first arg must be callable"); + return -1; + } + + data = g_new(PyGimpConstraintData, 1); + + data->constraint = constraint; + Py_INCREF(constraint); + + data->user_data = user_data; + Py_XINCREF(user_data); + + func = pygimp_vectors_constraint_marshal; + } + + self->obj = (GObject *)gimp_vectors_combo_box_new(func, data); + + Py_XDECREF(constraint); + Py_XDECREF(user_data); + g_free(data); + + if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_VECTORS_COMBO_BOX) { + PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used " + "when subclassing gimpui.VectorsComboBox"); + return -1; + } + + pygobject_register_wrapper((PyObject *)self); + return 0; +} +%% override gimp_image_combo_box_new kwargs static gboolean pygimp_image_constraint_marshal(gint32 image_id, gpointer user_data) Index: plug-ins/pygimp/gimpui.py =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/gimpui.py,v retrieving revision 1.19 diff -u -p -w -r1.19 gimpui.py --- plug-ins/pygimp/gimpui.py 17 Sep 2006 02:58:16 -0000 1.19 +++ plug-ins/pygimp/gimpui.py 16 Nov 2006 17:47:53 -0000 @@ -112,6 +112,20 @@ def DrawableMenu(constraint=None, callba items.sort() return _createMenu(items, callback, data) +def VectorsMenu(constraint=None, callback=None, data=None): + items = [] + for img in gimp.image_list(): + filename = img.filename + if not filename: + filename = img.name + for vectors in img.vectors: + if constraint and not constraint(img, vectors): + continue + name = filename + "/" + vectors.name + items.append((name, vectors)) + items.sort() + return _createMenu(items, callback, data) + class ImageSelector(ImageComboBox): def __init__(self, default=None): ImageComboBox.__init__(self) @@ -139,6 +153,14 @@ class ChannelSelector(ChannelComboBox): class DrawableSelector(DrawableComboBox): def __init__(self, default=None): DrawableComboBox.__init__(self) + if default is not None: + self.set_active(default) + def get_value(self): + return self.get_active() + +class VectorsSelector(VectorsComboBox): + def __init__(self, default=None): + VectorsComboBox.__init__(self) if default is not None: self.set_active(default) def get_value(self): Index: plug-ins/pygimp/pygimp-api.h =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/pygimp-api.h,v retrieving revision 1.3 diff -u -p -w -r1.3 pygimp-api.h --- plug-ins/pygimp/pygimp-api.h 20 Jul 2006 04:53:46 -0000 1.3 +++ plug-ins/pygimp/pygimp-api.h 16 Nov 2006 17:47:53 -0000 @@ -31,6 +31,7 @@ struct _PyGimp_Functions { PyObject *(* drawable_new)(GimpDrawable *drawable, gint32 ID); PyObject *(* layer_new)(gint32 ID); PyObject *(* channel_new)(gint32 ID); + PyObject *(* vectors_new)(gint32 ID); PyTypeObject *PDBFunction_Type; PyObject *(* pdb_function_new)(const char *name, const char *blurb, @@ -55,6 +56,7 @@ struct _PyGimp_Functions *_PyGimp_API; #define pygimp_drawable_new (_PyGimp_API->drawable_new) #define pygimp_layer_new (_PyGimp_API->layer_new) #define pygimp_channel_new (_PyGimp_API->channel_new) +#define pygimp_vectors_new (_PyGimp_API->vectors_new) #define PyGimpPDBFunction_Type (_PyGimp_API->PDBFunction_Type) #define pygimp_pdb_function_new (_PyGimp_API->pdb_function_new) Index: plug-ins/pygimp/pygimp.h =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/pygimp/pygimp.h,v retrieving revision 1.6 diff -u -p -w -r1.6 pygimp.h