[nautilus/gnome-3-20] files-view: select first on loading only if no previous selection



commit bf91cdb0dd108224602c3e98e23bd316c19263da
Author: Carlos Soriano <csoriano gnome org>
Date:   Thu Mar 3 11:07:47 2016 +0100

    files-view: select first on loading only if no previous selection
    
    Avoid to select the first file if there is a selection already.
    Although we were checking for the pending selection, it could be that
    there is a selection already because the user selected a file.
    
    This will be needed also for an upcoming patch, where we always select
    the first file on displaying new files, even if the directory is not
    fully loaded.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762595

 src/nautilus-files-view.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 056dd67..f91885d 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3165,6 +3165,7 @@ static void
 done_loading (NautilusFilesView *view,
               gboolean           all_files_seen)
 {
+        GList *pending_selection;
         GList *selection;
         gboolean do_reveal = FALSE;
 
@@ -3181,19 +3182,26 @@ done_loading (NautilusFilesView *view,
                 schedule_update_status (view);
                 reset_update_interval (view);
 
-                selection = view->details->pending_selection;
+                pending_selection = view->details->pending_selection;
+                selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
 
-                if (nautilus_view_is_searching (NAUTILUS_VIEW (view)) && all_files_seen) {
+                if (nautilus_view_is_searching (NAUTILUS_VIEW (view)) &&
+                    all_files_seen && !selection) {
                         nautilus_files_view_select_first (view);
                         do_reveal = TRUE;
-                } else if (selection != NULL && all_files_seen) {
+                } else if (pending_selection != NULL && all_files_seen) {
                         view->details->pending_selection = NULL;
 
                         nautilus_files_view_call_set_selection (view, selection);
-                        g_list_free_full (selection, g_object_unref);
                         do_reveal = TRUE;
                 }
 
+                if (selection)
+                        g_list_free_full (selection, g_object_unref);
+
+                if (pending_selection)
+                        g_list_free_full (pending_selection, g_object_unref);
+
                 if (do_reveal) {
                         if (NAUTILUS_IS_LIST_VIEW (view)) {
                                 /* HACK: We should be able to directly call reveal_selection here,


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