[gnome-software/1081-gsapp-show-packaging-format-in-origin-ui-string] GsApp: Show packaging format in the origin UI string



commit 6d188920a8591aca105eb6d740884af1a3b3808d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 2 10:21:35 2021 +0100

    GsApp: Show packaging format in the origin UI string
    
    Show the packaging format in the origin UI string to be able
    to easily distinguish what format the respective origin is,
    even when it has a similar name/title.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1081

 lib/gs-app.c                       | 20 ++++++++++++++++++--
 plugins/flatpak/gs-flatpak-utils.c | 12 ++++++++++--
 plugins/flatpak/gs-flatpak.c       |  8 +++++++-
 po/POTFILES.in                     |  1 +
 src/gs-origin-popover-row.c        | 16 ----------------
 src/gs-origin-popover-row.ui       | 29 -----------------------------
 6 files changed, 36 insertions(+), 50 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 9dc4465f5..01aae2a1c 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -4724,6 +4724,7 @@ gs_app_get_origin_ui (GsApp *app)
 {
        GsAppPrivate *priv;
        g_autoptr(GMutexLocker) locker = NULL;
+       g_autofree gchar *packaging_format = NULL;
 
        g_return_val_if_fail (GS_IS_APP (app), NULL);
 
@@ -4741,20 +4742,35 @@ gs_app_get_origin_ui (GsApp *app)
                        return g_strdup (gs_os_release_get_name (os_release));
        }
 
+       packaging_format = gs_app_get_packaging_format (app);
+
        /* use "Local file" rather than the filename for local files */
        if (gs_app_get_state (app) == GS_APP_STATE_AVAILABLE_LOCAL) {
+               if (packaging_format) {
+                       /* TRANSLATORS: this is a locally downloaded package with packaging format; example 
string: "Local file (RPM)" */
+                       return g_strdup_printf (_("Local file (%s)"), packaging_format);
+               }
+
                /* TRANSLATORS: this is a locally downloaded package */
                return g_strdup (_("Local file"));
        }
 
        /* capitalize "Flathub" and "Flathub Beta" */
        if (g_strcmp0 (gs_app_get_origin (app), "flathub") == 0) {
-               return g_strdup ("Flathub");
+               return g_strdup ("Flathub (Flatpak)");
        } else if (g_strcmp0 (gs_app_get_origin (app), "flathub-beta") == 0) {
-               return g_strdup ("Flathub Beta");
+               return g_strdup ("Flathub Beta (Flatpak)");
        }
 
        /* fall back to origin */
+
+       if (packaging_format) {
+               /* TRANSLATORS: the first %s is replaced with an origin name;
+                  the second %s is replaced with the packaging format.
+                  Example string: "Local file (RPM)" */
+               return g_strdup_printf (_("%s (%s)"), gs_app_get_origin (app), packaging_format);
+       }
+
        return g_strdup (gs_app_get_origin (app));
 }
 
diff --git a/plugins/flatpak/gs-flatpak-utils.c b/plugins/flatpak/gs-flatpak-utils.c
index 3d26cc29a..531bf081c 100644
--- a/plugins/flatpak/gs-flatpak-utils.c
+++ b/plugins/flatpak/gs-flatpak-utils.c
@@ -8,6 +8,7 @@
 
 #include <config.h>
 #include <ostree.h>
+#include <glib/gi18n.h>
 
 #include "gs-flatpak-app.h"
 #include "gs-flatpak.h"
@@ -77,8 +78,9 @@ gs_flatpak_app_new_from_remote (FlatpakRemote *xremote)
        /* title */
        title = flatpak_remote_get_title (xremote);
        if (title != NULL) {
+               g_autofree gchar *origin_ui = g_strdup_printf (_("%s (Flatpak)"), title);
                gs_app_set_summary (app, GS_APP_QUALITY_LOWEST, title);
-               gs_app_set_origin_ui (app, title);
+               gs_app_set_origin_ui (app, origin_ui);
        }
 
        /* url */
