[gnome-software] Show the package licence when available
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Show the package licence when available
- Date: Wed, 9 Oct 2013 10:53:24 +0000 (UTC)
commit 6d22efb6d341eba2940fa1cd342738a3d600d113
Author: Richard Hughes <richard hughsie com>
Date: Wed Oct 9 11:36:12 2013 +0100
Show the package licence when available
src/gs-app.c | 25 +++++++++++++++++++++++++
src/gs-app.h | 3 +++
src/gs-shell-details.c | 11 +++++++++++
src/plugins/appstream-app.c | 22 ++++++++++++++++++++++
src/plugins/appstream-app.h | 4 ++++
src/plugins/appstream-cache.c | 13 +++++++++++++
src/plugins/gs-plugin-appstream.c | 4 ++++
7 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 4be8b5d..181f4f2 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -63,6 +63,7 @@ struct GsAppPrivate
gchar *description;
GPtrArray *screenshots;
gchar *url;
+ gchar *licence;
gchar *update_version;
gchar *update_version_ui;
gchar *update_details;
@@ -197,6 +198,8 @@ gs_app_to_string (GsApp *app)
}
if (priv->url != NULL)
g_string_append_printf (str, "\turl:\t%s\n", priv->url);
+ if (priv->licence != NULL)
+ g_string_append_printf (str, "\tlicence:\t%s\n", priv->licence);
if (priv->rating != -1)
g_string_append_printf (str, "\trating:\t%i\n", priv->rating);
if (priv->pixbuf != NULL)
@@ -747,6 +750,27 @@ gs_app_set_url (GsApp *app, const gchar *url)
}
/**
+ * gs_app_get_licence:
+ */
+const gchar *
+gs_app_get_licence (GsApp *app)
+{
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+ return app->priv->licence;
+}
+
+/**
+ * gs_app_set_licence:
+ */
+void
+gs_app_set_licence (GsApp *app, const gchar *licence)
+{
+ g_return_if_fail (GS_IS_APP (app));
+ g_free (app->priv->licence);
+ app->priv->licence = g_strdup (licence);
+}
+
+/**
* gs_app_add_screenshot:
*/
void
@@ -1167,6 +1191,7 @@ gs_app_finalize (GObject *object)
g_free (priv->id);
g_free (priv->name);
g_free (priv->url);
+ g_free (priv->licence);
g_free (priv->source);
g_free (priv->project_group);
g_free (priv->version);
diff --git a/src/gs-app.h b/src/gs-app.h
index 18d2087..2f49e48 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -116,6 +116,9 @@ void gs_app_set_description (GsApp *app,
const gchar *gs_app_get_url (GsApp *app);
void gs_app_set_url (GsApp *app,
const gchar *url);
+const gchar *gs_app_get_licence (GsApp *app);
+void gs_app_set_licence (GsApp *app,
+ const gchar *licence);
GPtrArray *gs_app_get_screenshots (GsApp *app);
void gs_app_add_screenshot (GsApp *app,
GsScreenshot *screenshot);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 4028544..73372e3 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -348,6 +348,17 @@ gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
gtk_widget_set_visible (widget, TRUE);
}
+ /* set the licence */
+ tmp = gs_app_get_licence (app);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+ "label_details_licence_value"));
+ if (tmp == NULL) {
+ /* TRANSLATORS: this is where the licence is not known */
+ gtk_label_set_label (GTK_LABEL (widget), _("Unknown"));
+ } else {
+ gtk_label_set_label (GTK_LABEL (widget), tmp);
+ }
+
/* set version */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_details_version_value"));
gtk_label_set_label (GTK_LABEL (widget), gs_app_get_version (app));
diff --git a/src/plugins/appstream-app.c b/src/plugins/appstream-app.c
index ee818fd..adf69a5 100644
--- a/src/plugins/appstream-app.c
+++ b/src/plugins/appstream-app.c
@@ -38,6 +38,7 @@ struct AppstreamApp
gchar *description;
guint description_value;
gchar *url;
+ gchar *licence;
gchar *project_group;
gchar *icon;
AppstreamAppIconKind icon_kind;
@@ -57,6 +58,7 @@ appstream_app_free (AppstreamApp *app)
g_free (app->id);
g_free (app->pkgname);
g_free (app->url);
+ g_free (app->licence);
g_free (app->project_group);
g_free (app->icon);
g_free (app->name);
@@ -155,6 +157,15 @@ appstream_app_get_url (AppstreamApp *app)
}
/**
+ * appstream_app_get_licence:
+ */
+const gchar *
+appstream_app_get_licence (AppstreamApp *app)
+{
+ return app->licence;
+}
+
+/**
* appstream_app_get_project_group:
*/
const gchar *
@@ -285,6 +296,17 @@ appstream_app_set_url (AppstreamApp *app,
}
/**
+ * appstream_app_set_licence:
+ */
+void
+appstream_app_set_licence (AppstreamApp *app,
+ const gchar *licence,
+ gsize length)
+{
+ app->licence = g_strndup (licence, length);
+}
+
+/**
* appstream_app_set_project_group:
*/
void
diff --git a/src/plugins/appstream-app.h b/src/plugins/appstream-app.h
index 0e38dc0..6109a26 100644
--- a/src/plugins/appstream-app.h
+++ b/src/plugins/appstream-app.h
@@ -46,6 +46,7 @@ const gchar *appstream_app_get_name (AppstreamApp *app);
const gchar *appstream_app_get_summary (AppstreamApp *app);
const gchar *appstream_app_get_project_group (AppstreamApp *app);
const gchar *appstream_app_get_url (AppstreamApp *app);
+const gchar *appstream_app_get_licence (AppstreamApp *app);
const gchar *appstream_app_get_description (AppstreamApp *app);
const gchar *appstream_app_get_icon (AppstreamApp *app);
gboolean appstream_app_has_category (AppstreamApp *app,
@@ -69,6 +70,9 @@ void appstream_app_set_summary (AppstreamApp *app,
void appstream_app_set_url (AppstreamApp *app,
const gchar *summary,
gsize length);
+void appstream_app_set_licence (AppstreamApp *app,
+ const gchar *licence,
+ gsize length);
void appstream_app_set_project_group (AppstreamApp *app,
const gchar *project_group,
gsize length);
diff --git a/src/plugins/appstream-cache.c b/src/plugins/appstream-cache.c
index 7f67495..e372dbc 100644
--- a/src/plugins/appstream-cache.c
+++ b/src/plugins/appstream-cache.c
@@ -253,6 +253,7 @@ appstream_cache_start_element_cb (GMarkupParseContext *context,
case APPSTREAM_TAG_ID:
case APPSTREAM_TAG_PKGNAME:
case APPSTREAM_TAG_URL:
+ case APPSTREAM_TAG_LICENCE:
case APPSTREAM_TAG_PROJECT_GROUP:
if (helper->item_temp == NULL ||
helper->tag != APPSTREAM_TAG_APPLICATION) {
@@ -367,6 +368,7 @@ appstream_cache_end_element_cb (GMarkupParseContext *context,
case APPSTREAM_TAG_APPCATEGORIES:
case APPSTREAM_TAG_KEYWORDS:
case APPSTREAM_TAG_URL:
+ case APPSTREAM_TAG_LICENCE:
case APPSTREAM_TAG_ICON:
helper->tag = APPSTREAM_TAG_APPLICATION;
break;
@@ -488,6 +490,17 @@ appstream_cache_text_cb (GMarkupParseContext *context,
}
appstream_app_set_url (helper->item_temp, text, text_len);
break;
+ case APPSTREAM_TAG_LICENCE:
+ if (helper->item_temp == NULL ||
+ appstream_app_get_licence (helper->item_temp) != NULL) {
+ g_set_error_literal (error,
+ APPSTREAM_CACHE_ERROR,
+ APPSTREAM_CACHE_ERROR_FAILED,
+ "item_temp licence invalid");
+ return;
+ }
+ appstream_app_set_licence (helper->item_temp, text, text_len);
+ break;
case APPSTREAM_TAG_DESCRIPTION:
if (helper->item_temp == NULL) {
g_set_error_literal (error,
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index a1e5b6e..3358405 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -445,6 +445,10 @@ gs_plugin_refine_item (GsPlugin *plugin,
if (appstream_app_get_url (item) != NULL && gs_app_get_url (app) == NULL)
gs_app_set_url (app, appstream_app_get_url (item));
+ /* set licence */
+ if (appstream_app_get_licence (item) != NULL && gs_app_get_licence (app) == NULL)
+ gs_app_set_licence (app, appstream_app_get_licence (item));
+
/* set description */
if (appstream_app_get_description (item) != NULL && gs_app_get_description (app) == NULL)
gs_app_set_description (app, appstream_app_get_description (item));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]