Callbacks¶
| BaseFinalizeFunc(g_class) | |
| BaseInitFunc(g_class) | |
| BindingTransformFunc(binding, from_value, to_value, *user_data) | |
| BoxedCopyFunc(boxed) | |
| BoxedFreeFunc(boxed) | |
| Callback() | |
| ClassFinalizeFunc(g_class, class_data) | |
| ClassInitFunc(g_class, class_data) | |
| ClosureMarshal(closure, return_value, param_values, invocation_hint, marshal_data) | |
| ClosureNotify(data, closure) | |
| InstanceInitFunc(instance, g_class) | |
| InterfaceFinalizeFunc(g_iface, iface_data) | |
| InterfaceInitFunc(g_iface, iface_data) | |
| ObjectFinalizeFunc(object) | |
| ObjectGetPropertyFunc(object, property_id, value, pspec) | |
| ObjectSetPropertyFunc(object, property_id, value, pspec) | |
| SignalAccumulator(ihint, return_accu, handler_return, data) | |
| SignalEmissionHook(ihint, param_values, data) | |
| ToggleNotify(data, object, is_last_ref) | |
| TypeClassCacheFunc(cache_data, g_class) | |
| TypeInterfaceCheckFunc(check_data, g_iface) | |
| TypePluginCompleteInterfaceInfo(plugin, instance_type, interface_type, info) | |
| TypePluginCompleteTypeInfo(plugin, g_type, info, value_table) | |
| TypePluginUnuse(plugin) | |
| TypePluginUse(plugin) | |
| ValueTransform(src_value, dest_value) | |
| WeakNotify(data, where_the_object_was) | 
Details¶
- 
GObject.BaseFinalizeFunc(g_class)¶
- Parameters: - g_class ( - GObject.TypeClass) – The- GObject.TypeClassstructure to finalize- A callback function used by the type system to finalize those portions of a derived types class structure that were setup from the corresponding - GObject.BaseInitFunc() function. Class finalization basically works the inverse way in which class initialization is performed. See- GObject.ClassInitFunc() for a discussion of the class initialization process.
- 
GObject.BaseInitFunc(g_class)¶
- Parameters: - g_class ( - GObject.TypeClass) – The- GObject.TypeClassstructure to initialize- A callback function used by the type system to do base initialization of the class structures of derived types. It is called as part of the initialization process of all derived classes and should reallocate or reset all dynamic class members copied over from the parent class. For example, class members (such as strings) that are not sufficiently handled by a plain memory copy of the parent class into the derived class have to be altered. See - GObject.ClassInitFunc() for a discussion of the class initialization process.
- 
GObject.BindingTransformFunc(binding, from_value, to_value, *user_data)¶
- Parameters: - binding (GObject.Binding) – aGObject.Binding
- from_value (GObject.Value) – theGObject.Valuecontaining the value to transform
- to_value (GObject.Value) – theGObject.Valuein which to store the transformed value
- user_data (objectorNone) – data passed to the transform function
 - Returns: - Trueif the transformation was successful, and- Falseotherwise- Return type: - A function to be called to transform from_value to to_value. If this is the transform_to function of a binding, then from_value is the source_property on the source object, and to_value is the target_property on the target object. If this is the transform_from function of a - GObject.BindingFlags.BIDIRECTIONALbinding, then those roles are reversed.- New in version 2.26. 
