[Galago-commits] r2766 - in trunk/notify-python: . src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Mon Apr 24 23:13:38 PDT 2006
Author: chipx86
Date: 2006-04-24 23:13:36 -0700 (Mon, 24 Apr 2006)
New Revision: 2766
Modified:
trunk/notify-python/ChangeLog
trunk/notify-python/src/pynotify.override
Log:
Wrap notify_get_server_caps() and notify_get_server_info().
Modified: trunk/notify-python/ChangeLog
===================================================================
--- trunk/notify-python/ChangeLog 2006-04-25 06:04:14 UTC (rev 2765)
+++ trunk/notify-python/ChangeLog 2006-04-25 06:13:36 UTC (rev 2766)
@@ -0,0 +1,4 @@
+Mon Apr 24 23:13:16 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/pynotify.override:
+ - Wrap notify_get_server_caps() and notify_get_server_info().
Modified: trunk/notify-python/src/pynotify.override
===================================================================
--- trunk/notify-python/src/pynotify.override 2006-04-25 06:04:14 UTC (rev 2765)
+++ trunk/notify-python/src/pynotify.override 2006-04-25 06:13:36 UTC (rev 2766)
@@ -3,6 +3,67 @@
#include <Python.h>
#include <libnotify/notify.h>
#include "pygobject.h"
+
+static PyObject *
+pygalago_wrap_gobj_list(GList *list)
+{
+ GList *l;
+ PyObject *item, *ret;
+
+ ret = PyList_New(0);
+
+ if (ret == NULL)
+ return NULL;
+
+ for (l = list; l != NULL; l = l->next)
+ {
+ item = pygobject_new((GObject *)l->data);
+
+ if (item == NULL)
+ {
+ Py_DECREF(ret);
+ return NULL;
+ }
+
+ PyList_Append(ret, item);
+ Py_DECREF(item);
+ }
+
+ return ret;
+}
+
+GList *
+pygalago_unwrap_gobj_list(PyObject *py_items, PyTypeObject *type,
+ gboolean *ok)
+{
+ int len, i;
+ GList *items;
+
+ *ok = TRUE;
+
+ len = PyList_Size(py_items);
+
+ for (i = 0; i < len; i++)
+ {
+ PyObject *item = PyList_GetItem(py_items, i);
+
+ if (!pygobject_check(item, type))
+ {
+ char *err = g_strdup_printf("list item not a %s", type->tp_name);
+
+ PyErr_SetString(PyExc_TypeError, err);
+
+ g_free(err);
+ g_list_free(items);
+ *ok = FALSE;
+ return NULL;
+ }
+
+ items = g_list_append(items, pygobject_get(item));
+ }
+
+ return items;
+}
%%
modulename pynotify
%%
@@ -12,4 +73,41 @@
ignore-glob
*_get_type
%%
+override notify_get_server_caps
+static PyObject *
+_wrap_notify_get_server_caps(PyObject *self)
+{
+ return pygalago_wrap_gobj_list(notify_get_server_caps());
+}
+%%
+override notify_get_server_info
+static PyObject *
+_wrap_notify_get_server_info(PyObject *self)
+{
+ char *name;
+ char *vendor;
+ char *version;
+ char *spec_version;
+ PyObject *dict;
+
+ if (!notify_get_server_info(&name, &vendor, &version, &spec_version))
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ dict = PyDict_New();
+ PyDict_SetItemString(dict, "name", PyString_FromString(name));
+ PyDict_SetItemString(dict, "vendor", PyString_FromString(vendor));
+ PyDict_SetItemString(dict, "version", PyString_FromString(version));
+ PyDict_SetItemString(dict, "spec-version",
+ PyString_FromString(spec_version));
+
+ g_free(name);
+ g_free(vendor);
+ g_free(version);
+ g_free(spec_version);
+
+ return dict;
+}
// vim: ft=c
More information about the galago-commits
mailing list