[evince] thumbnailer: Also handle trash and recent files as local files



commit f25a684dd079baa30df2ee53e12e620eabd08bfa
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 21 14:07:15 2017 +0100

    thumbnailer: Also handle trash and recent files as local files
    
    By searching for the target.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780351

 thumbnailer/evince-thumbnailer.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c
index 89e4b78..1fd8c08 100644
--- a/thumbnailer/evince-thumbnailer.c
+++ b/thumbnailer/evince-thumbnailer.c
@@ -101,6 +101,31 @@ delete_temp_file (GFile *file)
        g_object_unref (file);
 }
 
+static char *
+get_target_uri (GFile *file)
+{
+       GFileInfo *info;
+       char *target;
+
+       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_strdup (g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI));
+       g_object_unref (info);
+
+       return target;
+}
+
+static char *
+get_local_path (GFile *file)
+{
+       if (g_file_has_uri_scheme (file, "trash") != FALSE ||
+           g_file_has_uri_scheme (file, "recent") != FALSE) {
+               return get_target_uri (file);
+       }
+       return g_file_get_path (file);
+}
+
 static EvDocument *
 evince_thumbnailer_get_document (GFile *file)
 {
@@ -109,7 +134,7 @@ evince_thumbnailer_get_document (GFile *file)
        GFile      *tmp_file = NULL;
        GError     *error = NULL;
 
-       path = g_file_get_path (file);
+       path = get_local_path (file);
 
        if (!path) {
                gchar *base_name, *template;


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