[gnome-software] Make the project licenses hyperlinked to the SPDX site
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Make the project licenses hyperlinked to the SPDX site
- Date: Mon, 12 May 2014 10:53:29 +0000 (UTC)
commit 44b2d6d7ca539e46bcf92ef50bd3465d6974e3b6
Author: Richard Hughes <richard hughsie com>
Date: Mon May 12 11:53:11 2014 +0100
Make the project licenses hyperlinked to the SPDX site
src/gs-shell-details.c | 4 +-
src/plugins/gs-plugin-appstream.c | 39 ++++++++++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index ab1fe38..934d8c5 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -597,9 +597,9 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
/* TRANSLATORS: this is where the licence is insanely
* complicated and the full string is put into the tooltip */
gtk_label_set_label (GTK_LABEL (priv->label_details_licence_value), C_("license",
"Complicated!"));
- gtk_widget_set_tooltip_text (priv->label_details_licence_value, tmp);
+ gtk_widget_set_tooltip_markup (priv->label_details_licence_value, tmp);
} else {
- gtk_label_set_label (GTK_LABEL (priv->label_details_licence_value), tmp);
+ gtk_label_set_markup (GTK_LABEL (priv->label_details_licence_value), tmp);
gtk_widget_set_tooltip_text (priv->label_details_licence_value, NULL);
}
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 2368049..b1021b7 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -330,6 +330,43 @@ gs_plugin_refine_add_screenshots (GsApp *app, AsApp *item)
}
/**
+ * gs_plugin_appstream_set_license:
+ */
+static void
+gs_plugin_appstream_set_license (GsApp *app, const gchar *license_string)
+{
+ GString *urld;
+ gchar **tokens;
+ guint i;
+
+ /* tokenize the license string and URLify any SPDX IDs */
+ urld = g_string_sized_new (strlen (license_string) + 1);
+ tokens = as_utils_spdx_license_tokenize (license_string);
+ for (i = 0; tokens[i] != NULL; i++) {
+
+ /* literal text */
+ if (g_str_has_prefix (tokens[i], "#")) {
+ g_string_append (urld, tokens[i] + 1);
+ continue;
+ }
+
+ /* unknown value */
+ if (!as_utils_is_spdx_license_id (tokens[i])) {
+ g_string_append (urld, tokens[i]);
+ continue;
+ }
+
+ /* SPDX value */
+ g_string_append_printf (urld,
+ "<a href=\"http://spdx.org/licenses/%s\">%s</a>",
+ tokens[i], tokens[i]);
+ }
+ gs_app_set_licence (app, urld->str);
+ g_strfreev (tokens);
+ g_string_free (urld, TRUE);
+}
+
+/**
* gs_plugin_refine_item:
*/
static gboolean
@@ -391,7 +428,7 @@ gs_plugin_refine_item (GsPlugin *plugin,
/* set licence */
if (as_app_get_project_license (item) != NULL && gs_app_get_licence (app) == NULL)
- gs_app_set_licence (app, as_app_get_project_license (item));
+ gs_plugin_appstream_set_license (app, as_app_get_project_license (item));
/* set keywords */
if (as_app_get_keywords (item) != NULL &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]