gnome-panel r11025 - trunk/applets/clock



Author: vuntz
Date: Thu Apr 10 03:31:09 2008
New Revision: 11025
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11025&view=rev

Log:
2008-04-10  Vincent Untz  <vuntz gnome org>

	* set-timezone.c: (can_set_system_timezone), (can_set_system_time):
	Implement some caching of the can_do variables. This is some minor
	saving (around 0.01s for each location when opening the calendar
	window), but it was kind of obvious to do.


Modified:
   trunk/applets/clock/ChangeLog
   trunk/applets/clock/set-timezone.c

Modified: trunk/applets/clock/set-timezone.c
==============================================================================
--- trunk/applets/clock/set-timezone.c	(original)
+++ trunk/applets/clock/set-timezone.c	Thu Apr 10 03:31:09 2008
@@ -37,6 +37,8 @@
 
 #include "set-timezone.h"
 
+#define CACHE_VALIDITY_SEC 2
+
 static DBusGConnection *
 get_session_bus (void)
 {
@@ -190,13 +192,33 @@
 gint
 can_set_system_timezone (void)
 {
-	return can_do ("org.gnome.clockapplet.mechanism.settimezone");
+	static gboolean cache = FALSE;
+	static time_t   last_refreshed = 0;
+	time_t          now;
+
+	time (&now);
+	if (ABS (now - last_refreshed) > CACHE_VALIDITY_SEC) {
+		cache = can_do ("org.gnome.clockapplet.mechanism.settimezone");
+		last_refreshed = now;
+	}
+
+	return cache;
 }
 
 gint
 can_set_system_time (void)
 {
-	return can_do ("org.gnome.clockapplet.mechanism.settime");
+	static gboolean cache = FALSE;
+	static time_t   last_refreshed = 0;
+	time_t          now;
+
+	time (&now);
+	if (ABS (now - last_refreshed) > CACHE_VALIDITY_SEC) {
+		cache = can_do ("org.gnome.clockapplet.mechanism.settime");
+		last_refreshed = now;
+	}
+
+	return cache;
 }
 
 typedef struct {



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