@@ -172,9 +174,15 @@ gs_flatpak_app_new_from_repo_file (GFile *file,
        gs_app_set_name (app, GS_APP_QUALITY_NORMAL, repo_title);
        gs_app_set_size_download (app, GS_APP_SIZE_UNKNOWABLE);
        gs_flatpak_app_set_repo_url (app, repo_url);
-       gs_app_set_origin_ui (app, repo_title);
        gs_app_set_origin_hostname (app, repo_url);
 
+       if (repo_title != NULL) {
+               g_autofree gchar *origin_ui = g_strdup_printf (_("%s (Flatpak)"), repo_title);
+               gs_app_set_origin_ui (app, origin_ui);
+       } else {
+               gs_app_set_origin_ui (app, repo_title);
+       }
+
        /* user specified a URL */
        repo_gpgkey = g_key_file_get_string (kf, "Flatpak Repo", "GPGKey", NULL);
        if (repo_gpgkey != NULL) {
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index c528fb5d0..a22b2e621 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -152,7 +152,13 @@ gs_flatpak_set_app_origin (GsFlatpak *self,
        }
 
        gs_app_set_origin (app, origin);
-       gs_app_set_origin_ui (app, title);
+
+       if (title != NULL) {
+               g_autofree gchar *origin_ui = g_strdup_printf (_("%s (Flatpak)"), title);
+               gs_app_set_origin_ui (app, origin_ui);
+       } else {
+               gs_app_set_origin_ui (app, title);
+       }
 }
 
 static void
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ecae3db32..a1a67b44b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -85,6 +85,7 @@ plugins/external-appstream/gs-plugin-external-appstream.c
 plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
 plugins/flatpak/org.gnome.Software.Plugin.Flatpak.metainfo.xml.in
 plugins/flatpak/gs-flatpak.c
+plugins/flatpak/gs-flatpak-utils.c
 plugins/flatpak/gs-plugin-flatpak.c
 plugins/fwupd/gs-fwupd-app.c
 plugins/fwupd/gs-plugin-fwupd.c
diff --git a/src/gs-origin-popover-row.c b/src/gs-origin-popover-row.c
index f5ee8c5a3..7e2a8d171 100644
--- a/src/gs-origin-popover-row.c
+++ b/src/gs-origin-popover-row.c
@@ -19,9 +19,6 @@ typedef struct
        GtkWidget       *url_box;
        GtkWidget       *url_title;
        GtkWidget       *url_label;
-       GtkWidget       *format_box;
-       GtkWidget       *format_title;
-       GtkWidget       *format_label;
        GtkWidget       *installation_box;
        GtkWidget       *installation_title;
        GtkWidget       *installation_label;
@@ -41,7 +38,6 @@ refresh_ui (GsOriginPopoverRow *row)
 {
        GsOriginPopoverRowPrivate *priv = gs_origin_popover_row_get_instance_private (row);
        g_autofree gchar *origin_ui = NULL;
-       g_autofree gchar *packaging_format = NULL;
        g_autofree gchar *url = NULL;
 
        g_assert (GS_IS_ORIGIN_POPOVER_ROW (row));
@@ -68,14 +64,6 @@ refresh_ui (GsOriginPopoverRow *row)
                gtk_widget_hide (priv->url_box);
        }
 
-       packaging_format = gs_app_get_packaging_format (priv->app);
-       if (packaging_format != NULL) {
-               gtk_label_set_text (GTK_LABEL (priv->format_label), packaging_format);
-               gtk_widget_show (priv->format_box);
-       } else {
-               gtk_widget_hide (priv->format_box);
-       }
-
        if (gs_app_get_bundle_kind (priv->app) == AS_BUNDLE_KIND_FLATPAK &&
            gs_app_get_scope (priv->app) != AS_APP_SCOPE_UNKNOWN) {
                AsAppScope scope = gs_app_get_scope (priv->app);
@@ -142,7 +130,6 @@ gs_origin_popover_row_set_size_group (GsOriginPopoverRow *row, GtkSizeGroup *siz
        GsOriginPopoverRowPrivate *priv = gs_origin_popover_row_get_instance_private (row);
 
        gtk_size_group_add_widget (size_group, priv->url_title);
-       gtk_size_group_add_widget (size_group, priv->format_title);
        gtk_size_group_add_widget (size_group, priv->installation_title);
        gtk_size_group_add_widget (size_group, priv->branch_title);
        gtk_size_group_add_widget (size_group, priv->version_title);
@@ -178,9 +165,6 @@ gs_origin_popover_row_class_init (GsOriginPopoverRowClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, url_box);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, url_title);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, url_label);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, format_box);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, format_title);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, format_label);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, installation_box);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, installation_title);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, installation_label);
diff --git a/src/gs-origin-popover-row.ui b/src/gs-origin-popover-row.ui
index 3fd4eb0df..b46c838f9 100644
--- a/src/gs-origin-popover-row.ui
+++ b/src/gs-origin-popover-row.ui
@@ -51,35 +51,6 @@
                 </child>
               </object>
             </child>
-            <child>
-              <object class="GtkBox" id="format_box">
-                <property name="visible">True</property>
-                <property name="orientation">horizontal</property>
-                <property name="spacing">12</property>
-                <child>
-                  <object class="GtkLabel" id="format_title">
-                    <property name="visible">True</property>
-                    <property name="halign">start</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes" comments="Translators: The packaging format of 
the app being installed, e.g. 'RPM' or 'Flatpak'">Format</property>
-                    <style>
-                      <class name="app-row-origin-text"/>
-                      <class name="dim-label"/>
-                    </style>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="format_label">
-                    <property name="visible">True</property>
-                    <property name="halign">start</property>
-                    <property name="ellipsize">end</property>
-                    <style>
-                      <class name="app-row-origin-text"/>
-                    </style>
-                  </object>
-                </child>
-              </object>
-            </child>
             <child>
               <object class="GtkBox" id="installation_box">
                 <property name="visible">True</property>


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