# HG changeset patch # User Sadrul Habib Chowdhury # Date 1190954757 0 # Node ID 66001118617dd8be411e6c604571a991e352166f # Parent dc129248eb7c3ec95035be6e126012f60db949b0 Make the row-insertion a little more robust. diff -r dc129248eb7c -r 66001118617d finch/libgnt/pygnt/gnttree.override --- 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; +} +