[gnome-software/gnome-3-20] trivial: Load screenshots directly if their URLs point to local files



commit e6f9d0615536cdd3877b7131a49bd009a48bf2b8
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Wed Apr 6 16:44:46 2016 +0100

    trivial: Load screenshots directly if their URLs point to local files

 src/gs-screenshot-image.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index e2f3b76..b72dda1 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -379,7 +379,17 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
                gs_screenshot_image_set_error (ssimg, _("Screenshot size not found"));
                return;
        }
+
+       /* check if the URL points to a local file */
        url = as_image_get_url (im);
+       if (g_str_has_prefix (url, "file://")) {
+               ssimg->filename = g_strdup (url + 7);
+               if (g_file_test (ssimg->filename, G_FILE_TEST_EXISTS)) {
+                       as_screenshot_show_image (ssimg);
+                       return;
+               }
+       }
+
        basename = gs_screenshot_get_cachefn_for_url (url);
        if (ssimg->width == G_MAXUINT || ssimg->height == G_MAXUINT) {
                sizedir = g_strdup ("unknown");


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