[gnome-software/1391-style-storage-units-differently: 177/178] gs-app-context-bar: Draw lozenge size unit with smaller font




commit fac021a7bcea3f41e2a265aa1eac72d913e83ff8
Author: Milan Crha <mcrha redhat com>
Date:   Mon May 16 13:49:22 2022 +0200

    gs-app-context-bar: Draw lozenge size unit with smaller font
    
    Helps https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1391

 src/gs-app-context-bar.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index 0e88aecd6..18f29b341 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -36,6 +36,7 @@
 #include "gs-age-rating-context-dialog.h"
 #include "gs-app.h"
 #include "gs-app-context-bar.h"
+#include "gs-common.h"
 #include "gs-hardware-support-context-dialog.h"
 #include "gs-safety-context-dialog.h"
 #include "gs-storage-context-dialog.h"
@@ -116,6 +117,7 @@ static void
 update_storage_tile (GsAppContextBar *self)
 {
        g_autofree gchar *lozenge_text = NULL;
+       gboolean lozenge_text_is_markup = FALSE;
        const gchar *title;
        g_autofree gchar *description = NULL;
        guint64 size_bytes;
@@ -199,10 +201,13 @@ update_storage_tile (GsAppContextBar *self)
                 * This is displayed in a context tile, so the string should be short. */
                description = g_strdup (_("Size is unknown"));
        } else {
-               lozenge_text = g_format_size (size_bytes);
+               lozenge_text = gs_utils_format_size (size_bytes, &lozenge_text_is_markup);
        }
 
-       gtk_label_set_text (GTK_LABEL (self->tiles[STORAGE_TILE].lozenge_content), lozenge_text);
+       if (lozenge_text_is_markup)
+               gtk_label_set_markup (GTK_LABEL (self->tiles[STORAGE_TILE].lozenge_content), lozenge_text);
+       else
+               gtk_label_set_text (GTK_LABEL (self->tiles[STORAGE_TILE].lozenge_content), lozenge_text);
        gtk_label_set_text (self->tiles[STORAGE_TILE].title, title);
        gtk_label_set_text (self->tiles[STORAGE_TILE].description, description);
 }


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