[nautilus/wip/antoniof/local_vs_native_fixup: 149/157] files-view: Set NAUTILUS_SCRIPT_SELECTED_FILE_PATHS in starred:/
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/local_vs_native_fixup: 149/157] files-view: Set NAUTILUS_SCRIPT_SELECTED_FILE_PATHS in starred:/
- Date: Mon, 14 Dec 2020 19:00:50 +0000 (UTC)
commit 919d960da953a4dffc4e90fd673ce04a91bbde30
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 b845245ac..bcec8562c 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5168,7 +5168,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;
@@ -5176,7 +5175,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;
@@ -5184,6 +5186,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)
{
@@ -5197,7 +5205,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;
@@ -5229,21 +5236,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]