[recipes] Make image loading work again for old, local recipes



commit 5be843f3bc404b520c523a7b02a8be34b529ca50
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon May 15 15:49:40 2017 -0400

    Make image loading work again for old, local recipes
    
    We used to store these as relative paths, so try the
    old location in this case. For new local recipes, we
    now store absolute paths for images.

 src/gr-image.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-image.c b/src/gr-image.c
index c018133..6c62d48 100644
--- a/src/gr-image.c
+++ b/src/gr-image.c
@@ -417,9 +417,19 @@ gr_image_load_full (GrImage         *ri,
         g_autoptr(GdkPixbuf) pixbuf = NULL;
         gboolean need_image;
         gboolean need_thumbnail;
+        g_autofree char *local_path = NULL;
 
-        if (ri->path[0] == '/') {
-                pixbuf = load_pixbuf (ri->path, width, height, fit);
+        /* We store images in local recipes with an absolute path nowadays.
+         * We used to store them as a relative path starting with images/,
+         * so try that case as well.
+         */
+        if (ri->path[0] == '/')
+                local_path = g_strdup (ri->path);
+        else if (g_str_has_prefix (ri->path, "images/"))
+                local_path = g_build_filename (get_user_data_dir (), ri->path, NULL);
+
+        if (local_path) {
+                pixbuf = load_pixbuf (local_path, width, height, fit);
                 if (pixbuf) {
                         g_debug ("Use local image for %s", ri->path);
                         callback (ri, pixbuf, data);


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