[gnome-software: 13/24] gs-app-query: Add a released-since property
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 13/24] gs-app-query: Add a released-since property
- Date: Tue, 3 May 2022 12:52:06 +0000 (UTC)
commit ba7630b514936f4cc128e79fd57d3d5786fc14af
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Apr 13 22:42:43 2022 +0100
gs-app-query: Add a released-since property
This allows querying for recently-updated apps.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-app-query.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
lib/gs-app-query.h | 1 +
2 files changed, 49 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-app-query.c b/lib/gs-app-query.c
index 4025d2a77..ec07757b5 100644
--- a/lib/gs-app-query.c
+++ b/lib/gs-app-query.c
@@ -72,6 +72,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) */
};
G_DEFINE_TYPE (GsAppQuery, gs_app_query, G_TYPE_OBJECT)
@@ -87,9 +88,10 @@ typedef enum {
PROP_FILTER_USER_DATA,
PROP_FILTER_USER_DATA_NOTIFY,
PROP_PROVIDES_FILES,
+ PROP_RELEASED_SINCE,
} GsAppQueryProperty;
-static GParamSpec *props[PROP_PROVIDES_FILES + 1] = { NULL, };
+static GParamSpec *props[PROP_RELEASED_SINCE + 1] = { NULL, };
static void
gs_app_query_get_property (GObject *object,
@@ -130,6 +132,9 @@ gs_app_query_get_property (GObject *object,
case PROP_PROVIDES_FILES:
g_value_set_boxed (value, self->provides_files);
break;
+ case PROP_RELEASED_SINCE:
+ g_value_set_boxed (value, self->released_since);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -199,6 +204,11 @@ gs_app_query_set_property (GObject *object,
if (self->provides_files != NULL && self->provides_files[0] == NULL)
g_clear_pointer (&self->provides_files, g_strfreev);
+ break;
+ case PROP_RELEASED_SINCE:
+ /* Construct only. */
+ g_assert (self->released_since == NULL);
+ self->released_since = g_value_dup_boxed (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -230,6 +240,7 @@ gs_app_query_finalize (GObject *object)
GsAppQuery *self = GS_APP_QUERY (object);
g_clear_pointer (&self->provides_files, g_strfreev);
+ g_clear_pointer (&self->released_since, g_date_time_unref);
G_OBJECT_CLASS (gs_app_query_parent_class)->finalize (object);
}
@@ -400,6 +411,24 @@ gs_app_query_class_init (GsAppQueryClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GsAppQuery:released-since: (nullable)
+ *
+ * A date/time which apps must have been released since (exclusive).
+ *
+ * Used to search for apps which have been updated recently.
+ *
+ * This may be %NULL to not filter on release date.
+ *
+ * Since: 43
+ */
+ props[PROP_RELEASED_SINCE] =
+ g_param_spec_boxed ("released-since", "Released Since",
+ "A date/time which apps must have been released since (exclusive).",
+ G_TYPE_DATE_TIME,
+ 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);
}
@@ -551,3 +580,21 @@ gs_app_query_get_provides_files (GsAppQuery *self)
return (const gchar * const *) self->provides_files;
}
+
+/**
+ * gs_app_query_get_released_since:
+ * @self: a #GsAppQuery
+ *
+ * Get the value of #GsAppQuery:released-since.
+ *
+ * Returns: (nullable): a date/time which apps must have been released since,
+ * or %NULL to not filter on release date
+ * Since: 43
+ */
+GDateTime *
+gs_app_query_get_released_since (GsAppQuery *self)
+{
+ g_return_val_if_fail (GS_IS_APP_QUERY (self), NULL);
+
+ return self->released_since;
+}
diff --git a/lib/gs-app-query.h b/lib/gs-app-query.h
index 1dc9b143f..23e1c95ab 100644
--- a/lib/gs-app-query.h
+++ b/lib/gs-app-query.h
@@ -35,5 +35,6 @@ GsAppListFilterFunc gs_app_query_get_filter_func (GsAppQuery *self,
gpointer *user_data_out);
const gchar * const *gs_app_query_get_provides_files (GsAppQuery *self);
+GDateTime *gs_app_query_get_released_since (GsAppQuery *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]