[nautilus] list-view: disable sorting on recent and search



commit 223d57c6e76c632e59f038bd476b7499a7d42a95
Author: Carlos Soriano <csoriano gnome org>
Date:   Mon Aug 31 21:58:54 2015 +0200

    list-view: disable sorting on recent and search
    
    Following what we did in the canvas view, and what the file
    chooser is doing, we disallow the manual sorting on recent
    and search for list view as well, since it kinda defeats the
    point to allow a diferent sorting in those situations.
    
    However, for search we can still want some different sorting,
    but let's try this way and also be consistent with filechooser.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751336

 src/nautilus-list-view.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 5816003..93fcea1 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -2146,6 +2146,38 @@ get_column_order (NautilusListView *list_view)
 }
 
 static void
+check_allow_sort (NautilusListView *list_view)
+{
+        GList *column_names;
+        GList *l;
+        NautilusFile *file;
+        GtkTreeViewColumn *column;
+        gboolean allow_sorting;
+        int sort_column_id;
+
+        column_names = g_hash_table_get_keys (list_view->details->columns);
+        file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (list_view));
+        allow_sorting = ! (nautilus_file_is_in_recent (file) || nautilus_file_is_in_search (file));
+
+        for (l = column_names; l != NULL; l = l->next) {
+                column = g_hash_table_lookup (list_view->details->columns, l->data);
+                if (allow_sorting) {
+                       sort_column_id = nautilus_list_model_get_sort_column_id_from_attribute 
(list_view->details->model,
+                                                                                                
g_quark_from_string (l->data));
+                        /* Restore its original sorting id. We rely on that the keys of the hashmap
+                         * use the same string than the sort criterias */
+                        gtk_tree_view_column_set_sort_column_id (column, sort_column_id);
+                } else {
+                        /* This disables the header and any sorting capability (like shortcuts),
+                         * but leaving them interactionable so the user can still resize them */
+                        gtk_tree_view_column_set_sort_column_id (column, -1);
+                }
+        }
+
+        g_list_free (column_names);
+}
+
+static void
 set_columns_settings_from_metadata_and_preferences (NautilusListView *list_view)
 {
        char **column_order;
@@ -2217,7 +2249,8 @@ nautilus_list_view_begin_loading (NautilusFilesView *view)
        list_view = NAUTILUS_LIST_VIEW (view);
 
        set_sort_order_from_metadata_and_preferences (list_view);
-       set_columns_settings_from_metadata_and_preferences (list_view);
+        set_columns_settings_from_metadata_and_preferences (list_view);
+        check_allow_sort (list_view);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]