GObject.Value¶
Fields¶
| Name | Type | Access | Description |
|---|---|---|---|
| data | [GObject._Value__data__union] |
r/w | |
| g_type | GObject.GType |
r |
Methods¶
Details¶
-
class
GObject.Value(value_type=None, py_value=None)¶ An opaque structure used to hold different types of values. The data within the structure has protected scope: it is accessible only to functions within a
GObject.TypeValueTablestructure, or implementations of the g_value_*() API. That is, code portions which implement new fundamental types.GObject.Valueusers cannot make any assumptions about how data is stored within the 2 element data union, and the g_type member should only be accessed through the G_VALUE_TYPE() macro.-
classmethod
type_compatible(src_type, dest_type)[source]¶ Parameters: - src_type (
GObject.GType) – source type to be copied. - dest_type (
GObject.GType) – destination type for copying.
Returns: TrueifGObject.Value.copy() is possible with src_type and dest_type.Return type: Returns whether a
GObject.Valueof type src_type can be copied into aGObject.Valueof type dest_type.- src_type (
-
classmethod
type_transformable(src_type, dest_type)[source]¶ Parameters: - src_type (
GObject.GType) – Source type. - dest_type (
GObject.GType) – Target type.
Returns: Return type: Check whether
GObject.Value.transform() is able to transform values of type src_type into values of type dest_type. Note that for the types to be transformable, they must be compatible or a transformation function must be registered.- src_type (
-
copy(dest_value)[source]¶ Parameters: dest_value ( GObject.Value) – An initializedGObject.Valuestructure of the same type as self.Copies the value of self into dest_value.
-
dup_object()[source]¶ Returns: object content of self, should be unreferenced when no longer needed. Return type: GObject.ObjectGet the contents of a
GObject.TYPE_OBJECTderivedGObject.Value, increasing its reference count. If the contents of theGObject.ValueareNone, thenNonewill be returned.
-
dup_string()[source]¶ Returns: a newly allocated copy of the string content of self Return type: strGet a copy the contents of a
GObject.TYPE_STRINGGObject.Value.
-
dup_variant()[source]¶ Returns: variant contents of self (may be None); should be unreffed usingGLib.Variant.unref() when no longer neededReturn type: GLib.VariantorNoneGet the contents of a variant
GObject.Value, increasing its refcount. The returnedGLib.Variantis never floating.New in version 2.26.
-
fits_pointer()[source]¶ Returns: Trueif self will fit inside a pointer value.Return type: boolDetermines if self will fit inside the size of a pointer value. This is an internal function introduced mainly for C marshallers.
-
get_boolean()[source]¶ Returns: boolean contents of self Return type: boolGet the contents of a
GObject.TYPE_BOOLEANGObject.Value.
-
get_boxed()[source]¶ Returns: boxed contents of self Return type: objectorNoneGet the contents of a
GObject.TYPE_BOXEDderivedGObject.Value.
-
get_char()[source]¶ Returns: character contents of self Return type: intDo not use this function; it is broken on platforms where the
strtype is unsigned, such as ARM and PowerPC. SeeGObject.Value.get_schar().Get the contents of a
GObject.TYPE_CHARGObject.Value.Deprecated since version 2.32: This function’s return type is broken, see
GObject.Value.get_schar()
-
get_double()[source]¶ Returns: double contents of self Return type: floatGet the contents of a
GObject.TYPE_DOUBLEGObject.Value.
-
get_enum()[source]¶ Returns: enum contents of self Return type: intGet the contents of a
GObject.TYPE_ENUMGObject.Value.
-
get_flags()[source]¶ Returns: flags contents of self Return type: intGet the contents of a
GObject.TYPE_FLAGSGObject.Value.
-
get_float()[source]¶ Returns: float contents of self Return type: floatGet the contents of a
GObject.TYPE_FLOATGObject.Value.
-
get_gtype()[source]¶ Returns: the GObject.GTypestored in selfReturn type: GObject.GTypeGet the contents of a
GObject.TYPE_GTYPEGObject.Value.New in version 2.12.
-
get_int()[source]¶ Returns: integer contents of self Return type: intGet the contents of a
GObject.TYPE_INTGObject.Value.
-
get_int64()[source]¶ Returns: 64bit integer contents of self Return type: intGet the contents of a
GObject.TYPE_INT64GObject.Value.
-
get_long()[source]¶ Returns: long integer contents of self Return type: intGet the contents of a
GObject.TYPE_LONGGObject.Value.
-
get_object()[source]¶ Returns: object contents of self Return type: GObject.ObjectGet the contents of a
GObject.TYPE_OBJECTderivedGObject.Value.
-
get_param()[source]¶ Returns: GObject.ParamSpeccontent of selfReturn type: GObject.ParamSpecGet the contents of a
GObject.TYPE_PARAMGObject.Value.
-
get_pointer()[source]¶ Returns: pointer contents of self Return type: objectorNoneGet the contents of a pointer
GObject.Value.
-
get_schar()[source]¶ Returns: signed 8 bit integer contents of self Return type: intGet the contents of a
GObject.TYPE_CHARGObject.Value.New in version 2.32.
-
get_string()[source]¶ Returns: string content of self Return type: strGet the contents of a
GObject.TYPE_STRINGGObject.Value.
-
get_uchar()[source]¶ Returns: unsigned character contents of self Return type: intGet the contents of a
GObject.TYPE_UCHARGObject.Value.
-
get_uint()[source]¶ Returns: unsigned integer contents of self Return type: intGet the contents of a
GObject.TYPE_UINTGObject.Value.
-
get_uint64()[source]¶ Returns: unsigned 64bit integer contents of self Return type: intGet the contents of a
GObject.TYPE_UINT64GObject.Value.
-
get_ulong()[source]¶ Returns: unsigned long integer contents of self Return type: intGet the contents of a
GObject.TYPE_ULONGGObject.Value.
-
get_value()¶
-
get_variant()[source]¶ Returns: variant contents of self (may be None)Return type: GLib.VariantorNoneGet the contents of a variant
GObject.Value.New in version 2.26.
-
init(g_type)[source]¶ Parameters: g_type ( GObject.GType) – Type theGObject.Valueshould hold values of.Returns: the GObject.Valuestructure that has been passed inReturn type: GObject.ValueInitializes self with the default value of type.
-
init_from_instance(instance)[source]¶ Parameters: instance ( GObject.TypeInstance) – the instanceInitializes and sets self from an instantiatable type via the value_table’s collect_value() function.
Note: The self will be initialised with the exact type of instance. If you wish to set the self’s type to a different
GObject.GType(such as a parent classGObject.GType), you need to manually callGObject.Value.init() andGObject.Value.set_instance().New in version 2.42.
-
peek_pointer()[source]¶ Returns: the value contents as pointer Return type: objectorNoneReturns the value contents as pointer. This function asserts that
GObject.Value.fits_pointer() returnedTruefor the passed in value. This is an internal function introduced mainly for C marshallers.
-
reset()[source]¶ Returns: the GObject.Valuestructure that has been passed inReturn type: GObject.ValueClears the current value in self and resets it to the default value (as if the value had just been initialized).
-
set_boolean(v_boolean)[source]¶ Parameters: v_boolean ( bool) – boolean value to be setSet the contents of a
GObject.TYPE_BOOLEANGObject.Valueto v_boolean.
-
set_boxed(v_boxed)[source]¶ Parameters: v_boxed ( objectorNone) – boxed value to be setSet the contents of a
GObject.TYPE_BOXEDderivedGObject.Valueto v_boxed.
-
set_boxed_take_ownership(v_boxed)[source]¶ Parameters: v_boxed ( objectorNone) – duplicated unowned boxed value to be setThis is an internal function introduced mainly for C marshallers.
Deprecated since version 2.4: Use
GObject.Value.take_boxed() instead.
-
set_char(v_char)[source]¶ Parameters: v_char ( int) – character value to be setSet the contents of a
GObject.TYPE_CHARGObject.Valueto v_char.Deprecated since version 2.32: This function’s input type is broken, see
GObject.Value.set_schar()
-
set_double(v_double)[source]¶ Parameters: v_double ( float) – double value to be setSet the contents of a
GObject.TYPE_DOUBLEGObject.Valueto v_double.
-
set_enum(v_enum)[source]¶ Parameters: v_enum ( int) – enum value to be setSet the contents of a
GObject.TYPE_ENUMGObject.Valueto v_enum.
-
set_flags(v_flags)[source]¶ Parameters: v_flags ( int) – flags value to be setSet the contents of a
GObject.TYPE_FLAGSGObject.Valueto v_flags.
-
set_float(v_float)[source]¶ Parameters: v_float ( float) – float value to be setSet the contents of a
GObject.TYPE_FLOATGObject.Valueto v_float.
-
set_gtype(v_gtype)[source]¶ Parameters: v_gtype ( GObject.GType) –GObject.GTypeto be setSet the contents of a
GObject.TYPE_GTYPEGObject.Valueto v_gtype.New in version 2.12.
-
set_instance(instance)[source]¶ Parameters: instance ( objectorNone) – the instanceSets self from an instantiatable type via the value_table’s collect_value() function.
-
set_int(v_int)[source]¶ Parameters: v_int ( int) – integer value to be setSet the contents of a
GObject.TYPE_INTGObject.Valueto v_int.
-
set_int64(v_int64)[source]¶ Parameters: v_int64 ( int) – 64bit integer value to be setSet the contents of a
GObject.TYPE_INT64GObject.Valueto v_int64.
-
set_interned_string(v_string)[source]¶ Parameters: v_string ( strorNone) – static string to be setSet the contents of a
GObject.TYPE_STRINGGObject.Valueto v_string. The string is assumed to be static and interned (canonical, for example fromGLib.intern_string()), and is thus not duplicated when setting theGObject.Value.New in version 2.66.
-
set_long(v_long)[source]¶ Parameters: v_long ( int) – long integer value to be setSet the contents of a
GObject.TYPE_LONGGObject.Valueto v_long.
-
set_object(v_object)[source]¶ Parameters: v_object ( GObject.ObjectorNone) – object value to be setSet the contents of a
GObject.TYPE_OBJECTderivedGObject.Valueto v_object.GObject.Value.set_object() increases the reference count of v_object (theGObject.Valueholds a reference to v_object). If you do not wish to increase the reference count of the object (i.e. you wish to pass your current reference to theGObject.Valuebecause you no longer need it), use g_value_take_object() instead.It is important that your
GObject.Valueholds a reference to v_object (either its own, or one it has taken) to ensure that the object won’t be destroyed while theGObject.Valuestill exists).
-
set_param(param)[source]¶ Parameters: param ( GObject.ParamSpecorNone) – theGObject.ParamSpecto be setSet the contents of a
GObject.TYPE_PARAMGObject.Valueto param.
-
set_pointer(v_pointer)[source]¶ Parameters: v_pointer ( objectorNone) – pointer value to be setSet the contents of a pointer
GObject.Valueto v_pointer.
-
set_schar(v_char)[source]¶ Parameters: v_char ( int) – signed 8 bit integer to be setSet the contents of a
GObject.TYPE_CHARGObject.Valueto v_char.New in version 2.32.
-
set_static_boxed(v_boxed)[source]¶ Parameters: v_boxed ( objectorNone) – static boxed value to be setSet the contents of a
GObject.TYPE_BOXEDderivedGObject.Valueto v_boxed. The boxed value is assumed to be static, and is thus not duplicated when setting theGObject.Value.
-
set_static_string(v_string)[source]¶ Parameters: v_string ( strorNone) – static string to be setSet the contents of a
GObject.TYPE_STRINGGObject.Valueto v_string. The string is assumed to be static, and is thus not duplicated when setting theGObject.Value.If the the string is a canonical string, using
GObject.Value.set_interned_string() is more appropriate.
-
set_string(v_string)[source]¶ Parameters: v_string ( strorNone) – caller-owned string to be duplicated for theGObject.ValueSet the contents of a
GObject.TYPE_STRINGGObject.Valueto v_string.
-
set_string_take_ownership(v_string)[source]¶ Parameters: v_string ( strorNone) – duplicated unowned string to be setThis is an internal function introduced mainly for C marshallers.
Deprecated since version 2.4: Use
GObject.Value.take_string() instead.
-
set_uchar(v_uchar)[source]¶ Parameters: v_uchar ( int) – unsigned character value to be setSet the contents of a
GObject.TYPE_UCHARGObject.Valueto v_uchar.
-
set_uint(v_uint)[source]¶ Parameters: v_uint ( int) – unsigned integer value to be setSet the contents of a
GObject.TYPE_UINTGObject.Valueto v_uint.
-
set_uint64(v_uint64)[source]¶ Parameters: v_uint64 ( int) – unsigned 64bit integer value to be setSet the contents of a
GObject.TYPE_UINT64GObject.Valueto v_uint64.
-
set_ulong(v_ulong)[source]¶ Parameters: v_ulong ( int) – unsigned long integer value to be setSet the contents of a
GObject.TYPE_ULONGGObject.Valueto v_ulong.
-
set_value(py_value)¶
-
set_variant(variant)[source]¶ Parameters: variant ( GLib.VariantorNone) – aGLib.Variant, orNoneSet the contents of a variant
GObject.Valueto variant. If the variant is floating, it is consumed.New in version 2.26.
-
take_boxed(v_boxed)[source]¶ Parameters: v_boxed ( objectorNone) – duplicated unowned boxed value to be setSets the contents of a
GObject.TYPE_BOXEDderivedGObject.Valueto v_boxed and takes over the ownership of the caller’s reference to v_boxed; the caller doesn’t have to unref it any more.New in version 2.4.
-
take_string(v_string)[source]¶ Parameters: v_string ( strorNone) – string to take ownership ofSets the contents of a
GObject.TYPE_STRINGGObject.Valueto v_string.New in version 2.4.
-
take_variant(variant)[source]¶ Parameters: variant ( GLib.VariantorNone) – aGLib.Variant, orNoneSet the contents of a variant
GObject.Valueto variant, and takes over the ownership of the caller’s reference to variant; the caller doesn’t have to unref it any more (i.e. the reference count of the variant is not increased).If variant was floating then its floating reference is converted to a hard reference.
If you want the
GObject.Valueto hold its own reference to variant, useGObject.Value.set_variant() instead.This is an internal function introduced mainly for C marshallers.
New in version 2.26.
-
transform(dest_value)[source]¶ Parameters: dest_value ( GObject.Value) – Target value.Returns: Whether a transformation rule was found and could be applied. Upon failing transformations, dest_value is left untouched. Return type: boolTries to cast the contents of self into a type appropriate to store in dest_value, e.g. to transform a
GObject.TYPE_INTvalue into aGObject.TYPE_FLOATvalue. Performing transformations between value types might incur precision lossage. Especially transformations into strings might reveal seemingly arbitrary results and shouldn’t be relied upon for production code (such as rcfile value or object property serialization).
-
unset()[source]¶ Clears the current value in self (if any) and “unsets” the type, this releases all resources associated with this
GObject.Value. An unset value is the same as an uninitialized (zero-filled)GObject.Valuestructure.
-
classmethod