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 448343 - File chooser should maintain sort state during folder switches
File chooser should maintain sort state during folder switches
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.10.x
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
Federico Mena Quintero
Depends on:
Blocks:
 
 
Reported: 2007-06-16 22:27 UTC by Josselin Mouette
Modified: 2010-08-11 16:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (2.46 KB, patch)
2007-09-15 20:26 UTC, Paolo Borelli
none Details | Review

Description Josselin Mouette 2007-06-16 22:27:09 UTC
[ forwarded from http://bugs.debian.org/428873 from Emil Nowak ]

Steps to reproduce:
1. Open filechooser dialog (ie. from gimp)
2. Click on the "Modified" column header, to sort by modify time
[a little arrow appears in this header indicating sort column]
3. Go to some sub-directory 
[Now we have two sort indicators: one o a "Name" and second on "Modified"
header]

Of course there should be one sort indicator - this previously selected (on
"Modified" column.)

Screenshot: http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=gtk2+-+sort+indicator+on+two+columns.png;att=1;bug=428873

----
This bug is perfectly reproducible for me on gtk 2.10.
Comment 1 Paolo Borelli 2007-09-15 20:26:00 UTC
Created attachment 95649 [details] [review]
patch

This patch fixes the bug here (only slightly tested though): it stores the selected sort column in impl and resets it when creating a new model when the folder changes instead of always using the NAME column
Comment 2 Emmanuele Bassi (:ebassi) 2007-09-16 12:38:36 UTC
(In reply to comment #1)
> Created an attachment (id=95649) [edit]
> patch
> 
> This patch fixes the bug here (only slightly tested though): it stores the
> selected sort column in impl and resets it when creating a new model when the
> folder changes instead of always using the NAME column

seems all right, except for:

+  if (gtk_tree_sortable_get_sort_column_id (sortable, &col, &sort_type))
+    {
+      impl->list_sort_column = col;
+      impl->list_sort_ascending = (sort_type == GTK_SORT_ASCENDING);
+    }

I would store the sort type as list_sort_type and then reuse it directly, to avoid the long ternary later:

+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (impl->sort_model),
+                                        impl->list_sort_column,
+                                        impl->list_sort_ascending ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);

with impl->list_sort_type. just for readability.
Comment 3 Kristian Rietveld 2007-10-01 09:08:37 UTC
Committed the GtkTreeView part as GtkTreeViewColumns were not properly resetting the arrow display:

2007-10-01  Kristian Rietveld  <kris@imendio.com>

        * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_update_button):
        fix up if-condition to only set the true arrow type if
        show_sort_indicator is TRUE.  (#448343, reported by Emil Nowak).


The file chooser seems to reset the sort state by creating a new sort model in load_set_model(); it is up to you guys to decide whether you want to maintain the sort state or not.  Updating subject.
Comment 4 Federico Mena Quintero 2010-08-11 16:35:33 UTC
This seems to work fine now (in GTK+ 2.18.6)