[gnome-software/1392-unify-lozenge-styling: 85/85] gs-app-context-bar: Use GsLozenge




commit fbb5623450a688e96a89443605a58dae1691dc49
Author: Milan Crha <mcrha redhat com>
Date:   Tue May 3 20:56:30 2022 +0200

    gs-app-context-bar: Use GsLozenge
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1392

 src/gs-app-context-bar.c  | 19 ++++------
 src/gs-app-context-bar.ui | 92 +++++++++++++++--------------------------------
 2 files changed, 36 insertions(+), 75 deletions(-)
---
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index 18f29b341..aa23cb587 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -38,6 +38,7 @@
 #include "gs-app-context-bar.h"
 #include "gs-common.h"
 #include "gs-hardware-support-context-dialog.h"
+#include "gs-lozenge.h"
 #include "gs-safety-context-dialog.h"
 #include "gs-storage-context-dialog.h"
 
@@ -45,7 +46,6 @@ typedef struct
 {
        GtkWidget       *tile;
        GtkWidget       *lozenge;
-       GtkWidget       *lozenge_content;
        GtkLabel        *title;
        GtkLabel        *description;
 } GsAppContextTile;
@@ -205,9 +205,9 @@ update_storage_tile (GsAppContextBar *self)
        }
 
        if (lozenge_text_is_markup)
-               gtk_label_set_markup (GTK_LABEL (self->tiles[STORAGE_TILE].lozenge_content), lozenge_text);
+               gs_lozenge_set_markup (GS_LOZENGE (self->tiles[STORAGE_TILE].lozenge), lozenge_text);
        else
-               gtk_label_set_text (GTK_LABEL (self->tiles[STORAGE_TILE].lozenge_content), lozenge_text);
+               gs_lozenge_set_text (GS_LOZENGE (self->tiles[STORAGE_TILE].lozenge), lozenge_text);
        gtk_label_set_text (self->tiles[STORAGE_TILE].title, title);
        gtk_label_set_text (self->tiles[STORAGE_TILE].description, description);
 }
@@ -472,7 +472,7 @@ update_safety_tile (GsAppContextBar *self)
                g_assert_not_reached ();
        }
 
-       gtk_image_set_from_icon_name (GTK_IMAGE (self->tiles[SAFETY_TILE].lozenge_content), icon_name);
+       gs_lozenge_set_icon_name (GS_LOZENGE (self->tiles[SAFETY_TILE].lozenge), icon_name);
        gtk_label_set_text (self->tiles[SAFETY_TILE].title, title);
        gtk_label_set_text (self->tiles[SAFETY_TILE].description, description);
 
@@ -644,8 +644,8 @@ update_hardware_support_tile (GsAppContextBar *self)
        /* Update the UI. The `adaptive-symbolic` icon needs a special size to
         * be set, as it is wider than it is tall. Setting the size ensures it’s
         * rendered at the right height. */
-       gtk_image_set_from_icon_name (GTK_IMAGE (self->tiles[HARDWARE_SUPPORT_TILE].lozenge_content), 
icon_name);
-       gtk_image_set_pixel_size (GTK_IMAGE (self->tiles[HARDWARE_SUPPORT_TILE].lozenge_content), g_str_equal 
(icon_name, "adaptive-symbolic") ? 56 : -1);
+       gs_lozenge_set_icon_name (GS_LOZENGE (self->tiles[HARDWARE_SUPPORT_TILE].lozenge), icon_name);
+       gs_lozenge_set_pixel_size (GS_LOZENGE (self->tiles[HARDWARE_SUPPORT_TILE].lozenge), g_str_equal 
(icon_name, "adaptive-symbolic") ? 56 : -1);
 
        gtk_label_set_text (self->tiles[HARDWARE_SUPPORT_TILE].title, title);
        gtk_label_set_text (self->tiles[HARDWARE_SUPPORT_TILE].description, description);
@@ -722,8 +722,7 @@ update_age_rating_tile (GsAppContextBar *self)
 
        content_rating = gs_app_dup_content_rating (self->app);
        gs_age_rating_context_dialog_update_lozenge (self->app,
-                                                    self->tiles[AGE_RATING_TILE].lozenge,
-                                                    GTK_LABEL (self->tiles[AGE_RATING_TILE].lozenge_content),
+                                                    GS_LOZENGE (self->tiles[AGE_RATING_TILE].lozenge),
                                                     &is_unknown);
 
        /* Description */
@@ -875,22 +874,18 @@ gs_app_context_bar_class_init (GsAppContextBarClass *klass)
 
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[STORAGE_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[STORAGE_TILE].lozenge));
-       gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_lozenge_content", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[STORAGE_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_title", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[STORAGE_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[STORAGE_TILE].description));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[SAFETY_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[SAFETY_TILE].lozenge));
-       gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_lozenge_content", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[SAFETY_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_title", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[SAFETY_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[SAFETY_TILE].description));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].lozenge));
-       gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_lozenge_content", 
FALSE, G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_title", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].description));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[AGE_RATING_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].lozenge));
-       gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_lozenge_content", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_title", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].description));
        gtk_widget_class_bind_template_callback (widget_class, tile_clicked_cb);
