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 87556 - Sorting TreeModel - can't disable.
Sorting TreeModel - can't disable.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.0.x
Other All
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
: 101547 101810 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-07-07 10:25 UTC by Jarek Dukat
Modified: 2011-02-04 16:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
beginning of a fix (1.32 KB, patch)
2002-12-22 17:06 UTC, Soren Sandmann Pedersen
none Details | Review

Description Jarek Dukat 2002-07-07 10:25:28 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.
Comment 1 Kristian Rietveld 2002-09-30 23:06:18 UTC
I think you mean:

gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, -1);
Comment 2 Jarek Dukat 2002-10-01 06:29:46 UTC
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.
Comment 3 Kristian Rietveld 2002-12-19 01:26:41 UTC
*** Bug 101547 has been marked as a duplicate of this bug. ***
Comment 4 Kristian Rietveld 2002-12-19 02:44:21 UTC
Moving remaining bugs to 2.2.1.
Comment 5 Kristian Rietveld 2002-12-22 16:36:15 UTC
*** Bug 101810 has been marked as a duplicate of this bug. ***
Comment 6 Soren Sandmann Pedersen 2002-12-22 17:06:00 UTC
Created attachment 13170 [details] [review]
beginning of a fix
Comment 7 Soren Sandmann Pedersen 2002-12-22 17:07:09 UTC
The patch I just attached works in my case.
Comment 8 Kristian Rietveld 2003-01-27 21:46:31 UTC
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.