diff finch/libgnt/pygnt/common.c @ 18556:5e1412f4e67a

Do some work to make pygnt more useful. The dbus-gnt script works fairly well now.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 17 Jul 2007 11:09:03 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/finch/libgnt/pygnt/common.c	Tue Jul 17 11:09:03 2007 +0000
@@ -0,0 +1,24 @@
+#include "common.h"
+
+PyObject *
+create_pyobject_from_string_list(GList *list)
+{
+	PyObject *py_list;
+	if (list == NULL) {
+		Py_INCREF(Py_None);
+		return Py_None;
+	}
+	if ((py_list = PyList_New(0)) == NULL) {
+		g_list_foreach(list, (GFunc)g_free, NULL);
+		g_list_free(list);
+		return NULL;
+	}
+	while (list) {
+		PyObject *obj = PyString_FromString(list->data);
+		PyList_Append(py_list, obj);
+		Py_DECREF(obj);
+		g_free(list->data);
+		list = g_list_delete_link(list, list);
+	}
+	return py_list;
+}