[gnome-software: 7/18] gs-app: Add a GsApp:license property
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/18] gs-app: Add a GsApp:license property
- Date: Tue, 29 Jun 2021 14:17:07 +0000 (UTC)
commit b267af6151df2422a8ead20e394b424feedecf42
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu May 27 18:48:10 2021 +0100
gs-app: Add a GsApp:license property
This exposes the existing license functionality, but adds support
for change notification, which parts of the UI could attach signals to.
The property is read-only, as the setter function is non-trivial.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
lib/gs-app.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 9613f8947..f06a792cf 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -152,9 +152,10 @@ typedef enum {
PROP_IS_UPDATE_DOWNLOADED,
PROP_URL_MISSING,
PROP_CONTENT_RATING,
+ PROP_LICENSE,
} GsAppProperty;
-static GParamSpec *obj_props[PROP_CONTENT_RATING + 1] = { NULL, };
+static GParamSpec *obj_props[PROP_LICENSE + 1] = { NULL, };
G_DEFINE_TYPE_WITH_PRIVATE (GsApp, gs_app, G_TYPE_OBJECT)
@@ -2677,7 +2678,8 @@ gs_app_set_license (GsApp *app, GsAppQuality quality, const gchar *license)
priv->license_is_free = as_license_is_free_license (license);
- _g_set_str (&priv->license, license);
+ if (_g_set_str (&priv->license, license))
+ gs_app_queue_notify (app, obj_props[PROP_LICENSE]);
}
/**
@@ -4715,6 +4717,9 @@ gs_app_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
case PROP_CONTENT_RATING:
g_value_set_object (value, priv->content_rating);
break;
+ case PROP_LICENSE:
+ g_value_set_string (value, priv->license);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -4792,6 +4797,9 @@ gs_app_set_property (GObject *object, guint prop_id, const GValue *value, GParam
case PROP_CONTENT_RATING:
gs_app_set_content_rating (app, g_value_get_object (value));
break;
+ case PROP_LICENSE:
+ /* Read-only */
+ g_assert_not_reached ();
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -5041,6 +5049,22 @@ gs_app_class_init (GsAppClass *klass)
as_content_rating_get_type (),
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GsApp:license: (nullable)
+ *
+ * The license for the app, which is typically its source code license.
+ *
+ * Use gs_app_set_license() to set this.
+ *
+ * This is %NULL if no licensing information is available.
+ *
+ * Since: 41
+ */
+ obj_props[PROP_LICENSE] =
+ g_param_spec_string ("license", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (object_class, G_N_ELEMENTS (obj_props), obj_props);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]