After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 780568 - GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID does not work for gtk_tree_sortable_set_sort_column_id
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID does not work for gtk_tree_sortable...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
unspecified
Other All
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2017-03-27 00:27 UTC by 12oClocker
Modified: 2018-05-02 18:19 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description 12oClocker 2017-03-27 00:27:24 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.
Comment 1 12oClocker 2017-03-27 00:53:10 UTC
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
Comment 2 Matthias Clasen 2017-03-30 20:14:07 UTC
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
Comment 3 12oClocker 2017-11-10 14:54:42 UTC
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!
Comment 4 12oClocker 2017-11-10 14:56:07 UTC
--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!
Comment 5 GNOME Infrastructure Team 2018-05-02 18:19:57 UTC
-- 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.