[gnome-software/1525-os-upgrade-vertically-center-download-button] gs-upgrade-banner: The 'GNOME OS' has no upgrade version set



commit 95a5864de8928906cefcdfcf3520602da2a9c24c
Author: Milan Crha <mcrha redhat com>
Date:   Mon Nov 1 15:22:04 2021 +0100

    gs-upgrade-banner: The 'GNOME OS' has no upgrade version set
    
    To make the text look properly, without two consecutive spaces,
    check whether the version is filled and use a different text
    when it's not filled.

 src/gs-upgrade-banner.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-upgrade-banner.c b/src/gs-upgrade-banner.c
index 8baf484cc..2dcfff089 100644
--- a/src/gs-upgrade-banner.c
+++ b/src/gs-upgrade-banner.c
@@ -73,18 +73,27 @@ static void
 gs_upgrade_banner_refresh (GsUpgradeBanner *self)
 {
        GsUpgradeBannerPrivate *priv = gs_upgrade_banner_get_instance_private (self);
-       const gchar *uri, *summary;
+       const gchar *uri, *summary, *version;
        g_autofree gchar *str = NULL;
        guint percentage;
 
        if (priv->app == NULL)
                return;
 
-       /* TRANSLATORS: This is the text displayed when a distro
-        * upgrade is available. The first %s is the distro name
-        * and the 2nd %s is the version, e.g. "Fedora 35 Available" */
-       str = g_strdup_printf (_("%s %s Available"), gs_app_get_name (priv->app), gs_app_get_version 
(priv->app));
-       gtk_label_set_markup (GTK_LABEL (priv->label_upgrades_title), str);
+       version = gs_app_get_version (priv->app);
+
+       if (version != NULL && *version != '\0') {
+               /* TRANSLATORS: This is the text displayed when a distro
+                * upgrade is available. The first %s is the distro name
+                * and the 2nd %s is the version, e.g. "Fedora 35 Available" */
+               str = g_strdup_printf (_("%s %s Available"), gs_app_get_name (priv->app), gs_app_get_version 
(priv->app));
+       } else {
+               /* TRANSLATORS: This is the text displayed when a distro
+                * upgrade is available. The %s is the distro name,
+                * e.g. "GNOME OS Available" */
+               str = g_strdup_printf (_("%s Available"), gs_app_get_name (priv->app));
+       }
+       gtk_label_set_text (GTK_LABEL (priv->label_upgrades_title), str);
 
        /* Normally a distro upgrade state goes from
         *


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