[gnome-software: 1/2] gs-license-tile: Add link to license text for FOSS apps




commit e5e33c02b3d906d91d93d25c8d08364a93a7e7b5
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Jul 25 16:40:42 2022 +0200

    gs-license-tile: Add link to license text for FOSS apps
    
    This can fail in cases where the app’s license is actually a complex
    SPDX expression, which can’t be represented as a single URI.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1626

 src/gs-license-tile.c  | 24 +++++++++++++++++++-----
 src/gs-license-tile.ui |  1 +
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-license-tile.c b/src/gs-license-tile.c
index a68326573..a49189f48 100644
--- a/src/gs-license-tile.c
+++ b/src/gs-license-tile.c
@@ -90,6 +90,8 @@ gs_license_tile_refresh (GsLicenseTile *self)
                return;
 
        if (gs_app_get_license_is_free (self->app)) {
+               const gchar *license_spdx, *license_url;
+
                title = _("Community Built");
                css_class = "green";
                lozenge_icon_names[0] = "heart-filled-symbolic";
@@ -102,11 +104,23 @@ gs_license_tile_refresh (GsLicenseTile *self)
                get_involved_visible = (gs_app_get_url (self->app, AS_URL_KIND_HOMEPAGE) != NULL);
 #endif
 
-               /* Translators: The placeholder here is the name of a software license. */
-               description = g_strdup_printf (_("This software is developed in the open by a community of 
volunteers, and released under the %s license."
-                                                "\n\n"
-                                                "You can contribute and help make it even better."),
-                                                gs_app_get_license (self->app));
+               license_spdx = gs_app_get_license (self->app);
+               license_url = as_get_license_url (license_spdx);
+
+               if (license_url != NULL) {
+                       /* Translators: The first placeholder here is a link to information about the 
license, and the second placeholder here is the name of a software license. */
+                       description = g_strdup_printf (_("This software is developed in the open by a 
community of volunteers, and released under the <a href=\"%s\">%s license</a>."
+                                                        "\n\n"
+                                                        "You can contribute and help make it even better."),
+                                                        license_url,
+                                                        license_spdx);
+               } else {
+                       /* Translators: The placeholder here is the name of a software license. */
+                       description = g_strdup_printf (_("This software is developed in the open by a 
community of volunteers, and released under the %s license."
+                                                        "\n\n"
+                                                        "You can contribute and help make it even better."),
+                                                        license_spdx);
+               }
        } else {
                title = _("Proprietary");
                css_class = "grey";
diff --git a/src/gs-license-tile.ui b/src/gs-license-tile.ui
index 3ef3075d4..814d29ffc 100644
--- a/src/gs-license-tile.ui
+++ b/src/gs-license-tile.ui
@@ -72,6 +72,7 @@
                   <object class="GtkLabel" id="description_label">
                     <!-- This text is a placeholder and will be set dynamically -->
                     <property name="label">This software is developed in the open by a community of 
volunteers, and released under the GNU GPL v3 license.\n\nYou can contribute and help make it even 
better.</property>
+                    <property name="use-markup">True</property>
                     <property name="wrap">True</property>
                   </object>
                 </child>


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