[pygobject] Revert "Do not bind gobject_get_data() and gobject_set_data()"



commit 73531fd7820bd1922347bd856298d68205a27877
Author: Martin Pitt <martinpitt gnome org>
Date:   Wed Jun 20 11:16:39 2012 +0200

    Revert "Do not bind gobject_get_data() and gobject_set_data()"
    
    We should have some deprecation period for this, so bring back these two
    methods and add deprecation warnings.
    
    This reverts commit 24cc09a7105299805fcc5bc151f53ac69958d728.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=641944

 gi/_gobject/pygobject.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/gi/_gobject/pygobject.c b/gi/_gobject/pygobject.c
index 75c8ba3..d9d2969 100644
--- a/gi/_gobject/pygobject.c
+++ b/gi/_gobject/pygobject.c
@@ -1684,6 +1684,48 @@ pygobject_thaw_notify(PyGObject *self, PyObject *args)
 }
 
 static PyObject *
+pygobject_get_data(PyGObject *self, PyObject *args)
+{
+    char *key;
+    GQuark quark;
+    PyObject *data;
+
+    g_warning("GObject.get_data() and set_data() are deprecated. Use normal Python attributes instead");
+
+    if (!PyArg_ParseTuple(args, "s:GObject.get_data", &key))
+	return NULL;
+    
+    CHECK_GOBJECT(self);
+    
+    quark = g_quark_from_string(key);
+    data = g_object_get_qdata(self->obj, quark);
+    if (!data) data = Py_None;
+    Py_INCREF(data);
+    return data;
+}
+
+static PyObject *
+pygobject_set_data(PyGObject *self, PyObject *args)
+{
+    char *key;
+    GQuark quark;
+    PyObject *data;
+
+    g_warning("GObject.get_data() and set_data() are deprecated. Use normal Python attributes instead");
+
+    if (!PyArg_ParseTuple(args, "sO:GObject.set_data", &key, &data))
+	return NULL;
+    
+    CHECK_GOBJECT(self);
+    
+    quark = g_quark_from_string(key);
+    Py_INCREF(data);
+    g_object_set_qdata_full(self->obj, quark, data, pyg_destroy_notify);
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
 pygobject_connect(PyGObject *self, PyObject *args)
 {
     PyObject *first, *callback, *extra_args;
@@ -2286,6 +2328,8 @@ static PyMethodDef pygobject_methods[] = {
     { "freeze_notify", (PyCFunction)pygobject_freeze_notify, METH_VARARGS },
     { "notify", (PyCFunction)pygobject_notify, METH_VARARGS },
     { "thaw_notify", (PyCFunction)pygobject_thaw_notify, METH_VARARGS },
+    { "get_data", (PyCFunction)pygobject_get_data, METH_VARARGS },
+    { "set_data", (PyCFunction)pygobject_set_data, METH_VARARGS },
     { "connect", (PyCFunction)pygobject_connect, METH_VARARGS },
     { "connect_after", (PyCFunction)pygobject_connect_after, METH_VARARGS },
     { "connect_object", (PyCFunction)pygobject_connect_object, METH_VARARGS },



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