[gnome-software: 9/16] gs-installed-page: Port from GsPluginJobListInstalledApps to ListApps
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 9/16] gs-installed-page: Port from GsPluginJobListInstalledApps to ListApps
- Date: Sun, 22 May 2022 13:39:42 +0000 (UTC)
commit 39ae21285b7d9e7ca364fcd200d189ad3a39f3ee
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon May 9 10:58:03 2022 +0100
gs-installed-page: Port from GsPluginJobListInstalledApps to ListApps
This will allow simplifying the code which implements the plugin jobs.
The filtering now needs to be done in the caller, as `ListApps` has
slightly less inbuilt filtering than `ListInstalledApps` did.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
src/gs-installed-page.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index ab6a6dbc3..978cd66c0 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -441,10 +441,32 @@ gs_installed_page_remove_all_cb (GtkWidget *container,
gtk_list_box_remove (GTK_LIST_BOX (container), child);
}
+static gboolean
+filter_app_kinds_cb (GsApp *app,
+ gpointer user_data)
+{
+ /* Remove invalid apps. */
+ if (!gs_plugin_loader_app_is_valid (app, GS_PLUGIN_REFINE_FLAGS_NONE))
+ return FALSE;
+
+ switch (gs_app_get_kind (app)) {
+ case AS_COMPONENT_KIND_OPERATING_SYSTEM:
+ case AS_COMPONENT_KIND_CODEC:
+ case AS_COMPONENT_KIND_FONT:
+ g_debug ("app invalid as %s: %s",
+ as_component_kind_to_string (gs_app_get_kind (app)),
+ gs_app_get_unique_id (app));
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
static void
gs_installed_page_load (GsInstalledPage *self)
{
GsPluginRefineFlags flags;
+ g_autoptr(GsAppQuery) query = NULL;
g_autoptr(GsPluginJob) plugin_job = NULL;
if (self->waiting)
@@ -475,8 +497,11 @@ gs_installed_page_load (GsInstalledPage *self)
flags |= GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE;
/* get installed apps */
- plugin_job = gs_plugin_job_list_installed_apps_new (flags, 0, GS_APP_LIST_FILTER_FLAG_NONE,
- GS_PLUGIN_LIST_INSTALLED_APPS_FLAGS_INTERACTIVE);
+ query = gs_app_query_new ("is-installed", GS_APP_QUERY_TRISTATE_TRUE,
+ "refine-flags", flags,
+ "filter-func", filter_app_kinds_cb,
+ NULL);
+ plugin_job = gs_plugin_job_list_apps_new (query, GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE);
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]