I've gotten a sortable treeview working. Clicking on the columns makes it sort by ascending order, and clicking it again makes it sort by descending order. However, if I click on the column header a third time, it goes to some "unsorted" state, instead of back to ascending. I connected a function to the clicked
signal of the column, and printed out the column's get_sort_order()
, and for each click I get SORT_ASCENDING
for ascending, SORT_DESCENDING
for descending, and SORT_DESCENDING
again for the "unsorted" state. My tree view construction is something like this:
self.hsModel = gtk.TreeStore(*[c[0] for c in columns])
self.hsModelFilter = self.hsModel.filter_new()
self.hsModelSort = gtk.TreeModelSort(self.hsModelFilter)
#... define filterfunc ...
self.hsModelFilter.set_visible_func(filterfunc)
self.hsSelect = gtk.TreeView(self.hsModelSort)
cl = gtk.TreeViewColumn(ctitle, renderer, **attrcols)
cl.set_clickable(True)
cl.set_sort_column_id(COL_ACTUALTIME)
#... define sortdate ...
self.hsModelSort.set_sort_func(COL_ACTUALTIME, sortdate)
self.hsModelSort.set_sort_column_id(COL_ACTUALTIME, gtk.SORT_DESCENDING)
Any ideas?