[nautilus/wip/antoniof/local_vs_native_fixup: 82/90] files-view: Set NAUTILUS_SCRIPT_SELECTED_FILE_PATHS in starred:/




commit c7b5e34e99b4d499b4ea7b1f2d5e0d98142c80de
Author: António Fernandes <antoniof gnome org>
Date:   Sat May 16 21:50:28 2020 +0100

    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.

 src/nautilus-files-view.c | 26 +++++++++++---------------
 1 file 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);
 


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