GNOME Bugzilla – Bug 780568
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID does not work for gtk_tree_sortable_set_sort_column_id
Last modified: 2018-05-02 18:19:57 UTC
per documentation here... https://developer.gnome.org/gtk3/stable/GtkTreeSortable.html#GTK-TREE-SORTABLE-UNSORTED-SORT-COLUMN-ID:CAPS And per documentation here... https://developer.gnome.org/gtk3/3.22/GtkTreeSortable.html#GTK-TREE-SORTABLE-UNSORTED-SORT-COLUMN-ID:CAPS GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID should be able to disable sorting when used with gtk_tree_view_column_set_sort_column_id, but instead it does not work, we get the error message... Gtk-CRITICAL **:gtk_tree_view_column_set_sort_column_id: assertion 'sort_column_id >= -1' failed This is because in source code... file: gtk+-3.22.0/gtk/gtktreeviewcolumn.c" function: gtk_tree_view_column_set_sort_column_id line: 2641 the following line of... g_return_if_fail (sort_column_id >= -1); should actually be... g_return_if_fail (sort_column_id >= -2); It is desirable for this feature to work, because users may want to disable sorting on a treeview that was previously sorted. Simply changing the -1 to -2 on line 2641 of file /gtk/gtktreeviewcolumn.c should fix the issue.
also it looks like line 2651 would need changed... from... if (sort_column_id == -1) to... if (sort_column_id == -1 || sort_column_id == -2) those two changes I believe should fix the issue
That is a misunderstanding. GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID is not something you can pass to gtk_tree_view_column_set_sort_column_id - you can't click a header to 'unsort' a list
I think my bug report was not clear, I am Not trying to click a sort header to make it unsortable, I and trying to disable the sort header so the treeview is Not sortable. Once you set make the control sortable, it seams you will never have the ability to remove the sort header and make it not sortable again. I have a control which I load data to. I want that data sortable. Later I clear the list, and load different data to it, I DON'T want that data sortable. How can I disable sorting on a treeview that was previously sort-able? This does not work... gtk_tree_view_column_set_sort_column_id(column,GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); Thank you in advance!
--edited--- [chagned "remove" in previous comment to "disable" I think my bug report was not clear, I am Not trying to click a sort header to make it unsortable, I and trying to disable the sort header so the treeview is Not sortable. Once you set make the control sortable, it seams you will never have the ability to "disable" the sort header and make it not sortable again. I have a control which I load data to. I want that data sortable. Later I clear the list, and load different data to it, I DON'T want that data sortable. How can I disable sorting on a treeview that was previously sort-able? This does not work... gtk_tree_view_column_set_sort_column_id(column,GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); Thank you in advance!
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/794.