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)


Parameters:g_class (GObject.TypeClass) – The GObject.TypeClass structure 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.

Parameters:g_class (GObject.TypeClass) – The GObject.TypeClass structure 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)

True if the transformation was successful, and False otherwise

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.BIDIRECTIONAL binding, then those roles are reversed.

New in version 2.26.

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.

Parameters:boxed (object) – The boxed structure to be freed.

This function is provided by the user and should free the boxed structure passed.


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)

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.TypeInfo structure 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).

GObject.ClassInitFunc(g_class, class_data)

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.

GObject.ClosureMarshal(closure, return_value, param_values, invocation_hint, marshal_data)

The type used for marshaller functions.

GObject.ClosureNotify(data, closure)

The type used for the various notification callbacks which can be registered on closures.

GObject.InstanceInitFunc(instance, g_class)

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.

GObject.InterfaceFinalizeFunc(g_iface, iface_data)

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.

GObject.InterfaceInitFunc(g_iface, iface_data)

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.

Parameters:object (GObject.Object) – the GObject.Object being finalized

The type of the finalize function of GObject.ObjectClass.

GObject.ObjectGetPropertyFunc(object, property_id, value, pspec)

The type of the get_property function of GObject.ObjectClass.

GObject.ObjectSetPropertyFunc(object, property_id, value, pspec)

The type of the set_property function of GObject.ObjectClass.

GObject.SignalAccumulator(ihint, return_accu, handler_return, data)

The accumulator function returns whether the signal emission should be aborted. Returning False means to abort the current emission and True is 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.

GObject.SignalEmissionHook(ihint, param_values, data)

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_HOOKS flag.

GObject.ToggleNotify(data, object, is_last_ref)
  • data (object or None) – 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) – True if the toggle reference is now the last reference to the object. False if 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().

GObject.TypeClassCacheFunc(cache_data, g_class)

True to stop further GObject.TypeClassCacheFuncs from being called, False to 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.TypeClassCacheFunc function 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.TypeClassCacheFunc chain.

GObject.TypeInterfaceCheckFunc(check_data, g_iface)

A callback called after an interface vtable is initialized. See g_type_add_interface_check().

New in version 2.4.

GObject.TypePluginCompleteInterfaceInfo(plugin, instance_type, interface_type, info)

The type of the complete_interface_info function of GObject.TypePluginClass.

GObject.TypePluginCompleteTypeInfo(plugin, g_type, info, value_table)

The type of the complete_type_info function of GObject.TypePluginClass.

Parameters:plugin (GObject.TypePlugin) – the GObject.TypePlugin whose use count should be decreased

The type of the unuse_plugin function of GObject.TypePluginClass.

Parameters:plugin (GObject.TypePlugin) – the GObject.TypePlugin whose 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)

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.

GObject.WeakNotify(data, where_the_object_was)
  • data (object or None) – data that was provided when the weak reference was established
  • where_the_object_was (GObject.Object) – the object being finalized

A GObject.WeakNotify function 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.WeakNotify is called, there’s not much you could do with the object, apart from e.g. using its address as hash-index or the like.