[gnome-software: 3/15] gs-app-query: Add an is-curated property
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 3/15] gs-app-query: Add an is-curated property
- Date: Mon, 9 May 2022 13:09:05 +0000 (UTC)
commit b8cc98a9b1773f5b72dbead47314e87d9d012704
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 3 16:53:47 2022 +0100
gs-app-query: Add an is-curated property
This allows for querying for apps which are curated.
Currently, those are apps which have the `GnomeSoftware::popular` kudo.
This query property will eventually replace the `GET_POPULAR` action /
`gs_plugin_add_popular()` vfunc.
The terminology is being changed from ‘popular’ to ‘curated’ to reflect
what actually happens: these apps are reviewed and curated by an editor,
rather than being selected through a popular vote or similar.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-app-query.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
lib/gs-app-query.h | 22 ++++++++++++++++++++++
2 files changed, 76 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-app-query.c b/lib/gs-app-query.c
index ec07757b5..5670ee5a0 100644
--- a/lib/gs-app-query.c
+++ b/lib/gs-app-query.c
@@ -73,6 +73,7 @@ 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) */
+ GsAppQueryTristate is_curated;
};
G_DEFINE_TYPE (GsAppQuery, gs_app_query, G_TYPE_OBJECT)
@@ -89,9 +90,10 @@ typedef enum {
PROP_FILTER_USER_DATA_NOTIFY,
PROP_PROVIDES_FILES,
PROP_RELEASED_SINCE,
+ PROP_IS_CURATED,
} GsAppQueryProperty;
-static GParamSpec *props[PROP_RELEASED_SINCE + 1] = { NULL, };
+static GParamSpec *props[PROP_IS_CURATED + 1] = { NULL, };
static void
gs_app_query_get_property (GObject *object,
@@ -135,6 +137,9 @@ gs_app_query_get_property (GObject *object,
case PROP_RELEASED_SINCE:
g_value_set_boxed (value, self->released_since);
break;
+ case PROP_IS_CURATED:
+ g_value_set_enum (value, self->is_curated);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -210,6 +215,11 @@ gs_app_query_set_property (GObject *object,
g_assert (self->released_since == NULL);
self->released_since = g_value_dup_boxed (value);
break;
+ case PROP_IS_CURATED:
+ /* Construct only. */
+ g_assert (self->is_curated == GS_APP_QUERY_TRISTATE_UNSET);
+ self->is_curated = g_value_get_enum (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -429,12 +439,36 @@ gs_app_query_class_init (GsAppQueryClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GsAppQuery:is-curated:
+ *
+ * Whether apps must be curated (%GS_APP_QUERY_TRISTATE_TRUE), or not
+ * curated (%GS_APP_QUERY_TRISTATE_FALSE).
+ *
+ * If this is %GS_APP_QUERY_TRISTATE_UNSET, apps are not filtered by
+ * their curation state.
+ *
+ * ‘Curated’ apps have been reviewed and picked by an editor to be
+ * promoted to users in some way. They should be high quality and
+ * feature complete.
+ *
+ * Since: 43
+ */
+ props[PROP_IS_CURATED] =
+ g_param_spec_enum ("is-curated", "Is Curated",
+ "Whether apps must be curated, or not curated.",
+ 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);
+
g_object_class_install_properties (object_class, G_N_ELEMENTS (props), props);
}
static void
gs_app_query_init (GsAppQuery *self)
{
+ self->is_curated = GS_APP_QUERY_TRISTATE_UNSET;
}
/**
@@ -598,3 +632,22 @@ gs_app_query_get_released_since (GsAppQuery *self)
return self->released_since;
}
+
+/**
+ * gs_app_query_get_is_curated:
+ * @self: a #GsAppQuery
+ *
+ * Get the value of #GsAppQuery:is-curated.
+ *
+ * Returns: %GS_APP_QUERY_TRISTATE_TRUE if apps must be curated,
+ * %GS_APP_QUERY_TRISTATE_FALSE if they must be not curated, or
+ * %GS_APP_QUERY_TRISTATE_UNSET if it doesn’t matter
+ * Since: 43
+ */
+GsAppQueryTristate
+gs_app_query_get_is_curated (GsAppQuery *self)
+{
+ g_return_val_if_fail (GS_IS_APP_QUERY (self), GS_APP_QUERY_TRISTATE_FALSE);
+
+ return self->is_curated;
+}
diff --git a/lib/gs-app-query.h b/lib/gs-app-query.h
index 23e1c95ab..56f6dcbf5 100644
--- a/lib/gs-app-query.h
+++ b/lib/gs-app-query.h
@@ -19,6 +19,27 @@
G_BEGIN_DECLS
+/**
+ * GsAppQueryTristate:
+ * @GS_APP_QUERY_TRISTATE_UNSET: Value is unset.
+ * @GS_APP_QUERY_TRISTATE_FALSE: False. Equal in value to %FALSE.
+ * @GS_APP_QUERY_TRISTATE_TRUE: True. Equal in value to %TRUE.
+ *
+ * A type for storing a boolean value which can also have an ‘unknown’ or
+ * ‘unset’ state.
+ *
+ * Within #GsAppQuery this is used for boolean query properties which are unset
+ * by default so that they don’t affect the query.
+ *
+ * Since: 43
+ */
+typedef enum
+{
+ GS_APP_QUERY_TRISTATE_UNSET = -1,
+ GS_APP_QUERY_TRISTATE_FALSE = 0,
+ GS_APP_QUERY_TRISTATE_TRUE = 1,
+} GsAppQueryTristate;
+
#define GS_TYPE_APP_QUERY (gs_app_query_get_type ())
G_DECLARE_FINAL_TYPE (GsAppQuery, gs_app_query, GS, APP_QUERY, GObject)
@@ -36,5 +57,6 @@ 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);
+GsAppQueryTristate gs_app_query_get_is_curated (GsAppQuery *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]