Index: clock.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.c,v
retrieving revision 1.154
diff -u -r1.154 clock.c
--- clock.c	28 Oct 2004 16:07:09 -0000	1.154
+++ clock.c	29 Oct 2004 11:10:21 -0000
@@ -138,7 +138,6 @@
         time_t             current_time;
 	char              *timeformat;
 	guint              timeout;
-	int                timeouttime;
 	PanelAppletOrient  orient;
 	int                size;
 
@@ -156,7 +155,8 @@
 	guint listeners [N_GCONF_PREFS];
 };
 
-static void update_clock (ClockData * cd);
+static void  update_clock (ClockData * cd);
+static float get_itime    (time_t current_time);
 
 static void set_atk_name_description (GtkWidget *widget,
                                       const char *name,
@@ -206,40 +206,26 @@
 clock_timeout_callback (gpointer data)
 {
 	ClockData *cd = data;
+	time_t new_time;
 
-	update_clock (cd);
+        time (&new_time);
 
 	if (!cd->showseconds && cd->format != CLOCK_FORMAT_UNIX) {
-		if (cd->format != CLOCK_FORMAT_INTERNET) {
-			int sec = cd->current_time % 60;
-			if (sec != 0 || cd->timeouttime != 60000) {
-				/* ensure next update is exactly on 0 seconds */
-				cd->timeouttime = (60 - sec)*1000;
-				cd->timeout = g_timeout_add (cd->timeouttime,
-							     clock_timeout_callback,
-							     cd);
-				return FALSE;
-			}
-		} else {
-			struct tm *tm;
-			time_t bmt;
-			long isec;
-
-			/* BMT (Biel Mean Time) is GMT+1 */
-			bmt = cd->current_time + 3600;
-			tm = gmtime (&bmt);
-			isec = ((tm->tm_hour*3600 + tm->tm_min*60 + tm->tm_sec)*10) % 864;
-			
-			if (isec != 0 || cd->timeouttime != INTERNETBEAT) {
-				/* ensure next update is exactly on beat limit */
-				cd->timeouttime = (864 - isec)*100;
-				cd->timeout = g_timeout_add (cd->timeouttime,
-							     clock_timeout_callback,
-							     cd);
-				return FALSE;
-			}
+		if (cd->format != CLOCK_FORMAT_INTERNET && 
+		    new_time % 60 != cd->current_time % 60)
+		{
+				update_clock (cd);
+		}
+		else if ((long)get_itime (new_time) !=
+			 (long)get_itime (cd->current_time))
+		{
+				update_clock (cd);
 		}
 	}
+	else
+	{
+		update_clock (cd);
+	}
 
 	return TRUE;
 }
@@ -407,6 +393,8 @@
 static void
 refresh_clock_timeout(ClockData *cd)
 {
+	int timeouttime;
+
 	unfix_size (cd);
 	
 	update_timeformat (cd);
@@ -416,29 +404,12 @@
 
 	update_clock (cd);
 	
-	if (cd->format == CLOCK_FORMAT_INTERNET) {
-		if (cd->showseconds)
-			cd->timeouttime = INTERNETSECOND;
-		else {
-			struct tm *tm;
-			time_t bmt;
-			long isec;
-
-			/* BMT (Biel Mean Time) is GMT+1 */
-			bmt = cd->current_time + 3600;
-			tm = gmtime (&bmt);
-			isec = ((tm->tm_hour*3600 + tm->tm_min*60 + tm->tm_sec)*10) % 864;
-			cd->timeouttime = (864 - isec)*100;
-		}
-	}
-	else if(cd->format == CLOCK_FORMAT_UNIX ||
-		cd->format == CLOCK_FORMAT_CUSTOM ||
-		cd->showseconds)
-		cd->timeouttime = 1000;
+	if (cd->format == CLOCK_FORMAT_INTERNET)
+		timeouttime = INTERNETSECOND;
 	else
-		cd->timeouttime = (60 - cd->current_time % 60)*1000;
+		timeouttime = 1000;
 	
-	cd->timeout = g_timeout_add (cd->timeouttime,
+	cd->timeout = g_timeout_add (timeouttime,
 	                             clock_timeout_callback,
 	                             cd);
 }
