summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-10-16 17:21:57 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-10-16 17:30:36 +0200
commitc34a879648053710fd22043230630b5a32681a95 (patch)
treeec96f83764bd26e9a85843ff1e9df4480c6de107
parenteabecc128c314c63592261d996c1886895616d92 (diff)
downloadnautilus-c34a879648053710fd22043230630b5a32681a95.tar.gz
application: specify cwd
We are managing all command line options in the main instance. That works always correctly except when resolving relative paths, which are relative the local instance, not the main one. To fix it, set a "cwd" option in the local instance to ensure the relative file paths are resolved in the main instance based on the local instance. https://bugzilla.gnome.org/show_bug.cgi?id=756688
-rw-r--r--src/nautilus-application.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 1b37fc3a5..218769292 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -796,7 +796,15 @@ nautilus_application_handle_file_args (NautilusApplication *self,
if (remaining) {
for (idx = 0; remaining[idx] != NULL; idx++) {
- file = g_file_new_for_commandline_arg (remaining[idx]);
+ gchar *cwd;
+
+ g_variant_dict_lookup (options, "cwd", "s", &cwd);
+ if (cwd == NULL) {
+ file = g_file_new_for_commandline_arg (remaining[idx]);
+ } else {
+ file = g_file_new_for_commandline_arg_and_cwd (remaining[idx], cwd);
+ g_free (cwd);
+ }
g_ptr_array_add (file_array, file);
}
} else if (g_variant_dict_contains (options, "new-window")) {
@@ -1216,6 +1224,23 @@ nautilus_application_window_removed (GtkApplication *app,
}
}
+/* Manage the local instance command line options. This is only necessary to
+ * resolv correctly relative paths, since if the main instance resolv them in
+ * command_line, it will do it with its current cwd, which may not be correct for the
+ * non main GApplication instance */
+static gint
+nautilus_application_handle_local_options (GApplication *app,
+ GVariantDict *options)
+{
+ gchar *cwd;
+
+ cwd = g_get_current_dir ();
+ g_variant_dict_insert (options, "cwd", "s", cwd);
+ g_free (cwd);
+
+ return -1;
+}
+
static void
nautilus_application_class_init (NautilusApplicationClass *class)
{
@@ -1234,6 +1259,7 @@ nautilus_application_class_init (NautilusApplicationClass *class)
application_class->dbus_unregister = nautilus_application_dbus_unregister;
application_class->open = nautilus_application_open;
application_class->command_line = nautilus_application_command_line;
+ application_class->handle_local_options = nautilus_application_handle_local_options;
gtkapp_class = GTK_APPLICATION_CLASS (class);
gtkapp_class->window_added = nautilus_application_window_added;