[gnome-software: 8/16] dummy: Port from GsPluginJobListInstalledApps to GsPluginJobListApps




commit bca8303cbafbf5b81d2f7aad8f1f186a5c09f24a
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon May 9 10:57:25 2022 +0100

    dummy: Port from GsPluginJobListInstalledApps to GsPluginJobListApps
    
    This will allow removing the former, and simplifying code.
    
    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

 plugins/dummy/gs-self-test.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 38fc26e04..671ca6287 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -347,6 +347,13 @@ gs_plugins_dummy_distro_upgrades_func (GsPluginLoader *plugin_loader)
        g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_UPDATABLE);
 }
 
+static gboolean
+filter_valid_cb (GsApp    *app,
+                 gpointer  user_data)
+{
+       return gs_plugin_loader_app_is_valid (app, GS_PLUGIN_REFINE_FLAGS_NONE);
+}
+
 static void
 gs_plugins_dummy_installed_func (GsPluginLoader *plugin_loader)
 {
@@ -356,6 +363,7 @@ gs_plugins_dummy_installed_func (GsPluginLoader *plugin_loader)
        g_autofree gchar *menu_path = NULL;
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
+       g_autoptr(GsAppQuery) query = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
        g_autoptr(GIcon) icon = NULL;
        GsPluginRefineFlags refine_flags;
@@ -369,8 +377,12 @@ gs_plugins_dummy_installed_func (GsPluginLoader *plugin_loader)
                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES |
                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE);
 
-       plugin_job = gs_plugin_job_list_installed_apps_new (refine_flags, 0, 
GS_PLUGIN_JOB_DEDUPE_FLAGS_DEFAULT,
-                                                           GS_PLUGIN_LIST_INSTALLED_APPS_FLAGS_NONE);
+       query = gs_app_query_new ("is-installed", GS_APP_QUERY_TRISTATE_TRUE,
+                                 "refine-flags", refine_flags,
+                                 "dedupe-flags", GS_PLUGIN_JOB_DEDUPE_FLAGS_DEFAULT,
+                                 "filter-func", filter_valid_cb,
+                                 NULL);
+       plugin_job = gs_plugin_job_list_apps_new (query, GS_PLUGIN_LIST_APPS_FLAGS_NONE);
        list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
        gs_test_flush_main_context ();
        g_assert_no_error (error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]