Skip to content

GObject

API reference for the GObject namespace (version 2.0), generated from GObject-Introspection.

Classes

  • BindingGObject instance (or source) and another property on another GObject instance (or target). Whenever the source property changes, the…
  • BindingGroupGBindingGroup can be used to bind multiple properties from an object collectively. Use the various methods to bind properties from a…
  • CClosure — A CClosure is a specialization of Closure for C function callbacks.
  • Closure — A GClosure represents a callback supplied by the programmer. It will generally comprise a function of some kind and a marshaller used to…
  • ClosureNotifyData
  • EnumClass — The class of an enumeration type holds information about its possible values.
  • EnumValue — A structure which contains a single enum value, its name, and its nickname.
  • FlagsClass — The class of a flags type holds information about its possible values.
  • FlagsValue — A structure which contains a single flags value, its name, and its nickname.
  • InitiallyUnowned — A type for objects that have an initially floating reference. All the fields in the GInitiallyUnowned structure are private to the…
  • InitiallyUnownedClass — The class structure for the GInitiallyUnowned type.
  • InterfaceInfo — A structure that provides information to the type system which is used specifically for managing interface types.
  • Object — The base object type. GObject is the fundamental type providing the common attributes and methods for all object types in GTK, Pango and…
  • ObjectClass — The class structure for the GObject type. ``` // Example of implementing a singleton using a constructor. static MySingleton *the_singleton…
  • ObjectConstructParam — The GObjectConstructParam struct is an auxiliary structure used to hand ParamSpec/Value pairs to the constructor of a ObjectClass.
  • ParamSpecGParamSpec encapsulates the metadata required to specify parameters, such as GObject properties. #### Parameter names A property name…
  • ParamSpecBoolean — A ParamSpec derived structure that contains the meta data for boolean properties.
  • ParamSpecBoxed — A ParamSpec derived structure that contains the meta data for boxed properties.
  • ParamSpecChar — A ParamSpec derived structure that contains the meta data for character properties.
  • ParamSpecClass — The class structure for the GParamSpec type. Normally, GParamSpec classes are filled by param_type_register_static.
  • ParamSpecDouble — A ParamSpec derived structure that contains the meta data for double properties.
  • ParamSpecEnum — A ParamSpec derived structure that contains the meta data for enum properties.
  • ParamSpecFlags — A ParamSpec derived structure that contains the meta data for flags properties.
  • ParamSpecFloat — A ParamSpec derived structure that contains the meta data for float properties.
  • ParamSpecGType — A ParamSpec derived structure that contains the meta data for GType properties.
  • ParamSpecInt — A ParamSpec derived structure that contains the meta data for integer properties.
  • ParamSpecInt64 — A ParamSpec derived structure that contains the meta data for 64bit integer properties.
  • ParamSpecLong — A ParamSpec derived structure that contains the meta data for long integer properties.
  • ParamSpecObject — A ParamSpec derived structure that contains the meta data for object properties.
  • ParamSpecOverride — A ParamSpec derived structure that redirects operations to other types of ParamSpec. All operations other than getting or setting the value…
  • ParamSpecParam — A ParamSpec derived structure that contains the meta data for G_TYPE_PARAM properties.
  • ParamSpecPointer — A ParamSpec derived structure that contains the meta data for pointer properties.
  • ParamSpecPool — A ParamSpecPool maintains a collection of GParamSpecs which can be quickly accessed by owner and name. The implementation of the Object…
  • ParamSpecString — A ParamSpec derived structure that contains the meta data for string properties.
  • ParamSpecTypeInfo — This structure is used to provide the type system with the information required to initialize and destruct (finalize) a parameter's class…
  • ParamSpecUChar — A ParamSpec derived structure that contains the meta data for unsigned character properties.
  • ParamSpecUInt — A ParamSpec derived structure that contains the meta data for unsigned integer properties.
  • ParamSpecUInt64 — A ParamSpec derived structure that contains the meta data for unsigned 64bit integer properties.
  • ParamSpecULong — A ParamSpec derived structure that contains the meta data for unsigned long integer properties.
  • ParamSpecUnichar — A ParamSpec derived structure that contains the meta data for unichar (unsigned integer) properties.
  • ParamSpecValueArray — A ParamSpec derived structure that contains the meta data for ValueArray properties.
  • ParamSpecVariant — A ParamSpec derived structure that contains the meta data for GLib.Variant properties. When comparing values with param_values_cmp, scalar…
  • Parameter — The GParameter struct is an auxiliary structure used to hand parameter name/value pairs to Object.newv.
  • SignalGroupGSignalGroup manages a collection of signals on a GObject. GSignalGroup simplifies the process of connecting many signals to a…
  • SignalInvocationHint — The SignalInvocationHint structure is used to pass on additional information to callbacks during a signal emission.
  • SignalQuery — A structure holding in-depth information for a specific signal. See also: signal_query
  • TypeCValue — A union holding one collected value.
  • TypeClass — An opaque structure used as the base of all classes.
  • TypeFundamentalInfo — A structure that provides information to the type system which is used specifically for managing fundamental types.
  • TypeInfo — This structure is used to provide the type system with the information required to initialize and destruct (finalize) a type's class and…
  • TypeInstance — An opaque structure used as the base of all type instances.
  • TypeInterface — An opaque structure used as the base of all interface types.
  • TypeModuleGTypeModule provides a simple implementation of the GTypePlugin interface. The model of GTypeModule is a dynamically loaded module…
  • TypeModuleClass — In order to implement dynamic loading of types based on TypeModule, the load and unload functions in TypeModuleClass must be…
  • TypePlugin — An interface that handles the lifecycle of dynamically loaded types. The GObject type system supports dynamic loading of types. It goes as…
  • TypePluginClass — The TypePlugin interface is used by the type system in order to handle the lifecycle of dynamically loaded types.
  • TypeQuery — A structure holding information for a specific type. See also: type_query
  • TypeValueTable — - 'i': Integers, passed as collect_values[].v_int - 'l': Longs, passed as collect_values[].v_long - 'd': Doubles, passed as…
  • Value — An opaque structure used to hold different types of values. Before it can be used, a GValue has to be initialized to a specific type by…
  • ValueArray — A GValueArray is a container structure to hold an array of generic values. The prime purpose of a GValueArray is for it to be used as…
  • WeakRef — A structure containing a weak reference to a Object. A GWeakRef can either be empty (i.e. point to None), or point to an object for as…
  • _Value__data__union

Functions

boxed_copy

def boxed_copy(boxed_type: type | Type, src_boxed: int) -> int

Provide a copy of a boxed structure src_boxed which is of type boxed_type.

Parameters:

  • boxed_type — The type of src_boxed.
  • src_boxed — The boxed structure to be copied.

boxed_free

def boxed_free(boxed_type: type | Type, boxed: int) -> None

Free the boxed structure boxed which is of type boxed_type.

Parameters:

  • boxed_type — The type of boxed.
  • boxed — The boxed structure to be freed.

boxed_type_register_static

def boxed_type_register_static(name: str, boxed_copy: BoxedCopyFunc, boxed_free: BoxedFreeFunc) -> type | Type

This function creates a new G_TYPE_BOXED derived type id for a new boxed type with name name.

Boxed type handling functions have to be provided to copy and free opaque boxed structures of this type.

For the general case, it is recommended to use G_DEFINE_BOXED_TYPE() instead of calling boxed_type_register_static directly. The macro will create the appropriate *_get_type() function for the boxed type.

Parameters:

  • name — Name of the new boxed type.
  • boxed_copy — Boxed structure copy function.
  • boxed_free — Boxed structure free function.

clear_signal_handler

def clear_signal_handler(handler_id_ptr: int, instance: Object) -> None

Disconnects a handler from instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to. The handler_id_ptr is then set to zero, which is never a valid handler ID value (see g_signal_connect()).

If the handler ID is 0 then this function does nothing.

There is also a macro version of this function so that the code will be inlined.

Parameters:

  • handler_id_ptr — A pointer to a handler ID (of type #gulong) of the handler to be disconnected.
  • instance — The instance to remove the signal handler from. This pointer may be None or invalid, if the handler ID is zero.

enum_complete_type_info

def enum_complete_type_info(g_enum_type: type | Type, const_values: list[EnumValue]) -> TypeInfo

This function is meant to be called from the complete_type_info function of a TypePlugin implementation, as in the following example:

static void
my_enum_complete_type_info (GTypePlugin     *plugin,
                            GType            g_type,
                            GTypeInfo       *info,
                            GTypeValueTable *value_table)
{
  static const GEnumValue values[] = {
    { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" },
    { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" },
    { 0, NULL, NULL }
  };

  g_enum_complete_type_info (type, info, values);
}

Parameters:

  • g_enum_type — the type identifier of the type being completed
  • const_values — An array of EnumValue structs for the possible enumeration values. The array is terminated by a struct with all members being 0.

enum_get_value

def enum_get_value(enum_class: EnumClass, value: int) -> EnumValue | None

Returns the EnumValue for a value.

Parameters:

  • enum_class — a EnumClass
  • value — the value to look up

enum_get_value_by_name

def enum_get_value_by_name(enum_class: EnumClass, name: str) -> EnumValue | None

Looks up a EnumValue by name.

Parameters:

  • enum_class — a EnumClass
  • name — the name to look up

enum_get_value_by_nick

def enum_get_value_by_nick(enum_class: EnumClass, nick: str) -> EnumValue | None

Looks up a EnumValue by nickname.

Parameters:

  • enum_class — a EnumClass
  • nick — the nickname to look up

enum_register_static

def enum_register_static(name: str, const_static_values: list[EnumValue]) -> type | Type

Registers a new static enumeration type with the name name.

It is normally more convenient to let [glib-mkenums][glib-mkenums], generate a my_enum_get_type() function from a usual C enumeration definition than to write one yourself using enum_register_static.

Parameters:

  • name — A nul-terminated string used as the name of the new type.
  • const_static_values — An array of EnumValue structs for the possible enumeration values. The array is terminated by a struct with all members being 0. GObject keeps a reference to the data, so it cannot be stack-allocated.

enum_to_string

def enum_to_string(g_enum_type: type | Type, value: int) -> str

Pretty-prints value in the form of the enum’s name.

This is intended to be used for debugging purposes. The format of the output may change in the future.

Parameters:

  • g_enum_type — the type identifier of a EnumClass type
  • value — the value

flags_complete_type_info

def flags_complete_type_info(g_flags_type: type | Type, const_values: list[FlagsValue]) -> TypeInfo

This function is meant to be called from the complete_type_info() function of a TypePlugin implementation, see the example for enum_complete_type_info above.

Parameters:

  • g_flags_type — the type identifier of the type being completed
  • const_values — An array of FlagsValue structs for the possible enumeration values. The array is terminated by a struct with all members being 0.

flags_get_first_value

def flags_get_first_value(flags_class: FlagsClass, value: int) -> FlagsValue | None

Returns the first FlagsValue which is set in value.

Parameters:

  • flags_class — a FlagsClass
  • value — the value

flags_get_value_by_name

def flags_get_value_by_name(flags_class: FlagsClass, name: str) -> FlagsValue | None

Looks up a FlagsValue by name.

Parameters:

  • flags_class — a FlagsClass
  • name — the name to look up

flags_get_value_by_nick

def flags_get_value_by_nick(flags_class: FlagsClass, nick: str) -> FlagsValue | None

Looks up a FlagsValue by nickname.

Parameters:

  • flags_class — a FlagsClass
  • nick — the nickname to look up

flags_register_static

def flags_register_static(name: str, const_static_values: list[FlagsValue]) -> type | Type

Registers a new static flags type with the name name.

It is normally more convenient to let [glib-mkenums][glib-mkenums] generate a my_flags_get_type() function from a usual C enumeration definition than to write one yourself using flags_register_static.

Parameters:

  • name — A nul-terminated string used as the name of the new type.
  • const_static_values — An array of FlagsValue structs for the possible flags values. The array is terminated by a struct with all members being 0. GObject keeps a reference to the data, so it cannot be stack-allocated.

flags_to_string

def flags_to_string(flags_type: type | Type, value: int) -> str

Pretty-prints value in the form of the flag names separated by | and sorted. Any extra bits will be shown at the end as a hexadecimal number.

This is intended to be used for debugging purposes. The format of the output may change in the future.

Parameters:

  • flags_type — the type identifier of a FlagsClass type
  • value — the value

gtype_get_type

def gtype_get_type() -> type | Type

param_spec_boolean

def param_spec_boolean(name: str, nick: str | None, blurb: str | None, default_value: bool, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecBoolean instance specifying a G_TYPE_BOOLEAN property. In many cases, it may be more appropriate to use an enum with param_spec_enum, both to improve code clarity by using explicitly named values, and to allow for more values to be added in future without breaking API.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_boxed

def param_spec_boxed(name: str, nick: str | None, blurb: str | None, boxed_type: type | Type, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecBoxed instance specifying a G_TYPE_BOXED derived property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • boxed_typeG_TYPE_BOXED derived type of this property
  • flags — flags for the property specified

param_spec_char

def param_spec_char(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecChar instance specifying a G_TYPE_CHAR property.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_double

def param_spec_double(name: str, nick: str | None, blurb: str | None, minimum: float, maximum: float, default_value: float, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecDouble instance specifying a G_TYPE_DOUBLE property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_enum

def param_spec_enum(name: str, nick: str | None, blurb: str | None, enum_type: type | Type, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecEnum instance specifying a G_TYPE_ENUM property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • enum_type — a GType derived from G_TYPE_ENUM
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_flags

def param_spec_flags(name: str, nick: str | None, blurb: str | None, flags_type: type | Type, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecFlags instance specifying a G_TYPE_FLAGS property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • flags_type — a GType derived from G_TYPE_FLAGS
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_float

def param_spec_float(name: str, nick: str | None, blurb: str | None, minimum: float, maximum: float, default_value: float, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecFloat instance specifying a G_TYPE_FLOAT property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_gtype

def param_spec_gtype(name: str, nick: str | None, blurb: str | None, is_a_type: type | Type, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecGType instance specifying a G_TYPE_GTYPE property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • is_a_type — a GType whose subtypes are allowed as values of the property (use G_TYPE_NONE for any type)
  • flags — flags for the property specified

param_spec_int

def param_spec_int(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecInt instance specifying a G_TYPE_INT property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_int64

def param_spec_int64(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecInt64 instance specifying a G_TYPE_INT64 property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_long

def param_spec_long(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecLong instance specifying a G_TYPE_LONG property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_object

def param_spec_object(name: str, nick: str | None, blurb: str | None, object_type: type | Type, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecBoxed instance specifying a G_TYPE_OBJECT derived property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • object_typeG_TYPE_OBJECT derived type of this property
  • flags — flags for the property specified

param_spec_param

def param_spec_param(name: str, nick: str | None, blurb: str | None, param_type: type | Type, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecParam instance specifying a G_TYPE_PARAM property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • param_type — a GType derived from G_TYPE_PARAM
  • flags — flags for the property specified

param_spec_pointer

def param_spec_pointer(name: str, nick: str | None, blurb: str | None, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecPointer instance specifying a pointer property. Where possible, it is better to use param_spec_object or param_spec_boxed to expose memory management information.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • flags — flags for the property specified

param_spec_string

def param_spec_string(name: str, nick: str | None, blurb: str | None, default_value: str | None, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecString instance.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_uchar

def param_spec_uchar(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecUChar instance specifying a G_TYPE_UCHAR property.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_uint

def param_spec_uint(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecUInt instance specifying a G_TYPE_UINT property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_uint64

def param_spec_uint64(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecUInt64 instance specifying a G_TYPE_UINT64 property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_ulong

def param_spec_ulong(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecULong instance specifying a G_TYPE_ULONG property.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • minimum — minimum value for the property specified
  • maximum — maximum value for the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_unichar

def param_spec_unichar(name: str, nick: str | None, blurb: str | None, default_value: str, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecUnichar instance specifying a G_TYPE_UINT property. Value structures for this property can be accessed with Value.set_uint and Value.get_uint.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • default_value — default value for the property specified
  • flags — flags for the property specified

param_spec_variant

def param_spec_variant(name: str, nick: str | None, blurb: str | None, type: GLib.VariantType, default_value: GLib.Variant | None, flags: ParamFlags | int) -> ParamSpec

Creates a new ParamSpecVariant instance specifying a GLib.Variant property.

If default_value is floating, it is consumed.

See g_param_spec_internal() for details on property names.

Parameters:

  • name — canonical name of the property specified
  • nick — nick name for the property specified
  • blurb — description of the property specified
  • type — a GLib.VariantType
  • default_value — a GLib.Variant of type type to use as the default value, or None
  • flags — flags for the property specified

param_type_register_static

def param_type_register_static(name: str, pspec_info: ParamSpecTypeInfo) -> type | Type

Registers name as the name of a new static type derived from G_TYPE_PARAM.

The type system uses the information contained in the ParamSpecTypeInfo structure pointed to by info to manage the ParamSpec type and its instances.

Parameters:

param_value_convert

def param_value_convert(pspec: ParamSpec, src_value: Value, dest_value: Value, strict_validation: bool) -> bool

Transforms src_value into dest_value if possible, and then validates dest_value, in order for it to conform to pspec. If strict_validation is True this function will only succeed if the transformed dest_value complied to pspec without modifications.

See also Value.type_transformable, Value.transform and param_value_validate.

Parameters:

  • pspec — a valid ParamSpec
  • src_value — source Value
  • dest_value — destination Value of correct type for pspec
  • strict_validationTrue requires dest_value to conform to pspec without modifications

param_value_defaults

def param_value_defaults(pspec: ParamSpec, value: Value) -> bool

Checks whether value contains the default value as specified in pspec.

Parameters:

  • pspec — a valid ParamSpec
  • value — a Value of correct type for pspec

param_value_is_valid

def param_value_is_valid(pspec: ParamSpec, value: Value) -> bool

Return whether the contents of value comply with the specifications set out by pspec.

Parameters:

  • pspec — a valid ParamSpec
  • value — a Value of correct type for pspec

param_value_set_default

def param_value_set_default(pspec: ParamSpec, value: Value) -> None

Sets value to its default value as specified in pspec.

Parameters:

  • pspec — a valid ParamSpec
  • value — a Value of correct type for pspec; since 2.64, you can also pass an empty Value, initialized with G_VALUE_INIT

param_value_validate

def param_value_validate(pspec: ParamSpec, value: Value) -> bool

Ensures that the contents of value comply with the specifications set out by pspec. For example, a ParamSpecInt might require that integers stored in value may not be smaller than -42 and not be greater than +42. If value contains an integer outside of this range, it is modified accordingly, so the resulting value will fit into the range -42 .. +42.

Parameters:

  • pspec — a valid ParamSpec
  • value — a Value of correct type for pspec

param_values_cmp

def param_values_cmp(pspec: ParamSpec, value1: Value, value2: Value) -> int

Compares value1 with value2 according to pspec, and return -1, 0 or +1, if value1 is found to be less than, equal to or greater than value2, respectively.

Parameters:

  • pspec — a valid ParamSpec
  • value1 — a Value of correct type for pspec
  • value2 — a Value of correct type for pspec

pointer_type_register_static

def pointer_type_register_static(name: str) -> type | Type

Creates a new G_TYPE_POINTER derived type id for a new pointer type with name name.

Parameters:

  • name — the name of the new pointer type.

signal_accumulator_first_wins

def signal_accumulator_first_wins(ihint: SignalInvocationHint, return_accu: Value, handler_return: Value, dummy: int | None = ...) -> bool

A predefined GSignalAccumulator for signals intended to be used as a hook for application code to provide a particular value. Usually only one such value is desired and multiple handlers for the same signal don't make much sense (except for the case of the default handler defined in the class structure, in which case you will usually want the signal connection to override the class handler).

This accumulator will use the return value from the first signal handler that is run as the return value for the signal and not run any further handlers (ie: the first handler "wins").

Parameters:

  • ihint — standard GSignalAccumulator parameter
  • return_accu — standard GSignalAccumulator parameter
  • handler_return — standard GSignalAccumulator parameter
  • dummy — standard GSignalAccumulator parameter

signal_accumulator_true_handled

def signal_accumulator_true_handled(ihint: SignalInvocationHint, return_accu: Value, handler_return: Value, dummy: int | None = ...) -> bool

A predefined GSignalAccumulator for signals that return a boolean values. The behavior that this accumulator gives is that a return of True stops the signal emission: no further callbacks will be invoked, while a return of False allows the emission to continue. The idea here is that a True return indicates that the callback handled the signal, and no further handling is needed.

Parameters:

  • ihint — standard GSignalAccumulator parameter
  • return_accu — standard GSignalAccumulator parameter
  • handler_return — standard GSignalAccumulator parameter
  • dummy — standard GSignalAccumulator parameter

signal_add_emission_hook

def signal_add_emission_hook(signal_id: int, detail: GLib.Quark, hook_func: SignalEmissionHook) -> int

Adds an emission hook for a signal, which will get called for any emission of that signal, independent of the instance. This is possible only for signals which don't have SignalFlags.NO_HOOKS flag set.

Parameters:

  • signal_id — the signal identifier, as returned by signal_lookup.
  • detail — the detail on which to call the hook.
  • hook_func — a GSignalEmissionHook function.

signal_chain_from_overridden

def signal_chain_from_overridden(instance_and_params: list[Value], return_value: Value) -> None

Calls the original class closure of a signal. This function should only be called from an overridden class closure; see signal_override_class_closure and signal_override_class_handler.

Parameters:

  • instance_and_params — the argument list of the signal emission. The first element in the array is a Value for the instance the signal is being emitted on. The rest are any arguments to be passed to the signal.
  • return_value — Location for the return value.

signal_connect_closure

def signal_connect_closure(instance: Object, detailed_signal: str, closure: Closure, after: bool) -> int

Connects a closure to a signal for a particular object.

If closure is a floating reference (see Closure.sink), this function takes ownership of closure.

This function cannot fail. If the given signal name doesn’t exist, a critical warning is emitted. No validation is performed on the ‘detail’ string when specified in detailed_signal, other than a non-empty check.

Refer to the signals documentation for more details.

Parameters:

  • instance — the instance to connect to.
  • detailed_signal — a string of the form "signal-name::detail".
  • closure — the closure to connect.
  • after — whether the handler should be called before or after the default handler of the signal.

signal_connect_closure_by_id

def signal_connect_closure_by_id(instance: Object, signal_id: int, detail: GLib.Quark, closure: Closure, after: bool) -> int

Connects a closure to a signal for a particular object.

If closure is a floating reference (see Closure.sink), this function takes ownership of closure.

This function cannot fail. If the given signal name doesn’t exist, a critical warning is emitted. No validation is performed on the ‘detail’ string when specified in detailed_signal, other than a non-empty check.

Refer to the signals documentation for more details.

Parameters:

  • instance — the instance to connect to.
  • signal_id — the id of the signal.
  • detail — the detail.
  • closure — the closure to connect.
  • after — whether the handler should be called before or after the default handler of the signal.

signal_emitv

def signal_emitv(instance_and_params: list[Value], signal_id: int, detail: GLib.Quark, return_value: Value) -> Value

Emits a signal. Signal emission is done synchronously. The method will only return control after all handlers are called or signal emission was stopped.

Note that signal_emitv doesn't change return_value if no handlers are connected, in contrast to g_signal_emit() and g_signal_emit_valist().

Parameters:

  • instance_and_params — argument list for the signal emission. The first element in the array is a Value for the instance the signal is being emitted on. The rest are any arguments to be passed to the signal.
  • signal_id — the signal id
  • detail — the detail
  • return_value — Location to store the return value of the signal emission. This must be provided if the specified signal returns a value, but may be ignored otherwise.

signal_get_invocation_hint

def signal_get_invocation_hint(instance: Object) -> SignalInvocationHint | None

Returns the invocation hint of the innermost signal emission of instance.

Parameters:

  • instance — the instance to query

signal_handler_block

def signal_handler_block(instance: Object, handler_id: int) -> None

Blocks a handler of an instance so it will not be called during any signal emissions unless it is unblocked again. Thus "blocking" a signal handler means to temporarily deactivate it, a signal handler has to be unblocked exactly the same amount of times it has been blocked before to become active again.

The handler_id has to be a valid signal handler id, connected to a signal of instance.

Parameters:

  • instance — The instance to block the signal handler of.
  • handler_id — Handler id of the handler to be blocked.

signal_handler_disconnect

def signal_handler_disconnect(instance: Object, handler_id: int) -> None

Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to. The handler_id becomes invalid and may be reused.

The handler_id has to be a valid signal handler id, connected to a signal of instance.

Parameters:

  • instance — The instance to remove the signal handler from.
  • handler_id — Handler id of the handler to be disconnected.

signal_handler_find

def signal_handler_find(instance: Object, mask: SignalMatchType | int, signal_id: int, detail: GLib.Quark, closure: Closure | None = ..., func: int | None = ..., data: int | None = ...) -> int

Finds the first signal handler that matches certain selection criteria. The criteria mask is passed as an OR-ed combination of SignalMatchType flags, and the criteria values are passed as arguments. The match mask has to be non-0 for successful matches. If no handler was found, 0 is returned.

Parameters:

  • instance — The instance owning the signal handler to be found.
  • mask — Mask indicating which of signal_id, detail, closure, func and/or data the handler has to match.
  • signal_id — Signal the handler has to be connected to.
  • detail — Signal detail the handler has to be connected to.
  • closure — The closure the handler will invoke.
  • func — The C closure callback of the handler (useless for non-C closures).
  • data — The closure data of the handler's closure.

signal_handler_is_connected

def signal_handler_is_connected(instance: Object, handler_id: int) -> bool

Returns whether handler_id is the ID of a handler connected to instance.

Parameters:

  • instance — The instance where a signal handler is sought.
  • handler_id — the handler ID.

signal_handler_unblock

def signal_handler_unblock(instance: Object, handler_id: int) -> None

Undoes the effect of a previous signal_handler_block call. A blocked handler is skipped during signal emissions and will not be invoked, unblocking it (for exactly the amount of times it has been blocked before) reverts its "blocked" state, so the handler will be recognized by the signal system and is called upon future or currently ongoing signal emissions (since the order in which handlers are called during signal emissions is deterministic, whether the unblocked handler in question is called as part of a currently ongoing emission depends on how far that emission has proceeded yet).

The handler_id has to be a valid id of a signal handler that is connected to a signal of instance and is currently blocked.

Parameters:

  • instance — The instance to unblock the signal handler of.
  • handler_id — Handler id of the handler to be unblocked.

signal_handlers_block_matched

def signal_handlers_block_matched(instance: Object, mask: SignalMatchType | int, signal_id: int, detail: GLib.Quark, closure: Closure | None = ..., func: int | None = ..., data: int | None = ...) -> int

Blocks all handlers on an instance that match a certain selection criteria.

The criteria mask is passed as a combination of SignalMatchType flags, and the criteria values are passed as arguments. A handler must match on all flags set in mask to be blocked (i.e. the match is conjunctive).

Passing at least one of the SignalMatchType.ID, SignalMatchType.CLOSURE, SignalMatchType.FUNC or SignalMatchType.DATA match flags is required for successful matches. If no handlers were found, 0 is returned, the number of blocked handlers otherwise.

Support for SignalMatchType.ID was added in GLib 2.78.

Parameters:

  • instance — The instance to block handlers from.
  • mask — Mask indicating which of signal_id, detail, closure, func and/or data the handlers have to match.
  • signal_id — Signal the handlers have to be connected to.
  • detail — Signal detail the handlers have to be connected to.
  • closure — The closure the handlers will invoke.
  • func — The C closure callback of the handlers (useless for non-C closures).
  • data — The closure data of the handlers' closures.

signal_handlers_destroy

def signal_handlers_destroy(instance: Object) -> None

Destroy all signal handlers of a type instance. This function is an implementation detail of the Object dispose implementation, and should not be used outside of the type system.

Parameters:

  • instance — The instance whose signal handlers are destroyed

signal_handlers_disconnect_matched

def signal_handlers_disconnect_matched(instance: Object, mask: SignalMatchType | int, signal_id: int, detail: GLib.Quark, closure: Closure | None = ..., func: int | None = ..., data: int | None = ...) -> int

Disconnects all handlers on an instance that match a certain selection criteria.

The criteria mask is passed as a combination of SignalMatchType flags, and the criteria values are passed as arguments. A handler must match on all flags set in mask to be disconnected (i.e. the match is conjunctive).

Passing at least one of the SignalMatchType.ID, SignalMatchType.CLOSURE, SignalMatchType.FUNC or SignalMatchType.DATA match flags is required for successful matches. If no handlers were found, 0 is returned, the number of disconnected handlers otherwise.

Support for SignalMatchType.ID was added in GLib 2.78.

Parameters:

  • instance — The instance to remove handlers from.
  • mask — Mask indicating which of signal_id, detail, closure, func and/or data the handlers have to match.
  • signal_id — Signal the handlers have to be connected to.
  • detail — Signal detail the handlers have to be connected to.
  • closure — The closure the handlers will invoke.
  • func — The C closure callback of the handlers (useless for non-C closures).
  • data — The closure data of the handlers' closures.

signal_handlers_unblock_matched

def signal_handlers_unblock_matched(instance: Object, mask: SignalMatchType | int, signal_id: int, detail: GLib.Quark, closure: Closure | None = ..., func: int | None = ..., data: int | None = ...) -> int

Unblocks all handlers on an instance that match a certain selection criteria.

The criteria mask is passed as a combination of SignalMatchType flags, and the criteria values are passed as arguments. A handler must match on all flags set in mask to be unblocked (i.e. the match is conjunctive).

Passing at least one of the SignalMatchType.ID, SignalMatchType.CLOSURE, SignalMatchType.FUNC or SignalMatchType.DATA match flags is required for successful matches. If no handlers were found, 0 is returned, the number of unblocked handlers otherwise. The match criteria should not apply to any handlers that are not currently blocked.

Support for SignalMatchType.ID was added in GLib 2.78.

Parameters:

  • instance — The instance to unblock handlers from.
  • mask — Mask indicating which of signal_id, detail, closure, func and/or data the handlers have to match.
  • signal_id — Signal the handlers have to be connected to.
  • detail — Signal detail the handlers have to be connected to.
  • closure — The closure the handlers will invoke.
  • func — The C closure callback of the handlers (useless for non-C closures).
  • data — The closure data of the handlers' closures.

signal_has_handler_pending

def signal_has_handler_pending(instance: Object, signal_id: int, detail: GLib.Quark, may_be_blocked: bool) -> bool

Returns whether there are any handlers connected to instance for the given signal id and detail.

If detail is 0 then it will only match handlers that were connected without detail. If detail is non-zero then it will match handlers connected both without detail and with the given detail. This is consistent with how a signal emitted with detail would be delivered to those handlers.

Since 2.46 this also checks for a non-default class closure being installed, as this is basically always what you want.

One example of when you might use this is when the arguments to the signal are difficult to compute. A class implementor may opt to not emit the signal if no one is attached anyway, thus saving the cost of building the arguments.

Parameters:

  • instance — the object whose signal handlers are sought.
  • signal_id — the signal id.
  • detail — the detail.
  • may_be_blocked — whether blocked handlers should count as match.

signal_is_valid_name

def signal_is_valid_name(name: str) -> bool

Validate a signal name. This can be useful for dynamically-generated signals which need to be validated at run-time before actually trying to create them.

See GObject.signal_new for details of the rules for valid names. The rules for signal names are the same as those for property names.

Parameters:

  • name — the canonical name of the signal

signal_list_ids

def signal_list_ids(itype: type | Type) -> list[int]

Lists the signals by id that a certain instance or interface type created. Further information about the signals can be acquired through signal_query.

Parameters:

  • itype — Instance or interface type.

signal_lookup

def signal_lookup(name: str, itype: type | Type) -> int

Given the name of the signal and the type of object it connects to, gets the signal's identifying integer. Emitting the signal by number is somewhat faster than using the name each time.

Also tries the ancestors of the given type.

The type class passed as itype must already have been instantiated (for example, using TypeClass.ref) for this function to work, as signals are always installed during class initialization.

See g_signal_new() for details on allowed signal names.

Parameters:

  • name — the signal's name.
  • itype — the type that the signal operates on.

signal_name

def signal_name(signal_id: int) -> str | None

Given the signal's identifier, finds its name.

Two different signals may have the same name, if they have differing types.

Parameters:

  • signal_id — the signal's identifying number.

signal_override_class_closure

def signal_override_class_closure(signal_id: int, instance_type: type | Type, class_closure: Closure) -> None

Overrides the class closure (i.e. the default handler) for the given signal for emissions on instances of instance_type. instance_type must be derived from the type to which the signal belongs.

See signal_chain_from_overridden and g_signal_chain_from_overridden_handler() for how to chain up to the parent class closure from inside the overridden one.

Parameters:

  • signal_id — the signal id
  • instance_type — the instance type on which to override the class closure for the signal.
  • class_closure — the closure.

signal_override_class_handler

def signal_override_class_handler(signal_name: str, instance_type: type | Type, class_handler: Callback) -> None

Overrides the class closure (i.e. the default handler) for the given signal for emissions on instances of instance_type with callback class_handler. instance_type must be derived from the type to which the signal belongs.

See signal_chain_from_overridden and g_signal_chain_from_overridden_handler() for how to chain up to the parent class closure from inside the overridden one.

Parameters:

  • signal_name — the name for the signal
  • instance_type — the instance type on which to override the class handler for the signal.
  • class_handler — the handler.

signal_parse_name

def signal_parse_name(detailed_signal: str, itype: type | Type, force_detail_quark: bool) -> tuple[bool, int, GLib.Quark]

Internal function to parse a signal name into its signal_id and detail quark.

Parameters:

  • detailed_signal — a string of the form "signal-name::detail".
  • itype — The interface/instance type that introduced "signal-name".
  • force_detail_quarkTrue forces creation of a GQuark for the detail.

signal_query

def signal_query(signal_id: int) -> SignalQuery

Queries the signal system for in-depth information about a specific signal. This function will fill in a user-provided structure to hold signal-specific information. If an invalid signal id is passed in, the signal_id member of the SignalQuery is 0. All members filled into the SignalQuery structure should be considered constant and have to be left untouched.

Parameters:

  • signal_id — The signal id of the signal to query information for.

signal_remove_emission_hook

def signal_remove_emission_hook(signal_id: int, hook_id: int) -> None

Deletes an emission hook.

Parameters:

signal_stop_emission

def signal_stop_emission(instance: Object, signal_id: int, detail: GLib.Quark) -> None

Stops a signal's current emission.

This will prevent the default method from running, if the signal was SignalFlags.RUN_LAST and you connected normally (i.e. without the "after" flag).

Prints a warning if used on a signal which isn't being emitted.

Parameters:

  • instance — the object whose signal handlers you wish to stop.
  • signal_id — the signal identifier, as returned by signal_lookup.
  • detail — the detail which the signal was emitted with.

signal_stop_emission_by_name

def signal_stop_emission_by_name(instance: Object, detailed_signal: str) -> None

Stops a signal's current emission.

This is just like signal_stop_emission except it will look up the signal id for you.

Parameters:

  • instance — the object whose signal handlers you wish to stop.
  • detailed_signal — a string of the form "signal-name::detail".

signal_type_cclosure_new

def signal_type_cclosure_new(itype: type | Type, struct_offset: int) -> Closure

Creates a new closure which invokes the function found at the offset struct_offset in the class structure of the interface or classed type identified by itype.

Parameters:

  • itype — the GType identifier of an interface or classed type
  • struct_offset — the offset of the member function of itype's class structure which is to be invoked by the new closure

strdup_value_contents

def strdup_value_contents(value: Value) -> str

Return a newly allocated string, which describes the contents of a Value. The main purpose of this function is to describe Value contents for debugging output, the way in which the contents are described may change between different GLib versions.

Parameters:

  • valueValue which contents are to be described.

type_add_class_private

def type_add_class_private(class_type: type | Type, private_size: int) -> None

Registers a private class structure for a classed type; when the class is allocated, the private structures for the class and all of its parent types are allocated sequentially in the same memory block as the public structures, and are zero-filled.

This function should be called in the type's get_type() function after the type is registered. The private structure can be retrieved using the G_TYPE_CLASS_GET_PRIVATE() macro.

Parameters:

  • class_type — GType of a classed type
  • private_size — size of private structure

type_add_instance_private

def type_add_instance_private(class_type: type | Type, private_size: int) -> int

type_add_interface_dynamic

def type_add_interface_dynamic(instance_type: type | Type, interface_type: type | Type, plugin: TypePlugin) -> None

Adds interface_type to the dynamic instance_type. The information contained in the TypePlugin structure pointed to by plugin is used to manage the relationship.

Parameters:

  • instance_typeGType value of an instantiatable type
  • interface_typeGType value of an interface type
  • pluginTypePlugin structure to retrieve the InterfaceInfo from

type_add_interface_static

def type_add_interface_static(instance_type: type | Type, interface_type: type | Type, info: InterfaceInfo) -> None

Adds interface_type to the static instance_type. The information contained in the InterfaceInfo structure pointed to by info is used to manage the relationship.

Parameters:

  • instance_typeGType value of an instantiatable type
  • interface_typeGType value of an interface type
  • infoInterfaceInfo structure for this (instance_type, interface_type) combination

type_check_class_is_a

def type_check_class_is_a(g_class: TypeClass, is_a_type: type | Type) -> bool

type_check_instance

def type_check_instance(instance: TypeInstance) -> bool

Private helper function to aid implementation of the G_TYPE_CHECK_INSTANCE() macro.

Parameters:

type_check_instance_is_a

def type_check_instance_is_a(instance: TypeInstance, iface_type: type | Type) -> bool

type_check_instance_is_fundamentally_a

def type_check_instance_is_fundamentally_a(instance: TypeInstance, fundamental_type: type | Type) -> bool

type_check_is_value_type

def type_check_is_value_type(type: type | Type) -> bool

type_check_value

def type_check_value(value: Value) -> bool

type_check_value_holds

def type_check_value_holds(value: Value, type: type | Type) -> bool

type_children

def type_children(type: type | Type) -> list[type | Type]

Return a newly allocated and 0-terminated array of type IDs, listing the child types of type.

Parameters:

  • type — the parent type

type_default_interface_get

def type_default_interface_get(g_type: type | Type) -> TypeInterface

Returns the default interface vtable for the given g_type.

If the type is not currently in use, then the default vtable for the type will be created and initialized by calling the base interface init and default vtable init functions for the type (the base_init and class_init members of TypeInfo).

If you don't want to create the interface vtable, you should use type_default_interface_peek instead.

Calling type_default_interface_get is useful when you want to make sure that signals and properties for an interface have been installed.

Parameters:

  • g_type — an interface type

type_default_interface_peek

def type_default_interface_peek(g_type: type | Type) -> TypeInterface

If the interface type g_type is currently in use, returns its default interface vtable.

Parameters:

  • g_type — an interface type

type_default_interface_ref

def type_default_interface_ref(g_type: type | Type) -> TypeInterface

:::warning Deprecated since 2.84 This API is deprecated. :::

Increments the reference count for the interface type g_type, and returns the default interface vtable for the type.

If the type is not currently in use, then the default vtable for the type will be created and initialized by calling the base interface init and default vtable init functions for the type (the base_init and class_init members of TypeInfo). Calling type_default_interface_ref is useful when you want to make sure that signals and properties for an interface have been installed.

Parameters:

  • g_type — an interface type

type_default_interface_unref

def type_default_interface_unref(g_iface: TypeInterface) -> None

:::warning Deprecated since 2.84 This API is deprecated. :::

Decrements the reference count for the type corresponding to the interface default vtable g_iface.

If the type is dynamic, then when no one is using the interface and all references have been released, the finalize function for the interface's default vtable (the class_finalize member of TypeInfo) will be called.

Parameters:

type_depth

def type_depth(type: type | Type) -> int

Returns the length of the ancestry of the passed in type. This includes the type itself, so that e.g. a fundamental type has depth 1.

Parameters:

  • type — a GType

type_ensure

def type_ensure(type: type | Type) -> None

Ensures that the indicated type has been registered with the type system, and its _class_init() method has been run.

In theory, simply calling the type's _get_type() method (or using the corresponding macro) is supposed take care of this. However, _get_type() methods are often marked G_GNUC_CONST for performance reasons, even though this is technically incorrect (since G_GNUC_CONST requires that the function not have side effects, which _get_type() methods do on the first call). As a result, if you write a bare call to a _get_type() macro, it may get optimized out by the compiler. Using type_ensure guarantees that the type's _get_type() method is called.

Parameters:

  • type — a GType

type_free_instance

def type_free_instance(instance: TypeInstance) -> None

Frees an instance of a type, returning it to the instance pool for the type, if there is one.

Like g_type_create_instance(), this function is reserved for implementors of fundamental types.

Parameters:

  • instance — an instance of a type

type_from_name

def type_from_name(name: str) -> type | Type

Look up the type ID from a given type name, returning 0 if no type has been registered under this name (this is the preferred method to find out by name whether a specific type has been registered yet).

Parameters:

  • name — type name to look up

type_fundamental

def type_fundamental(type_id: type | Type) -> type | Type

Internal function, used to extract the fundamental type ID portion. Use G_TYPE_FUNDAMENTAL() instead.

Parameters:

  • type_id — valid type ID

type_fundamental_next

def type_fundamental_next() -> type | Type

Returns the next free fundamental type id which can be used to register a new fundamental type with type_register_fundamental. The returned type ID represents the highest currently registered fundamental type identifier.

type_get_instance_count

def type_get_instance_count(type: type | Type) -> int

Returns the number of instances allocated of the particular type; this is only available if GLib is built with debugging support and the instance-count debug flag is set (by setting the GOBJECT_DEBUG variable to include instance-count).

Parameters:

  • type — a GType

type_get_plugin

def type_get_plugin(type: type | Type) -> TypePlugin

Returns the TypePlugin structure for type.

Parameters:

  • typeGType to retrieve the plugin for

type_get_qdata

def type_get_qdata(type: type | Type, quark: GLib.Quark) -> int | None

Obtains data which has previously been attached to type with type_set_qdata.

Note that this does not take subtyping into account; data attached to one type with type_set_qdata cannot be retrieved from a subtype using type_get_qdata.

Parameters:

  • type — a GType
  • quark — a GQuark id to identify the data

type_get_type_registration_serial

def type_get_type_registration_serial() -> int

Returns an opaque serial number that represents the state of the set of registered types. Any time a type is registered this serial changes, which means you can cache information based on type lookups (such as type_from_name) and know if the cache is still valid at a later time by comparing the current serial with the one at the type lookup.

type_init

def type_init() -> None

:::warning Deprecated since 2.36 This API is deprecated. :::

This function used to initialise the type system. Since GLib 2.36, the type system is initialised automatically and this function does nothing.

type_init_with_debug_flags

def type_init_with_debug_flags(debug_flags: TypeDebugFlags | int) -> None

:::warning Deprecated since 2.36 This API is deprecated. :::

This function used to initialise the type system with debugging flags. Since GLib 2.36, the type system is initialised automatically and this function does nothing.

If you need to enable debugging features, use the GOBJECT_DEBUG environment variable.

Parameters:

  • debug_flags — bitwise combination of TypeDebugFlags values for debugging purposes

type_interfaces

def type_interfaces(type: type | Type) -> list[type | Type]

Return a newly allocated and 0-terminated array of type IDs, listing the interface types that type conforms to.

Parameters:

  • type — the type to list interface types for

type_is_a

def type_is_a(type: type | Type, is_a_type: type | Type) -> bool

If is_a_type is a derivable type, check whether type is a descendant of is_a_type. If is_a_type is an interface, check whether type conforms to it.

Parameters:

  • type — type to check ancestry for
  • is_a_type — possible ancestor of type or interface that type could conform to

type_name

def type_name(type: type | Type) -> str | None

Get the unique name that is assigned to a type ID.

Note that this function (like all other GType API) cannot cope with invalid type IDs. G_TYPE_INVALID may be passed to this function, as may be any other validly registered type ID, but randomized type IDs should not be passed in and will most likely lead to a crash.

Parameters:

  • type — type to return name for

type_name_from_class

def type_name_from_class(g_class: TypeClass) -> str

type_name_from_instance

def type_name_from_instance(instance: TypeInstance) -> str

type_next_base

def type_next_base(leaf_type: type | Type, root_type: type | Type) -> type | Type

Given a leaf_type and a root_type which is contained in its ancestry, return the type that root_type is the immediate parent of. In other words, this function determines the type that is derived directly from root_type which is also a base class of leaf_type. Given a root type and a leaf type, this function can be used to determine the types and order in which the leaf type is descended from the root type.

Parameters:

  • leaf_type — descendant of root_type and the type to be returned
  • root_type — immediate parent of the returned type

type_parent

def type_parent(type: type | Type) -> type | Type

Return the direct parent type of the passed in type. If the passed in type has no parent, i.e. is a fundamental type, 0 is returned.

Parameters:

  • type — the derived type

type_qname

def type_qname(type: type | Type) -> GLib.Quark

Get the corresponding quark of the type IDs name.

Parameters:

  • type — type to return quark of type name for

type_query

def type_query(type: type | Type) -> TypeQuery

Queries the type system for information about a specific type.

This function will fill in a user-provided structure to hold type-specific information. If an invalid GType is passed in, the type member of the TypeQuery is 0. All members filled into the TypeQuery structure should be considered constant and have to be left untouched.

Since GLib 2.78, this function allows queries on dynamic types. Previously it only supported static types.

Parameters:

  • typeGType of a static, classed type

type_register_dynamic

def type_register_dynamic(parent_type: type | Type, type_name: str, plugin: TypePlugin, flags: TypeFlags | int) -> type | Type

Registers type_name as the name of a new dynamic type derived from parent_type. The type system uses the information contained in the TypePlugin structure pointed to by plugin to manage the type and its instances (if not abstract). The value of flags determines the nature (e.g. abstract or not) of the type.

Parameters:

  • parent_type — type from which this type will be derived
  • type_name — 0-terminated string used as the name of the new type
  • pluginTypePlugin structure to retrieve the TypeInfo from
  • flags — bitwise combination of TypeFlags values

type_register_fundamental

def type_register_fundamental(type_id: type | Type, type_name: str, info: TypeInfo, finfo: TypeFundamentalInfo, flags: TypeFlags | int) -> type | Type

Registers type_id as the predefined identifier and type_name as the name of a fundamental type. If type_id is already registered, or a type named type_name is already registered, the behaviour is undefined. The type system uses the information contained in the TypeInfo structure pointed to by info and the TypeFundamentalInfo structure pointed to by finfo to manage the type and its instances. The value of flags determines additional characteristics of the fundamental type.

Parameters:

  • type_id — a predefined type identifier
  • type_name — 0-terminated string used as the name of the new type
  • infoTypeInfo structure for this type
  • finfoTypeFundamentalInfo structure for this type
  • flags — bitwise combination of TypeFlags values

type_register_static

def type_register_static(parent_type: type | Type, type_name: str, info: TypeInfo, flags: TypeFlags | int) -> type | Type

Registers type_name as the name of a new static type derived from parent_type. The type system uses the information contained in the TypeInfo structure pointed to by info to manage the type and its instances (if not abstract). The value of flags determines the nature (e.g. abstract or not) of the type.

Parameters:

  • parent_type — type from which this type will be derived
  • type_name — 0-terminated string used as the name of the new type
  • infoTypeInfo structure for this type
  • flags — bitwise combination of TypeFlags values

type_set_qdata

def type_set_qdata(type: type | Type, quark: GLib.Quark, data: int | None = ...) -> None

Attaches arbitrary data to a type.

Parameters:

  • type — a GType
  • quark — a GQuark id to identify the data
  • data — the data

type_test_flags

def type_test_flags(type: type | Type, flags: int) -> bool

variant_get_gtype

def variant_get_gtype() -> type | Type

Enumerations

BindingFlags

Bit flags.

  • DEFAULT = 0 — The default binding; if the source property changes, the target property is updated with its value.
  • BIDIRECTIONAL = 1 — Bidirectional binding; if either the property of the source or the property of the target changes, the other is updated.
  • SYNC_CREATE = 2 — Synchronize the values of the source and target properties when creating the binding; the direction of the synchronization is always from the source to the target.
  • INVERT_BOOLEAN = 4 — If the two properties being bound are booleans, setting one to True will result in the other being set to False and vice versa. This flag will only work for boolean properties, and cannot be used when passing custom transformation functions to Object.bind_property_full.

ConnectFlags

Bit flags.

  • DEFAULT = 0 — Default behaviour (no special flags). Since: 2.74
  • AFTER = 1 — If set, the handler should be called after the default handler of the signal. Normally, the handler is called before the default handler.
  • SWAPPED = 2 — If set, the instance and data should be swapped when calling the handler; see g_signal_connect_swapped() for an example.

IOCondition

Bit flags.

  • IN = 1
  • OUT = 4
  • PRI = 2
  • ERR = 8
  • HUP = 16
  • NVAL = 32

ParamFlags

Bit flags.

  • READABLE = 1 — the parameter is readable
  • WRITABLE = 2 — the parameter is writable
  • READWRITE = 3 — alias for ParamFlags.READABLE | ParamFlags.WRITABLE
  • CONSTRUCT = 4 — the parameter will be set upon object construction. See Object.constructed for more details
  • CONSTRUCT_ONLY = 8 — the parameter can only be set upon object construction. See Object.constructed for more details
  • LAX_VALIDATION = 16 — upon parameter conversion (see param_value_convert) strict validation is not required
  • STATIC_NAME = 32 — the string used as name when constructing the parameter is guaranteed to remain valid and unmodified for the lifetime of the parameter. Since 2.8
  • PRIVATE = 32 — internal
  • STATIC_NICK = 64 — the string used as nick when constructing the parameter is guaranteed to remain valid and unmmodified for the lifetime of the parameter. Since 2.8
  • STATIC_BLURB = 128 — the string used as blurb when constructing the parameter is guaranteed to remain valid and unmodified for the lifetime of the parameter. Since 2.8
  • EXPLICIT_NOTIFY = 1073741824 — calls to Object.set_property for this property will not automatically result in a "notify" signal being emitted: the implementation must call Object.notify themselves in case the property actually changes. Since: 2.42.
  • DEPRECATED = 2147483648 — the parameter is deprecated and will be removed in a future version. A warning will be generated if it is used while running with G_ENABLE_DIAGNOSTIC=1. Since 2.26

SignalFlags

Bit flags.

  • RUN_FIRST = 1 — Invoke the object method handler in the first emission stage.
  • RUN_LAST = 2 — Invoke the object method handler in the third emission stage.
  • RUN_CLEANUP = 4 — Invoke the object method handler in the last emission stage.
  • NO_RECURSE = 8 — Signals being emitted for an object while currently being in emission for this very object will not be emitted recursively, but instead cause the first emission to be restarted.
  • DETAILED = 16 — This signal supports "::detail" appendices to the signal name upon handler connections and emissions.
  • ACTION = 32 — Action signals are signals that may freely be emitted on alive objects from user code via g_signal_emit() and friends, without the need of being embedded into extra code that performs pre or post emission adjustments on the object. They can also be thought of as object methods which can be called generically by third-party code.
  • NO_HOOKS = 64 — No emissions hooks are supported for this signal.
  • MUST_COLLECT = 128 — Varargs signal emission will always collect the arguments, even if there are no signal handlers connected.
  • DEPRECATED = 256 — The signal is deprecated and will be removed in a future version. A warning will be generated if it is connected while running with G_ENABLE_DIAGNOSTIC=1.
  • ACCUMULATOR_FIRST_RUN = 131072 — The signal accumulator was invoked for the first time. This flag is only used in SignalAccumulator[accumulator functions] for the run_type field of the SignalInvocationHint, to mark the first call to the accumulator function for a signal emission.

SignalMatchType

Bit flags.

  • ID = 1 — The signal id must be equal.
  • DETAIL = 2 — The signal detail must be equal.
  • CLOSURE = 4 — The closure must be the same.
  • FUNC = 8 — The C closure callback must be the same.
  • DATA = 16 — The closure data must be the same.
  • UNBLOCKED = 32 — Only unblocked signals may be matched.

TypeDebugFlags

Bit flags.

  • NONE = 0 — Print no messages
  • OBJECTS = 1 — Print messages about object bookkeeping
  • SIGNALS = 2 — Print messages about signal emissions
  • INSTANCE_COUNT = 4 — Keep a count of instances of each type
  • MASK = 7 — Mask covering all debug flags

TypeFlags

Bit flags.

  • NONE = 0 — No special flags. Since: 2.74
  • ABSTRACT = 16 — Indicates an abstract type. No instances can be created for an abstract type
  • VALUE_ABSTRACT = 32 — Indicates an abstract value type, i.e. a type that introduces a value table, but can't be used for Value.init
  • FINAL = 64 — Indicates a final type. A final type is a non-derivable leaf node in a deep derivable type hierarchy tree. Since: 2.70
  • DEPRECATED = 128 — The type is deprecated and may be removed in a future version. A warning will be emitted if it is instantiated while running with G_ENABLE_DIAGNOSTIC=1. Since 2.76

TypeFundamentalFlags

Bit flags.

  • CLASSED = 1 — Indicates a classed type
  • INSTANTIATABLE = 2 — Indicates an instantiatable type (implies classed)
  • DERIVABLE = 4 — Indicates a flat derivable type
  • DEEP_DERIVABLE = 8 — Indicates a deep derivable type (implies derivable)

Constants

PARAM_MASK

PARAM_MASK: int

Mask containing the bits of ParamSpec.flags which are reserved for GLib.

PARAM_STATIC_STRINGS

PARAM_STATIC_STRINGS: int

ParamSpecFlags value alias for ParamFlags.STATIC_NAME | ParamFlags.STATIC_NICK | ParamFlags.STATIC_BLURB.

It is recommended to use this for all properties by default, as it allows for internal performance improvements in GObject.

It is very rare that a property would have a dynamically constructed name, nickname or blurb.

Since 2.13.0

PARAM_USER_SHIFT

PARAM_USER_SHIFT: int

Minimum shift count to be used for user defined flags, to be stored in ParamSpec.flags. The maximum allowed is 10.

SIGNAL_FLAGS_MASK

SIGNAL_FLAGS_MASK: int

A mask for all SignalFlags bits.

SIGNAL_MATCH_MASK

SIGNAL_MATCH_MASK: int

A mask for all SignalMatchType bits.

TYPE_FLAG_RESERVED_ID_BIT

TYPE_FLAG_RESERVED_ID_BIT: Type

A bit in the type number that's supposed to be left untouched.

TYPE_FUNDAMENTAL_MAX

TYPE_FUNDAMENTAL_MAX: int

An integer constant that represents the number of identifiers reserved for types that are assigned at compile-time.

TYPE_FUNDAMENTAL_SHIFT

TYPE_FUNDAMENTAL_SHIFT: int

Shift value used in converting numbers to type IDs.

TYPE_RESERVED_BSE_FIRST

TYPE_RESERVED_BSE_FIRST: int

First fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE.

TYPE_RESERVED_BSE_LAST

TYPE_RESERVED_BSE_LAST: int

Last fundamental type number reserved for BSE.

TYPE_RESERVED_GLIB_FIRST

TYPE_RESERVED_GLIB_FIRST: int

First fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib.

TYPE_RESERVED_GLIB_LAST

TYPE_RESERVED_GLIB_LAST: int

Last fundamental type number reserved for GLib.

TYPE_RESERVED_USER_FIRST

TYPE_RESERVED_USER_FIRST: int

First available fundamental type number to create new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL().

VALUE_COLLECT_FORMAT_MAX_LENGTH

VALUE_COLLECT_FORMAT_MAX_LENGTH: int

The maximal number of GTypeCValues which can be collected for a single Value.

VALUE_INTERNED_STRING

VALUE_INTERNED_STRING: int

Flag to indicate that a string in a Value is canonical and will exist for the duration of the process.

See Value.set_interned_string.

This flag should be checked by implementations of TypeValueFreeFunc, TypeValueCollectFunc and TypeValueLCopyFunc.

VALUE_NOCOPY_CONTENTS

VALUE_NOCOPY_CONTENTS: int

Flag to indicate that allocated data in a Value shouldn’t be copied.

If passed to GObject.VALUE_COLLECT, allocated data won’t be copied but used verbatim. This does not affect ref-counted types like objects.

This does not affect usage of Value.copy: the data will be copied if it is not ref-counted.

This flag should be checked by implementations of TypeValueFreeFunc, TypeValueCollectFunc and TypeValueLCopyFunc.

Callbacks

BaseFinalizeFunc

BaseFinalizeFunc = Callable[[g_class: TypeClass], None]

BaseInitFunc

BaseInitFunc = Callable[[g_class: TypeClass], None]

BindingTransformFunc

BindingTransformFunc = Callable[[binding: Binding, from_value: Value, to_value: Value], bool]

BoxedCopyFunc

BoxedCopyFunc = Callable[[boxed: int], int]

BoxedFreeFunc

BoxedFreeFunc = Callable[[boxed: int], None]

Callback

Callback = Callable[[], None]

ClassFinalizeFunc

ClassFinalizeFunc = Callable[[g_class: TypeClass], None]

ClassInitFunc

ClassInitFunc = Callable[[g_class: TypeClass], None]

ClosureMarshal

ClosureMarshal = Callable[[closure: Closure, return_value: Value | None, param_values: list[Value]], None]

ClosureNotify

ClosureNotify = Callable[[data: int | None, closure: Closure], None]

InstanceInitFunc

InstanceInitFunc = Callable[[instance: TypeInstance, g_class: TypeClass], None]

InterfaceFinalizeFunc

InterfaceFinalizeFunc = Callable[[g_iface: TypeInterface], None]

InterfaceInitFunc

InterfaceInitFunc = Callable[[g_iface: TypeInterface], None]

ObjectFinalizeFunc

ObjectFinalizeFunc = Callable[[object: Object], None]

ObjectGetPropertyFunc

ObjectGetPropertyFunc = Callable[[object: Object, property_id: int, value: Value, pspec: ParamSpec], None]

ObjectSetPropertyFunc

ObjectSetPropertyFunc = Callable[[object: Object, property_id: int, value: Value, pspec: ParamSpec], None]

SignalAccumulator

SignalAccumulator = Callable[[ihint: SignalInvocationHint, return_accu: Value, handler_return: Value], bool]

SignalEmissionHook

SignalEmissionHook = Callable[[ihint: SignalInvocationHint, param_values: list[Value]], bool]

ToggleNotify

ToggleNotify = Callable[[data: int | None, object: Object, is_last_ref: bool], None]

TypeClassCacheFunc

TypeClassCacheFunc = Callable[[cache_data: int | None, g_class: TypeClass], bool]

TypeInterfaceCheckFunc

TypeInterfaceCheckFunc = Callable[[check_data: int | None, g_iface: TypeInterface], None]

TypePluginCompleteInterfaceInfo

TypePluginCompleteInterfaceInfo = Callable[[plugin: TypePlugin, instance_type: type | Type, interface_type: type | Type, info: InterfaceInfo], None]

TypePluginCompleteTypeInfo

TypePluginCompleteTypeInfo = Callable[[plugin: TypePlugin, g_type: type | Type, info: TypeInfo, value_table: TypeValueTable], None]

TypePluginUnuse

TypePluginUnuse = Callable[[plugin: TypePlugin], None]

TypePluginUse

TypePluginUse = Callable[[plugin: TypePlugin], None]

TypeValueCollectFunc

TypeValueCollectFunc = Callable[[value: Value, collect_values: list[TypeCValue], collect_flags: int], str]

TypeValueCopyFunc

TypeValueCopyFunc = Callable[[src_value: Value], None]

TypeValueFreeFunc

TypeValueFreeFunc = Callable[[value: Value], None]

TypeValueInitFunc

TypeValueInitFunc = Callable[[value: Value], None]

TypeValueLCopyFunc

TypeValueLCopyFunc = Callable[[value: Value, collect_values: list[TypeCValue], collect_flags: int], str]

TypeValuePeekPointerFunc

TypeValuePeekPointerFunc = Callable[[value: Value], int]

ValueTransform

ValueTransform = Callable[[src_value: Value, dest_value: Value], None]

WeakNotify

WeakNotify = Callable[[data: int | None, where_the_object_was: Object], None]