diff finch/libgnt/pygnt/gnttree.override @ 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 6b16fca71f8b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/finch/libgnt/pygnt/gnttree.override	Tue Jul 17 11:09:03 2007 +0000
@@ -0,0 +1,103 @@
+/**
+ * pygnt- Python bindings for the GNT toolkit.
+ * Copyright (C) 2007 Sadrul Habib Chowdhury <sadrul@pidgin.im>
+ *
+ *   gnttree.override: overrides for the tree widget.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+%%
+headrs
+#include "common.h"
+%%
+ignore 
+gnt_tree_create_row
+gnt_tree_create_row_from_list
+%%
+override gnt_tree_get_selection_text_list noargs
+static PyObject *
+_wrap_gnt_tree_get_selection_text_list(PyGObject *self)
+{
+	GList *list = gnt_tree_get_selection_text_list(GNT_TREE(self->obj));
+	return create_pyobject_from_string_list(list);
+}
+%%
+override gnt_tree_get_rows noargs
+static PyObject *
+_wrap_gnt_tree_get_rows(PyGObject *self)
+{
+	GList *list = gnt_tree_get_rows(GNT_TREE(self->obj));
+	PyObject *py_list;
+	if (list == NULL) {
+		Py_INCREF(Py_None);
+		return Py_None;
+	}
+	if ((py_list = PyList_New(0)) == NULL) {
+		return NULL;
+	}
+	while (list) {
+		PyObject *obj = pyg_pointer_new(G_TYPE_POINTER, list->data);
+		PyList_Append(py_list, obj);
+		Py_DECREF(obj);
+		list = list->next;
+	}
+	return py_list;
+}
+%%
+override gnt_tree_add_row_after
+static PyObject *
+_wrap_gnt_tree_add_row_after(PyGObject *self, PyObject *args)
+{
+	static char *kwlist[] = {"key", "row", "parent", "bigbro", NULL};
+	PyObject *py_list;
+	gpointer key, parent, bigbro;
+	int len, i;
+	GList *list = NULL;
+	GntTreeRow *row;
+
+	if (!PyArg_ParseTuple(args,
+				"OOOO:GntTree.add_row_after",
+				&key,
+				&py_list,
+				&parent,
+				&bigbro))
+		return NULL;
+
+	len = PySequence_Length(py_list);
+	for (i = 0; i < len; i++) {
+		PyObject *item = PySequence_GetItem(py_list, i);
+		if (!pygobject_check(item, &PyString_Type)) {
+			PyErr_SetString(PyExc_TypeError,
+					"column_list members must be strings");
+			Py_DECREF(item);
+			return NULL;
+		}
+		list = g_list_prepend(list, PyString_AsString(item));
+		Py_DECREF(item);
+	}
+
+	list = g_list_reverse(list);
+	row = gnt_tree_create_row_from_list(GNT_TREE(self->obj), list);
+	gnt_tree_add_row_after(GNT_TREE(self->obj),
+			key,
+			row,
+			parent, bigbro);
+	g_list_free(list);
+
+	Py_INCREF(Py_None);
+	return Py_None;
+}
+