[gnome-software: 2/6] screenshot-image: Use GsPicture




commit ac3e5d8f7557315e6106f861aa0ab03024637aa2
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Jul 27 19:55:54 2021 +0200

    screenshot-image: Use GsPicture
    
    This will allow the screenshots to be resizable height-for-width. This
    also stops centering the pictures as it is needed to let them take care
    of drawing themselves at the right size.

 src/gs-screenshot-image.c  | 17 ++++++++---------
 src/gs-screenshot-image.ui |  8 ++------
 2 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 2b19449af..1372667f9 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -14,6 +14,7 @@
 
 #include "gs-screenshot-image.h"
 #include "gs-common.h"
+#include "gs-picture.h"
 
 #define SPINNER_TIMEOUT_SECS 2
 
@@ -98,15 +99,13 @@ as_screenshot_show_image (GsScreenshotImage *ssimg)
        /* show icon */
        if (g_strcmp0 (ssimg->current_image, "image1") == 0) {
                if (pixbuf != NULL) {
-                       gs_image_set_from_pixbuf_with_scale (GTK_IMAGE (ssimg->image2),
-                                                            pixbuf, (gint) ssimg->scale);
+                       gs_picture_set_pixbuf (GS_PICTURE (ssimg->image2), pixbuf);
                }
                gtk_stack_set_visible_child_name (GTK_STACK (ssimg->stack), "image2");
                ssimg->current_image = "image2";
        } else {
                if (pixbuf != NULL) {
-                       gs_image_set_from_pixbuf_with_scale (GTK_IMAGE (ssimg->image1),
-                                                            pixbuf, (gint) ssimg->scale);
+                       gs_picture_set_pixbuf (GS_PICTURE (ssimg->image1), pixbuf);
                }
                gtk_stack_set_visible_child_name (GTK_STACK (ssimg->stack), "image1");
                ssimg->current_image = "image1";
@@ -224,11 +223,9 @@ gs_screenshot_image_show_blurred (GsScreenshotImage *ssimg,
                return;
 
        if (g_strcmp0 (ssimg->current_image, "image1") == 0) {
-               gs_image_set_from_pixbuf_with_scale (GTK_IMAGE (ssimg->image1),
-                                                    pb, (gint) ssimg->scale);
+               gs_picture_set_pixbuf (GS_PICTURE (ssimg->image1), pb);
        } else {
-               gs_image_set_from_pixbuf_with_scale (GTK_IMAGE (ssimg->image2),
-                                                    pb, (gint) ssimg->scale);
+               gs_picture_set_pixbuf (GS_PICTURE (ssimg->image2), pb);
        }
 }
 
@@ -417,7 +414,7 @@ gs_screenshot_image_set_size (GsScreenshotImage *ssimg,
 
        ssimg->width = width;
        ssimg->height = height;
-       gtk_widget_set_size_request (ssimg->stack, (gint) width, (gint) height);
+       gtk_widget_set_size_request (ssimg->stack, -1, (gint) height);
 }
 
 static gchar *
@@ -687,6 +684,8 @@ gs_screenshot_image_init (GsScreenshotImage *ssimg)
        ssimg->showing_image = FALSE;
 
        gtk_widget_set_has_window (GTK_WIDGET (ssimg), FALSE);
+
+       g_type_ensure (GS_TYPE_PICTURE);
        gtk_widget_init_template (GTK_WIDGET (ssimg));
 
        accessible = gtk_widget_get_accessible (GTK_WIDGET (ssimg));
diff --git a/src/gs-screenshot-image.ui b/src/gs-screenshot-image.ui
index 4b58e5a2a..c01ea8386 100644
--- a/src/gs-screenshot-image.ui
+++ b/src/gs-screenshot-image.ui
@@ -27,10 +27,8 @@
             <property name="visible">True</property>
             <property name="transition-type">crossfade</property>
             <child>
-              <object class="GtkImage" id="image1">
+              <object class="GsPicture" id="image1">
                 <property name="visible">True</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
                 <style>
                   <class name="image1"/>
                 </style>
@@ -40,10 +38,8 @@
               </packing>
             </child>
             <child>
-              <object class="GtkImage" id="image2">
+              <object class="GsPicture" id="image2">
                 <property name="visible">True</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
                 <style>
                   <class name="image2"/>
                 </style>


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