[Xfce4-commits] [apps/ristretto] 03/03: Check for thumbnails in the new location

noreply at xfce.org noreply at xfce.org
Sun Jan 18 09:23:08 CET 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository apps/ristretto.

commit a0e20e0dbb2e77182427ed1caa5a011d88500cfb
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Fri Oct 31 22:02:04 2014 +0300

    Check for thumbnails in the new location
    
    The thumbnail managing standard was updated to change the location
    where thumbnails are stored. This has been changed to
    $XDG_CACHE_HOME/thumbnails/ unless $XDG_CACHE_HOME
    isn't defined, at which point it's back to $HOME/.cache/thumbnails
    This patch looks in both places when the thumbnail is created and
    reports the first one that's found.
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 src/file.c              |   23 ++++++++++++++++++++++-
 src/properties_dialog.c |   17 ++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/file.c b/src/file.c
index 7491954..faf8740 100644
--- a/src/file.c
+++ b/src/file.c
@@ -482,7 +482,22 @@ rstto_file_get_thumbnail_path ( RsttoFile *r_file)
         checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, strlen (uri));
         filename = g_strconcat (checksum, ".png", NULL);
 
-        r_file->priv->thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
+        /* build and check if the thumbnail is in the new location */
+        r_file->priv->thumbnail_path = g_build_path ("/", g_get_user_cache_dir(), "thumbnails", "normal", filename, NULL);
+
+        if(!g_file_test (r_file->priv->thumbnail_path, G_FILE_TEST_EXISTS))
+        {
+            /* Fallback to old version */
+            g_free (r_file->priv->thumbnail_path);
+
+            r_file->priv->thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
+            if(!g_file_test (r_file->priv->thumbnail_path, G_FILE_TEST_EXISTS))
+            {
+                /* Thumbnail doesn't exist in either spot */
+                g_free (r_file->priv->thumbnail_path);
+                r_file->priv->thumbnail_path = NULL;
+            }
+        }
 
         g_free (checksum);
         g_free (filename);
@@ -507,6 +522,12 @@ rstto_file_get_thumbnail (
     thumbnailer = rstto_thumbnailer_new();
     rstto_thumbnailer_queue_file (thumbnailer, r_file);
 
+    if (NULL == thumbnail_path)
+    {
+        /* No thumbnail to return at this time */
+        return NULL;
+    }
+
     /* FIXME:
      *
      * The thumbnail should be updated on the "ready" signal
diff --git a/src/properties_dialog.c b/src/properties_dialog.c
index 77f70a8..def362a 100644
--- a/src/properties_dialog.c
+++ b/src/properties_dialog.c
@@ -436,7 +436,22 @@ properties_dialog_set_file (
         file_uri_checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, file_uri, strlen (file_uri));
         filename = g_strconcat (file_uri_checksum, ".png", NULL);
 
-        thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
+        /* build and check if the thumbnail is in the new location */
+        thumbnail_path = g_build_path ("/", g_get_user_cache_dir(), "thumbnails", "normal", filename, NULL);
+
+        if(!g_file_test (thumbnail_path, G_FILE_TEST_EXISTS))
+        {
+            /* Fallback to old version */
+            g_free (thumbnail_path);
+
+            thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
+            if(!g_file_test (thumbnail_path, G_FILE_TEST_EXISTS))
+            {
+                /* Thumbnail doesn't exist in either spot */
+                g_free (thumbnail_path);
+                thumbnail_path = NULL;
+            }
+        }
         pixbuf = gdk_pixbuf_new_from_file_at_scale (thumbnail_path, 96, 96, TRUE, NULL);
         if (NULL != pixbuf)
         {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list