[nautilus-sendto] main: Fix handling of files in Recent or in the Trash
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-sendto] main: Fix handling of files in Recent or in the Trash
- Date: Mon, 29 Feb 2016 17:19:00 +0000 (UTC)
commit 34b6876587506c57aba0c6ad98fb7f5e14229e6b
Author: Bastien Nocera <hadess hadess net>
Date: Mon Feb 29 18:17:22 2016 +0100
main: Fix handling of files in Recent or in the Trash
Look up the target URI for files that fail to return a local file path
for g_file_get_path() calls.
https://bugzilla.gnome.org/show_bug.cgi?id=758988
src/nautilus-sendto.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-sendto.c b/src/nautilus-sendto.c
index 8d618b9..c7963e2 100644
--- a/src/nautilus-sendto.c
+++ b/src/nautilus-sendto.c
@@ -434,6 +434,34 @@ escape_ampersands_and_commas (const char *url)
return str;
}
+static char *
+get_target_filename (GFile *file)
+{
+ GFileInfo *info;
+ const char *target;
+ GFile *new_file;
+ char *ret;
+
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI, G_FILE_QUERY_INFO_NONE, NULL,
NULL);
+ if (info == NULL)
+ return NULL;
+
+ target = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
+ if (target == NULL) {
+ g_object_unref (info);
+ return NULL;
+ }
+
+ new_file = g_file_new_for_uri (target);
+ g_object_unref (info);
+
+ ret = g_file_get_path (new_file);
+ g_object_unref (new_file);
+
+ return ret;
+}
+
+
static void
nautilus_sendto_init (NautilusSendto *nst)
{
@@ -450,8 +478,11 @@ nautilus_sendto_init (NautilusSendto *nst)
file = g_file_new_for_commandline_arg (filenames[i]);
filename = g_file_get_path (file);
if (filename == NULL) {
- g_object_unref (file);
- continue;
+ filename = get_target_filename (file);
+ if (filename == NULL) {
+ g_object_unref (file);
+ continue;
+ }
}
/* Get the mime-type, and whether the file is readable */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]