Function

Gdkthreads_add_timeout_full

Declaration [src]

guint
gdk_threads_add_timeout_full (
  gint priority,
  guint interval,
  GSourceFunc function,
  gpointer data,
  GDestroyNotify notify
)

Description [src]

Sets a function to be called at regular intervals holding the GDK lock, 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.

Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to “catch up” time lost in delays).

This variant of g_timeout_add_full() can be thought of a MT-safe version for GTK+ widgets for the following use case:

static gboolean timeout_callback (gpointer data)
{
   SomeWidget *self = data;

   // do stuff with self

   self->timeout_id = 0;

   return G_SOURCE_REMOVE;
}

static void some_widget_do_stuff_later (SomeWidget *self)
{
   self->timeout_id = g_timeout_add (timeout_callback, self)
}

static void some_widget_finalize (GObject *object)
{
   SomeWidget *self = SOME_WIDGET (object);

   if (self->timeout_id)
     g_source_remove (self->timeout_id);

   G_OBJECT_CLASS (parent_class)->finalize (object);
}
Available since:2.12

Parameters

priority gint
 

The priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.

interval guint
 

The time between calls to the function, in milliseconds (1/1000ths of a second)

function GSourceFunc
 

Function to call.

data gpointer
 

Data to pass to function.

notify GDestroyNotify
 

Function to call when the timeout is removed, or NULL.

Return value

Returns: guint
 

The ID (greater than 0) of the event source.