[Gtk-sharp-list] Sorting a TreeView with a filter

Adam Tauno Williams awilliam at whitemice.org
Fri Sep 12 20:11:30 EDT 2008


On Fri, 2008-09-12 at 13:36 -0700, Peter Johanson wrote:
> On Fri, Sep 12, 2008 at 08:13:46AM -0400, Adam Tauno Williams wrote:
> > I have a rather complicated TreeView using a ListStore.  Filtering the
> > view works,  but I'm so far unable to get sorting to work.  I have a
> > sort object connected to the model and the filter object connected to
> > the sort object;  I'm found very similair constructs in other projects
> You need to filter, and *then* sort. This prevents sorting items you'll
> end up filtering out anyways (speeds things up) and makes it so you have
> a TreeSortable actually hooked up to the Gtk.TreeView.

Yep, that helped; setting the TreeModelSort between the filter and the
view instead of between the Model and the Filter.

taskFilter = new TreeModelFilter(taskStore, null);
taskFilter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc(TaskFilter);
sortAdapter = new TreeModelSort(taskFilter);
sortAdapter.SetSortFunc(-2, OrderTasks);
view.Model = sortAdapter;

Now I get fewer warnings. :)

(Whitemice.Consonance:10699): Gtk-CRITICAL **:
gtk_tree_model_sort_set_sort_column_id: assertion `header != NULL'
failed
ColumnClicked
Sort Column:1 Order:Ascending
(Whitemice.Consonance:10699): Gtk-CRITICAL **:
gtk_tree_model_sort_set_sort_column_id: assertion `header != NULL'
failed

But the sort method still doesn't get dinged.  The message "header !=
NULL" I don't understand.



More information about the Gtk-sharp-list mailing list