summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@src.gnome.org>2016-10-17 16:33:16 +0300
committerErnestas Kulik <ernestask@src.gnome.org>2016-11-11 13:11:01 +0200
commit37d6da00c799fe2cf475cc6ae80f95a03064b1bf (patch)
tree55db3b85f5d4a75fd001b626399a8fcdec569bad
parentc4874aaafb8261e81240f8d39f538a6f4ce2514c (diff)
downloadnautilus-37d6da00c799fe2cf475cc6ae80f95a03064b1bf.tar.gz
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
-rw-r--r--src/nautilus-application.c31
-rw-r--r--src/resources/gtk/menus.ui2
2 files changed, 21 insertions, 12 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index fa07dda4a..b33142f43 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 5385406ac..a7cf02484 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>