[gnome-software: 1/8] gs-app-query: Add an is-featured property
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/8] gs-app-query: Add an is-featured property
- Date: Mon, 23 May 2022 15:55:35 +0000 (UTC)
commit f6192ae001cede9ab8f1f5cd0b43e69013a8fbc9
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon May 23 13:49:56 2022 +0100
gs-app-query: Add an is-featured property
This allows for querying for apps which are featured.
Currently, those are apps which have the `GnomeSoftware::FeatureTile`
custom data set to `True` on them.
This query property will eventually replace the `GET_FEATURED` action /
`gs_plugin_add_featured()` vfunc.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-app-query.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/gs-app-query.h | 1 +
2 files changed, 56 insertions(+)
---
diff --git a/lib/gs-app-query.c b/lib/gs-app-query.c
index f4dad5035..21448b56d 100644
--- a/lib/gs-app-query.c
+++ b/lib/gs-app-query.c
@@ -74,6 +74,7 @@ struct _GsAppQuery
gchar **provides_files; /* (owned) (nullable) (array zero-terminated=1) */
GDateTime *released_since; /* (owned) (nullable) */
GsAppQueryTristate is_curated;
+ GsAppQueryTristate is_featured;
GsCategory *category; /* (nullable) (owned) */
GsAppQueryTristate is_installed;
};
@@ -93,6 +94,7 @@ typedef enum {
PROP_PROVIDES_FILES,
PROP_RELEASED_SINCE,
PROP_IS_CURATED,
+ PROP_IS_FEATURED,
PROP_CATEGORY,
PROP_IS_INSTALLED,
} GsAppQueryProperty;
@@ -144,6 +146,9 @@ gs_app_query_get_property (GObject *object,
case PROP_IS_CURATED:
g_value_set_enum (value, self->is_curated);
break;
+ case PROP_IS_FEATURED:
+ g_value_set_enum (value, self->is_featured);
+ break;
case PROP_CATEGORY:
g_value_set_object (value, self->category);
break;
@@ -230,6 +235,11 @@ gs_app_query_set_property (GObject *object,
g_assert (self->is_curated == GS_APP_QUERY_TRISTATE_UNSET);
self->is_curated = g_value_get_enum (value);
break;
+ case PROP_IS_FEATURED:
+ /* Construct only. */
+ g_assert (self->is_featured == GS_APP_QUERY_TRISTATE_UNSET);
+ self->is_featured = g_value_get_enum (value);
+ break;
case PROP_CATEGORY:
/* Construct only. */
g_assert (self->category == NULL);
@@ -484,6 +494,29 @@ gs_app_query_class_init (GsAppQueryClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GsAppQuery:is-featured:
+ *
+ * Whether apps must be featured (%GS_APP_QUERY_TRISTATE_TRUE), or not
+ * featured (%GS_APP_QUERY_TRISTATE_FALSE).
+ *
+ * If this is %GS_APP_QUERY_TRISTATE_UNSET, apps are not filtered by
+ * their featured state.
+ *
+ * ‘Featured’ apps have been selected by the distribution or software
+ * source to be highlighted or promoted to users in some way. They
+ * should be high quality and feature complete.
+ *
+ * Since: 43
+ */
+ props[PROP_IS_FEATURED] =
+ g_param_spec_enum ("is-featured", "Is Featured",
+ "Whether apps must be featured, or not featured.",
+ GS_TYPE_APP_QUERY_TRISTATE,
+ GS_APP_QUERY_TRISTATE_UNSET,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* GsAppQuery:category: (nullable)
*
@@ -526,6 +559,7 @@ static void
gs_app_query_init (GsAppQuery *self)
{
self->is_curated = GS_APP_QUERY_TRISTATE_UNSET;
+ self->is_featured = GS_APP_QUERY_TRISTATE_UNSET;
self->is_installed = GS_APP_QUERY_TRISTATE_UNSET;
}
@@ -679,6 +713,8 @@ gs_app_query_get_n_properties_set (GsAppQuery *self)
n++;
if (self->is_curated != GS_APP_QUERY_TRISTATE_UNSET)
n++;
+ if (self->is_featured != GS_APP_QUERY_TRISTATE_UNSET)
+ n++;
if (self->category != NULL)
n++;
if (self->is_installed != GS_APP_QUERY_TRISTATE_UNSET)
@@ -745,6 +781,25 @@ gs_app_query_get_is_curated (GsAppQuery *self)
return self->is_curated;
}
+/**
+ * gs_app_query_get_is_featured:
+ * @self: a #GsAppQuery
+ *
+ * Get the value of #GsAppQuery:is-featured.
+ *
+ * Returns: %GS_APP_QUERY_TRISTATE_TRUE if apps must be featured,
+ * %GS_APP_QUERY_TRISTATE_FALSE if they must be not featured, or
+ * %GS_APP_QUERY_TRISTATE_UNSET if it doesn’t matter
+ * Since: 43
+ */
+GsAppQueryTristate
+gs_app_query_get_is_featured (GsAppQuery *self)
+{
+ g_return_val_if_fail (GS_IS_APP_QUERY (self), GS_APP_QUERY_TRISTATE_UNSET);
+
+ return self->is_featured;
+}
+
/**
* gs_app_query_get_category:
* @self: a #GsAppQuery
diff --git a/lib/gs-app-query.h b/lib/gs-app-query.h
index 203cdeaef..02c138f8c 100644
--- a/lib/gs-app-query.h
+++ b/lib/gs-app-query.h
@@ -61,6 +61,7 @@ guint gs_app_query_get_n_properties_set (GsAppQuery *self);
const gchar * const *gs_app_query_get_provides_files (GsAppQuery *self);
GDateTime *gs_app_query_get_released_since (GsAppQuery *self);
GsAppQueryTristate gs_app_query_get_is_curated (GsAppQuery *self);
+GsAppQueryTristate gs_app_query_get_is_featured (GsAppQuery *self);
GsCategory *gs_app_query_get_category (GsAppQuery *self);
GsAppQueryTristate gs_app_query_get_is_installed (GsAppQuery *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]