Mercurial > pidgin
changeset 20711:66001118617d
Make the row-insertion a little more robust.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 28 Sep 2007 04:45:57 +0000 |
parents | dc129248eb7c |
children | f62eb68c9dda |
files | finch/libgnt/pygnt/gnttree.override |
diffstat | 1 files changed, 37 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/libgnt/pygnt/gnttree.override Fri Sep 28 04:44:59 2007 +0000 +++ b/finch/libgnt/pygnt/gnttree.override Fri Sep 28 04:45:57 2007 +0000 @@ -62,13 +62,14 @@ { static char *kwlist[] = {"key", "row", "parent", "bigbro", NULL}; PyObject *py_list; - gpointer key, parent, bigbro; + gpointer key, parent, bigbro = NULL; int len, i; GList *list = NULL; GntTreeRow *row; + gboolean insert_last = FALSE; if (!PyArg_ParseTuple(args, - "OOOO:GntTree.add_row_after", + "OOO|O:GntTree.add_row_after", &key, &py_list, &parent, @@ -92,13 +93,20 @@ parent = NULL; if (bigbro == Py_None) bigbro = NULL; + else if (bigbro == NULL) + insert_last = TRUE; + + Py_INCREF((PyObject*)key); 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); + if (insert_last) + gnt_tree_add_row_last(GNT_TREE(self->obj), + key, row, parent); + else + gnt_tree_add_row_after(GNT_TREE(self->obj), + key, row, + parent, bigbro); g_list_free(list); Py_INCREF(Py_None); @@ -179,4 +187,27 @@ Py_INCREF(Py_None); return Py_None; } +%% +override gnt_tree_set_compare_func +static PyObject * +_wrap_gnt_tree_set_compare_func(PyGObject *self, PyObject *args) +{ + static char *kwlist[] = {"compare_func", NULL}; + PyGObject *compare; + if (!PyArg_ParseTuple(args, "O:GntTree.set_compare_func", &compare)) { + return NULL; + } + + if (!PyCallable_Check(compare)) { + PyErr_SetString(PyExc_TypeError, "the callback must be callable ... doh!"); + return NULL; + } + + Py_INCREF(compare); + gnt_tree_set_compare_func(GNT_TREE(self->obj), (GCompareFunc)compare->obj); + + Py_INCREF(Py_None); + return Py_None; +} +