GNOME Bugzilla – Bug 87556
Sorting TreeModel - can't disable.
Last modified: 2011-02-04 16:11:56 UTC
There is no way to disable model sorting. One must use dirty hacks like: list_store->sort_column_id = -2; 'sort_column_id' is marked as private, but there is no other method to do it.
I think you mean: gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, -1);
No, it won't work because gtk_tree_sortable_set_sort_column_id checks the argument and it ignores it if it is -1, so you can't go back from sorted to unsorted state. It is a part of gtk_tree_store_set_sort_column_id: if (sort_column_id != -1) { GtkTreeDataSortHeader *header = NULL; header = _gtk_tree_data_list_get_header (tree_store->sort_list, sort_colum /* We want to make sure that we have a function */ g_return_if_fail (header != NULL); g_return_if_fail (header->func != NULL); } else { g_return_if_fail (tree_store->default_sort_func != NULL); } As you can see it only will work if you add default sort function. But you can't change column into not sorted at all.
*** Bug 101547 has been marked as a duplicate of this bug. ***
Moving remaining bugs to 2.2.1.
*** Bug 101810 has been marked as a duplicate of this bug. ***
Created attachment 13170 [details] [review] beginning of a fix
The patch I just attached works in my case.
Soeren's patch is right. I committed it with a slight change, I added a line to make the button non-clickable. You should indeed be setting the column's sort_column_id to -1 in order to disable sorting. Thanks go to Soeren for figuring this out (I start to understand all this sorting stuff now :). Fixed on HEAD/stable.