Method
GLibSourceset_callback
Declaration
void
g_source_set_callback (
GSource* source,
GSourceFunc func,
gpointer data,
GDestroyNotify notify
)
Description
Sets the callback function for a source. The callback for a source is called from the source’s dispatch function.
The exact type of func depends on the type of source; ie. you
should not count on func being called with data as its first
parameter. Cast func with G_SOURCE_FUNC() to avoid warnings about
incompatible function types.
See [memory management of sources][mainloop-memory-management] for details
on how to handle memory management of data.
Typically, you won’t use this function. Instead use functions specific
to the type of source you are using, such as g_idle_add() or g_timeout_add().
It is safe to call this function multiple times on a source which has already been attached to a context. The changes will take effect for the next time the source is dispatched after this call returns.
Note that g_source_destroy() for a currently attached source has the effect
of also unsetting the callback.
Parameters
func-
Type:
GSourceFuncA callback function.
data-
Type:
gpointerThe data to pass to callback function.
The argument can be NULL.The data is owned by the caller of the method. notify-
Type:
GDestroyNotifyA function to call when
datais no longer in use, orNULL.The argument can be NULL.