[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 1236/1241] gs-app-query: Add 'deployment-featured' property
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 1236/1241] gs-app-query: Add 'deployment-featured' property
- Date: Fri, 6 May 2022 11:39:57 +0000 (UTC)
commit f88358817c9270d2c8681e35d048d73437f89612
Author: Milan Crha <mcrha redhat com>
Date: Fri May 6 11:38:33 2022 +0200
gs-app-query: Add 'deployment-featured' property
lib/gs-app-query.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/gs-app-query.h | 2 ++
2 files changed, 63 insertions(+)
---
diff --git a/lib/gs-app-query.c b/lib/gs-app-query.c
index ec07757b5..b355534c5 100644
--- a/lib/gs-app-query.c
+++ b/lib/gs-app-query.c
@@ -73,6 +73,8 @@ struct _GsAppQuery
/* This is guaranteed to either be %NULL, or a non-empty array */
gchar **provides_files; /* (owned) (nullable) (array zero-terminated=1) */
GDateTime *released_since; /* (owned) (nullable) */
+ /* This is guaranteed to either be %NULL, or a non-empty array */
+ gchar **deployment_featured; /* (owned) (nullable) (array zero-terminated=1) */
};
G_DEFINE_TYPE (GsAppQuery, gs_app_query, G_TYPE_OBJECT)
@@ -87,6 +89,7 @@ typedef enum {
PROP_FILTER_FUNC,
PROP_FILTER_USER_DATA,
PROP_FILTER_USER_DATA_NOTIFY,
+ PROP_DEPLOYMENT_FEATURED,
PROP_PROVIDES_FILES,
PROP_RELEASED_SINCE,
} GsAppQueryProperty;
@@ -129,6 +132,9 @@ gs_app_query_get_property (GObject *object,
case PROP_FILTER_USER_DATA_NOTIFY:
g_value_set_pointer (value, self->filter_user_data_notify);
break;
+ case PROP_DEPLOYMENT_FEATURED:
+ g_value_set_boxed (value, self->deployment_featured);
+ break;
case PROP_PROVIDES_FILES:
g_value_set_boxed (value, self->provides_files);
break;
@@ -194,6 +200,16 @@ gs_app_query_set_property (GObject *object,
/* Construct only. */
g_assert (self->filter_user_data_notify == NULL);
self->filter_user_data_notify = g_value_get_pointer (value);
+ break;
+ case PROP_DEPLOYMENT_FEATURED:
+ /* Construct only. */
+ g_assert (self->deployment_featured == NULL);
+ self->deployment_featured = g_value_dup_boxed (value);
+
+ /* Squash empty arrays to %NULL. */
+ if (self->deployment_featured != NULL && self->deployment_featured[0] == NULL)
+ g_clear_pointer (&self->deployment_featured, g_strfreev);
+
break;
case PROP_PROVIDES_FILES:
/* Construct only. */
@@ -239,6 +255,7 @@ gs_app_query_finalize (GObject *object)
{
GsAppQuery *self = GS_APP_QUERY (object);
+ g_clear_pointer (&self->deployment_featured, g_strfreev);
g_clear_pointer (&self->provides_files, g_strfreev);
g_clear_pointer (&self->released_since, g_date_time_unref);
@@ -391,6 +408,29 @@ gs_app_query_class_init (GsAppQueryClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GsAppQuery:deployment-featured: (nullable)
+ *
+ * A list of `GnomeSoftware::DeploymentFeatured` app keys.
+ *
+ * Search for applications that should be featured in a deployment-specific
+ * section on the overview page.
+ * This is expected to be a curated list of applications that are high quality
+ * and feature-complete. Only apps matching at least one of the keys in this
+ * list are returned.
+ *
+ * This may be %NULL to not filter on it. An empty array is
+ * considered equivalent to %NULL.
+ *
+ * Since: 43
+ */
+ props[PROP_DEPLOYMENT_FEATURED] =
+ g_param_spec_boxed ("deployment-featured", "Deployment Featured",
+ "A list of `GnomeSoftware::DeploymentFeatured` app keys.",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* GsAppQuery:provides-files: (nullable)
*
@@ -598,3 +638,24 @@ gs_app_query_get_released_since (GsAppQuery *self)
return self->released_since;
}
+
+/**
+ * gs_app_query_get_deployment_featured:
+ * @self: a #GsAppQuery
+ *
+ * Get the value of #GsAppQuery:deployment-featured.
+ *
+ * Returns: (nullable): a list of `GnomeSoftware::DeploymentFeatured` app keys,
+ * which the apps have set in a custom key, or %NULL to not filter on this
+ * Since: 43
+ */
+const gchar * const *
+gs_app_query_get_deployment_featured (GsAppQuery *self)
+{
+ g_return_val_if_fail (GS_IS_APP_QUERY (self), NULL);
+
+ /* Always return %NULL or a non-empty array */
+ g_assert (self->deployment_featured == NULL || self->deployment_featured[0] != NULL);
+
+ return (const gchar * const *) self->deployment_featured;
+}
diff --git a/lib/gs-app-query.h b/lib/gs-app-query.h
index 23e1c95ab..df06b0ecc 100644
--- a/lib/gs-app-query.h
+++ b/lib/gs-app-query.h
@@ -36,5 +36,7 @@ GsAppListFilterFunc gs_app_query_get_filter_func (GsAppQuery *self,
const gchar * const *gs_app_query_get_provides_files (GsAppQuery *self);
GDateTime *gs_app_query_get_released_since (GsAppQuery *self);
+const gchar * const *gs_app_query_get_deployment_featured
+ (GsAppQuery *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]