summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2020-05-16 21:50:28 +0100
committerOndrej Holy <oholy@redhat.com>2021-01-25 10:54:11 +0000
commitc7b5e34e99b4d499b4ea7b1f2d5e0d98142c80de (patch)
treedaa21ef7206fe84bb086c801ca05f44d7ee2ddd5
parent078603d269e5fb684ed400bb9bb324b16ced9eef (diff)
downloadnautilus-c7b5e34e99b4d499b4ea7b1f2d5e0d98142c80de.tar.gz
files-view: Set NAUTILUS_SCRIPT_SELECTED_FILE_PATHS in starred:/
We have been calling is_local_or_fuse() on the current directory to know if we can pass local paths for scripts in as an environment variable. This is wrong because the current directory may not be the actual location of the files. That's why a workaround has been introduced for search directories in commit 8fdd3792ed4e1fb95e6c4f2adc4c8631c27bb2d3 But the same problem still happens in the starred:/ directory. In the case of paths passed as command line parameters, we call is_local_or_fuse() directly on the files, so there is no need for any workaround for search and starred. This enhancement had been proposed in https://bugzilla.gnome.org/show_bug.cgi?id=341657, and introduced in commit 34d594099868445b1c2d4f16da3bcdf05f914100. However, this enhancement was not applied to the envar case. Let's do something equivalent now.
-rw-r--r--src/nautilus-files-view.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b5784d183..9746b5c51 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5171,7 +5171,6 @@ get_file_paths_or_uris_as_newline_delimited_string (NautilusFilesView *view,
gboolean get_paths)
{
char *path;
- char *uri;
char *result;
GString *expanding_string;
GList *node;
@@ -5179,7 +5178,10 @@ get_file_paths_or_uris_as_newline_delimited_string (NautilusFilesView *view,
expanding_string = g_string_new ("");
for (node = selection; node != NULL; node = node->next)
{
- uri = nautilus_file_get_uri (NAUTILUS_FILE (node->data));
+ NautilusFile *file = NAUTILUS_FILE (node->data);
+ g_autofree gchar *uri = NULL;
+
+ uri = nautilus_file_get_uri (file);
if (uri == NULL)
{
continue;
@@ -5187,6 +5189,12 @@ get_file_paths_or_uris_as_newline_delimited_string (NautilusFilesView *view,
if (get_paths)
{
+ if (!nautilus_file_is_local_or_fuse (file))
+ {
+ g_string_free (expanding_string, TRUE);
+ return g_strdup ("");
+ }
+
path = g_filename_from_uri (uri, NULL, NULL);
if (path != NULL)
{
@@ -5200,7 +5208,6 @@ get_file_paths_or_uris_as_newline_delimited_string (NautilusFilesView *view,
g_string_append (expanding_string, uri);
g_string_append (expanding_string, "\n");
}
- g_free (uri);
}
result = expanding_string->str;
@@ -5232,21 +5239,10 @@ get_strings_for_environment_variables (NautilusFilesView *view,
char **uri)
{
NautilusFilesViewPrivate *priv;
- char *directory_uri;
priv = nautilus_files_view_get_instance_private (view);
- directory_uri = nautilus_directory_get_uri (priv->model);
- if (nautilus_directory_is_local_or_fuse (priv->model) ||
- eel_uri_is_search (directory_uri))
- {
- *file_paths = get_file_paths_as_newline_delimited_string (view, selected_files);
- }
- else
- {
- *file_paths = g_strdup ("");
- }
- g_free (directory_uri);
+ *file_paths = get_file_paths_as_newline_delimited_string (view, selected_files);
*uris = get_file_uris_as_newline_delimited_string (view, selected_files);