DBusUtilities.gvalueToGvariant

Converts a gobject.Value to a glib.Variant of the type indicated by the type parameter.

The conversion is using the following rules:

- G_TYPE_STRING.get 's', 'o', 'g' or 'ay' - G_TYPE_STRV.get 'as', 'ao' or 'aay' - G_TYPE_BOOLEAN.get 'b' - G_TYPE_UCHAR.get 'y' - G_TYPE_INT.get 'i', 'n' - G_TYPE_UINT.get 'u', 'q' - G_TYPE_INT64 'x' - G_TYPE_UINT64.get 't' - G_TYPE_DOUBLE.get 'd' - G_TYPE_VARIANT.get Any glib.VariantType

This can fail if e.g. gvalue is of type G_TYPE_STRING and type is ['i'][G-VARIANT-TYPE-INT32:CAPS]. It will also fail for any GType (including e.g. G_TYPE_OBJECT and G_TYPE_BOXED derived-types) not in the table above.

Note that if gvalue is of type G_TYPE_VARIANT and its value is NULL, the empty glib.Variant instance (never NULL) for type is returned (e.g. 0 for scalar types, the empty string for string types, '/' for object path types, the empty array for any array type and so on).

See the g_dbus_gvariant_to_gvalue() function for how to convert a glib.Variant to a gobject.Value

struct DBusUtilities
static
gvalueToGvariant

Parameters

gvalue Value

A gobject.Value to convert to a glib.Variant

type VariantType

Return Value

Type: Variant

A glib.Variant (never floating) of glib.VariantType type holding the data from gvalue or NULL in case of failure. Free with Variant.unref.

Meta

Since

2.30