[gnome-software: 19/24] gs-overview-page: Use GsPluginJobListApps rather than ACTION_GET_RECENT
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 19/24] gs-overview-page: Use GsPluginJobListApps rather than ACTION_GET_RECENT
- Date: Tue, 3 May 2022 12:52:06 +0000 (UTC)
commit 36bde44f36f29fe2ed2dc65a15a22dcd6b9b1570
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Apr 13 23:47:41 2022 +0100
gs-overview-page: Use GsPluginJobListApps rather than ACTION_GET_RECENT
This is another step towards removing `ACTION_GET_RECENT` and allowing
plugins to consolidate their vfuncs which list apps.
For the overview page specifically, it will allow filtering to be moved
into the plugin job, rather than done on the returned results. That
should avoid problems with filtering after `max-results` has been
applied meaning too few results are returned.
Taking advantage of that will be done in a following commit. This commit
just ports the query verbatim, using the default filter which was
previously applied by `gs-plugin-loader.c`.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
src/gs-overview-page.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 479d49b26..567d32c96 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -182,6 +182,14 @@ gs_overview_page_sort_recent_cb (GsApp *app1,
return -1;
}
+static gboolean
+gs_overview_page_filter_recent_cb (GsApp *app,
+ gpointer user_data)
+{
+ return (!gs_app_has_quirk (app, GS_APP_QUIRK_COMPULSORY) &&
+ gs_app_get_kind (app) == AS_COMPONENT_KIND_DESKTOP_APP);
+}
+
static void
gs_overview_page_get_recent_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
@@ -527,18 +535,28 @@ gs_overview_page_load (GsOverviewPage *self)
if (!self->loading_recent) {
g_autoptr(GsPluginJob) plugin_job = NULL;
+ g_autoptr(GDateTime) now = NULL;
+ g_autoptr(GDateTime) released_since = NULL;
+ g_autoptr(GsAppQuery) query = NULL;
+ GsPluginListAppsFlags flags = GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE;
+
+ now = g_date_time_new_now_local ();
+ released_since = g_date_time_add_seconds (now, -(60 * 60 * 24 * 30));
+ query = gs_app_query_new ("released-since", released_since,
+ /* To have large-enough set, in case filtering removes some
non-applicable apps */
+ "max-results", 3 * N_TILES,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
+ "dedupe-flags", GS_APP_LIST_FILTER_FLAG_KEY_ID |
+ GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
+ GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
+ "sort-func", gs_overview_page_sort_recent_cb,
+ "filter-func", gs_overview_page_filter_recent_cb,
+ NULL);
+
+ plugin_job = gs_plugin_job_list_apps_new (query, flags);
self->loading_recent = TRUE;
- plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_RECENT,
- "age", (guint64) (60 * 60 * 24 * 30),
- /* To have large-enough set, in case filtering removes some
non-applicable apps */
- "max-results", 3 * N_TILES,
- "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
- "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
- GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
- NULL);
- gs_plugin_job_set_sort_func (plugin_job, gs_overview_page_sort_recent_cb, NULL);
gs_plugin_loader_job_process_async (self->plugin_loader,
plugin_job,
self->cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]