[nautilus] application: Launch new window in the current directory



commit 43bd93ed4db63bc4ceac838e25e830ead77194ff
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Oct 13 14:12:33 2016 +0200

    application: Launch new window in the current directory
    
    When pressing Control+N, Nautilus should open the new window in the
    same location as the current open one and fallback to the home
    directory otherwise.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772856

 src/nautilus-application.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 9c1a78c..b80c60a 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -707,14 +707,25 @@ action_new_window (GSimpleAction *action,
                    GVariant      *parameter,
                    gpointer       user_data)
 {
+    NautilusWindowSlot *active_slot = NULL;
+    NautilusWindow *active_window = NULL;
     GtkApplication *application = user_data;
-    GFile *home;
+    g_autoptr (GFile) current_location;
+
+    active_window = NAUTILUS_WINDOW (gtk_application_get_active_window (application));
+    if (active_window)
+    {
+        active_slot = nautilus_window_get_active_slot (active_window);
+        current_location = nautilus_window_slot_get_location (active_slot);
+    }
+    else
+    {
+        current_location = g_file_new_for_path (g_get_home_dir ());
+    }
 
-    home = g_file_new_for_path (g_get_home_dir ());
-    nautilus_application_open_location_full (NAUTILUS_APPLICATION (application), home,
+    nautilus_application_open_location_full (NAUTILUS_APPLICATION (application), current_location,
                                              NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW, NULL, NULL, NULL);
 
-    g_object_unref (home);
 }
 
 static void


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