diff --git a/ChangeLog b/ChangeLog index 627d4736fd9d0208688be61489efb5cfc818d7ac..7d40fab1e873ee6b5181379b5f9665c533662d2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-31 Matthisa Clasen + + * gdk/gdk.[hc]: + * gdk/gdk.symbols: Complete the set of thread-safe timeout function + with second-granularity versions. Patch by Marek Kasik. + 2008-07-30 Tor Lillqvist * gtk/gtkprintoperation-win32.c: Fix problems in handling custom diff --git a/gdk/gdk.c b/gdk/gdk.c index 53667a07af3cb8907cf9a820f80049fa2b2b9acb..969869ffd6264c94dbbfab8949d70f7d96f9c196 100644 --- a/gdk/gdk.c +++ b/gdk/gdk.c @@ -691,6 +691,71 @@ gdk_threads_add_timeout (guint interval, } +/** + * gdk_threads_add_timeout_seconds_full: + * @priority: the priority of the timeout source. Typically this will be in the + * range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE. + * @interval: the time between calls to the function, in seconds + * @function: function to call + * @data: data to pass to @function + * @notify: function to call when the timeout is removed, or %NULL + * + * A variant of gdk_threads_add_timout_full() with second-granularity. + * See g_timeout_add_seconds_full() for a discussion of why it is + * a good idea to use this function if you don't need finer granularity. + * + * Return value: the ID (greater than 0) of the event source. + * + * Since: 2.14 + */ +guint +gdk_threads_add_timeout_seconds_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify) +{ + GdkThreadsDispatch *dispatch; + + g_return_val_if_fail (function != NULL, 0); + + dispatch = g_slice_new (GdkThreadsDispatch); + dispatch->func = function; + dispatch->data = data; + dispatch->destroy = notify; + + return g_timeout_add_seconds_full (priority, + interval, + gdk_threads_dispatch, + dispatch, + gdk_threads_dispatch_free); +} + +/** + * gdk_threads_add_timeout_seconds: + * @interval: the time between calls to the function, in seconds + * @function: function to call + * @data: data to pass to @function + * + * A wrapper for the common usage of gdk_threads_add_timeout_seconds_full() + * assigning the default priority, #G_PRIORITY_DEFAULT. + * + * For details, see gdk_threads_add_timeout_full(). + * + * Return value: the ID (greater than 0) of the event source. + * + * Since: 2.14 + */ +guint +gdk_threads_add_timeout_seconds (guint interval, + GSourceFunc function, + gpointer data) +{ + return gdk_threads_add_timeout_seconds_full (G_PRIORITY_DEFAULT, + interval, function, data, NULL); +} + + G_CONST_RETURN char * gdk_get_program_class (void) { diff --git a/gdk/gdk.h b/gdk/gdk.h index 008713d2acca7024d506085a8028575bccaa6ec3..d834bb16221bd8ba338259fa425dc45592936407 100644 --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -195,26 +195,34 @@ GDKVAR GMutex *gdk_threads_mutex; /* private */ GDKVAR GCallback gdk_threads_lock; GDKVAR GCallback gdk_threads_unlock; -void gdk_threads_enter (void); -void gdk_threads_leave (void); -void gdk_threads_init (void); -void gdk_threads_set_lock_functions (GCallback enter_fn, - GCallback leave_fn); - -guint gdk_threads_add_idle_full (gint priority, - GSourceFunc function, - gpointer data, - GDestroyNotify notify); -guint gdk_threads_add_idle (GSourceFunc function, - gpointer data); -guint gdk_threads_add_timeout_full (gint priority, - guint interval, - GSourceFunc function, - gpointer data, - GDestroyNotify notify); -guint gdk_threads_add_timeout (guint interval, - GSourceFunc function, - gpointer data); +void gdk_threads_enter (void); +void gdk_threads_leave (void); +void gdk_threads_init (void); +void gdk_threads_set_lock_functions (GCallback enter_fn, + GCallback leave_fn); + +guint gdk_threads_add_idle_full (gint priority, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +guint gdk_threads_add_idle (GSourceFunc function, + gpointer data); +guint gdk_threads_add_timeout_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +guint gdk_threads_add_timeout (guint interval, + GSourceFunc function, + gpointer data); +guint gdk_threads_add_timeout_seconds_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +guint gdk_threads_add_timeout_seconds (guint interval, + GSourceFunc function, + gpointer data); #ifdef G_THREADS_ENABLED # define GDK_THREADS_ENTER() G_STMT_START { \