[gnome-software: 3/14] dummy: Make get_installed asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 3/14] dummy: Make get_installed asynchronous
- Date: Thu, 27 Jan 2022 20:27:48 +0000 (UTC)
commit 6df8de4e9ae4305050c6ffbeaedb0a7c2d885009
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Dec 9 15:49:11 2021 +0000
dummy: Make get_installed asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/dummy/gs-plugin-dummy.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index 12395325e..20b7ae909 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -458,16 +458,21 @@ gs_plugin_add_updates (GsPlugin *plugin,
return TRUE;
}
-gboolean
-gs_plugin_add_installed (GsPlugin *plugin,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_dummy_list_installed_apps_async (GsPlugin *plugin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
const gchar *packages[] = { "zeus", "zeus-common", NULL };
const gchar *app_ids[] = { "Uninstall Zeus.desktop", NULL };
+ g_autoptr(GsAppList) list = gs_app_list_new ();
+ g_autoptr(GTask) task = NULL;
guint i;
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_dummy_list_installed_apps_async);
+
/* add all packages */
for (i = 0; packages[i] != NULL; i++) {
g_autoptr(GsApp) app = gs_app_new (NULL);
@@ -488,7 +493,15 @@ gs_plugin_add_installed (GsPlugin *plugin,
gs_app_list_add (list, app);
}
- return TRUE;
+ g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
+}
+
+static GsAppList *
+gs_plugin_dummy_list_installed_apps_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_pointer (G_TASK (result), error);
}
gboolean
@@ -924,6 +937,8 @@ gs_plugin_dummy_class_init (GsPluginDummyClass *klass)
plugin_class->setup_finish = gs_plugin_dummy_setup_finish;
plugin_class->refine_async = gs_plugin_dummy_refine_async;
plugin_class->refine_finish = gs_plugin_dummy_refine_finish;
+ plugin_class->list_installed_apps_async = gs_plugin_dummy_list_installed_apps_async;
+ plugin_class->list_installed_apps_finish = gs_plugin_dummy_list_installed_apps_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]