Closure
A GClosure
represents a callback supplied by the programmer.
It will generally comprise a function of some kind and a marshaller used to call it. It is the responsibility of the marshaller to convert the arguments for the invocation from #GValues into a suitable form, perform the callback on the converted arguments, and transform the return value back into a #GValue.
In the case of C programs, a closure usually just holds a pointer to a function and maybe a data argument, and the marshaller converts between #GValue and native C types. The GObject library provides the #GCClosure type for this purpose. Bindings for other languages need marshallers which convert between #GValues and suitable representations in the runtime of the language in order to use functions written in that language as callbacks. Use g_closure_set_marshal() to set the marshaller on such a custom closure implementation.
Within GObject, closures play an important role in the implementation of signals. When a signal is registered, the
Constructors
Allocate a new Closure.
Allocate a new Closure using the provided AutofreeScope.
Allocate a new Closure.
Allocate a new Closure using the provided AutofreeScope.