[dia] [embedded image] preliminary Python access to Pixbuf property



commit 72266ab07475d594186f2cd73e30544ed0ae17a2
Author: Hans Breuer <hans breuer org>
Date:   Sun Jul 17 15:53:48 2011 +0200

    [embedded image] preliminary Python access to Pixbuf property
    
    I really dont konow if it useful at all to have it as PyCObject.
    Also it may have issues with reference counting.

 plug-ins/python/pydia-property.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/python/pydia-property.c b/plug-ins/python/pydia-property.c
index 7e0838b..009b643 100644
--- a/plug-ins/python/pydia-property.c
+++ b/plug-ins/python/pydia-property.c
@@ -41,6 +41,7 @@
 #include "prop_sdarray.h"
 #include "prop_dict.h"
 #include "prop_matrix.h"
+#include "prop_pixbuf.h"
 
 /*
  * New
@@ -201,6 +202,9 @@ static PyObject * PyDia_get_Array (ArrayProperty *prop);
 static PyObject * PyDia_get_Dict (DictProperty *prop);
 static int PyDia_set_Dict (Property *prop, PyObject *val);
 
+static PyObject * PyDia_get_Pixbuf (PixbufProperty *prop);
+static int PyDia_set_Pixbuf (Property *prop, PyObject *val);
+
 static int
 PyDia_set_Bool (Property *prop, PyObject *val)
 {
@@ -580,7 +584,8 @@ struct {
   { PROP_TYPE_FONT, PyDia_get_Font },
   { PROP_TYPE_SARRAY, PyDia_get_Array, PyDia_set_Array },
   { PROP_TYPE_DARRAY, PyDia_get_Array, PyDia_set_Array },
-  { PROP_TYPE_DICT, PyDia_get_Dict, PyDia_set_Dict }
+  { PROP_TYPE_DICT, PyDia_get_Dict, PyDia_set_Dict },
+  { PROP_TYPE_PIXBUF, PyDia_get_Pixbuf, PyDia_set_Pixbuf }
 };
 
 static void
@@ -764,6 +769,34 @@ PyDia_set_Dict (Property *prop, PyObject *val)
   return -1;
 }
 
+static PyObject *
+PyDia_get_Pixbuf (PixbufProperty *prop)
+{
+  PyObject *pb;
+
+  if (!prop->pixbuf) {
+    Py_INCREF(Py_None);
+    return Py_None;
+  }
+  pb = PyCObject_FromVoidPtrAndDesc (prop->pixbuf, NULL, NULL);
+  
+  return pb;
+}
+static int
+PyDia_set_Pixbuf (Property *prop, PyObject *val)
+{
+  PixbufProperty *p = (PixbufProperty *)prop;
+
+  if PyCObject_Check(val) {
+    gpointer pp = PyCObject_AsVoidPtr (val);
+
+    /* FIXME: refernce counting? */
+    p->pixbuf = pp;
+    return 0;
+  }
+  return -1;
+}
+
 /*
  * GetAttr
  */



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