Index: docs/reference/glib/tmpl/timers.sgml
===================================================================
RCS file: /cvs/gnome/glib/docs/reference/glib/tmpl/timers.sgml,v
retrieving revision 1.11
diff -u -b -r1.11 timers.sgml
--- docs/reference/glib/tmpl/timers.sgml	11 Dec 2002 23:13:24 -0000	1.11
+++ docs/reference/glib/tmpl/timers.sgml	22 Jan 2004 03:27:29 -0000
@@ -52,6 +52,18 @@
 @timer: a #GTimer.
 
 
+<!-- ##### FUNCTION g_timer_continue ##### -->
+<para>
+Resumes a timer that has previously been stopped with g_timer_stop().
+g_timer_stop() must be called before using this function, or the
+behaviour of the timer will be undefined for the rest of its lifetime.
+g_timer_continue() works internally by resetting the start time of the
+timer to the current time minus the previously elapsed interval.
+</para>
+
+@timer: a #GTimer.
+@Since: 2.4
+
 <!-- ##### FUNCTION g_timer_elapsed ##### -->
 <para>
 If @timer has been started but not stopped, obtains the time since the timer was
Index: glib/gtimer.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gtimer.c,v
retrieving revision 1.20
diff -u -b -r1.20 gtimer.c
--- glib/gtimer.c	11 Dec 2002 23:40:10 -0000	1.20
+++ glib/gtimer.c	22 Jan 2004 03:27:30 -0000
@@ -118,6 +118,53 @@
   GETTIME (timer->start);
 }
 
+void
+g_timer_continue (GTimer *timer)
+{
+#ifdef G_OS_WIN32
+  DWORD elapsed;
+#else
+  struct timeval elapsed;
+#endif /* G_OS_WIN32 */
+
+  g_return_if_fail (timer != NULL);
+  g_return_if_fail (timer->active == FALSE); /* should this silently be ignored? */
+
+#ifdef G_OS_WIN32
+
+  elapsed = timer->end - timer->start;
+
+  GETTIME (timer->start);
+
+  timer->start -= elapsed;
+
+#else /* !G_OS_WIN32 */
+
+  if (timer->start.tv_usec > timer->end.tv_usec)
+    {
+      timer->end.tv_usec += G_USEC_PER_SEC;
+      timer->end.tv_sec--;
+    }
+
+  elapsed.tv_usec = timer->end.tv_usec - timer->start.tv_usec;
+  elapsed.tv_sec = timer->end.tv_sec - timer->start.tv_sec;
+
+  GETTIME (timer->start);
+
+  if (timer->start.tv_usec < elapsed.tv_usec)
+    {
+      timer->start.tv_usec += G_USEC_PER_SEC;
+      timer->start.tv_sec--;
+    }
+
+  timer->start.tv_usec -= elapsed.tv_usec;
+  timer->start.tv_sec -= elapsed.tv_sec;
+
+#endif /* !G_OS_WIN32 */
+
+  timer->active = TRUE;
+}
+
 gdouble
 g_timer_elapsed (GTimer *timer,
 		 gulong *microseconds)
Index: glib/gtimer.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gtimer.h,v
retrieving revision 1.4
diff -u -b -r1.4 gtimer.h
--- glib/gtimer.h	8 Nov 2002 18:47:54 -0000	1.4
+++ glib/gtimer.h	22 Jan 2004 03:27:30 -0000
@@ -44,6 +44,7 @@
 void	g_timer_start	(GTimer	  *timer);
 void	g_timer_stop	(GTimer	  *timer);
 void	g_timer_reset	(GTimer	  *timer);
+void	g_timer_continue	(GTimer   *timer);
 gdouble g_timer_elapsed (GTimer	  *timer,
 			 gulong	  *microseconds);
 
Index: tests/testglib.c
===================================================================
RCS file: /cvs/gnome/glib/tests/testglib.c,v
retrieving revision 1.64
diff -u -b -r1.64 testglib.c
--- tests/testglib.c	20 Nov 2003 23:12:05 -0000	1.64
+++ tests/testglib.c	22 Jan 2004 03:27:32 -0000
@@ -316,7 +316,7 @@
   GHashTable *hash_table;
   GMemChunk *mem_chunk;
   GStringChunk *string_chunk;
-  GTimer *timer;
+  GTimer *timer, *timer2;
   gint nums[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
   gint morenums[10] = { 8, 9, 7, 0, 3, 2, 5, 1, 4, 6};
   gchar *string;
@@ -945,6 +945,56 @@
   g_timer_destroy (timer);
 
   g_print ("ok\n");
+
+  g_print ("checking g_timer_continue...\n");
+
+  timer2 = g_timer_new ();
+
+  g_print ("\trun for 1 second...\n");
+  timer = g_timer_new();
+  g_usleep(G_USEC_PER_SEC); /* run timer for 1 second */
+  g_timer_stop(timer);
+
+  g_print ("\tstop for 1 second...\n");
+  g_usleep(G_USEC_PER_SEC); /* wait for 1 second */
+  g_print ("\trun for 2 seconds...\n");
+
+  g_timer_continue(timer);
+  g_usleep(2*G_USEC_PER_SEC); /* run timer for 2 seconds */
+  g_timer_stop(timer);
+
+  g_print ("\tstop for 1.5 seconds...\n");
+  g_usleep((3*G_USEC_PER_SEC)/2); /* wait for 1.5 seconds */
+  g_print ("\trun for 0.2 seconds...\n");
+
+  g_timer_continue(timer);
+  g_usleep(G_USEC_PER_SEC/5); /* run timer for 0.2 seconds */
+  g_timer_stop(timer);
+
+  g_print ("\tstop for 4 seconds...\n");
+  g_usleep(4*G_USEC_PER_SEC); /* wait for 4 seconds */
+  g_print ("\trun for 5.8 seconds...\n");
+
+  g_timer_continue(timer);
+  g_usleep((29*G_USEC_PER_SEC)/5); /* run timer for 5.8 seconds */
+  g_timer_stop(timer);
+
+  g_print ("\t=> total elapsed = %.2f seconds (should be: 9.00 seconds)\n\n", g_timer_elapsed(timer, NULL));
+
+  if (g_timer_elapsed(timer, NULL) > 8.8 && g_timer_elapsed(timer, NULL) < 9.2)
+    g_print ("g_timer_continue ... ok\n\n");
+  else
+    g_print ("g_timer_continue ... ***** FAILED *****\n\n");
+
+  g_timer_stop(timer2);
+
+  if (g_timer_elapsed(timer2, NULL) > (8.8+6.5) && g_timer_elapsed(timer2, NULL) < (9.2+6.5))
+    g_print ("timer2 ... ok\n\n");
+  else
+    g_print ("timer2 ... ***** FAILED *****\n\n");
+
+  g_timer_destroy(timer);
+  g_timer_destroy(timer2);
 
   g_print ("checking g_ascii_strcasecmp...");
   g_assert (g_ascii_strcasecmp ("FroboZZ", "frobozz") == 0);
