gnome-panel r11007 - trunk/applets/clock



Author: vuntz
Date: Tue Apr  8 13:56:12 2008
New Revision: 11007
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11007&view=rev

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

	* clock-map.c: make last_refresh a time_t since we don't need struct tm
	(clock_map_init): initialize last_refresh
	(clock_map_display): update the last_refresh time here
	(clock_map_needs_refresh): simplify a bit, do not update the
	last_refresh time here since we didn't refresh anything, and also take
	into account the fact that the clock can go back in the past when
	changing time


Modified:
   trunk/applets/clock/ChangeLog
   trunk/applets/clock/clock-map.c

Modified: trunk/applets/clock/clock-map.c
==============================================================================
--- trunk/applets/clock/clock-map.c	(original)
+++ trunk/applets/clock/clock-map.c	Tue Apr  8 13:56:12 2008
@@ -23,7 +23,7 @@
 static guint signals[LAST_SIGNAL];
 
 typedef struct {
-        struct tm last_refresh;
+        time_t last_refresh;
 
         gint width;
         gint height;
@@ -123,6 +123,7 @@
 
 	GTK_WIDGET_SET_FLAGS (this, GTK_NO_WINDOW);
 
+	priv->last_refresh = 0;
 	priv->highlight_timeout_id = 0;
         priv->stock_map_pixbuf = NULL;
         priv->location_marker_pixbuf[0] = NULL;
@@ -653,9 +654,13 @@
 static void
 clock_map_display (ClockMap *this)
 {
+        ClockMapPrivate *priv = PRIVATE (this);
+
         clock_map_render_shadow (this);
         clock_map_rotate (this);
 	gtk_widget_queue_draw (GTK_WIDGET (this));
+
+        time (&priv->last_refresh);
 }
 
 typedef struct {
@@ -727,26 +732,12 @@
 clock_map_needs_refresh (ClockMap *this)
 {
         ClockMapPrivate *priv = PRIVATE (this);
-        gboolean refresh = FALSE;
-
-        struct tm now;
         time_t now_t;
-        time (&now_t);
 
-        gmtime_r (&now_t, &now);
-
-        /* refresh once per minute */
-        if (now.tm_year > priv->last_refresh.tm_year
-            || now.tm_mon > priv->last_refresh.tm_mon
-            || now.tm_mday > priv->last_refresh.tm_mday
-            || now.tm_hour > priv->last_refresh.tm_hour
-            || now.tm_min > priv->last_refresh.tm_min) {
-                refresh = TRUE;
-        }
-
-        gmtime_r (&now_t, &priv->last_refresh);
+        time (&now_t);
 
-        return refresh;
+	/* refresh once per minute */
+	return (ABS (now_t - priv->last_refresh) >= 60);
 }
 
 void



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