[nautilus] application: open home directory on new window if searching



commit 9106fab3c083463d1a5a76e58db7c56fa6fc83bf
Author: Ernestas Kulik <ernestask src gnome org>
Date:   Tue Oct 18 06:28:50 2016 +0300

    application: open home directory on new window if searching
    
    Opening a new window in the search view results in a crash, because the
    new window does not have a view for the initial location. That can be
    worked around by pointing the new window to the home directory.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772856

 src/nautilus-application.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index b33142f..234fbb5 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -724,13 +724,24 @@ action_clone_window (GSimpleAction *action,
     NautilusWindowSlot *active_slot = NULL;
     NautilusWindow *active_window = NULL;
     GtkApplication *application = user_data;
-    g_autoptr (GFile) current_location = NULL;
+    g_autoptr (GFile) location = NULL;
+    NautilusView *current_view;
 
     active_window = NAUTILUS_WINDOW (gtk_application_get_active_window (application));
     active_slot = nautilus_window_get_active_slot (active_window);
-    current_location = nautilus_window_slot_get_location (active_slot);
+    current_view = nautilus_window_slot_get_current_view (active_slot);
 
-    nautilus_application_open_location_full (NAUTILUS_APPLICATION (application), current_location,
+    if (current_view != NULL &&
+        nautilus_view_is_searching (current_view))
+    {
+        location = g_file_new_for_path (g_get_home_dir ());
+    }
+    else
+    {
+        location = nautilus_window_slot_get_location (active_slot);
+    }
+
+    nautilus_application_open_location_full (NAUTILUS_APPLICATION (application), location,
                                              NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW, NULL, NULL, NULL);
 }
 


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