Functions#
- add_emission_hook(type: Object, name: str, callback: Callable[[...], None], *args: Any) None#
- Parameters:
type
name
callback
args
- boxed_free(boxed_type: GType, boxed: Any) None#
Free the boxed structure
boxedwhich is of typeboxed_type.- Parameters:
boxed_type – The type of
boxed.boxed – The boxed structure to be freed.
- boxed_type_register_static(name: str, boxed_copy: Callable[[Any], Any], boxed_free: Callable[[Any], None]) GType#
This function creates a new
Boxedderived type id for a new boxed type with namename.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
DEFINE_BOXED_TYPE()instead of callingboxed_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.
- Returns:
New
Boxedderived type id forname.
- cclosure_marshal_BOOLEAN__BOXED_BOXED(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_BOOLEAN__FLAGS(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_STRING__OBJECT_POINTER(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__BOOLEAN(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__BOXED(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__CHAR(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__DOUBLE(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__ENUM(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__FLAGS(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__FLOAT(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__INT(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__LONG(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__OBJECT(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__PARAM(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__POINTER(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__STRING(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__UCHAR(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__UINT(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__UINT_POINTER(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__ULONG(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__VARIANT(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_VOID__VOID(closure: Closure, return_value: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_value
n_param_values
param_values
invocation_hint
marshal_data
- cclosure_marshal_generic(closure: Closure, return_gvalue: Value, n_param_values: int, param_values: Value, invocation_hint: Any = None, marshal_data: Any = None) None#
- Parameters:
closure
return_gvalue
n_param_values
param_values
invocation_hint
marshal_data
- child_watch_add(*args, **kwargs)#
Deprecated since version PyGObject-3.16.0: GObject.child_watch_add is deprecated; use GLib.child_watch_add instead
- Parameters:
args
kwargs
- clear_signal_handler(handler_id_ptr: int, instance: Object) None#
Disconnects a handler from
instanceso it will not be called during any future or currently ongoing emissions of the signal it has been connected to. Thehandler_id_ptris then set to zero, which is never a valid handler ID value (seesignal_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.
Added in version 2.62.
- 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
Noneor invalid, if the handler ID is zero.
- enum_complete_type_info(g_enum_type: GType, const_values: EnumValue) TypeInfo#
This function is meant to be called from the
complete_type_infofunction of aTypePluginimplementation, 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
EnumValuestructs for the possible enumeration values. The array is terminated by a struct with all members being 0.
- enum_get_value(enum_class: EnumClass, value: int) EnumValue | None#
Returns the
EnumValuefor a value.
- enum_get_value_by_name(enum_class: EnumClass, name: str) EnumValue | None#
Looks up a
EnumValueby name.
- enum_get_value_by_nick(enum_class: EnumClass, nick: str) EnumValue | None#
Looks up a
EnumValueby nickname.
- enum_register_static(name: str, const_static_values: EnumValue) GType#
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
EnumValuestructs 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.
- Returns:
The new type identifier.
- enum_to_string(g_enum_type: GType, value: int) str#
Pretty-prints
valuein 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.
Added in version 2.54.
- Parameters:
g_enum_type – the type identifier of a
EnumClasstypevalue – the value
- Returns:
a newly-allocated text string
- filename_display_basename(filename: str) str#
Deprecated since version PyGObject-3.16.0: GObject.filename_display_basename is deprecated; use GLib.filename_display_basename instead
- Parameters:
filename
- filename_display_name(filename: str) str#
Deprecated since version PyGObject-3.16.0: GObject.filename_display_name is deprecated; use GLib.filename_display_name instead
- Parameters:
filename
- filename_from_utf8(utf8string, len=-1)#
Deprecated since version PyGObject-3.16.0: GObject.filename_from_utf8 is deprecated; use GLib.filename_from_utf8 instead
- Parameters:
utf8string
len
- flags_complete_type_info(g_flags_type: GType, const_values: FlagsValue) TypeInfo#
This function is meant to be called from the complete_type_info() function of a
TypePluginimplementation, see the example forenum_complete_type_info()above.- Parameters:
g_flags_type – the type identifier of the type being completed
const_values – An array of
FlagsValuestructs for the possible enumeration values. The array is terminated by a struct with all members being 0.
- flags_get_first_value(flags_class: FlagsClass, value: int) FlagsValue | None#
Returns the first
FlagsValuewhich is set invalue.- Parameters:
flags_class – a
FlagsClassvalue – the value
- Returns:
the first
FlagsValuewhich is set invalue, orNoneif none is set
- flags_get_value_by_name(flags_class: FlagsClass, name: str) FlagsValue | None#
Looks up a
FlagsValueby name.- Parameters:
flags_class – a
FlagsClassname – the name to look up
- Returns:
the
FlagsValuewith namename, orNoneif there is no flag with that name
- flags_get_value_by_nick(flags_class: FlagsClass, nick: str) FlagsValue | None#
Looks up a
FlagsValueby nickname.- Parameters:
flags_class – a
FlagsClassnick – the nickname to look up
- Returns:
the
FlagsValuewith nicknamenick, orNoneif there is no flag with that nickname
- flags_register_static(name: str, const_static_values: FlagsValue) GType#
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
FlagsValuestructs 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.
- Returns:
The new type identifier.
- flags_to_string(flags_type: GType, value: int) str#
Pretty-prints
valuein 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.
Added in version 2.54.
- Parameters:
flags_type – the type identifier of a
FlagsClasstypevalue – the value
- Returns:
a newly-allocated text string
- get_application_name() str | None#
Deprecated since version PyGObject-3.16.0: GObject.get_application_name is deprecated; use GLib.get_application_name instead
- get_current_time()#
Deprecated since version PyGObject-3.16.0: GObject.get_current_time is deprecated; use GLib.get_current_time instead
- get_prgname() str | None#
Deprecated since version PyGObject-3.16.0: GObject.get_prgname is deprecated; use GLib.get_prgname instead
- gtype_get_type() GType#
- idle_add(function, *user_data, priority=200)#
Deprecated since version PyGObject-3.16.0: GObject.idle_add is deprecated; use GLib.idle_add instead
- Parameters:
function
user_data
priority
- io_add_watch(*args, **kwargs)#
Deprecated since version PyGObject-3.16.0: GObject.io_add_watch is deprecated; use GLib.io_add_watch instead
- Parameters:
args
kwargs
- main_context_default() MainContext#
Deprecated since version PyGObject-3.16.0: GObject.main_context_default is deprecated; use GLib.main_context_default instead
- main_depth() int#
Deprecated since version PyGObject-3.16.0: GObject.main_depth is deprecated; use GLib.main_depth instead
- markup_escape_text(text, length=-1)#
Deprecated since version PyGObject-3.16.0: GObject.markup_escape_text is deprecated; use GLib.markup_escape_text instead
- Parameters:
text
length
- param_spec_boolean(name: str, nick: str | None, blurb: str | None, default_value: bool, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecBooleaninstance specifying aboolproperty. In many cases, it may be more appropriate to use an enum withparam_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
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
- Returns:
a newly created parameter specification
- param_spec_boxed(name: str, nick: str | None, blurb: str | None, boxed_type: GType, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecBoxedinstance specifying aBoxedderived property.See
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_type –
Boxedderived type of this propertyflags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_char(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecCharinstance specifying aintproperty.- 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
- Returns:
a newly created parameter specification
- param_spec_double(name: str, nick: str | None, blurb: str | None, minimum: float, maximum: float, default_value: float, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecDoubleinstance specifying afloatproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_enum(name: str, nick: str | None, blurb: str | None, enum_type: GType, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecEnuminstance specifying aEnumproperty.See
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
Typederived fromEnumdefault_value – default value for the property specified
flags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_flags(name: str, nick: str | None, blurb: str | None, flags_type: GType, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecFlagsinstance specifying aFlagsproperty.See
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
Typederived fromFlagsdefault_value – default value for the property specified
flags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_float(name: str, nick: str | None, blurb: str | None, minimum: float, maximum: float, default_value: float, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecFloatinstance specifying afloatproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_gtype(name: str, nick: str | None, blurb: str | None, is_a_type: GType, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecGTypeinstance specifying aGTypeproperty.See
internal()for details on property names.Added in version 2.10.
- 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
Typewhose subtypes are allowed as values of the property (use %G_TYPE_NONE for any type)flags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_int(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecIntinstance specifying aintproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_int64(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecInt64instance specifying aintproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_long(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecLonginstance specifying aintproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_object(name: str, nick: str | None, blurb: str | None, object_type: GType, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecBoxedinstance specifying aobjectderived property.See
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_type –
objectderived type of this propertyflags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_param(name: str, nick: str | None, blurb: str | None, param_type: GType, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecParaminstance specifying aParamSpecproperty.See
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
Typederived fromParamSpecflags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_pointer(name: str, nick: str | None, blurb: str | None, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecPointerinstance specifying a pointer property. Where possible, it is better to useparam_spec_object()orparam_spec_boxed()to expose memory management information.See
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
- Returns:
a newly created parameter specification
- param_spec_string(name: str, nick: str | None, blurb: str | None, default_value: str | None, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecStringinstance.See
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
- Returns:
a newly created parameter specification
- param_spec_uchar(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecUCharinstance specifying a unsignedintproperty.- 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
- Returns:
a newly created parameter specification
- param_spec_uint(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecUIntinstance specifying a unsignedintproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_uint64(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecUInt64instance specifying a unsignedintproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_ulong(name: str, nick: str | None, blurb: str | None, minimum: int, maximum: int, default_value: int, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecULonginstance specifying a unsignedintproperty.See
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
- Returns:
a newly created parameter specification
- param_spec_unichar(name: str, nick: str | None, blurb: str | None, default_value: str, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecUnicharinstance specifying a unsignedintproperty.Valuestructures for this property can be accessed withset_uint()andget_uint().See
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
- Returns:
a newly created parameter specification
- param_spec_variant(name: str, nick: str | None, blurb: str | None, type: VariantType, default_value: Variant | None, flags: ParamFlags) ParamSpec#
Creates a new
GParamSpecVariantinstance specifying aVariantproperty.If
default_valueis floating, it is consumed.See
internal()for details on property names.Added in version 2.26.
- Parameters:
name – canonical name of the property specified
nick – nick name for the property specified
blurb – description of the property specified
type – a
VariantTypedefault_value – a
Variantof typetypeto use as the default value, orNoneflags – flags for the property specified
- Returns:
the newly created
ParamSpec
- param_type_register_static(name: str, pspec_info: ParamSpecTypeInfo) GType#
Registers
nameas the name of a new static type derived fromParamSpec.The type system uses the information contained in the
ParamSpecTypeInfostructure pointed to byinfoto manage theParamSpectype and its instances.- Parameters:
name – 0-terminated string used as the name of the new
ParamSpectype.pspec_info – The
ParamSpecTypeInfofor thisParamSpectype.
- Returns:
The new type identifier.
- param_value_convert(pspec: ParamSpec, src_value: Value, dest_value: Value, strict_validation: bool) bool#
Transforms
src_valueintodest_valueif possible, and then validatesdest_value, in order for it to conform topspec. Ifstrict_validationisTruethis function will only succeed if the transformeddest_valuecomplied topspecwithout modifications.See also
type_transformable(),transform()andparam_value_validate().- Parameters:
- Returns:
Trueif transformation and validation were successful,Falseotherwise anddest_valueis left untouched.
- param_value_defaults(pspec: ParamSpec, value: Value) bool#
Checks whether
valuecontains the default value as specified inpspec.
- param_value_is_valid(pspec: ParamSpec, value: Value) bool#
Return whether the contents of
valuecomply with the specifications set out bypspec.Added in version 2.74.
- param_value_set_default(pspec: ParamSpec, value: Value) None#
Sets
valueto its default value as specified inpspec.
- param_value_validate(pspec: ParamSpec, value: Value) bool#
Ensures that the contents of
valuecomply with the specifications set out bypspec. For example, aGParamSpecIntmight require that integers stored invaluemay not be smaller than -42 and not be greater than +42. Ifvaluecontains an integer outside of this range, it is modified accordingly, so the resulting value will fit into the range -42 .. +42.
- param_values_cmp(pspec: ParamSpec, value1: Value, value2: Value) int#
Compares
value1withvalue2according topspec, and return -1, 0 or +1, ifvalue1is found to be less than, equal to or greater thanvalue2, respectively.
- pointer_type_register_static(name: str) GType#
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.
- Returns:
a new %G_TYPE_POINTER derived type id for
name.
- remove_emission_hook(obj, detailed_signal, hook_id)#
- Parameters:
obj
detailed_signal
hook_id
- set_application_name(application_name: str) None#
Deprecated since version PyGObject-3.16.0: GObject.set_application_name is deprecated; use GLib.set_application_name instead
- Parameters:
application_name
- set_prgname(prgname: str) None#
Deprecated since version PyGObject-3.16.0: GObject.set_prgname is deprecated; use GLib.set_prgname instead
- Parameters:
prgname
- signal_accumulator_first_wins(ihint, return_accu, handler_return, user_data=None)#
A predefined
SignalAccumulatorfor 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”).
Added in version 2.28.
- Parameters:
ihint – standard
SignalAccumulatorparameterreturn_accu – standard
SignalAccumulatorparameterhandler_return – standard
SignalAccumulatorparameteruser_data
- Returns:
standard
SignalAccumulatorresult
- signal_accumulator_true_handled(ihint, return_accu, handler_return, user_data=None)#
A predefined
SignalAccumulatorfor signals that return a boolean values. The behavior that this accumulator gives is that a return ofTruestops the signal emission: no further callbacks will be invoked, while a return ofFalseallows the emission to continue. The idea here is that aTruereturn indicates that the callback handled the signal, and no further handling is needed.Added in version 2.4.
- Parameters:
ihint – standard
SignalAccumulatorparameterreturn_accu – standard
SignalAccumulatorparameterhandler_return – standard
SignalAccumulatorparameteruser_data
- Returns:
standard
SignalAccumulatorresult
- signal_add_emission_hook(signal_id: int, detail: int, hook_func: Callable[[SignalInvocationHint, list[Value], Any], bool]) 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
NO_HOOKSflag set.- Parameters:
signal_id – the signal identifier, as returned by
signal_lookup().detail – the detail on which to call the hook.
hook_func – a
SignalEmissionHookfunction.
- Returns:
the hook id, for later use with
signal_remove_emission_hook().
- 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()andsignal_override_class_handler().- Parameters:
instance_and_params – the argument list of the signal emission. The first element in the array is a
Valuefor 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(instance: Object, detailed_signal: str, closure: Closure, after: bool) int#
Connects a closure to a signal for a particular object.
If
closureis a floating reference (seesink()), this function takes ownership ofclosure.This function cannot fail. If the given signal doesn’t exist, a critical warning is emitted.
- 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.
- Returns:
the handler ID (always greater than 0)
- signal_connect_closure_by_id(instance: Object, signal_id: int, detail: int, closure: Closure, after: bool) int#
Connects a closure to a signal for a particular object.
If
closureis a floating reference (seesink()), this function takes ownership ofclosure.This function cannot fail. If the given signal doesn’t exist, a critical warning is emitted.
- 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.
- Returns:
the handler ID (always greater than 0)
- signal_emitv(instance_and_params: list[Value], signal_id: int, detail: int, return_value: Value = Ellipsis) 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 changereturn_valueif no handlers are connected, in contrast tosignal_emit()andsignal_emit_valist().- Parameters:
instance_and_params – argument list for the signal emission. The first element in the array is a
Valuefor 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(instance: Object) SignalInvocationHint | None#
Returns the invocation hint of the innermost signal emission of instance.
- Parameters:
instance – the instance to query
- Returns:
the invocation hint of the innermost signal emission, or
Noneif not found.
- signal_handler_block(obj, handler_id)#
Blocks the signal handler from being invoked until handler_unblock() is called.
- Parameters:
obj (GObject.Object) – Object instance to block handlers for.
handler_id (int) – Id of signal to block.
- Returns:
A context manager which optionally can be used to automatically unblock the handler:
with GObject.signal_handler_block(obj, id): pass
- 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_idbecomes invalid and may be reused.The
handler_idhas to be a valid signal handler id, connected to a signal ofinstance.- Parameters:
instance – The instance to remove the signal handler from.
handler_id – Handler id of the handler to be disconnected.
- signal_handler_find(instance: Object, mask: SignalMatchType, signal_id: int, detail: int, closure: Closure | None = None, func: Any = None, data: Any = None) int#
Finds the first signal handler that matches certain selection criteria. The criteria mask is passed as an OR-ed combination of
SignalMatchTypeflags, and the criteria values are passed as arguments. The matchmaskhas 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,funcand/ordatathe 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.
- Returns:
A valid non-0 signal handler id for a successful match.
- signal_handler_is_connected(instance: Object, handler_id: int) bool#
Returns whether
handler_idis the ID of a handler connected toinstance.- Parameters:
instance – The instance where a signal handler is sought.
handler_id – the handler ID.
- Returns:
whether
handler_ididentifies a handler connected toinstance.
- 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_idhas to be a valid id of a signal handler that is connected to a signal ofinstanceand 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(instance: Object, mask: SignalMatchType, signal_id: int, detail: int, closure: Closure | None = None, func: Any = None, data: Any = None) int#
Blocks all handlers on an instance that match a certain selection criteria.
The criteria mask is passed as a combination of
SignalMatchTypeflags, and the criteria values are passed as arguments. A handler must match on all flags set inmaskto be blocked (i.e. the match is conjunctive).Passing at least one of the
ID,CLOSURE,FUNCorDATAmatch flags is required for successful matches. If no handlers were found, 0 is returned, the number of blocked handlers otherwise.Support for
IDwas added in GLib 2.78.- Parameters:
instance – The instance to block handlers from.
mask – Mask indicating which of
signal_id,detail,closure,funcand/ordatathe 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.
- Returns:
The number of handlers that matched.
- signal_handlers_destroy(instance: Object) None#
Destroy all signal handlers of a type instance. This function is an implementation detail of the
Objectdispose implementation, and should not be used outside of the type system.- Parameters:
instance – The instance whose signal handlers are destroyed
- signal_handlers_disconnect_matched(instance: Object, mask: SignalMatchType, signal_id: int, detail: int, closure: Closure | None = None, func: Any = None, data: Any = None) int#
Disconnects all handlers on an instance that match a certain selection criteria.
The criteria mask is passed as a combination of
SignalMatchTypeflags, and the criteria values are passed as arguments. A handler must match on all flags set inmaskto be disconnected (i.e. the match is conjunctive).Passing at least one of the
ID,CLOSURE,FUNCorDATAmatch flags is required for successful matches. If no handlers were found, 0 is returned, the number of disconnected handlers otherwise.Support for
IDwas added in GLib 2.78.- Parameters:
instance – The instance to remove handlers from.
mask – Mask indicating which of
signal_id,detail,closure,funcand/ordatathe 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.
- Returns:
The number of handlers that matched.
- signal_handlers_unblock_matched(instance: Object, mask: SignalMatchType, signal_id: int, detail: int, closure: Closure | None = None, func: Any = None, data: Any = None) int#
Unblocks all handlers on an instance that match a certain selection criteria.
The criteria mask is passed as a combination of
SignalMatchTypeflags, and the criteria values are passed as arguments. A handler must match on all flags set inmaskto be unblocked (i.e. the match is conjunctive).Passing at least one of the
ID,CLOSURE,FUNCorDATAmatch 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
IDwas added in GLib 2.78.- Parameters:
instance – The instance to unblock handlers from.
mask – Mask indicating which of
signal_id,detail,closure,funcand/ordatathe 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.
- Returns:
The number of handlers that matched.
- signal_has_handler_pending(instance: Object, signal_id: int, detail: int, may_be_blocked: bool) bool#
Returns whether there are any handlers connected to
instancefor the given signal id and detail.If
detailis 0 then it will only match handlers that were connected without detail. Ifdetailis non-zero then it will match handlers connected both without detail and with the given detail. This is consistent with how a signal emitted withdetailwould 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.
- Returns:
Trueif a handler is connected to the signal,Falseotherwise.
- 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
signal_newfor details of the rules for valid names. The rules for signal names are the same as those for property names.Added in version 2.66.
- Parameters:
name – the canonical name of the signal
- Returns:
Trueifnameis a valid signal name,Falseotherwise.
- signal_list_ids(type_)#
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:
type
- Returns:
Newly allocated array of signal IDs.
- signal_list_names(type_)#
- Parameters:
type
- signal_lookup(name, type_)#
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
itypemust already have been instantiated (for example, usingref()) for this function to work, as signals are always installed during class initialization.See
signal_new()for details on allowed signal names.- Parameters:
name – the signal’s name.
type
- Returns:
the signal’s identifying number, or 0 if no signal was found.
- 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.
- Returns:
the signal name, or
Noneif the signal number was invalid.
- signal_new(signal_name: str, itype: type[Object], signal_flags: SignalFlags, return_type: type, param_types: Sequence[GType]) int#
Creates a new signal. (This is usually done in the class initializer.)
A signal name consists of segments consisting of ASCII letters and digits, separated by either the
-or_character. The first character of a signal name must be a letter. Names which violate these rules lead to undefined behaviour. These are the same rules as for property naming (seeinternal()).When registering a signal and looking up a signal, either separator can be used, but they cannot be mixed. Using
-is considerably more efficient. Using_is discouraged.If 0 is used for
class_offsetsubclasses cannot override the class handler in their class_init method by doing super_class->signal_handler = my_signal_handler. Instead they will have to usesignal_override_class_handler().If
c_marshallerisNone,marshal_generic()will be used as the marshaller for this signal. In some simple cases,signal_new()will use a more optimized c_marshaller and va_marshaller for the signal instead ofmarshal_generic().If
c_marshalleris non-None, you need to also specify a va_marshaller usingsignal_set_va_marshaller()or the generic va_marshaller will be used.- Parameters:
signal_name – the name for the signal
itype – the type this signal pertains to. It will also pertain to types which are derived from this type.
signal_flags – a combination of
SignalFlagsspecifying detail of when the default handler is to be invoked. You should at least specifyRUN_FIRSTorRUN_LAST.return_type – the type of return value, or %G_TYPE_NONE for a signal without a return value.
param_types
- Returns:
the signal id
- signal_override_class_closure(signal_id: int, instance_type: GType, 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_typemust be derived from the type to which the signal belongs.See
signal_chain_from_overridden()andsignal_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(signal_name: str, instance_type: GType, class_handler: Callable[[], None]) None#
Overrides the class closure (i.e. the default handler) for the given signal for emissions on instances of
instance_typewith callbackclass_handler.instance_typemust be derived from the type to which the signal belongs.See
signal_chain_from_overridden()andsignal_chain_from_overridden_handler()for how to chain up to the parent class closure from inside the overridden one.Added in version 2.18.
- 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(detailed_signal, itype, force_detail_quark)#
Parse a detailed signal name into (signal_id, detail).
- Parameters:
detailed_signal (str) – Signal name which can include detail. For example: “notify:prop_name”
- Returns:
Tuple of (signal_id, detail)
- Raises:
ValueError – If the given signal is unknown.
- signal_query(id_or_name, type_=None)#
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_idmember of theSignalQueryis 0. All members filled into theSignalQuerystructure should be considered constant and have to be left untouched.- Parameters:
id_or_name
type
- signal_remove_emission_hook(signal_id: int, hook_id: int) None#
Deletes an emission hook.
- Parameters:
signal_id – the id of the signal
hook_id – the id of the emission hook, as returned by
signal_add_emission_hook()
- signal_stop_emission(instance: Object, signal_id: int, detail: int) None#
Stops a signal’s current emission.
This will prevent the default method from running, if the signal was
RUN_LASTand 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(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(itype: GType, struct_offset: int) Closure#
Creates a new closure which invokes the function found at the offset
struct_offsetin the class structure of the interface or classed type identified byitype.- Parameters:
itype – the
Typeidentifier of an interface or classed typestruct_offset – the offset of the member function of
itype's class structure which is to be invoked by the new closure
- Returns:
a floating reference to a new
GCClosure
- source_remove(tag: int) bool#
Deprecated since version PyGObject-3.16.0: GObject.source_remove is deprecated; use GLib.source_remove instead
- Parameters:
tag
- source_set_closure(source: Source, closure: Closure) None#
Set the callback for a source as a
Closure.If the source is not one of the standard GLib types, the
closure_callbackandclosure_marshalfields of theSourceFuncsstructure must have been filled in with pointers to appropriate functions.- Parameters:
source – the source
closure – a
Closure
- source_set_dummy_callback(source: Source) None#
Sets a dummy callback for
source. The callback will do nothing, and if the source expects agbooleanreturn value, it will returnTrue. (If the source expects any other type of return value, it will return a 0/Nonevalue; whateverinit()initializes aValueto for that type.)If the source is not one of the standard GLib types, the
closure_callbackandclosure_marshalfields of theSourceFuncsstructure must have been filled in with pointers to appropriate functions.- Parameters:
source – the source
- spawn_async(argv: ~typing.Sequence[str], envp: ~typing.Sequence[str] | None = None, working_directory: str | None = None, flags: ~gi.repository.GLib.SpawnFlags = <SpawnFlags.DEFAULT: 0>, child_setup: ~typing.Callable[[~typing.Any], None] | None = None, user_data: ~typing.Any = None, standard_input: bool = False, standard_output: bool = False, standard_error: bool = False) tuple[Pid, int | None, int | None, int | None]#
- spawn_async(argv, envp=None, working_directory=None,
flags=0, child_setup=None, user_data=None, standard_input=None, standard_output=None, standard_error=None) -> (pid, stdin, stdout, stderr)
Execute a child program asynchronously within a glib.MainLoop() See the reference manual for a complete reference.
Deprecated since version PyGObject-3.16.0: GObject.spawn_async is deprecated; use GLib.spawn_async instead
- Parameters:
argv
envp
working_directory
flags
child_setup
user_data
standard_input
standard_output
standard_error
- 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 describeValuecontents for debugging output, the way in which the contents are described may change between different GLib versions.- Parameters:
value –
Valuewhich contents are to be described.- Returns:
Newly allocated string.
- threads_init()#
- timeout_add(interval, function, *user_data, priority=0)#
Deprecated since version PyGObject-3.16.0: GObject.timeout_add is deprecated; use GLib.timeout_add instead
- Parameters:
interval
function
user_data
priority
- timeout_add_seconds(interval, function, *user_data, priority=0)#
Deprecated since version PyGObject-3.16.0: GObject.timeout_add_seconds is deprecated; use GLib.timeout_add_seconds instead
- Parameters:
interval
function
user_data
priority
- type_add_class_private(class_type: GType, 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
TYPE_CLASS_GET_PRIVATE()macro.Added in version 2.24.
- Parameters:
class_type – GType of a classed type
private_size – size of private structure
- type_add_instance_private(class_type: GType, private_size: int) int#
- Parameters:
class_type
private_size
- type_add_interface_dynamic(instance_type: GType, interface_type: GType, plugin: TypePlugin) None#
Adds
interface_typeto the dynamicinstance_type. The information contained in theTypePluginstructure pointed to bypluginis used to manage the relationship.- Parameters:
instance_type –
Typevalue of an instantiatable typeinterface_type –
Typevalue of an interface typeplugin –
TypePluginstructure to retrieve theInterfaceInfofrom
- type_add_interface_static(instance_type: GType, interface_type: GType, info: InterfaceInfo) None#
Adds
interface_typeto the staticinstance_type. The information contained in theInterfaceInfostructure pointed to byinfois used to manage the relationship.- Parameters:
instance_type –
Typevalue of an instantiatable typeinterface_type –
Typevalue of an interface typeinfo –
InterfaceInfostructure for this (instance_type,interface_type) combination
- type_check_instance(instance: TypeInstance) bool#
Private helper function to aid implementation of the
TYPE_CHECK_INSTANCE()macro.- Parameters:
instance – a valid
TypeInstancestructure- Returns:
Trueifinstanceis valid,Falseotherwise
- type_check_instance_is_a(instance: TypeInstance, iface_type: GType) bool#
- Parameters:
instance
iface_type
- type_check_instance_is_fundamentally_a(instance: TypeInstance, fundamental_type: GType) bool#
- Parameters:
instance
fundamental_type
- type_children(type: GType) list[GType]#
Return a newly allocated and 0-terminated array of type IDs, listing the child types of
type.- Parameters:
type – the parent type
- Returns:
Newly allocated and 0-terminated array of child types, free with
free()
- type_class_adjust_private_offset(g_class: Any, private_size_or_offset: int) None#
- Parameters:
g_class
private_size_or_offset
- type_default_interface_peek(g_type: GType) TypeInterface#
If the interface type
g_typeis currently in use, returns its default interface vtable.Added in version 2.4.
- Parameters:
g_type – an interface type
- Returns:
the default vtable for the interface, or
Noneif the type is not currently in use
- type_depth(type: GType) 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
Type- Returns:
the depth of
type
- type_ensure(type: GType) None#
Ensures that the indicated
typehas 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.Added in version 2.34.
- Parameters:
type – a
Type
- 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
type_create_instance(), this function is reserved for implementors of fundamental types.- Parameters:
instance – an instance of a type
- type_from_name(name)#
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
- Returns:
corresponding type ID or 0
- type_fundamental(type_id: GType) GType#
Internal function, used to extract the fundamental type ID portion. Use
TYPE_FUNDAMENTAL()instead.- Parameters:
type_id – valid type ID
- Returns:
fundamental type ID
- type_fundamental_next() GType#
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.- Returns:
the next available fundamental type ID to be registered, or 0 if the type system ran out of fundamental type IDs
- type_get_instance_count(type: GType) 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-countdebug flag is set (by setting theGOBJECT_DEBUGvariable to includeinstance-count).Added in version 2.44.
- Parameters:
type – a
Type- Returns:
the number of instances allocated of the given type; if instance counts are not available, returns 0.
- type_get_plugin(type: GType) TypePlugin#
Returns the
TypePluginstructure fortype.- Parameters:
type –
Typeto retrieve the plugin for- Returns:
the corresponding plugin if
typeis a dynamic type,Noneotherwise
- type_get_qdata(type: GType, quark: int) Any | None#
Obtains data which has previously been attached to
typewithtype_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 usingtype_get_qdata().- Parameters:
type – a
Typequark – a
Quarkid to identify the data
- Returns:
the data, or
Noneif no data was found
- 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.Added in version 2.36.
- Returns:
An unsigned int, representing the state of type registrations
- type_init() None#
This function used to initialise the type system. Since GLib 2.36, the type system is initialised automatically and this function does nothing.
Deprecated since version 2.36: the type system is now initialised automatically
- type_init_with_debug_flags(debug_flags: TypeDebugFlags) None#
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_DEBUGenvironment variable.Deprecated since version 2.36: the type system is now initialised automatically
- Parameters:
debug_flags – bitwise combination of
TypeDebugFlagsvalues for debugging purposes
- type_interface_add_prerequisite(interface_type: GType, prerequisite_type: GType) None#
- Parameters:
interface_type
prerequisite_type
- type_interface_get_plugin(instance_type: GType, interface_type: GType) TypePlugin#
- Parameters:
instance_type
interface_type
- type_interface_instantiatable_prerequisite(interface_type: GType) GType#
- Parameters:
interface_type
- type_interface_peek(instance_class: TypeClass, iface_type: GType) TypeInterface#
- Parameters:
instance_class
iface_type
- type_interfaces(type: GType) list[GType]#
Return a newly allocated and 0-terminated array of type IDs, listing the interface types that
typeconforms to.- Parameters:
type – the type to list interface types for
- Returns:
Newly allocated and 0-terminated array of interface types, free with
free()
- type_is_a(type: GType, is_a_type: GType) bool#
If
is_a_typeis a derivable type, check whethertypeis a descendant ofis_a_type. Ifis_a_typeis an interface, check whethertypeconforms to it.- Parameters:
type – type to check ancestry for
is_a_type – possible ancestor of
typeor interface thattypecould conform to
- Returns:
Trueiftypeis ais_a_type
- type_name(type: GType) 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.
Invalidmay 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
- Returns:
static type name or
None
- type_name_from_instance(instance: TypeInstance) str#
- Parameters:
instance
- type_next_base(leaf_type: GType, root_type: GType) GType#
Given a
leaf_typeand aroot_typewhich is contained in its ancestry, return the type thatroot_typeis the immediate parent of. In other words, this function determines the type that is derived directly fromroot_typewhich is also a base class ofleaf_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_typeand the type to be returnedroot_type – immediate parent of the returned type
- Returns:
immediate child of
root_typeand ancestor ofleaf_type
- type_parent(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
- Returns:
the parent type
- type_qname(type: GType) int#
Get the corresponding quark of the type IDs name.
- Parameters:
type – type to return quark of type name for
- Returns:
the type names quark or 0
- type_query(type: GType) 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
Typeis passed in, thetypemember of theTypeQueryis 0. All members filled into theTypeQuerystructure 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:
type –
Typeof a static, classed type
- type_register(type) GType#
- Parameters:
type
- type_register_dynamic(parent_type: GType, type_name: str, plugin: TypePlugin, flags: TypeFlags) GType#
Registers
type_nameas the name of a new dynamic type derived fromparent_type. The type system uses the information contained in theTypePluginstructure pointed to bypluginto manage the type and its instances (if not abstract). The value offlagsdetermines 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
plugin –
TypePluginstructure to retrieve theTypeInfofromflags – bitwise combination of
TypeFlagsvalues
- Returns:
the new type identifier or
Invalidif registration failed
- type_register_fundamental(type_id: GType, type_name: str, info: TypeInfo, finfo: TypeFundamentalInfo, flags: TypeFlags) GType#
Registers
type_idas the predefined identifier andtype_nameas the name of a fundamental type. Iftype_idis already registered, or a type namedtype_nameis already registered, the behaviour is undefined. The type system uses the information contained in theTypeInfostructure pointed to byinfoand theTypeFundamentalInfostructure pointed to byfinfoto manage the type and its instances. The value offlagsdetermines 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
info –
TypeInfostructure for this typefinfo –
TypeFundamentalInfostructure for this typeflags – bitwise combination of
TypeFlagsvalues
- Returns:
the predefined type identifier
- type_register_static(parent_type: GType, type_name: str, info: TypeInfo, flags: TypeFlags) GType#
Registers
type_nameas the name of a new static type derived fromparent_type. The type system uses the information contained in theTypeInfostructure pointed to byinfoto manage the type and its instances (if not abstract). The value offlagsdetermines the nature (e.g. abstract or not) of the type.
- type_set_qdata(type: GType, quark: int, data: Any = None) None#
Attaches arbitrary data to a type.
- Parameters:
type – a
Typequark – a
Quarkid to identify the datadata – the data
- uri_list_extract_uris(uri_list: str) list[str]#
Deprecated since version PyGObject-3.16.0: GObject.uri_list_extract_uris is deprecated; use GLib.uri_list_extract_uris instead
- Parameters:
uri_list
- variant_get_gtype() GType#