[nautilus] application: add “clone-window” action



commit 37d6da00c799fe2cf475cc6ae80f95a03064b1bf
Author: Ernestas Kulik <ernestask src gnome org>
Date:   Mon Oct 17 16:33:16 2016 +0300

    application: add “clone-window” action
    
    Opening a new window from the shell should open the home directory, as
    the intent of the user is not clear and it is thus the safest
    assumption (it preserves the old behavior). This requires splitting the
    “new-window” action in half: “new-window” for use from the shell and
    “clone-window” for use from the application.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772856

 src/nautilus-application.c |   31 ++++++++++++++++++++-----------
 src/resources/gtk/menus.ui |    2 +-
 2 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index fa07dda..b33142f 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -705,25 +705,33 @@ action_new_window (GSimpleAction *action,
                    GVariant      *parameter,
                    gpointer       user_data)
 {
+    NautilusApplication *application;
+    g_autoptr (GFile) home = NULL;
+
+    application = NAUTILUS_APPLICATION (user_data);
+    home = g_file_new_for_path (g_get_home_dir ());
+
+    nautilus_application_open_location_full (application, home,
+                                             NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW,
+                                             NULL, NULL, NULL);
+}
+
+static void
+action_clone_window (GSimpleAction *action,
+                     GVariant      *parameter,
+                     gpointer       user_data)
+{
     NautilusWindowSlot *active_slot = NULL;
     NautilusWindow *active_window = NULL;
     GtkApplication *application = user_data;
-    g_autoptr (GFile) current_location;
+    g_autoptr (GFile) current_location = NULL;
 
     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 ());
-    }
+    active_slot = nautilus_window_get_active_slot (active_window);
+    current_location = nautilus_window_slot_get_location (active_slot);
 
     nautilus_application_open_location_full (NAUTILUS_APPLICATION (application), current_location,
                                              NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW, NULL, NULL, NULL);
-
 }
 
 static void
@@ -849,6 +857,7 @@ action_show_help_overlay (GSimpleAction *action,
 static GActionEntry app_entries[] =
 {
     { "new-window", action_new_window, NULL, NULL, NULL },
+    { "clone-window", action_clone_window, NULL, NULL, NULL },
     { "preferences", action_preferences, NULL, NULL, NULL },
     { "show-hide-sidebar", NULL, NULL, "true", action_show_hide_sidebar },
     { "about", action_about, NULL, NULL, NULL },
diff --git a/src/resources/gtk/menus.ui b/src/resources/gtk/menus.ui
index 5385406..a7cf024 100644
--- a/src/resources/gtk/menus.ui
+++ b/src/resources/gtk/menus.ui
@@ -2,7 +2,7 @@
   <menu id="app-menu">
     <section>
       <item>
-       <attribute name="action">app.new-window</attribute>
+       <attribute name="action">app.clone-window</attribute>
        <attribute name="label" translatable="yes">New _Window</attribute>
        <attribute name="accel">&lt;Primary&gt;n</attribute>
       </item>


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