diff --git a/src/gs-app-context-bar.ui b/src/gs-app-context-bar.ui
index 705d7dcdb..db7091283 100644
--- a/src/gs-app-context-bar.ui
+++ b/src/gs-app-context-bar.ui
@@ -24,25 +24,15 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">8</property>
                 <child>
-                  <object class="GtkBox" id="storage_tile_lozenge">
-                    <property name="halign">center</property>
+                  <object class="GsLozenge" id="storage_tile_lozenge">
+                    <property name="circular">False</property>
                     <style>
-                      <class name="context-tile-lozenge"/>
                       <class name="grey"/>
                     </style>
-                    <child>
-                      <object class="GtkLabel" id="storage_tile_lozenge_content">
-                        <property name="halign">center</property>
-                        <property name="hexpand">True</property>
-                        <!-- this is a placeholder: the text is actually set in code -->
-                        <property name="label">20 MB</property>
-                        <property name="xalign">0.5</property>
-                        <accessibility>
-                          <relation name="labelled-by">storage_tile_title</relation>
-                          <relation name="details">storage_tile_description</relation>
-                        </accessibility>
-                      </object>
-                    </child>
+                    <accessibility>
+                      <relation name="labelled-by">storage_tile_title</relation>
+                      <relation name="details">storage_tile_description</relation>
+                    </accessibility>
                   </object>
                 </child>
                 <child>
@@ -86,24 +76,17 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">8</property>
                 <child>
-                  <object class="GtkBox" id="safety_tile_lozenge">
-                    <property name="halign">center</property>
+                  <object class="GsLozenge" id="safety_tile_lozenge">
+                    <property name="circular">True</property>
+                    <!-- this is a placeholder: the icon is actually set in code -->
+                    <property name="icon-name">safety-symbolic</property>
                     <style>
-                      <class name="context-tile-lozenge"/>
                       <class name="green"/>
                     </style>
-                    <child>
-                      <object class="GtkImage" id="safety_tile_lozenge_content">
-                        <property name="halign">center</property>
-                        <property name="hexpand">True</property>
-                        <!-- this is a placeholder: the icon is actually set in code -->
-                        <property name="icon-name">safety-symbolic</property>
-                        <accessibility>
-                          <relation name="labelled-by">safety_tile_title</relation>
-                          <relation name="details">safety_tile_description</relation>
-                        </accessibility>
-                      </object>
-                    </child>
+                    <accessibility>
+                      <relation name="labelled-by">safety_tile_title</relation>
+                      <relation name="details">safety_tile_description</relation>
+                    </accessibility>
                   </object>
                 </child>
                 <child>
@@ -154,26 +137,19 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">8</property>
                 <child>
-                  <object class="GtkBox" id="hardware_support_tile_lozenge">
-                    <property name="halign">center</property>
+                  <object class="GsLozenge" id="hardware_support_tile_lozenge">
+                    <property name="circular">False</property>
+                    <!-- this is a placeholder: the icon is actually set in code -->
+                    <property name="icon-name">adaptive-symbolic</property>
+                    <property name="pixel-size">56</property>
                     <style>
-                      <class name="context-tile-lozenge"/>
                       <class name="green"/>
                       <class name="wide-image"/>
                     </style>
-                    <child>
-                      <object class="GtkImage" id="hardware_support_tile_lozenge_content">
-                        <property name="halign">center</property>
-                        <property name="hexpand">True</property>
-                        <!-- this is a placeholder: the icon is actually set in code -->
-                        <property name="icon-name">adaptive-symbolic</property>
-                        <property name="pixel-size">56</property>
-                        <accessibility>
-                          <relation name="labelled-by">hardware_support_tile_title</relation>
-                          <relation name="details">hardware_support_tile_description</relation>
-                        </accessibility>
-                      </object>
-                    </child>
+                    <accessibility>
+                      <relation name="labelled-by">hardware_support_tile_title</relation>
+                      <relation name="details">hardware_support_tile_description</relation>
+                    </accessibility>
                   </object>
                 </child>
                 <child>
@@ -217,25 +193,15 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">8</property>
                 <child>
-                  <object class="GtkBox" id="age_rating_tile_lozenge">
-                    <property name="halign">center</property>
+                  <object class="GsLozenge" id="age_rating_tile_lozenge">
+                    <property name="circular">True</property>
                     <style>
-                      <class name="context-tile-lozenge"/>
                       <class name="details-rating-18"/>
                     </style>
-                    <child>
-                      <object class="GtkLabel" id="age_rating_tile_lozenge_content">
-                        <property name="halign">center</property>
-                        <property name="hexpand">True</property>
-                        <!-- this is a placeholder: the text is actually set in code -->
-                        <property name="label">18+</property>
-                        <property name="xalign">0.5</property>
-                        <accessibility>
-                          <relation name="labelled-by">age_rating_tile_title</relation>
-                          <relation name="details">age_rating_tile_description</relation>
-                        </accessibility>
-                      </object>
-                    </child>
+                    <accessibility>
+                      <relation name="labelled-by">age_rating_tile_title</relation>
+                      <relation name="details">age_rating_tile_description</relation>
+                    </accessibility>
                   </object>
                 </child>
                 <child>


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