[gnome-software: 3/11] dummy: Port gs_plugin_add_alternates() vfunc to GsPluginJobListApps




commit 77db38f04b5d151b2bdea99065386e89698711c7
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Jul 6 13:56:17 2022 +0100

    dummy: Port gs_plugin_add_alternates() vfunc to GsPluginJobListApps
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 plugins/dummy/gs-plugin-dummy.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index ff702f3b6..ac584af34 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -355,20 +355,6 @@ gs_plugin_dummy_timeout_finish (GsPluginDummy  *self,
        return g_task_propagate_boolean (G_TASK (result), error);
 }
 
-gboolean
-gs_plugin_add_alternates (GsPlugin *plugin,
-                         GsApp *app,
-                         GsAppList *list,
-                         GCancellable *cancellable,
-                         GError **error)
-{
-       if (g_strcmp0 (gs_app_get_id (app), "zeus.desktop") == 0) {
-               g_autoptr(GsApp) app2 = gs_app_new ("chiron.desktop");
-               gs_app_list_add (list, app2);
-       }
-       return TRUE;
-}
-
 gboolean
 gs_plugin_add_updates (GsPlugin *plugin,
                       GsAppList *list,
@@ -740,6 +726,7 @@ gs_plugin_dummy_list_apps_async (GsPlugin              *plugin,
        GsCategory *category = NULL;
        GsAppQueryTristate is_installed = GS_APP_QUERY_TRISTATE_UNSET;
        const gchar * const *keywords = NULL;
+       GsApp *alternate_of = NULL;
 
        task = g_task_new (plugin, cancellable, callback, user_data);
        g_task_set_source_tag (task, gs_plugin_dummy_list_apps_async);
@@ -751,6 +738,7 @@ gs_plugin_dummy_list_apps_async (GsPlugin              *plugin,
                category = gs_app_query_get_category (query);
                is_installed = gs_app_query_get_is_installed (query);
                keywords = gs_app_query_get_keywords (query);
+               alternate_of = gs_app_query_get_alternate_of (query);
        }
 
        /* Currently only support a subset of query properties, and only one set at once.
@@ -759,7 +747,8 @@ gs_plugin_dummy_list_apps_async (GsPlugin              *plugin,
             is_curated == GS_APP_QUERY_TRISTATE_UNSET &&
             category == NULL &&
             is_installed == GS_APP_QUERY_TRISTATE_UNSET &&
-            keywords == NULL) ||
+            keywords == NULL &&
+            alternate_of == NULL) ||
            is_curated == GS_APP_QUERY_TRISTATE_FALSE ||
            is_installed == GS_APP_QUERY_TRISTATE_FALSE ||
            gs_app_query_get_n_properties_set (query) != 1) {
@@ -891,6 +880,13 @@ gs_plugin_dummy_list_apps_async (GsPlugin              *plugin,
                }
        }
 
+       if (alternate_of != NULL) {
+               if (g_strcmp0 (gs_app_get_id (alternate_of), "zeus.desktop") == 0) {
+                       g_autoptr(GsApp) app = gs_app_new ("chiron.desktop");
+                       gs_app_list_add (list, app);
+               }
+       }
+
        g_task_return_pointer (task, g_steal_pointer (&list), (GDestroyNotify) g_object_unref);
 }
 


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