[nautilus/gnome-3-26] Prefer local (file://) URIs than native ones (smb:// for example).
- From: Ernestas Kulik <ernestask src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-26] Prefer local (file://) URIs than native ones (smb:// for example).
- Date: Sat, 24 Mar 2018 18:49:58 +0000 (UTC)
commit 1fce6830b239d5a259f5f79568b74af6ac5ba9d5
Author: Colin Leroy <colin colino net>
Date: Fri Sep 8 10:14:11 2017 +0200
Prefer local (file://) URIs than native ones (smb:// for example).
This allows drag and dropping files from network shares in Thunar
to other applications that don't handle native URIs (Claws Mail,
Chromium, Firefox...)
src/nautilus-dnd.c | 8 +++++++-
src/nautilus-file-utilities.c | 21 +++++++++++++++++++++
src/nautilus-file-utilities.h | 2 ++
3 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-dnd.c b/src/nautilus-dnd.c
index 4b1d016d0..575d12f2a 100644
--- a/src/nautilus-dnd.c
+++ b/src/nautilus-dnd.c
@@ -709,7 +709,13 @@ cache_one_item (const char *uri,
NautilusDragSelectionItem *item;
item = nautilus_drag_selection_item_new ();
- item->uri = g_strdup (uri);
+ item->uri = nautilus_uri_to_native_uri (uri);
+
+ if (item->uri == NULL)
+ {
+ item->uri = g_strdup (uri);
+ }
+
item->file = nautilus_file_get_by_uri (uri);
item->icon_x = x;
item->icon_y = y;
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
index 59add50e4..78d693eca 100644
--- a/src/nautilus-file-utilities.c
+++ b/src/nautilus-file-utilities.c
@@ -1396,3 +1396,24 @@ nautilus_file_can_rename_files (GList *files)
return TRUE;
}
+
+/* Try to get a native file:// URI instead of any other GVFS
+ * scheme, for interoperability with apps only handling file:// URIs.
+ */
+gchar *
+nautilus_uri_to_native_uri (const gchar *uri)
+{
+ g_autoptr (GFile) file = NULL;
+ g_autofree gchar *path = NULL;
+
+ file = g_file_new_for_uri (uri);
+ path = g_file_get_path (file);
+
+ if (path != NULL)
+ {
+ return g_filename_to_uri (path, NULL, NULL);
+ }
+
+ return NULL;
+}
+
diff --git a/src/nautilus-file-utilities.h b/src/nautilus-file-utilities.h
index da165cd73..e9b9a2218 100644
--- a/src/nautilus-file-utilities.h
+++ b/src/nautilus-file-utilities.h
@@ -123,4 +123,6 @@ gboolean nautilus_file_can_rename_files (GList *files);
GList * nautilus_file_list_from_uri_list (GList *uris);
+gchar * nautilus_uri_to_native_uri (const gchar *uri);
+
#endif /* NAUTILUS_FILE_UTILITIES_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]