[Gtk-sharp-list] a treeview sorting question

Mike Kestner mkestner@speakeasy.net
Sun, 21 Sep 2003 20:31:58 -0500


On Sat, 2003-09-20 at 13:49, Davy Brion wrote:

> I have a treeview, and when the user clicks one of the headers, i want the 
> treeview to sort all the rows based on the columnheader that was clicked 
> (this was easy to get working), but after it finishes sorting i would like it 
> to return to a state where it doesn't automatically put the newly added rows 
> in a sorted order, but rather at the end of the treeview.

My knee jerk reaction is that you probably don't really want to do
this.  ;-)  

When a column header shows a sorted indicator, users are going to expect
all rows to be sorted by that indicator.  What you are proposing is a
behavior that is inconsistent with the standard visual feedback of the
interface, and will likely confuse your users.

>   Basically, i want 
> the treeview to sort all the rows when one of the headers is clicked, but i 
> want to just sort all those rows once.  If rows are added after that 
> operation, they are added in an unsorted order until the user once again 
> presses on one of the columnheaders.  Could anyone tell me how i can do this 
> with gtk#?

If you really want to do this, you would have to implement your own
custom model, which means implementing GtkTreeModel on a GObject
subclass, and also implementing the GtkTreeSortable interface.  

Unfortunately, there is no mechanism currently in Gtk# to register
GObject interface implementations at type registration time, so the
above approach isn't possible yet with the binding.

-- 
Mike Kestner <mkestner@speakeasy.net>