Updating branch refs/heads/master
         to c397903391346d2078219ba03488f2ffa27cac6c (commit)
       from ed71ded18db1b056936cb44537aea2a84e640a76 (commit)

commit c397903391346d2078219ba03488f2ffa27cac6c
Author: Danny Milosavljevic <[email protected]>
Date:   Wed Dec 29 00:34:21 2010 +0100

    fix XfconfChannel.get_properties()

 xfconf/channel.override    |   27 +++++++++++++++++++++++++++
 xfconf/tests/testwmconf.py |    9 +++++++++
 xfconf/xfconfmodule.c      |    7 +++++--
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/xfconf/channel.override b/xfconf/channel.override
index c17574f..6c89fd9 100644
--- a/xfconf/channel.override
+++ b/xfconf/channel.override
@@ -44,3 +44,30 @@ _wrap_xfconf_list_channels(PyObject *self, PyObject *args, 
PyObject *kwargs)
     Py_INCREF(Py_None);
     return Py_None;
 }
+%%
+override xfconf_channel_get_properties kwargs
+static PyObject *
+_wrap_xfconf_channel_get_properties(PyGObject *self, PyObject *args, PyObject 
*kwargs)
+{
+    static char *kwlist[] = { "property_base", NULL };
+    GHashTable *ret;
+    char* path;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
"s:XfconfChannel.get_properties", kwlist, &path))
+        return NULL;
+    ret = xfconf_channel_get_properties(XFCONF_CHANNEL(self->obj), path);
+    if (ret) {
+        GHashTableIter iter;
+        gpointer key, value;
+        PyObject* py_ret;
+        py_ret = PyDict_New();
+        g_hash_table_iter_init(&iter, ret);
+        while(g_hash_table_iter_next(&iter, &key, &value)) {
+            PyDict_SetItem(py_ret, PyString_FromString((const char*) key), 
pyg_value_as_pyobject((GValue*) value, TRUE));
+        }
+        g_hash_table_destroy(ret);
+        return py_ret;
+    }
+    Py_INCREF(Py_None);
+    return Py_None;
+}
diff --git a/xfconf/tests/testwmconf.py b/xfconf/tests/testwmconf.py
new file mode 100644
index 0000000..2b26a37
--- /dev/null
+++ b/xfconf/tests/testwmconf.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+import xfce4.xfconf
+print(xfce4.xfconf.list_channels())
+wm = xfce4.xfconf.channel_get("xfwm4")
+print(wm.get_properties("/"))
+wm = xfce4.xfconf.channel_get("xfwm4")
+print(wm.get_properties("/"))
+
diff --git a/xfconf/xfconfmodule.c b/xfconf/xfconfmodule.c
index 5cf0de0..3594597 100644
--- a/xfconf/xfconfmodule.c
+++ b/xfconf/xfconfmodule.c
@@ -11,6 +11,8 @@
 #include <pygobject.h>
 #include <pyerrors.h>
 
+#include <xfconf/xfconf.h>
+
 extern const PyMethodDef pybinding_functions[];
 extern const PyMethodDef pychannel_functions[];
 extern const PyMethodDef pyerrors_functions[];
@@ -71,8 +73,9 @@ init_xfconf(void)
 
        init_pygobject ();
        if(!xfconf_init(&error)) {
-               fprintf (stderr, "Unable to initialize xfconf: %s\n", 
error->message);
-               g_error_free(error);
+               fprintf(stderr, "Unable to initialize xfconf: %s\n", 
error->message);
+               if(pyg_error_check(&error))
+                       return;
        }
 
        my_register1 ();
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to