[gnome-software: 7/14] docs: Make get_installed asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/14] docs: Make get_installed asynchronous
- Date: Thu, 27 Jan 2022 20:27:48 +0000 (UTC)
commit 04cf7ddfd45afcd2d0761e8a5f226b6b98281658
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Dec 9 16:44:51 2021 +0000
docs: Make get_installed asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
doc/api/gnome-software-docs.xml | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/doc/api/gnome-software-docs.xml b/doc/api/gnome-software-docs.xml
index 4720dcb91..e20808f3f 100644
--- a/doc/api/gnome-software-docs.xml
+++ b/doc/api/gnome-software-docs.xml
@@ -211,20 +211,27 @@ gs_plugin_sample_init (GsPluginSample *self)
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "icons");
}
-gboolean
-gs_plugin_add_installed (GsPlugin *plugin,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_custom_list_installed_apps_async (GsPlugin *plugin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
g_autofree gchar *fn = NULL;
g_autoptr(GsApp) app = NULL;
g_autoptr(GIcon) icon = NULL;
+ g_autoptr(GsAppList) list = gs_app_list_new ();
+ g_autoptr(GTask) task = NULL;
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_custom_list_installed_apps_async);
/* check if the app exists */
fn = g_build_filename (g_get_home_dir (), "chiron", NULL);
- if (!g_file_test (fn, G_FILE_TEST_EXISTS))
- return TRUE;
+ if (!g_file_test (fn, G_FILE_TEST_EXISTS)) {
+ g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
+ return;
+ }
/* the trigger exists, so create a fake app */
app = gs_app_new ("chiron.desktop");
@@ -254,7 +261,15 @@ gs_plugin_add_installed (GsPlugin *plugin,
/* return new app */
gs_app_list_add (list, app);
- return TRUE;
+ g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
+}
+
+static GsAppList *
+gs_plugin_custom_list_installed_apps_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_pointer (G_TASK (result), error);
}
</programlisting>
</example>
@@ -618,7 +633,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
same logical thing.
This means we can query the installed list, start installing an
application, then query it again before the install has finished.
- The GsApp returned from the second <code>add_installed()</code>
+ The GsApp returned from the second <code>list_installed_apps()</code>
request will be the same GObject, and thus all the signals connecting
up to the UI will still be correct.
This means we don't have to care about <emphasis>migrating</emphasis>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]