[gnome-software] Show a blurred low-resolution screenshot while loading the HiDPI one
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Show a blurred low-resolution screenshot while loading the HiDPI one
- Date: Fri, 24 Oct 2014 12:53:32 +0000 (UTC)
commit bc8ba3c22cd87dfb074ba5fb187e66fa79f9b1b8
Author: Richard Hughes <richard hughsie com>
Date: Fri Oct 24 13:50:20 2014 +0100
Show a blurred low-resolution screenshot while loading the HiDPI one
Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=738854
configure.ac | 2 +-
src/gs-screenshot-image.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5470f81..4f1557d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ dnl - Check library dependencies
dnl ---------------------------------------------------------------------------
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.14.1 gio-unix-2.0)
PKG_CHECK_MODULES(PACKAGEKIT, packagekit-glib2 >= 1.0.0)
-PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.2.4)
+PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.3.2)
PKG_CHECK_MODULES(SQLITE, sqlite3)
PKG_CHECK_MODULES(SOUP, libsoup-2.4)
PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5)
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index bd81053..a96b993 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -193,6 +193,46 @@ as_screenshot_show_image (GsScreenshotImage *ssimg)
}
/**
+ * gs_screenshot_image_show_blurred:
+ **/
+static void
+gs_screenshot_image_show_blurred (GsScreenshotImage *ssimg,
+ const gchar *filename_thumb)
+{
+ AsImage *im;
+ GdkPixbuf *pb = NULL;
+ GsScreenshotImagePrivate *priv;
+ gboolean ret;
+
+ priv = gs_screenshot_image_get_instance_private (ssimg);
+
+ /* create an helper which can do the blurring for us */
+ im = as_image_new ();
+ ret = as_image_load_filename (im, filename_thumb, NULL);
+ if (!ret)
+ goto out;
+ pb = as_image_save_pixbuf (im,
+ priv->width * priv->scale,
+ priv->height * priv->scale,
+ AS_IMAGE_SAVE_FLAG_BLUR);
+ if (pb == NULL)
+ goto out;
+
+ if (g_strcmp0 (priv->current_image, "image1") == 0) {
+ gs_image_set_from_pixbuf_with_scale (GTK_IMAGE (priv->image1),
+ pb, priv->scale);
+ } else {
+ gs_image_set_from_pixbuf_with_scale (GTK_IMAGE (priv->image2),
+ pb, priv->scale);
+ }
+out:
+ if (im != NULL)
+ g_object_unref (im);
+ if (pb != NULL)
+ g_object_unref (pb);
+}
+
+/**
* gs_screenshot_image_complete_cb:
**/
static void
@@ -339,6 +379,7 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
const gchar *url;
gchar *basename = NULL;
gchar *cachedir = NULL;
+ gchar *cachedir2 = NULL;
gchar *sizedir = NULL;
gint rc;
@@ -399,6 +440,19 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
goto out;
}
+ /* can we load a blurred smaller version of this straight away */
+ if (priv->width > AS_IMAGE_THUMBNAIL_WIDTH &&
+ priv->height > AS_IMAGE_THUMBNAIL_HEIGHT) {
+ cachedir2 = g_build_filename (priv->cachedir,
+ "gnome-software",
+ "screenshots",
+ "112x63",
+ basename,
+ NULL);
+ if (g_file_test (cachedir2, G_FILE_TEST_EXISTS))
+ gs_screenshot_image_show_blurred (ssimg, cachedir2);
+ }
+
/* download file */
g_debug ("downloading %s to %s", url, priv->filename);
base_uri = soup_uri_new (url);
@@ -423,6 +477,7 @@ out:
g_free (basename);
g_free (sizedir);
g_free (cachedir);
+ g_free (cachedir2);
if (base_uri != NULL)
soup_uri_free (base_uri);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]