[gnome-software/gnome-3-16] Avoid scaled up fonts on non-hidpi displays



commit ed18d653fb166edacc4ffcff06fcf0482100912f
Author: Kalev Lember <kalevlember gmail com>
Date:   Fri May 15 16:42:24 2015 +0200

    Avoid scaled up fonts on non-hidpi displays
    
    Font screenshots have only one (hidpi) size in the metadata. This commit
    makes sure that we downscale the font images on non-hidpi displays.

 src/gs-screenshot-image.c |   22 ++++++++++++++++++++--
 src/gs-screenshot-image.h |    3 +++
 src/gs-shell-details.c    |    5 +++--
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index d0d13c7..59479ae 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -46,6 +46,7 @@ struct _GsScreenshotImagePrivate
        gchar           *cachedir;
        gchar           *filename;
        const gchar     *current_image;
+       gboolean         use_desktop_background;
        guint            width;
        guint            height;
        gint             scale;
@@ -111,13 +112,17 @@ gs_screenshot_image_get_desktop_pixbuf (GsScreenshotImage *ssimg)
  * gs_screenshot_image_use_desktop_background:
  **/
 static gboolean
-gs_screenshot_image_use_desktop_background (GdkPixbuf *pixbuf)
+gs_screenshot_image_use_desktop_background (GsScreenshotImage *ssimg, GdkPixbuf *pixbuf)
 {
+       GsScreenshotImagePrivate *priv = gs_screenshot_image_get_instance_private (ssimg);
        _cleanup_object_unref_ AsImage *im = NULL;
 
        /* nothing to show, means no background mode */
        if (pixbuf == NULL)
                return FALSE;
+       /* background mode explicitly disabled */
+       if (!priv->use_desktop_background)
+               return FALSE;
 
        /* use a temp AsImage */
        im = as_image_new ();
@@ -147,7 +152,7 @@ as_screenshot_show_image (GsScreenshotImage *ssimg)
                                                            priv->height * priv->scale,
                                                            FALSE, NULL);
                if (pixbuf != NULL) {
-                       if (gs_screenshot_image_use_desktop_background (pixbuf)) {
+                       if (gs_screenshot_image_use_desktop_background (ssimg, pixbuf)) {
                                pixbuf_bg = gs_screenshot_image_get_desktop_pixbuf (ssimg);
                                if (pixbuf_bg == NULL) {
                                        pixbuf_bg = g_object_ref (pixbuf);
@@ -345,6 +350,18 @@ gs_screenshot_image_set_size (GsScreenshotImage *ssimg,
 }
 
 /**
+ * gs_screenshot_image_set_use_desktop_background:
+ **/
+void
+gs_screenshot_image_set_use_desktop_background (GsScreenshotImage *ssimg,
+                                                gboolean use_desktop_background)
+{
+       GsScreenshotImagePrivate *priv = gs_screenshot_image_get_instance_private (ssimg);
+       g_return_if_fail (GS_IS_SCREENSHOT_IMAGE (ssimg));
+       priv->use_desktop_background = use_desktop_background;
+}
+
+/**
  * gs_screenshot_image_load_async:
  **/
 void
@@ -499,6 +516,7 @@ gs_screenshot_image_init (GsScreenshotImage *ssimg)
        AtkObject *accessible;
 
        ssimg->priv = gs_screenshot_image_get_instance_private (ssimg);
+       ssimg->priv->use_desktop_background = TRUE;
 
        gtk_widget_set_has_window (GTK_WIDGET (ssimg), FALSE);
        gtk_widget_init_template (GTK_WIDGET (ssimg));
diff --git a/src/gs-screenshot-image.h b/src/gs-screenshot-image.h
index 820d038..5bbded0 100644
--- a/src/gs-screenshot-image.h
+++ b/src/gs-screenshot-image.h
@@ -62,6 +62,9 @@ void           gs_screenshot_image_set_cachedir       (GsScreenshotImage      *ssimg,
 void            gs_screenshot_image_set_size           (GsScreenshotImage      *ssimg,
                                                         guint                   width,
                                                         guint                   height);
+void            gs_screenshot_image_set_use_desktop_background
+                                                       (GsScreenshotImage      *ssimg,
+                                                        gboolean                use_desktop_background);
 void            gs_screenshot_image_load_async         (GsScreenshotImage      *ssimg,
                                                         GCancellable           *cancellable);
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 9a0c9ac..484268b 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -367,8 +367,9 @@ gs_shell_details_refresh_screenshots (GsShellDetails *shell_details)
                                                          g_get_user_cache_dir ());
                        gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss);
                        gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg),
-                                                     G_MAXUINT,
-                                                     G_MAXUINT);
+                                                     640,
+                                                     48);
+                       gs_screenshot_image_set_use_desktop_background (GS_SCREENSHOT_IMAGE (ssimg), FALSE);
                        gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), NULL);
                        gtk_box_pack_start (GTK_BOX (priv->box_details_screenshot_main), ssimg, FALSE, FALSE, 
0);
                        gtk_widget_set_visible (ssimg, TRUE);


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