[gnome-packagekit] Don't do the update check as soon as the UpdatesChanged signal is recieved, wait a little time
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-packagekit] Don't do the update check as soon as the UpdatesChanged signal is recieved, wait a little time
- Date: Wed, 15 Jul 2009 14:18:14 +0000 (UTC)
commit 92aea2faeb83d0f7257c76b3b5cd69752dbbaee0
Author: Richard Hughes <richard hughsie com>
Date: Wed Jul 15 13:45:07 2009 +0100
Don't do the update check as soon as the UpdatesChanged signal is recieved, wait a little time
src/gpk-check-update.c | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 7a4b61e..a8f8ac0 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -60,6 +60,9 @@ static void gpk_check_update_finalize (GObject *object);
/* the maximum number of lines of data on the libnotify widget */
#define GPK_CHECK_UPDATE_MAX_NUMBER_SECURITY_ENTRIES 7
+/* the amount of time after ::UpdatesChanged we refresh the update list */
+#define GPK_CHECK_UPDATE_UPDATES_CHANGED_TIMEOUT 60 /* seconds */
+
struct GpkCheckUpdatePrivate
{
GtkStatusIcon *status_icon;
@@ -78,6 +81,7 @@ struct GpkCheckUpdatePrivate
NotifyNotification *notification_updates_available;
GPtrArray *important_updates_array;
EggDbusMonitor *dbus_monitor_viewer;
+ guint updates_changed_id;
};
G_DEFINE_TYPE (GpkCheckUpdate, gpk_check_update, G_TYPE_OBJECT)
@@ -1020,6 +1024,18 @@ gpk_check_update_query_updates_idle_cb (GpkCheckUpdate *cupdate)
}
/**
+ * gpk_check_update_query_updates_changed_cb:
+ **/
+static gboolean
+gpk_check_update_query_updates_changed_cb (GpkCheckUpdate *cupdate)
+{
+ egg_debug ("getting new update list (after we waited a short delay)");
+ cupdate->priv->updates_changed_id = 0;
+ gpk_check_update_query_updates (cupdate, TRUE);
+ return FALSE;
+}
+
+/**
* gpk_check_update_updates_changed_cb:
**/
static void
@@ -1036,9 +1052,15 @@ gpk_check_update_updates_changed_cb (PkControl *control, GpkCheckUpdate *cupdate
return;
}
+ /* if we get this in the timeout, just remove and start again from now */
+ if (cupdate->priv->updates_changed_id > 0)
+ g_source_remove (cupdate->priv->updates_changed_id);
+
/* now try to get newest update list */
- egg_debug ("updates changed, so getting new update list");
- g_idle_add ((GSourceFunc) gpk_check_update_query_updates_idle_cb, cupdate);
+ egg_debug ("updates changed, so getting new update list soon");
+ cupdate->priv->updates_changed_id =
+ g_timeout_add_seconds (GPK_CHECK_UPDATE_UPDATES_CHANGED_TIMEOUT,
+ (GSourceFunc) gpk_check_update_query_updates_changed_cb, cupdate);
}
/**
@@ -1509,6 +1531,7 @@ gpk_check_update_init (GpkCheckUpdate *cupdate)
cupdate->priv = GPK_CHECK_UPDATE_GET_PRIVATE (cupdate);
+ cupdate->priv->updates_changed_id = 0;
cupdate->priv->notification_updates_available = NULL;
cupdate->priv->important_updates_array = NULL;
cupdate->priv->icon_name = NULL;
@@ -1622,6 +1645,8 @@ gpk_check_update_finalize (GObject *object)
g_ptr_array_free (cupdate->priv->important_updates_array, TRUE);
}
g_free (cupdate->priv->icon_name);
+ if (cupdate->priv->updates_changed_id > 0)
+ g_source_remove (cupdate->priv->updates_changed_id);
G_OBJECT_CLASS (gpk_check_update_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]