[gnome-software: 16/29] dummy: Make plugin setup asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 16/29] dummy: Make plugin setup asynchronous
- Date: Mon, 6 Dec 2021 10:24:18 +0000 (UTC)
commit 33b9e72725628d2b0be6f30dddfbd9e040f69578
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Oct 15 14:05:35 2021 +0100
dummy: Make plugin setup asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/dummy/gs-plugin-dummy.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index c09a5f1fa..0c95fa921 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -72,12 +72,17 @@ gs_plugin_dummy_dispose (GObject *object)
G_OBJECT_CLASS (gs_plugin_dummy_parent_class)->dispose (object);
}
-gboolean
-gs_plugin_setup (GsPlugin *plugin,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_dummy_setup_async (GsPlugin *plugin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GsPluginDummy *self = GS_PLUGIN_DUMMY (plugin);
+ g_autoptr(GTask) task = NULL;
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_dummy_setup_async);
/* toggle this */
if (g_getenv ("GS_SELF_TEST_TOGGLE_ALLOW_UPDATES") != NULL) {
@@ -111,7 +116,15 @@ gs_plugin_setup (GsPlugin *plugin,
g_strdup ("com.hughski.ColorHug2.driver"),
GUINT_TO_POINTER (1));
- return TRUE;
+ g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gs_plugin_dummy_setup_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
}
void
@@ -887,8 +900,12 @@ static void
gs_plugin_dummy_class_init (GsPluginDummyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GsPluginClass *plugin_class = GS_PLUGIN_CLASS (klass);
object_class->dispose = gs_plugin_dummy_dispose;
+
+ plugin_class->setup_async = gs_plugin_dummy_setup_async;
+ plugin_class->setup_finish = gs_plugin_dummy_setup_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]