[gnome-software] Delay the updates-changed notification for a few seconds
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Delay the updates-changed notification for a few seconds
- Date: Thu, 11 Dec 2014 16:54:25 +0000 (UTC)
commit 420908bab1d3112c1ec2480a92b0205f69e4f63c
Author: Richard Hughes <richard hughsie com>
Date: Thu Dec 11 16:43:15 2014 +0000
Delay the updates-changed notification for a few seconds
This allows us to continue with the current multi-stage task without ripping
down and refreshing all the existing GsApp's.
src/gs-plugin-loader.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index d66fc04..dfc4a06 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -27,6 +27,8 @@
#include "gs-plugin.h"
#include "gs-profile.h"
+#define GS_PLUGIN_LOADER_UPDATES_CHANGED_DELAY 3 /* s */
+
static void gs_plugin_loader_finalize (GObject *object);
struct GsPluginLoaderPrivate
@@ -47,6 +49,7 @@ struct GsPluginLoaderPrivate
gint scale;
GList *queued_installs;
+ guint updates_changed_id;
gboolean online;
};
@@ -2549,10 +2552,10 @@ gs_plugin_loader_status_update_cb (GsPlugin *plugin,
}
/**
- * gs_plugin_loader_updates_changed_cb:
+ * gs_plugin_loader_updates_changed_delay_cb:
*/
-static void
-gs_plugin_loader_updates_changed_cb (GsPlugin *plugin, gpointer user_data)
+static gboolean
+gs_plugin_loader_updates_changed_delay_cb (gpointer user_data)
{
GList *apps;
GList *l;
@@ -2575,6 +2578,23 @@ gs_plugin_loader_updates_changed_cb (GsPlugin *plugin, gpointer user_data)
/* notify shells */
g_debug ("updates-changed");
g_signal_emit (plugin_loader, signals[SIGNAL_UPDATES_CHANGED], 0);
+ plugin_loader->priv->updates_changed_id = 0;
+ return FALSE;
+}
+
+/**
+ * gs_plugin_loader_updates_changed_cb:
+ */
+static void
+gs_plugin_loader_updates_changed_cb (GsPlugin *plugin, gpointer user_data)
+{
+ GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (user_data);
+ if (plugin_loader->priv->updates_changed_id != 0)
+ return;
+ plugin_loader->priv->updates_changed_id =
+ g_timeout_add_seconds (GS_PLUGIN_LOADER_UPDATES_CHANGED_DELAY,
+ gs_plugin_loader_updates_changed_delay_cb,
+ plugin_loader);
}
/**
@@ -2937,6 +2957,9 @@ gs_plugin_loader_finalize (GObject *object)
g_return_if_fail (plugin_loader->priv != NULL);
+ if (plugin_loader->priv->updates_changed_id != 0)
+ g_source_remove (plugin_loader->priv->updates_changed_id);
+
/* application stop */
gs_profile_stop (plugin_loader->priv->profile, "GsPluginLoader");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]