[gnome-software/wip/automatic-update-fixes: 20/25] plugin-loader: Add gs_plugin_loader_emit_updates_changed()




commit 20dfe9f6a0038fe6977b8758abff91d77e9416e7
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 15 18:02:11 2022 +0200

    plugin-loader: Add gs_plugin_loader_emit_updates_changed()
    
    It will help to avoid delays with the GUI after changes in the updates.

 lib/gs-plugin-loader.c | 23 +++++++++++++++++++++++
 lib/gs-plugin-loader.h |  1 +
 2 files changed, 24 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 03692fe82..a0e099b36 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -4466,3 +4466,26 @@ gs_plugin_loader_get_category_manager (GsPluginLoader *plugin_loader)
 
        return plugin_loader->category_manager;
 }
+
+/**
+ * gs_plugin_loader_emit_updates_changed:
+ * @self: a #GsPluginLoader
+ *
+ * Emits the #GsPluginLoader:updates-changed signal in the nearest
+ * idle in the main thread.
+ *
+ * Since: 43
+ **/
+void
+gs_plugin_loader_emit_updates_changed (GsPluginLoader *self)
+{
+       g_return_if_fail (GS_IS_PLUGIN_LOADER (self));
+
+       if (self->updates_changed_id != 0)
+               g_source_remove (self->updates_changed_id);
+
+       self->updates_changed_id =
+               g_idle_add_full (G_PRIORITY_HIGH_IDLE,
+                                gs_plugin_loader_job_updates_changed_delay_cb,
+                                g_object_ref (self), g_object_unref);
+}
diff --git a/lib/gs-plugin-loader.h b/lib/gs-plugin-loader.h
index bb2c7d8e6..91c5f643c 100644
--- a/lib/gs-plugin-loader.h
+++ b/lib/gs-plugin-loader.h
@@ -125,5 +125,6 @@ gboolean     gs_plugin_loader_app_is_compatible     (GsPluginLoader *plugin_loader,
 
 void            gs_plugin_loader_run_adopt             (GsPluginLoader *plugin_loader,
                                                         GsAppList *list);
+void            gs_plugin_loader_emit_updates_changed  (GsPluginLoader *self);
 
 G_END_DECLS


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