From 9144b3902eb8153045e6f7ae0b9fec347c735bea Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 9 May 2008 16:27:06 +0000 Subject: [PATCH] * clutter/clutter-frame-source.c (clutter_frame_source_add) (clutter_frame_source_add_full): Add gtk-doc and rename the 'function' parameter to 'func'. * clutter/clutter-frame-source.h: Rename the 'function' parameters to 'func'. * clutter/Makefile.am (source_h): Make clutter-frame-source.h a public header. * clutter/clutter-main.c (clutter_threads_add_frame_source_full): Improve gtk-doc * doc/reference/clutter/clutter-sections.txt: Added clutter_threads_add_frame_source, clutter_threads_add_frame_source_full, clutter_frame_source_add and clutter_frame_source_add_full. --- ChangeLog | 15 +++++++ clutter/Makefile.am | 2 +- clutter/clutter-frame-source.c | 50 ++++++++++++++++++++-- clutter/clutter-frame-source.h | 4 +- clutter/clutter-main.c | 19 ++++---- doc/reference/ChangeLog | 7 +++ doc/reference/clutter/clutter-sections.txt | 6 +++ 7 files changed, 88 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56c815bc4..cd016ada9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-05-09 Neil Roberts + + * clutter/clutter-frame-source.c (clutter_frame_source_add) + (clutter_frame_source_add_full): Add gtk-doc and rename the + 'function' parameter to 'func'. + + * clutter/clutter-frame-source.h: Rename the 'function' parameters + to 'func'. + + * clutter/Makefile.am (source_h): Make clutter-frame-source.h a + public header. + + * clutter/clutter-main.c (clutter_threads_add_frame_source_full): + Improve gtk-doc + 2008-05-09 Emmanuele Bassi * clutter/clutter-script-private.h: Add a flag for the diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 98d6e6996..2f2183832 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -67,6 +67,7 @@ source_h = \ $(srcdir)/clutter-event.h \ $(srcdir)/clutter-feature.h \ $(srcdir)/clutter-fixed.h \ + $(srcdir)/clutter-frame-source.h \ $(srcdir)/clutter-group.h \ $(srcdir)/clutter-keysyms.h \ $(srcdir)/clutter-label.h \ @@ -178,7 +179,6 @@ source_c = \ source_h_priv = \ clutter-debug.h \ - clutter-frame-source.h \ clutter-keysyms-table.h \ clutter-model-private.h \ clutter-private.h \ diff --git a/clutter/clutter-frame-source.c b/clutter/clutter-frame-source.c index 93fb27914..b3fb55a25 100644 --- a/clutter/clutter-frame-source.c +++ b/clutter/clutter-frame-source.c @@ -53,10 +53,40 @@ static GSourceFuncs clutter_frame_source_funcs = NULL }; +/** + * clutter_frame_source_add_full: + * @priority: the priority of the frame source. Typically this will be in the + * range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH. + * @interval: the time between calls to the function, in milliseconds + * @func: function to call + * @data: data to pass to the function + * @notify: function to call when the timeout source is removed + * + * Sets a function to be called at regular intervals with the given + * priority. The function is called repeatedly until it returns + * %FALSE, at which point the timeout is automatically destroyed and + * the function will not be called again. The @notify function is + * called when the timeout is destroyed. The first call to the + * function will be at the end of the first @interval. + * + * This function is similar to g_timeout_add_full() except that it + * will try to compensate for delays. For example, if @func takes half + * the interval time to execute then the function will be called again + * half the interval time after it finished. In contrast + * g_timeout_add_full() would not fire until a full interval after the + * function completes so the delay between calls would be @interval * + * 1.5. This function does not however try to invoke the function + * multiple times to catch up missing frames if @func takes more than + * @interval ms to execute. + * + * Return value: the ID (greater than 0) of the event source. + * + * Since: 0.8 + */ guint clutter_frame_source_add_full (gint priority, guint interval, - GSourceFunc function, + GSourceFunc func, gpointer data, GDestroyNotify notify) { @@ -72,7 +102,7 @@ clutter_frame_source_add_full (gint priority, if (priority != G_PRIORITY_DEFAULT) g_source_set_priority (source, priority); - g_source_set_callback (source, function, data, notify); + g_source_set_callback (source, func, data, notify); ret = g_source_attach (source, NULL); @@ -81,13 +111,25 @@ clutter_frame_source_add_full (gint priority, return ret; } +/** + * clutter_frame_source_add: + * @interval: the time between calls to the function, in milliseconds + * @func: function to call + * @data: data to pass to the function + * + * Simple wrapper around clutter_frame_source_add_full(). + * + * Return value: the ID (greater than 0) of the event source. + * + * Since: 0.8 + */ guint clutter_frame_source_add (guint interval, - GSourceFunc function, + GSourceFunc func, gpointer data) { return clutter_frame_source_add_full (G_PRIORITY_DEFAULT, - interval, function, data, NULL); + interval, func, data, NULL); } static guint diff --git a/clutter/clutter-frame-source.h b/clutter/clutter-frame-source.h index bc55dbcf1..07c8c958c 100644 --- a/clutter/clutter-frame-source.h +++ b/clutter/clutter-frame-source.h @@ -31,12 +31,12 @@ G_BEGIN_DECLS guint clutter_frame_source_add (guint interval, - GSourceFunc function, + GSourceFunc func, gpointer data); guint clutter_frame_source_add_full (gint priority, guint interval, - GSourceFunc function, + GSourceFunc func, gpointer data, GDestroyNotify notify); diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 68853586d..6622b1cf0 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -682,16 +682,19 @@ clutter_threads_add_timeout (guint interval, * called when the timeout is destroyed. The first call to the * function will be at the end of the first @interval. * - * This function is similar to clutter_threads_add_timeout_full except - * that it will try to compensate for delays. For example, if @func - * takes half the interval time to execute then the function will be - * called again half the interval time after it finished. In contrast - * clutter_threads_add_timeout_full would not fire until a full - * interval after the function completes so the delay between calls - * would be @interval * 1.5. This function does not however try to - * invoke the function multiple times to catch up missing frames if + * This function is similar to clutter_threads_add_timeout_full() + * except that it will try to compensate for delays. For example, if + * @func takes half the interval time to execute then the function + * will be called again half the interval time after it finished. In + * contrast clutter_threads_add_timeout_full() would not fire until a + * full interval after the function completes so the delay between + * calls would be @interval * 1.5. This function does not however try + * to invoke the function multiple times to catch up missing frames if * @func takes more than @interval ms to execute. * + * This variant of clutter_frame_source_add_full() can be thought of a + * MT-safe version for Clutter actors. + * Return value: the ID (greater than 0) of the event source. * * Since: 0.8 diff --git a/doc/reference/ChangeLog b/doc/reference/ChangeLog index 94f32d345..52de5b4b2 100644 --- a/doc/reference/ChangeLog +++ b/doc/reference/ChangeLog @@ -1,3 +1,10 @@ +2008-05-09 Neil Roberts + + * clutter/clutter-sections.txt: Added + clutter_threads_add_frame_source, + clutter_threads_add_frame_source_full, clutter_frame_source_add + and clutter_frame_source_add_full. + 2008-04-29 Neil Roberts * cogl/cogl-sections.txt: Added cogl_shader_ref, diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 1f382ea62..8deafc0c6 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -963,6 +963,12 @@ clutter_threads_add_idle clutter_threads_add_idle_full clutter_threads_add_timeout clutter_threads_add_timeout_full +clutter_threads_add_frame_source +clutter_threads_add_frame_source_full + + +clutter_frame_source_add +clutter_frame_source_add_full clutter_get_keyboard_grab