- binding (
- 
GObject.BoxedCopyFunc(boxed)¶
- Parameters: - boxed ( - object) – The boxed structure to be copied.- Returns: - The newly created copy of the boxed structure. - Return type: - object- This function is provided by the user and should produce a copy of the passed in boxed structure. 
- 
GObject.BoxedFreeFunc(boxed)¶
- Parameters: - boxed ( - object) – The boxed structure to be freed.- This function is provided by the user and should free the boxed structure passed. 
- 
GObject.Callback()¶
- The type used for callback functions in structure definitions and function signatures. This doesn’t mean that all callback functions must take no parameters and return void. The required signature of a callback function is determined by the context in which is used (e.g. the signal to which it is connected). Use G_CALLBACK() to cast the callback function to a - GObject.Callback.
- 
GObject.ClassFinalizeFunc(g_class, class_data)¶
- Parameters: - g_class (GObject.TypeClass) – TheGObject.TypeClassstructure to finalize
- class_data (objectorNone) – The class_data member supplied via theGObject.TypeInfostructure
 - A callback function used by the type system to finalize a class. This function is rarely needed, as dynamically allocated class resources should be handled by - GObject.BaseInitFunc() and- GObject.BaseFinalizeFunc(). Also, specification of a- GObject.ClassFinalizeFunc() in the- GObject.TypeInfostructure of a static type is invalid, because classes of static types will never be finalized (they are artificially kept alive when their reference count drops to zero).
- g_class (
- 
GObject.ClassInitFunc(g_class, class_data)¶
- Parameters: - g_class (GObject.TypeClass) – TheGObject.TypeClassstructure to initialize.
- class_data (objectorNone) – The class_data member supplied via theGObject.TypeInfostructure.
 - A callback function used by the type system to initialize the class of a specific type. This function should initialize all static class members. - The initialization process of a class involves: - Copying common members from the parent class over to the derived class structure.
- Zero initialization of the remaining members not copied over from the parent class.
- Invocation of the GObject.BaseInitFunc() initializers of all parent types and the class’ type.
- Invocation of the class’ GObject.ClassInitFunc() initializer.
 - Since derived classes are partially initialized through a memory copy of the parent class, the general rule is that - GObject.BaseInitFunc() and- GObject.BaseFinalizeFunc() should take care of necessary reinitialization and release of those class members that were introduced by the type that specified these- GObject.BaseInitFunc()/- GObject.BaseFinalizeFunc().- GObject.ClassInitFunc() should only care about initializing static class members, while dynamic class members (such as allocated strings or reference counted resources) are better handled by a- GObject.BaseInitFunc() for this type, so proper initialization of the dynamic class members is performed for class initialization of derived types as well.- An example may help to correspond the intend of the different class initializers: - typedef struct { GObjectClass parent_class; gint static_integer; gchar *dynamic_string; } TypeAClass; static void type_a_base_class_init (TypeAClass *class) { class->dynamic_string = g_strdup ("some string"); } static void type_a_base_class_finalize (TypeAClass *class) { g_free (class->dynamic_string); } static void type_a_class_init (TypeAClass *class) { class->static_integer = 42; } typedef struct { TypeAClass parent_class; gfloat static_float; GString *dynamic_gstring; } TypeBClass; static void type_b_base_class_init (TypeBClass *class) { class->dynamic_gstring = g_string_new ("some other string"); } static void type_b_base_class_finalize (TypeBClass *class) { g_string_free (class->dynamic_gstring); } static void type_b_class_init (TypeBClass *class) { class->static_float = 3.14159265358979323846; } - Initialization of TypeBClass will first cause initialization of TypeAClass (derived classes reference their parent classes, see - GObject.TypeClass.ref() on this).- Initialization of TypeAClass roughly involves zero-initializing its fields, then calling its - GObject.BaseInitFunc() type_a_base_class_init() to allocate its dynamic members (dynamic_string), and finally calling its- GObject.ClassInitFunc() type_a_class_init() to initialize its static members (static_integer). The first step in the initialization process of TypeBClass is then a plain memory copy of the contents of TypeAClass into TypeBClass and zero-initialization of the remaining fields in TypeBClass. The dynamic members of TypeAClass within TypeBClass now need reinitialization which is performed by calling type_a_base_class_init() with an argument of TypeBClass.- After that, the - GObject.BaseInitFunc() of TypeBClass, type_b_base_class_init() is called to allocate the dynamic members of TypeBClass (dynamic_gstring), and finally the- GObject.ClassInitFunc() of TypeBClass, type_b_class_init(), is called to complete the initialization process with the static members (static_float).- Corresponding finalization counter parts to the - GObject.BaseInitFunc() functions have to be provided to release allocated resources at class finalization time.
- g_class (
- 
GObject.ClosureMarshal(closure, return_value, param_values, invocation_hint, marshal_data)¶
- Parameters: - closure (GObject.Closure) – theGObject.Closureto which the marshaller belongs
- return_value (GObject.ValueorNone) – aGObject.Valueto store the return value. May beNoneif the callback of closure doesn’t return a value.
- param_values ([GObject.Value]) – an array ofGObject.Valuesholding the arguments on which to invoke the callback of closure
- invocation_hint (objectorNone) – the invocation hint given as the last argument toGObject.Closure.invoke()
- marshal_data (objectorNone) – additional data specified when registering the marshaller, see g_closure_set_marshal() and g_closure_set_meta_marshal()
 - The type used for marshaller functions. 
- closure (
- 
GObject.ClosureNotify(data, closure)¶
- Parameters: - data (objectorNone) – data specified when registering the notification callback
- closure (GObject.Closure) – theGObject.Closureon which the notification is emitted
 - The type used for the various notification callbacks which can be registered on closures. 
- data (
- 
GObject.InstanceInitFunc(instance, g_class)¶
- Parameters: - instance (GObject.TypeInstance) – The instance to initialize
- g_class (GObject.TypeClass) – The class of the type the instance is created for
 - A callback function used by the type system to initialize a new instance of a type. This function initializes all instance members and allocates any resources required by it. - Initialization of a derived instance involves calling all its parent types instance initializers, so the class member of the instance is altered during its initialization to always point to the class that belongs to the type the current initializer was introduced for. - The extended members of instance are guaranteed to have been filled with zeros before this function is called. 
- instance (
- 
GObject.InterfaceFinalizeFunc(g_iface, iface_data)¶
- Parameters: - g_iface (GObject.TypeInterface) – The interface structure to finalize
- iface_data (objectorNone) – The interface_data supplied via theGObject.InterfaceInfostructure
 - A callback function used by the type system to finalize an interface. This function should destroy any internal data and release any resources allocated by the corresponding - GObject.InterfaceInitFunc() function.
- g_iface (
- 
GObject.InterfaceInitFunc(g_iface, iface_data)¶
- Parameters: - g_iface (GObject.TypeInterface) – The interface structure to initialize
- iface_data (objectorNone) – The interface_data supplied via theGObject.InterfaceInfostructure
 - A callback function used by the type system to initialize a new interface. This function should initialize all internal data and allocate any resources required by the interface. - The members of iface_data are guaranteed to have been filled with zeros before this function is called. 
- g_iface (
- 
GObject.ObjectFinalizeFunc(object)¶
- Parameters: - object ( - GObject.Object) – the- GObject.Objectbeing finalized- The type of the finalize function of - GObject.ObjectClass.
- 
GObject.ObjectGetPropertyFunc(object, property_id, value, pspec)¶
- Parameters: - object (GObject.Object) – aGObject.Object
- property_id (int) – the numeric id under which the property was registered withGObject.ObjectClass.install_property().
- value (GObject.Value) – aGObject.Valueto return the property value in
- pspec (GObject.ParamSpec) – theGObject.ParamSpecdescribing the property
 - The type of the get_property function of - GObject.ObjectClass.
- object (
- 
GObject.ObjectSetPropertyFunc(object, property_id, value, pspec)¶
- Parameters: - object (GObject.Object) – aGObject.Object
- property_id (int) – the numeric id under which the property was registered withGObject.ObjectClass.install_property().
- value (GObject.Value) – the new value for the property
- pspec (GObject.ParamSpec) – theGObject.ParamSpecdescribing the property
 - The type of the set_property function of - GObject.ObjectClass.
- object (
- 
GObject.SignalAccumulator(ihint, return_accu, handler_return, data)¶
- Parameters: - ihint (GObject.SignalInvocationHint) – Signal invocation hint, seeGObject.SignalInvocationHint.
- return_accu (GObject.Value) – Accumulator to collect callback return values in, this is the return value of the current signal emission.
- handler_return (GObject.Value) – AGObject.Valueholding the return value of the signal handler.
- data (objectorNone) – Callback data that was specified when creating the signal.
 - Returns: - The accumulator function returns whether the signal emission should be aborted. Returning - Falsemeans to abort the current emission and- Trueis returned for continuation.- Return type: - The signal accumulator is a special callback function that can be used to collect return values of the various callbacks that are called during a signal emission. The signal accumulator is specified at signal creation time, if it is left - None, no accumulation of callback return values is performed. The return value of signal emissions is then the value returned by the last callback.
- ihint (
- 
GObject.SignalEmissionHook(ihint, param_values, data)¶
- Parameters: - ihint (GObject.SignalInvocationHint) – Signal invocation hint, seeGObject.SignalInvocationHint.
- param_values ([GObject.Value]) – the instance on which the signal was emitted, followed by the parameters of the emission.
- data (objectorNone) – user data associated with the hook.
 - Returns: - whether it wants to stay connected. If it returns - False, the signal hook is disconnected (and destroyed).- Return type: - A simple function pointer to get invoked when the signal is emitted. This allows you to tie a hook to the signal type, so that it will trap all emissions of that signal, from any object. - You may not attach these to signals created with the - GObject.SignalFlags.NO_HOOKSflag.
- ihint (
- 
GObject.ToggleNotify(data, object, is_last_ref)¶
- Parameters: - data (objectorNone) – Callback data passed to g_object_add_toggle_ref()
- object (GObject.Object) – The object on which g_object_add_toggle_ref() was called.
- is_last_ref (bool) –Trueif the toggle reference is now the last reference to the object.Falseif the toggle reference was the last reference and there are now other references.
 - A callback function used for notification when the state of a toggle reference changes. See g_object_add_toggle_ref(). 
- data (
- 
GObject.TypeClassCacheFunc(cache_data, g_class)¶
- Parameters: - cache_data (objectorNone) – data that was given to the g_type_add_class_cache_func() call
- g_class (GObject.TypeClass) – TheGObject.TypeClassstructure which is unreferenced
 - Returns: - Trueto stop further- GObject.TypeClassCacheFuncsfrom being called,- Falseto continue- Return type: - A callback function which is called when the reference count of a class drops to zero. It may use - GObject.TypeClass.ref() to prevent the class from being freed. You should not call- GObject.TypeClass.unref() from a- GObject.TypeClassCacheFuncfunction to prevent infinite recursion, use g_type_class_unref_uncached() instead.- The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same - GObject.TypeClassCacheFuncchain.
- cache_data (
- 
GObject.TypeInterfaceCheckFunc(check_data, g_iface)¶
- Parameters: - check_data (objectorNone) – data passed to g_type_add_interface_check()
- g_iface (GObject.TypeInterface) – the interface that has been initialized
 - A callback called after an interface vtable is initialized. See g_type_add_interface_check(). - New in version 2.4. 
- check_data (
- 
GObject.TypePluginCompleteInterfaceInfo(plugin, instance_type, interface_type, info)¶
- Parameters: - plugin (GObject.TypePlugin) – theGObject.TypePlugin
- instance_type (GObject.GType) – theGObject.GTypeof an instantiable type to which the interface is added
- interface_type (GObject.GType) – theGObject.GTypeof the interface whose info is completed
- info (GObject.InterfaceInfo) – theGObject.InterfaceInfoto fill in
 - The type of the complete_interface_info function of - GObject.TypePluginClass.
- plugin (
- 
GObject.TypePluginCompleteTypeInfo(plugin, g_type, info, value_table)¶
- Parameters: - plugin (GObject.TypePlugin) – theGObject.TypePlugin
- g_type (GObject.GType) – theGObject.GTypewhose info is completed
- info (GObject.TypeInfo) – theGObject.TypeInfostruct to fill in
- value_table (GObject.TypeValueTable) – theGObject.TypeValueTableto fill in
 - The type of the complete_type_info function of - GObject.TypePluginClass.
- plugin (
- 
GObject.TypePluginUnuse(plugin)¶
- Parameters: - plugin ( - GObject.TypePlugin) – the- GObject.TypePluginwhose use count should be decreased- The type of the unuse_plugin function of - GObject.TypePluginClass.
- 
GObject.TypePluginUse(plugin)¶
- Parameters: - plugin ( - GObject.TypePlugin) – the- GObject.TypePluginwhose use count should be increased- The type of the use_plugin function of - GObject.TypePluginClass, which gets called to increase the use count of plugin.
- 
GObject.ValueTransform(src_value, dest_value)¶
- Parameters: - src_value (GObject.Value) – Source value.
- dest_value (GObject.Value) – Target value.
 - The type of value transformation functions which can be registered with g_value_register_transform_func(). - dest_value will be initialized to the correct destination type. 
- src_value (
- 
GObject.WeakNotify(data, where_the_object_was)¶
- Parameters: - data (objectorNone) – data that was provided when the weak reference was established
- where_the_object_was (GObject.Object) – the object being finalized
 - A - GObject.WeakNotifyfunction can be added to an object as a callback that gets triggered when the object is finalized. Since the object is already being finalized when the- GObject.WeakNotifyis called, there’s not much you could do with the object, apart from e.g. using its address as hash-index or the like.
- data (