summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-01-22 19:56:28 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-01-22 19:56:28 +0000
commit7ace455394c2f7b52e2e74982d8a4527ca4e1460 (patch)
treee66eb45d254b19fdbeeb759a01eaca608a3e901a
parent6726db0afb43685d0a7bdbc3a7a903d1c5b8ec16 (diff)
Add g_timer_continue(). (#98536, Tim-Philipp Müller)
Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com> * glib/gtimer.c: Add g_timer_continue(). (#98536, Tim-Philipp Müller) * configure.in: Version 2.3.2, interface age 0. * NEWS: tweak, finish.
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLog.pre-2-109
-rw-r--r--ChangeLog.pre-2-129
-rw-r--r--ChangeLog.pre-2-49
-rw-r--r--ChangeLog.pre-2-69
-rw-r--r--ChangeLog.pre-2-89
-rw-r--r--NEWS15
-rw-r--r--configure.in2
-rw-r--r--docs/reference/ChangeLog5
-rw-r--r--docs/reference/glib/glib-sections.txt1
-rw-r--r--docs/reference/glib/tmpl/timers.sgml9
-rw-r--r--docs/reference/gobject/tmpl/objects.sgml22
-rw-r--r--glib/gtimer.c52
-rw-r--r--glib/gtimer.h1
-rw-r--r--tests/testglib.c52
15 files changed, 195 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 51d891a0c..ad0cd6090 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/gtimer.c: Add g_timer_continue().
+ (#98536, Tim-Philipp Müller)
+
+ * configure.in: Version 2.3.2, interface age 0.
+
+ * NEWS: tweak, finish.
+
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 51d891a0c..ad0cd6090 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,12 @@
+Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/gtimer.c: Add g_timer_continue().
+ (#98536, Tim-Philipp Müller)
+
+ * configure.in: Version 2.3.2, interface age 0.
+
+ * NEWS: tweak, finish.
+
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 51d891a0c..ad0cd6090 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,3 +1,12 @@
+Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/gtimer.c: Add g_timer_continue().
+ (#98536, Tim-Philipp Müller)
+
+ * configure.in: Version 2.3.2, interface age 0.
+
+ * NEWS: tweak, finish.
+
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 51d891a0c..ad0cd6090 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,12 @@
+Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/gtimer.c: Add g_timer_continue().
+ (#98536, Tim-Philipp Müller)
+
+ * configure.in: Version 2.3.2, interface age 0.
+
+ * NEWS: tweak, finish.
+
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 51d891a0c..ad0cd6090 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,12 @@
+Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/gtimer.c: Add g_timer_continue().
+ (#98536, Tim-Philipp Müller)
+
+ * configure.in: Version 2.3.2, interface age 0.
+
+ * NEWS: tweak, finish.
+
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 51d891a0c..ad0cd6090 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,12 @@
+Thu Jan 22 13:55:44 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/gtimer.c: Add g_timer_continue().
+ (#98536, Tim-Philipp Müller)
+
+ * configure.in: Version 2.3.2, interface age 0.
+
+ * NEWS: tweak, finish.
+
Thu Jan 22 20:50:55 2004 Matthias Clasen <maclas@gmx.de>
* glib/gutils.c (g_get_any_init): Protect against
diff --git a/NEWS b/NEWS
index 2c129ecd5..e4899e7b1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,21 +1,26 @@
Overview of Changes from GLib 2.3.1 to GLib 2.3.2
=================================================
-* Add G_MAXSIZE. [Manish Singh]
+* Add G_MAXSIZE. [Manish Singh]
* Add g_rand_new_with_seed_array(), g_rand_set_seed_array(),
implementing the init-by-array functionality of the
- original mersenne twister. [George Lebl]
+ original mersenne twister. Add g_rand_copy(). Improve seeding.
+ [George Lebl]
* Add a lowercase_name option to glib-mkenums. [Murray Cumming]
* Add g_ptr_array_foreach(). [Matthias Clasen]
-* Fix a threadsafety issue in mem chunks. [Matthias]
+* Add g_timer_continue(). [Tim-Philipp Müller]
+* Fix a threadsafety issue in mem chunks. [Matthias, Balazs Scheidler]
* Fix g_filename_{to,from}_utf8() on Win32 and improve
g_file_test() there too [Hans Breuer]
* Add a boxed type for NULL-terminated string arrays. [Matthias]
* Add G_DEFINE_TYPE() plus variants to ease the constuction
of GObject boilerplate code. [Tim Janik]
+* Support & in password GECOS field [Matthias, Soeren Boll Overgaard]
* Documentation improvements [Matthias, Manish]
-* Misc bug fixes [Manish, Matthias, Owen Taylor]
-* Updated translations (ar,nn,fa,de,mn,no,ga)
+* Win32 build fixes [Hans]
+* Misc bug fixes [Damien Carbery, Matthias, Manish, Olivier Poncet,
+ Zack Rusin]
+* Updated translations (ar,de,fa,ga,mn,nn,no,sq)
Overview of Changes from GLib 2.3.0 to GLib-2.3.1
=================================================
diff --git a/configure.in b/configure.in
index b5622b216..2af80acef 100644
--- a/configure.in
+++ b/configure.in
@@ -27,7 +27,7 @@ m4_include(m4macros/glib-gettext.m4)dnl
#
m4_define([glib_major_version], [2])
m4_define([glib_minor_version], [3])
-m4_define([glib_micro_version], [1])
+m4_define([glib_micro_version], [2])
m4_define([glib_interface_age], [0])
m4_define([glib_binary_age],
[m4_eval(100 * glib_minor_version + glib_micro_version)])
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 03b2eb6ae..5cbd26d44 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 22 14:51:19 2004 Owen Taylor <otaylor@redhat.com>
+
+ * glib/glib-sections.txt glib/tmpl/timers.sgml: Document
+ g_timer_continue. (Tim-Philipp Müller)
+
Sun Jan 11 01:25:44 2004 Matthias Clasen <maclas@gmx.de>
* gobject/tmpl/gtype.sgml: Improve docs for G_DEFINE_TYPE_* macros.
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 0f27726bf..7fb4b71a5 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -829,6 +829,7 @@ GTimer
g_timer_new
g_timer_start
g_timer_stop
+g_timer_continue
g_timer_elapsed
g_timer_reset
g_timer_destroy
diff --git a/docs/reference/glib/tmpl/timers.sgml b/docs/reference/glib/tmpl/timers.sgml
index 328ca3f96..5ea87151a 100644
--- a/docs/reference/glib/tmpl/timers.sgml
+++ b/docs/reference/glib/tmpl/timers.sgml
@@ -52,6 +52,15 @@ between this end time and the start time.
@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.
+</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
diff --git a/docs/reference/gobject/tmpl/objects.sgml b/docs/reference/gobject/tmpl/objects.sgml
index 2d16e5d2c..4c311e911 100644
--- a/docs/reference/gobject/tmpl/objects.sgml
+++ b/docs/reference/gobject/tmpl/objects.sgml
@@ -21,17 +21,6 @@ to the #GObject implementation and should never be accessed directly.
</para>
-<!-- ##### SIGNAL GObject::notify ##### -->
-<para>
-The notify signal is emitted on an object when one of its properties
-has been changed. Note that getting this signal doesn't guarantee that the
-value of the property has actually changed, it may also be emitted when
-the setter for the property is called to reinstate the previous value.
-</para>
-
-@gobject: the object which received the signal.
-@pspec: the #GParamSpec of the property which changed
-
<!-- ##### STRUCT GObjectClass ##### -->
<para>
The class structure for the <structname>GObject</structname> type.
@@ -866,3 +855,14 @@ properties in set_property() and get_property() implementations.
@pspec: the #GParamSpec of the property
+<!-- ##### SIGNAL GObject::notify ##### -->
+<para>
+The notify signal is emitted on an object when one of its properties
+has been changed. Note that getting this signal doesn't guarantee that the
+value of the property has actually changed, it may also be emitted when
+the setter for the property is called to reinstate the previous value.
+</para>
+
+@gobject: the object which received the signal.
+@pspec: the #GParamSpec of the property which changed
+
diff --git a/glib/gtimer.c b/glib/gtimer.c
index cdfbb19b3..b2f516bc4 100644
--- a/glib/gtimer.c
+++ b/glib/gtimer.c
@@ -118,6 +118,58 @@ g_timer_reset (GTimer *timer)
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);
+
+ /* Get elapsed time and reset timer start time
+ * to the current time minus the previously
+ * elapsed interval.
+ */
+
+#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)
diff --git a/glib/gtimer.h b/glib/gtimer.h
index 33e533043..fc434d06a 100644
--- a/glib/gtimer.h
+++ b/glib/gtimer.h
@@ -44,6 +44,7 @@ void g_timer_destroy (GTimer *timer);
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);
diff --git a/tests/testglib.c b/tests/testglib.c
index c4a8c2c45..bc807a422 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -316,7 +316,7 @@ main (int argc,
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;
@@ -946,6 +946,56 @@ main (int argc,
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);
g_assert (g_ascii_strcasecmp ("frobozz", "frobozz") == 0);