Type Information

Type Information — The GLib Runtime type identification and management system

Functions

#define G_TYPE_FUNDAMENTAL()
#define G_TYPE_MAKE_FUNDAMENTAL()
#define G_TYPE_IS_ABSTRACT()
#define G_TYPE_IS_DERIVED()
#define G_TYPE_IS_FUNDAMENTAL()
#define G_TYPE_IS_VALUE_TYPE()
#define G_TYPE_HAS_VALUE_TABLE()
#define G_TYPE_IS_CLASSED()
#define G_TYPE_IS_INSTANTIATABLE()
#define G_TYPE_IS_DERIVABLE()
#define G_TYPE_IS_DEEP_DERIVABLE()
#define G_TYPE_IS_INTERFACE()
#define G_TYPE_IS_FINAL()
#define G_TYPE_FROM_INSTANCE()
#define G_TYPE_FROM_CLASS()
#define G_TYPE_FROM_INTERFACE()
#define G_TYPE_INSTANCE_GET_CLASS()
#define G_TYPE_INSTANCE_GET_INTERFACE()
#define G_TYPE_INSTANCE_GET_PRIVATE()
#define G_TYPE_CLASS_GET_PRIVATE()
#define G_TYPE_CHECK_INSTANCE()
#define G_TYPE_CHECK_INSTANCE_CAST()
#define G_TYPE_CHECK_INSTANCE_TYPE()
#define G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE()
#define G_TYPE_CHECK_CLASS_CAST()
#define G_TYPE_CHECK_CLASS_TYPE()
#define G_TYPE_CHECK_VALUE()
#define G_TYPE_CHECK_VALUE_TYPE()
void g_type_init ()
void g_type_init_with_debug_flags ()
const gchar * g_type_name ()
GQuark g_type_qname ()
GType g_type_from_name ()
GType g_type_parent ()
guint g_type_depth ()
GType g_type_next_base ()
gboolean g_type_is_a ()
gpointer g_type_class_ref ()
gpointer g_type_class_peek ()
gpointer g_type_class_peek_static ()
void g_type_class_unref ()
gpointer g_type_class_peek_parent ()
void g_type_class_add_private ()
void g_type_add_class_private ()
gpointer g_type_interface_peek ()
gpointer g_type_interface_peek_parent ()
gpointer g_type_default_interface_ref ()
gpointer g_type_default_interface_peek ()
void g_type_default_interface_unref ()
GType * g_type_children ()
GType * g_type_interfaces ()
GType * g_type_interface_prerequisites ()
GType g_type_interface_instantiatable_prerequisite ()
void g_type_set_qdata ()
gpointer g_type_get_qdata ()
void g_type_query ()
void (*GBaseInitFunc) ()
void (*GBaseFinalizeFunc) ()
void (*GClassInitFunc) ()
void (*GClassFinalizeFunc) ()
void (*GInstanceInitFunc) ()
void (*GInterfaceInitFunc) ()
void (*GInterfaceFinalizeFunc) ()
gboolean (*GTypeClassCacheFunc) ()
GType g_type_register_static ()
GType g_type_register_static_simple ()
GType g_type_register_dynamic ()
GType g_type_register_fundamental ()
void g_type_add_interface_static ()
void g_type_add_interface_dynamic ()
void g_type_interface_add_prerequisite ()
GTypePlugin * g_type_get_plugin ()
GTypePlugin * g_type_interface_get_plugin ()
GType g_type_fundamental_next ()
GType g_type_fundamental ()
GTypeInstance * g_type_create_instance ()
void g_type_free_instance ()
void g_type_add_class_cache_func ()
void g_type_remove_class_cache_func ()
void g_type_class_unref_uncached ()
void g_type_add_interface_check ()
void g_type_remove_interface_check ()
void (*GTypeInterfaceCheckFunc) ()
GTypeValueTable * g_type_value_table_peek ()
void g_type_ensure ()
guint g_type_get_type_registration_serial ()
int g_type_get_instance_count ()
#define G_DECLARE_FINAL_TYPE()
#define G_DECLARE_DERIVABLE_TYPE()
#define G_DECLARE_INTERFACE()
#define G_DEFINE_TYPE()
#define G_DEFINE_TYPE_WITH_PRIVATE()
#define G_DEFINE_TYPE_WITH_CODE()
#define G_DEFINE_ABSTRACT_TYPE()
#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE()
#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE()
#define G_DEFINE_FINAL_TYPE()
#define G_DEFINE_FINAL_TYPE_WITH_PRIVATE()
#define G_DEFINE_FINAL_TYPE_WITH_CODE()
#define G_ADD_PRIVATE()
#define G_PRIVATE_OFFSET()
#define G_PRIVATE_FIELD()
#define G_PRIVATE_FIELD_P()
#define G_DEFINE_INTERFACE()
#define G_DEFINE_INTERFACE_WITH_CODE()
#define G_IMPLEMENT_INTERFACE()
#define G_DEFINE_TYPE_EXTENDED()
#define G_DEFINE_BOXED_TYPE()
#define G_DEFINE_BOXED_TYPE_WITH_CODE()
#define G_DEFINE_POINTER_TYPE()
#define G_DEFINE_POINTER_TYPE_WITH_CODE()
#define G_DEFINE_ENUM_VALUE()
#define G_DEFINE_ENUM_TYPE()
#define G_DEFINE_FLAGS_TYPE()

Types and Values

Object Hierarchy

    gpointer
    ╰── GType

Includes

#include <glib-object.h>

Description

The GType API is the foundation of the GObject system. It provides the facilities for registering and managing all fundamental data types, user-defined object and interface types.

For type creation and registration purposes, all types fall into one of two categories: static or dynamic. Static types are never loaded or unloaded at run-time as dynamic types may be. Static types are created with g_type_register_static() that gets type specific information passed in via a GTypeInfo structure.

Dynamic types are created with g_type_register_dynamic() which takes a GTypePlugin structure instead. The remaining type information (the GTypeInfo structure) is retrieved during runtime through GTypePlugin and the g_type_plugin_*() API.

These registration functions are usually called only once from a function whose only purpose is to return the type identifier for a specific class. Once the type (or class or interface) is registered, it may be instantiated, inherited, or implemented depending on exactly what sort of type it is.

There is also a third registration function for registering fundamental types called g_type_register_fundamental() which requires both a GTypeInfo structure and a GTypeFundamentalInfo structure but it is seldom used since most fundamental types are predefined rather than user-defined.

Type instance and class structs are limited to a total of 64 KiB, including all parent types. Similarly, type instances' private data (as created by G_ADD_PRIVATE()) are limited to a total of 64 KiB. If a type instance needs a large static buffer, allocate it separately (typically by using GArray or GPtrArray) and put a pointer to the buffer in the structure.

As mentioned in the GType conventions, type names must be at least three characters long. There is no upper length limit. The first character must be a letter (a–z or A–Z) or an underscore (‘_’). Subsequent characters can be letters, numbers or any of ‘-_+’.

Functions

G_TYPE_FUNDAMENTAL()

#define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type))

The fundamental type which is the ancestor of type .

Fundamental types are types that serve as ultimate bases for the derived types, thus they are the roots of distinct inheritance hierarchies.

Parameters

type

A GType value.

 

G_TYPE_MAKE_FUNDAMENTAL()

#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))

Get the type ID for the fundamental type number x .

Use g_type_fundamental_next() instead of this macro to create new fundamental types.

Parameters

x

the fundamental type number.

 

Returns

the GType


G_TYPE_IS_ABSTRACT()

#define G_TYPE_IS_ABSTRACT(type)                (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))

Checks if type is an abstract type. An abstract type cannot be instantiated and is normally used as an abstract base class for derived classes.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_DERIVED()

#define G_TYPE_IS_DERIVED(type)                 ((type) > G_TYPE_FUNDAMENTAL_MAX)

Checks if type is derived (or in object-oriented terminology: inherited) from another type (this holds true for all non-fundamental types).

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_FUNDAMENTAL()

#define G_TYPE_IS_FUNDAMENTAL(type)             ((type) <= G_TYPE_FUNDAMENTAL_MAX)

Checks if type is a fundamental type.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_VALUE_TYPE()

#define G_TYPE_IS_VALUE_TYPE(type)              (g_type_check_is_value_type (type))

Checks if type is a value type and can be used with g_value_init().

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_HAS_VALUE_TABLE()

#define G_TYPE_HAS_VALUE_TABLE(type)            (g_type_value_table_peek (type) != NULL)

Checks if type has a GTypeValueTable.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_CLASSED()

#define G_TYPE_IS_CLASSED(type)                 (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED))

Checks if type is a classed type.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_INSTANTIATABLE()

#define G_TYPE_IS_INSTANTIATABLE(type)          (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))

Checks if type can be instantiated. Instantiation is the process of creating an instance (object) of this type.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_DERIVABLE()

#define G_TYPE_IS_DERIVABLE(type)               (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE))

Checks if type is a derivable type. A derivable type can be used as the base class of a flat (single-level) class hierarchy.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_DEEP_DERIVABLE()

#define G_TYPE_IS_DEEP_DERIVABLE(type)          (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE))

Checks if type is a deep derivable type. A deep derivable type can be used as the base class of a deep (multi-level) class hierarchy.

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_INTERFACE()

#define G_TYPE_IS_INTERFACE(type)               (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE)

Checks if type is an interface type.

An interface type provides a pure API, the implementation of which is provided by another type (which is then said to conform to the interface). GLib interfaces are somewhat analogous to Java interfaces and C++ classes containing only pure virtual functions, with the difference that GType interfaces are not derivable (but see g_type_interface_add_prerequisite() for an alternative).

Parameters

type

A GType value

 

Returns

TRUE on success


G_TYPE_IS_FINAL()

#define G_TYPE_IS_FINAL(type)                   (g_type_test_flags ((type), G_TYPE_FLAG_FINAL)) GLIB_AVAILABLE_MACRO_IN_2_70

Checks if type is a final type. A final type cannot be derived any further.

Parameters

type

a GType value

 

Returns

TRUE on success

Since: 2.70


G_TYPE_FROM_INSTANCE()

#define G_TYPE_FROM_INSTANCE(instance)                          (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class))

Get the type identifier from a given instance structure.

This macro should only be used in type implementations.

Parameters

instance

Location of a valid GTypeInstance structure

 

Returns

the GType


G_TYPE_FROM_CLASS()

#define G_TYPE_FROM_CLASS(g_class)                              (((GTypeClass*) (g_class))->g_type)

Get the type identifier from a given class structure.

This macro should only be used in type implementations.

Parameters

g_class

Location of a valid GTypeClass structure

 

Returns

the GType


G_TYPE_FROM_INTERFACE()

#define G_TYPE_FROM_INTERFACE(g_iface)                          (((GTypeInterface*) (g_iface))->g_type)

Get the type identifier from a given interface structure.

This macro should only be used in type implementations.

Parameters

g_iface

Location of a valid GTypeInterface structure

 

Returns

the GType


G_TYPE_INSTANCE_GET_CLASS()

#define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type)     (_G_TYPE_IGC ((instance), (g_type), c_type))

Get the class structure of a given instance , casted to a specified ancestor type g_type of the instance.

Note that while calling a GInstanceInitFunc(), the class pointer gets modified, so it might not always return the expected pointer.

This macro should only be used in type implementations.

Parameters

instance

Location of the GTypeInstance structure

 

g_type

The GType of the class to be returned

 

c_type

The C type of the class structure

 

Returns

a pointer to the class structure


G_TYPE_INSTANCE_GET_INTERFACE()

#define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type))

Get the interface structure for interface g_type of a given instance .

This macro should only be used in type implementations.

Parameters

instance

Location of the GTypeInstance structure

 

g_type

The GType of the interface to be returned

 

c_type

The C type of the interface structure

 

Returns

a pointer to the interface structure


G_TYPE_INSTANCE_GET_PRIVATE()

#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type)   ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) GLIB_DEPRECATED_MACRO_IN_2_58_FOR(G_ADD_PRIVATE)

G_TYPE_INSTANCE_GET_PRIVATE has been deprecated since version 2.58 and should not be used in newly-written code.

Use G_ADD_PRIVATE() and the generated your_type_get_instance_private() function instead

Gets the private structure for a particular type.

The private structure must have been registered in the class_init function with g_type_class_add_private().

This macro should only be used in type implementations.

Parameters

instance

the instance of a type deriving from private_type

 

g_type

the type identifying which private data to retrieve

 

c_type

The C type for the private structure

 

Returns

a pointer to the private data structure.

[not nullable]

Since: 2.4


G_TYPE_CLASS_GET_PRIVATE()

#define G_TYPE_CLASS_GET_PRIVATE(klass, g_type, c_type)   ((c_type*) g_type_class_get_private ((GTypeClass*) (klass), (g_type)))

Gets the private class structure for a particular type.

The private structure must have been registered in the get_type() function with g_type_add_class_private().

This macro should only be used in type implementations.

Parameters

klass

the class of a type deriving from private_type

 

g_type

the type identifying which private data to retrieve

 

c_type

The C type for the private structure

 

Returns

a pointer to the private data structure.

[not nullable]

Since: 2.24


G_TYPE_CHECK_INSTANCE()

#define G_TYPE_CHECK_INSTANCE(instance)				(_G_TYPE_CHI ((GTypeInstance*) (instance)))

Checks if instance is a valid GTypeInstance structure, otherwise issues a warning and returns FALSE. NULL is not a valid GTypeInstance.

This macro should only be used in type implementations.

Parameters

instance

Location of a GTypeInstance structure

 

Returns

TRUE on success


G_TYPE_CHECK_INSTANCE_CAST()

#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type)    (_G_TYPE_CIC ((instance), (g_type), c_type))

Checks that instance is an instance of the type identified by g_type and issues a warning if this is not the case. Returns instance casted to a pointer to c_type .

No warning will be issued if instance is NULL, and NULL will be returned.

This macro should only be used in type implementations.

Parameters

instance

Location of a GTypeInstance structure.

[nullable]

g_type

The type to be returned

 

c_type

The corresponding C type of g_type

 

G_TYPE_CHECK_INSTANCE_TYPE()

#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type)            (_G_TYPE_CIT ((instance), (g_type)))

Checks if instance is an instance of the type identified by g_type . If instance is NULL, FALSE will be returned.

This macro should only be used in type implementations.

Parameters

instance

Location of a GTypeInstance structure.

[nullable]

g_type

The type to be checked

 

Returns

TRUE on success


G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE()

#define G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE(instance, g_type)            (_G_TYPE_CIFT ((instance), (g_type)))

Checks if instance is an instance of the fundamental type identified by g_type . If instance is NULL, FALSE will be returned.

This macro should only be used in type implementations.

Parameters

instance

Location of a GTypeInstance structure.

[nullable]

g_type

The fundamental type to be checked

 

Returns

TRUE on success


G_TYPE_CHECK_CLASS_CAST()

#define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type)        (_G_TYPE_CCC ((g_class), (g_type), c_type))

Checks that g_class is a class structure of the type identified by g_type and issues a warning if this is not the case. Returns g_class casted to a pointer to c_type . NULL is not a valid class structure.

This macro should only be used in type implementations.

Parameters

g_class

Location of a GTypeClass structure

 

g_type

The type to be returned

 

c_type

The corresponding C type of class structure of g_type

 

G_TYPE_CHECK_CLASS_TYPE()

#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type)                (_G_TYPE_CCT ((g_class), (g_type)))

Checks if g_class is a class structure of the type identified by g_type . If g_class is NULL, FALSE will be returned.

This macro should only be used in type implementations.

Parameters

g_class

Location of a GTypeClass structure.

[nullable]

g_type

The type to be checked

 

Returns

TRUE on success


G_TYPE_CHECK_VALUE()

#define G_TYPE_CHECK_VALUE(value)				(_G_TYPE_CHV ((value)))

Checks if value has been initialized to hold values of a value type.

This macro should only be used in type implementations.

Parameters

value

a GValue

 

Returns

TRUE on success


G_TYPE_CHECK_VALUE_TYPE()

#define G_TYPE_CHECK_VALUE_TYPE(value, g_type)			(_G_TYPE_CVH ((value), (g_type)))

Checks if value has been initialized to hold values of type g_type .

This macro should only be used in type implementations.

Parameters

value

a GValue

 

g_type

The type to be checked

 

Returns

TRUE on success


g_type_init ()

void
g_type_init (void);

g_type_init has been deprecated since version 2.36 and should not be used in newly-written code.

the type system is now initialised automatically

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


g_type_init_with_debug_flags ()

void
g_type_init_with_debug_flags (GTypeDebugFlags debug_flags);

g_type_init_with_debug_flags has been deprecated since version 2.36 and should not be used in newly-written code.

the type system is now initialised automatically

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 GTypeDebugFlags values for debugging purposes

 

g_type_name ()

const gchar *
g_type_name (GType type);

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

 

Returns

static type name or NULL


g_type_qname ()

GQuark
g_type_qname (GType type);

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


g_type_from_name ()

GType
g_type_from_name (const gchar *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


g_type_parent ()

GType
g_type_parent (GType 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

 

Returns

the parent type


g_type_depth ()

guint
g_type_depth (GType type);

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

 

Returns

the depth of type


g_type_next_base ()

GType
g_type_next_base (GType leaf_type,
                  GType root_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

 

Returns

immediate child of root_type and ancestor of leaf_type


g_type_is_a ()

gboolean
g_type_is_a (GType type,
             GType is_a_type);

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

 

Returns

TRUE if type is a is_a_type


g_type_class_ref ()

gpointer
g_type_class_ref (GType type);

Increments the reference count of the class structure belonging to type . This function will demand-create the class if it doesn't exist already.

Parameters

type

type ID of a classed type

 

Returns

the GTypeClass structure for the given type ID.

[type GObject.TypeClass][transfer none]


g_type_class_peek ()

gpointer
g_type_class_peek (GType type);

This function is essentially the same as g_type_class_ref(), except that the classes reference count isn't incremented. As a consequence, this function may return NULL if the class of the type passed in does not currently exist (hasn't been referenced before).

Parameters

type

type ID of a classed type

 

Returns

the GTypeClass structure for the given type ID or NULL if the class does not currently exist.

[type GObject.TypeClass][transfer none]


g_type_class_peek_static ()

gpointer
g_type_class_peek_static (GType type);

A more efficient version of g_type_class_peek() which works only for static types.

Parameters

type

type ID of a classed type

 

Returns

the GTypeClass structure for the given type ID or NULL if the class does not currently exist or is dynamically loaded.

[type GObject.TypeClass][transfer none]

Since: 2.4


g_type_class_unref ()

void
g_type_class_unref (gpointer g_class);

Decrements the reference count of the class structure being passed in. Once the last reference count of a class has been released, classes may be finalized by the type system, so further dereferencing of a class pointer after g_type_class_unref() are invalid.

Parameters

g_class

a GTypeClass structure to unref.

[type GObject.TypeClass]

g_type_class_peek_parent ()

gpointer
g_type_class_peek_parent (gpointer g_class);

This is a convenience function often needed in class initializers. It returns the class structure of the immediate parent type of the class passed in. Since derived classes hold a reference count on their parent classes as long as they are instantiated, the returned class will always exist.

This function is essentially equivalent to: g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)))

Parameters

g_class

the GTypeClass structure to retrieve the parent class for.

[type GObject.TypeClass]

Returns

the parent class of g_class .

[type GObject.TypeClass][transfer none]


g_type_class_add_private ()

void
g_type_class_add_private (gpointer g_class,
                          gsize private_size);

g_type_class_add_private has been deprecated since version 2.58 and should not be used in newly-written code.

Use the G_ADD_PRIVATE() macro with the G_DEFINE_* family of macros to add instance private data to a type

Registers a private structure for an instantiatable type.

When an object is allocated, the private structures for the type and all of its parent types are allocated sequentially in the same memory block as the public structures, and are zero-filled.

Note that the accumulated size of the private structures of a type and all its parent types cannot exceed 64 KiB.

This function should be called in the type's class_init() function. The private structure can be retrieved using the G_TYPE_INSTANCE_GET_PRIVATE() macro.

The following example shows attaching a private structure MyObjectPrivate to an object MyObject defined in the standard GObject fashion in the type's class_init() function.

Note the use of a structure member "priv" to avoid the overhead of repeatedly calling MY_OBJECT_GET_PRIVATE().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
typedef struct _MyObject        MyObject;
typedef struct _MyObjectPrivate MyObjectPrivate;

struct _MyObject {
 GObject parent;

 MyObjectPrivate *priv;
};

struct _MyObjectPrivate {
  int some_field;
};

static void
my_object_class_init (MyObjectClass *klass)
{
  g_type_class_add_private (klass, sizeof (MyObjectPrivate));
}

static void
my_object_init (MyObject *my_object)
{
  my_object->priv = G_TYPE_INSTANCE_GET_PRIVATE (my_object,
                                                 MY_TYPE_OBJECT,
                                                 MyObjectPrivate);
  // my_object->priv->some_field will be automatically initialised to 0
}

static int
my_object_get_some_field (MyObject *my_object)
{
  MyObjectPrivate *priv;

  g_return_val_if_fail (MY_IS_OBJECT (my_object), 0);

  priv = my_object->priv;

  return priv->some_field;
}

Parameters

g_class

class structure for an instantiatable type.

[type GObject.TypeClass]

private_size

size of private structure

 

Since: 2.4


g_type_add_class_private ()

void
g_type_add_class_private (GType class_type,
                          gsize private_size);

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

 

Since: 2.24


g_type_interface_peek ()

gpointer
g_type_interface_peek (gpointer instance_class,
                       GType iface_type);

Returns the GTypeInterface structure of an interface to which the passed in class conforms.

Parameters

instance_class

a GTypeClass structure.

[type GObject.TypeClass]

iface_type

an interface ID which this class conforms to

 

Returns

the GTypeInterface structure of iface_type if implemented by instance_class , NULL otherwise.

[type GObject.TypeInterface][transfer none]


g_type_interface_peek_parent ()

gpointer
g_type_interface_peek_parent (gpointer g_iface);

Returns the corresponding GTypeInterface structure of the parent type of the instance type to which g_iface belongs. This is useful when deriving the implementation of an interface from the parent type and then possibly overriding some methods.

Parameters

g_iface

a GTypeInterface structure.

[type GObject.TypeInterface]

Returns

the corresponding GTypeInterface structure of the parent type of the instance type to which g_iface belongs, or NULL if the parent type doesn't conform to the interface.

[transfer none][type GObject.TypeInterface]


g_type_default_interface_ref ()

gpointer
g_type_default_interface_ref (GType g_type);

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 GTypeInfo). Calling g_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

 

Returns

the default vtable for the interface; call g_type_default_interface_unref() when you are done using the interface.

[type GObject.TypeInterface][transfer none]

Since: 2.4


g_type_default_interface_peek ()

gpointer
g_type_default_interface_peek (GType g_type);

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

Parameters

g_type

an interface type

 

Returns

the default vtable for the interface, or NULL if the type is not currently in use.

[type GObject.TypeInterface][transfer none]

Since: 2.4


g_type_default_interface_unref ()

void
g_type_default_interface_unref (gpointer g_iface);

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 GTypeInfo) will be called.

Parameters

g_iface

the default vtable structure for an interface, as returned by g_type_default_interface_ref().

[type GObject.TypeInterface]

Since: 2.4


g_type_children ()

GType *
g_type_children (GType type,
                 guint *n_children);

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

Parameters

type

the parent type

 

n_children

location to store the length of the returned array, or NULL.

[out][optional]

Returns

Newly allocated and 0-terminated array of child types, free with g_free().

[array length=n_children][transfer full]


g_type_interfaces ()

GType *
g_type_interfaces (GType type,
                   guint *n_interfaces);

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

 

n_interfaces

location to store the length of the returned array, or NULL.

[out][optional]

Returns

Newly allocated and 0-terminated array of interface types, free with g_free().

[array length=n_interfaces][transfer full]


g_type_interface_prerequisites ()

GType *
g_type_interface_prerequisites (GType interface_type,
                                guint *n_prerequisites);

Returns the prerequisites of an interfaces type.

Parameters

interface_type

an interface type

 

n_prerequisites

location to return the number of prerequisites, or NULL.

[out][optional]

Returns

a newly-allocated zero-terminated array of GType containing the prerequisites of interface_type .

[array length=n_prerequisites][transfer full]

Since: 2.2


g_type_interface_instantiatable_prerequisite ()

GType
g_type_interface_instantiatable_prerequisite
                               (GType interface_type);

Returns the most specific instantiatable prerequisite of an interface type. If the interface type has no instantiatable prerequisite, G_TYPE_INVALID is returned.

See g_type_interface_add_prerequisite() for more information about prerequisites.

Parameters

interface_type

an interface type

 

Returns

the instantiatable prerequisite type or G_TYPE_INVALID if none

Since: 2.68


g_type_set_qdata ()

void
g_type_set_qdata (GType type,
                  GQuark quark,
                  gpointer data);

Attaches arbitrary data to a type.

Parameters

type

a GType

 

quark

a GQuark id to identify the data

 

data

the data

 

g_type_get_qdata ()

gpointer
g_type_get_qdata (GType type,
                  GQuark quark);

Obtains data which has previously been attached to type with g_type_set_qdata().

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

Parameters

type

a GType

 

quark

a GQuark id to identify the data

 

Returns

the data, or NULL if no data was found.

[transfer none]


g_type_query ()

void
g_type_query (GType type,
              GTypeQuery *query);

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 GTypeQuery is 0. All members filled into the GTypeQuery structure should be considered constant and have to be left untouched.

Parameters

type

GType of a static, classed type

 

query

a user provided structure that is filled in with constant values upon success.

[out caller-allocates]

GBaseInitFunc ()

void
(*GBaseInitFunc) (gpointer g_class);

A callback function used by the type system to do base initialization of the class structures of derived types.

This function is called as part of the initialization process of all derived classes and should reallocate or reset all dynamic class members copied over from the parent class.

For example, class members (such as strings) that are not sufficiently handled by a plain memory copy of the parent class into the derived class have to be altered. See GClassInitFunc() for a discussion of the class initialization process.

Parameters

g_class

The GTypeClass structure to initialize.

[type GObject.TypeClass]

GBaseFinalizeFunc ()

void
(*GBaseFinalizeFunc) (gpointer g_class);

A callback function used by the type system to finalize those portions of a derived types class structure that were setup from the corresponding GBaseInitFunc() function.

Class finalization basically works the inverse way in which class initialization is performed.

See GClassInitFunc() for a discussion of the class initialization process.

Parameters

g_class

The GTypeClass structure to finalize.

[type GObject.TypeClass]

GClassInitFunc ()

void
(*GClassInitFunc) (gpointer g_class,
                   gpointer class_data);

A callback function used by the type system to initialize the class of a specific type.

This function should initialize all static class members.

The initialization process of a class involves:

  • Copying common members from the parent class over to the derived class structure.

  • Zero initialization of the remaining members not copied over from the parent class.

  • Invocation of the GBaseInitFunc() initializers of all parent types and the class' type.

  • Invocation of the class' GClassInitFunc() initializer.

Since derived classes are partially initialized through a memory copy of the parent class, the general rule is that GBaseInitFunc() and GBaseFinalizeFunc() should take care of necessary reinitialization and release of those class members that were introduced by the type that specified these GBaseInitFunc()/GBaseFinalizeFunc(). GClassInitFunc() should only care about initializing static class members, while dynamic class members (such as allocated strings or reference counted resources) are better handled by a GBaseInitFunc() for this type, so proper initialization of the dynamic class members is performed for class initialization of derived types as well.

An example may help to correspond the intend of the different class initializers:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
typedef struct {
  GObjectClass parent_class;
  gint         static_integer;
  gchar       *dynamic_string;
} TypeAClass;
static void
type_a_base_class_init (TypeAClass *class)
{
  class->dynamic_string = g_strdup ("some string");
}
static void
type_a_base_class_finalize (TypeAClass *class)
{
  g_free (class->dynamic_string);
}
static void
type_a_class_init (TypeAClass *class)
{
  class->static_integer = 42;
}

typedef struct {
  TypeAClass   parent_class;
  gfloat       static_float;
  GString     *dynamic_gstring;
} TypeBClass;
static void
type_b_base_class_init (TypeBClass *class)
{
  class->dynamic_gstring = g_string_new ("some other string");
}
static void
type_b_base_class_finalize (TypeBClass *class)
{
  g_string_free (class->dynamic_gstring);
}
static void
type_b_class_init (TypeBClass *class)
{
  class->static_float = 3.14159265358979323846;
}

Initialization of TypeBClass will first cause initialization of TypeAClass (derived classes reference their parent classes, see g_type_class_ref() on this).

Initialization of TypeAClass roughly involves zero-initializing its fields, then calling its GBaseInitFunc() type_a_base_class_init() to allocate its dynamic members (dynamic_string), and finally calling its GClassInitFunc() type_a_class_init() to initialize its static members (static_integer). The first step in the initialization process of TypeBClass is then a plain memory copy of the contents of TypeAClass into TypeBClass and zero-initialization of the remaining fields in TypeBClass. The dynamic members of TypeAClass within TypeBClass now need reinitialization which is performed by calling type_a_base_class_init() with an argument of TypeBClass.

After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init() is called to allocate the dynamic members of TypeBClass (dynamic_gstring), and finally the GClassInitFunc() of TypeBClass, type_b_class_init(), is called to complete the initialization process with the static members (static_float).

Corresponding finalization counter parts to the GBaseInitFunc() functions have to be provided to release allocated resources at class finalization time.

Parameters

g_class

The GTypeClass structure to initialize.

[type GObject.TypeClass]

class_data

The class_data member supplied via the GTypeInfo structure.

 

GClassFinalizeFunc ()

void
(*GClassFinalizeFunc) (gpointer g_class,
                       gpointer class_data);

A callback function used by the type system to finalize a class.

This function is rarely needed, as dynamically allocated class resources should be handled by GBaseInitFunc() and GBaseFinalizeFunc().

Also, specification of a GClassFinalizeFunc() in the GTypeInfo structure of a static type is invalid, because classes of static types will never be finalized (they are artificially kept alive when their reference count drops to zero).

Parameters

g_class

The GTypeClass structure to finalize.

[type GObject.TypeClass]

class_data

The class_data member supplied via the GTypeInfo structure

 

GInstanceInitFunc ()

void
(*GInstanceInitFunc) (GTypeInstance *instance,
                      gpointer g_class);

A callback function used by the type system to initialize a new instance of a type.

This function initializes all instance members and allocates any resources required by it.

Initialization of a derived instance involves calling all its parent types instance initializers, so the class member of the instance is altered during its initialization to always point to the class that belongs to the type the current initializer was introduced for.

The extended members of instance are guaranteed to have been filled with zeros before this function is called.

Parameters

instance

The instance to initialize

 

g_class

The class of the type the instance is created for.

[type GObject.TypeClass]

GInterfaceInitFunc ()

void
(*GInterfaceInitFunc) (gpointer g_iface,
                       gpointer iface_data);

A callback function used by the type system to initialize a new interface.

This function should initialize all internal data and* allocate any resources required by the interface.

The members of iface_data are guaranteed to have been filled with zeros before this function is called.

Parameters

g_iface

The interface structure to initialize.

[type GObject.TypeInterface]

iface_data

The interface_data supplied via the GInterfaceInfo structure

 

GInterfaceFinalizeFunc ()

void
(*GInterfaceFinalizeFunc) (gpointer g_iface,
                           gpointer iface_data);

A callback function used by the type system to finalize an interface.

This function should destroy any internal data and release any resources allocated by the corresponding GInterfaceInitFunc() function.

Parameters

g_iface

The interface structure to finalize.

[type GObject.TypeInterface]

iface_data

The interface_data supplied via the GInterfaceInfo structure

 

GTypeClassCacheFunc ()

gboolean
(*GTypeClassCacheFunc) (gpointer cache_data,
                        GTypeClass *g_class);

A callback function which is called when the reference count of a class drops to zero.

It may use g_type_class_ref() to prevent the class from being freed. You should not call g_type_class_unref() from a GTypeClassCacheFunc function to prevent infinite recursion, use g_type_class_unref_uncached() instead.

The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same GTypeClassCacheFunc chain.

Parameters

cache_data

data that was given to the g_type_add_class_cache_func() call

 

g_class

The GTypeClass structure which is unreferenced.

[type GObject.TypeClass]

Returns

TRUE to stop further GTypeClassCacheFuncs from being called, FALSE to continue


g_type_register_static ()

GType
g_type_register_static (GType parent_type,
                        const gchar *type_name,
                        const GTypeInfo *info,
                        GTypeFlags flags);

Registers type_name as the name of a new static type derived from parent_type . The type system uses the information contained in the GTypeInfo 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

 

info

GTypeInfo structure for this type

 

flags

bitwise combination of GTypeFlags values

 

Returns

the new type identifier


g_type_register_static_simple ()

GType
g_type_register_static_simple (GType parent_type,
                               const gchar *type_name,
                               guint class_size,
                               GClassInitFunc class_init,
                               guint instance_size,
                               GInstanceInitFunc instance_init,
                               GTypeFlags flags);

Registers type_name as the name of a new static type derived from parent_type . The value of flags determines the nature (e.g. abstract or not) of the type. It works by filling a GTypeInfo struct and calling g_type_register_static().

[skip]

Parameters

parent_type

type from which this type will be derived

 

type_name

0-terminated string used as the name of the new type

 

class_size

size of the class structure (see GTypeInfo)

 

class_init

location of the class initialization function (see GTypeInfo)

 

instance_size

size of the instance structure (see GTypeInfo)

 

instance_init

location of the instance initialization function (see GTypeInfo)

 

flags

bitwise combination of GTypeFlags values

 

Returns

the new type identifier

Since: 2.12


g_type_register_dynamic ()

GType
g_type_register_dynamic (GType parent_type,
                         const gchar *type_name,
                         GTypePlugin *plugin,
                         GTypeFlags flags);

Registers type_name as the name of a new dynamic type derived from parent_type . The type system uses the information contained in the GTypePlugin 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

 

plugin

GTypePlugin structure to retrieve the GTypeInfo from

 

flags

bitwise combination of GTypeFlags values

 

Returns

the new type identifier or G_TYPE_INVALID if registration failed


g_type_register_fundamental ()

GType
g_type_register_fundamental (GType type_id,
                             const gchar *type_name,
                             const GTypeInfo *info,
                             const GTypeFundamentalInfo *finfo,
                             GTypeFlags flags);

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 GTypeInfo structure pointed to by info and the GTypeFundamentalInfo 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

 

info

GTypeInfo structure for this type

 

finfo

GTypeFundamentalInfo structure for this type

 

flags

bitwise combination of GTypeFlags values

 

Returns

the predefined type identifier


g_type_add_interface_static ()

void
g_type_add_interface_static (GType instance_type,
                             GType interface_type,
                             const GInterfaceInfo *info);

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

Parameters

instance_type

GType value of an instantiatable type

 

interface_type

GType value of an interface type

 

info

GInterfaceInfo structure for this (instance_type , interface_type ) combination

 

g_type_add_interface_dynamic ()

void
g_type_add_interface_dynamic (GType instance_type,
                              GType interface_type,
                              GTypePlugin *plugin);

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

Parameters

instance_type

GType value of an instantiatable type

 

interface_type

GType value of an interface type

 

plugin

GTypePlugin structure to retrieve the GInterfaceInfo from

 

g_type_interface_add_prerequisite ()

void
g_type_interface_add_prerequisite (GType interface_type,
                                   GType prerequisite_type);

Adds prerequisite_type to the list of prerequisites of interface_type . This means that any type implementing interface_type must also implement prerequisite_type . Prerequisites can be thought of as an alternative to interface derivation (which GType doesn't support). An interface can have at most one instantiatable prerequisite type.

Parameters

interface_type

GType value of an interface type

 

prerequisite_type

GType value of an interface or instantiatable type

 

g_type_get_plugin ()

GTypePlugin *
g_type_get_plugin (GType type);

Returns the GTypePlugin structure for type .

Parameters

type

GType to retrieve the plugin for

 

Returns

the corresponding plugin if type is a dynamic type, NULL otherwise.

[transfer none]


g_type_interface_get_plugin ()

GTypePlugin *
g_type_interface_get_plugin (GType instance_type,
                             GType interface_type);

Returns the GTypePlugin structure for the dynamic interface interface_type which has been added to instance_type , or NULL if interface_type has not been added to instance_type or does not have a GTypePlugin structure. See g_type_add_interface_dynamic().

Parameters

instance_type

GType of an instantiatable type

 

interface_type

GType of an interface type

 

Returns

the GTypePlugin for the dynamic interface interface_type of instance_type .

[transfer none]


g_type_fundamental_next ()

GType
g_type_fundamental_next (void);

Returns the next free fundamental type id which can be used to register a new fundamental type with g_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


g_type_fundamental ()

GType
g_type_fundamental (GType type_id);

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

Parameters

type_id

valid type ID

 

Returns

fundamental type ID


g_type_create_instance ()

GTypeInstance *
g_type_create_instance (GType type);

Creates and initializes an instance of type if type is valid and can be instantiated. The type system only performs basic allocation and structure setups for instances: actual instance creation should happen through functions supplied by the type's fundamental type implementation. So use of g_type_create_instance() is reserved for implementers of fundamental types only. E.g. instances of the GObject hierarchy should be created via g_object_new() and never directly through g_type_create_instance() which doesn't handle things like singleton objects or object construction.

The extended members of the returned instance are guaranteed to be filled with zeros.

Note: Do not use this function, unless you're implementing a fundamental type. Also language bindings should not use this function, but g_object_new() instead.

[skip]

Parameters

type

an instantiatable type to create an instance for

 

Returns

an allocated and initialized instance, subject to further treatment by the fundamental type implementation


g_type_free_instance ()

void
g_type_free_instance (GTypeInstance *instance);

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

 

g_type_add_class_cache_func ()

void
g_type_add_class_cache_func (gpointer cache_data,
                             GTypeClassCacheFunc cache_func);

Adds a GTypeClassCacheFunc to be called before the reference count of a class goes from one to zero. This can be used to prevent premature class destruction. All installed GTypeClassCacheFunc functions will be chained until one of them returns TRUE. The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same GTypeClassCacheFunc chain.

[skip]

Parameters

cache_data

data to be passed to cache_func

 

cache_func

a GTypeClassCacheFunc

 

g_type_remove_class_cache_func ()

void
g_type_remove_class_cache_func (gpointer cache_data,
                                GTypeClassCacheFunc cache_func);

Removes a previously installed GTypeClassCacheFunc. The cache maintained by cache_func has to be empty when calling g_type_remove_class_cache_func() to avoid leaks.

[skip]

Parameters

cache_data

data that was given when adding cache_func

 

cache_func

a GTypeClassCacheFunc

 

g_type_class_unref_uncached ()

void
g_type_class_unref_uncached (gpointer g_class);

A variant of g_type_class_unref() for use in GTypeClassCacheFunc implementations. It unreferences a class without consulting the chain of GTypeClassCacheFuncs, avoiding the recursion which would occur otherwise.

[skip]

Parameters

g_class

a GTypeClass structure to unref.

[type GObject.TypeClass]

g_type_add_interface_check ()

void
g_type_add_interface_check (gpointer check_data,
                            GTypeInterfaceCheckFunc check_func);

Adds a function to be called after an interface vtable is initialized for any class (i.e. after the interface_init member of GInterfaceInfo has been called).

This function is useful when you want to check an invariant that depends on the interfaces of a class. For instance, the implementation of GObject uses this facility to check that an object implements all of the properties that are defined on its interfaces.

[skip]

Parameters

check_data

data to pass to check_func

 

check_func

function to be called after each interface is initialized

 

Since: 2.4


g_type_remove_interface_check ()

void
g_type_remove_interface_check (gpointer check_data,
                               GTypeInterfaceCheckFunc check_func);

Removes an interface check function added with g_type_add_interface_check().

[skip]

Parameters

check_data

callback data passed to g_type_add_interface_check()

 

check_func

callback function passed to g_type_add_interface_check()

 

Since: 2.4


GTypeInterfaceCheckFunc ()

void
(*GTypeInterfaceCheckFunc) (gpointer check_data,
                            gpointer g_iface);

A callback called after an interface vtable is initialized.

See g_type_add_interface_check().

Parameters

check_data

data passed to g_type_add_interface_check()

 

g_iface

the interface that has been initialized.

[type GObject.TypeInterface]

Since: 2.4


g_type_value_table_peek ()

GTypeValueTable *
g_type_value_table_peek (GType type);

Returns the location of the GTypeValueTable associated with type .

Note that this function should only be used from source code that implements or has internal knowledge of the implementation of type .

[skip]

Parameters

type

a GType

 

Returns

location of the GTypeValueTable associated with type or NULL if there is no GTypeValueTable associated with type


g_type_ensure ()

void
g_type_ensure (GType type);

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 g_type_ensure() guarantees that the type's _get_type() method is called.

Parameters

type

a GType

 

Since: 2.34


g_type_get_type_registration_serial ()

guint
g_type_get_type_registration_serial (void);

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 g_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.

Returns

An unsigned int, representing the state of type registrations

Since: 2.36


g_type_get_instance_count ()

int
g_type_get_instance_count (GType type);

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

 

Returns

the number of instances allocated of the given type; if instance counts are not available, returns 0.

Since: 2.44


G_DECLARE_FINAL_TYPE()

#define             G_DECLARE_FINAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName)

A convenience macro for emitting the usual declarations in the header file for a type which is not (at the present time) intended to be subclassed.

You might use it in a header as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef _myapp_window_h_
#define _myapp_window_h_

#include <gtk/gtk.h>

#define MY_APP_TYPE_WINDOW my_app_window_get_type ()
G_DECLARE_FINAL_TYPE (MyAppWindow, my_app_window, MY_APP, WINDOW, GtkWindow)

MyAppWindow *    my_app_window_new    (void);

...

#endif

And use it as follow in your C file:

1
2
3
4
5
6
struct _MyAppWindow
{
 GtkWindow parent;
 ...
};
G_DEFINE_TYPE (MyAppWindow, my_app_window, GTK_TYPE_WINDOW)

This results in the following things happening:

  • the usual my_app_window_get_type() function is declared with a return type of GType

  • the MyAppWindow type is defined as a typedef of struct _MyAppWindow. The struct itself is not defined and should be defined from the .c file before G_DEFINE_TYPE() is used.

  • the MY_APP_WINDOW() cast is emitted as static inline function along with the MY_APP_IS_WINDOW() type checking function

  • the MyAppWindowClass type is defined as a struct containing GtkWindowClass. This is done for the convenience of the person defining the type and should not be considered to be part of the ABI. In particular, without a firm declaration of the instance structure, it is not possible to subclass the type and therefore the fact that the size of the class structure is exposed is not a concern and it can be freely changed at any point in the future.

  • g_autoptr() support being added for your type, based on the type of your parent class

You can only use this function if your parent type also supports g_autoptr().

Because the type macro (MY_APP_TYPE_WINDOW in the above example) is not a callable, you must continue to manually define this as a macro for yourself.

The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro to be used in the usual way with export control and API versioning macros.

If you want to declare your own class structure, use G_DECLARE_DERIVABLE_TYPE().

If you are writing a library, it is important to note that it is possible to convert a type from using G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be subclassed. Once a class structure has been exposed it is not possible to change its size or remove or reorder items without breaking the API and/or ABI.

Parameters

ModuleObjName

The name of the new type, in camel case (like GtkWidget)

 

module_obj_name

The name of the new type in lowercase, with words separated by _ (like gtk_widget)

 

MODULE

The name of the module, in all caps (like GTK)

 

OBJ_NAME

The bare name of the type, in all caps (like WIDGET)

 

ParentName

the name of the parent type, in camel case (like GtkWidget)

 

Since: 2.44


G_DECLARE_DERIVABLE_TYPE()

#define             G_DECLARE_DERIVABLE_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName)

A convenience macro for emitting the usual declarations in the header file for a type which is intended to be subclassed.

You might use it in a header as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef _gtk_frobber_h_
#define _gtk_frobber_h_

#define GTK_TYPE_FROBBER gtk_frobber_get_type ()
GDK_AVAILABLE_IN_3_12
G_DECLARE_DERIVABLE_TYPE (GtkFrobber, gtk_frobber, GTK, FROBBER, GtkWidget)

struct _GtkFrobberClass
{
  GtkWidgetClass parent_class;

  void (* handle_frob)  (GtkFrobber *frobber,
                         guint       n_frobs);

  gpointer padding[12];
};

GtkWidget *    gtk_frobber_new   (void);

...

#endif

Since the instance structure is public it is often needed to declare a private struct as follow in your C file:

1
2
3
4
5
6
typedef struct _GtkFrobberPrivate GtkFrobberPrivate;
struct _GtkFrobberPrivate
{
  ...
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkFrobber, gtk_frobber, GTK_TYPE_WIDGET)

This results in the following things happening:

  • the usual gtk_frobber_get_type() function is declared with a return type of GType

  • the GtkFrobber struct is created with GtkWidget as the first and only item. You are expected to use a private structure from your .c file to store your instance variables.

  • the GtkFrobberClass type is defined as a typedef to struct _GtkFrobberClass, which is left undefined. You should do this from the header file directly after you use the macro.

  • the GTK_FROBBER() and GTK_FROBBER_CLASS() casts are emitted as static inline functions along with the GTK_IS_FROBBER() and GTK_IS_FROBBER_CLASS() type checking functions and GTK_FROBBER_GET_CLASS() function.

  • g_autoptr() support being added for your type, based on the type of your parent class

You can only use this function if your parent type also supports g_autoptr().

Because the type macro (GTK_TYPE_FROBBER in the above example) is not a callable, you must continue to manually define this as a macro for yourself.

The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro to be used in the usual way with export control and API versioning macros.

If you are writing a library, it is important to note that it is possible to convert a type from using G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be subclassed. Once a class structure has been exposed it is not possible to change its size or remove or reorder items without breaking the API and/or ABI. If you want to declare your own class structure, use G_DECLARE_DERIVABLE_TYPE(). If you want to declare a class without exposing the class or instance structures, use G_DECLARE_FINAL_TYPE().

If you must use G_DECLARE_DERIVABLE_TYPE() you should be sure to include some padding at the bottom of your class structure to leave space for the addition of future virtual functions.

Parameters

ModuleObjName

The name of the new type, in camel case (like GtkWidget)

 

module_obj_name

The name of the new type in lowercase, with words separated by _ (like gtk_widget)

 

MODULE

The name of the module, in all caps (like GTK)

 

OBJ_NAME

The bare name of the type, in all caps (like WIDGET)

 

ParentName

the name of the parent type, in camel case (like GtkWidget)

 

Since: 2.44


G_DECLARE_INTERFACE()

#define             G_DECLARE_INTERFACE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, PrerequisiteName)

A convenience macro for emitting the usual declarations in the header file for a GInterface type.

You might use it in a header as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef _my_model_h_
#define _my_model_h_

#define MY_TYPE_MODEL my_model_get_type ()
GDK_AVAILABLE_IN_3_12
G_DECLARE_INTERFACE (MyModel, my_model, MY, MODEL, GObject)

struct _MyModelInterface
{
  GTypeInterface g_iface;

  gpointer (* get_item)  (MyModel *model);
};

gpointer my_model_get_item (MyModel *model);

...

#endif

And use it as follow in your C file:

1
2
3
4
5
6
7
G_DEFINE_INTERFACE (MyModel, my_model, G_TYPE_OBJECT);

static void
my_model_default_init (MyModelInterface *iface)
{
  ...
}

This results in the following things happening:

  • the usual my_model_get_type() function is declared with a return type of GType

  • the MyModelInterface type is defined as a typedef to struct _MyModelInterface, which is left undefined. You should do this from the header file directly after you use the macro.

  • the MY_MODEL() cast is emitted as static inline functions along with the MY_IS_MODEL() type checking function and MY_MODEL_GET_IFACE() function.

  • g_autoptr() support being added for your type, based on your prerequisite type.

You can only use this function if your prerequisite type also supports g_autoptr().

Because the type macro (MY_TYPE_MODEL in the above example) is not a callable, you must continue to manually define this as a macro for yourself.

The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro to be used in the usual way with export control and API versioning macros.

Parameters

ModuleObjName

The name of the new type, in camel case (like GtkWidget)

 

module_obj_name

The name of the new type in lowercase, with words separated by _ (like gtk_widget)

 

MODULE

The name of the module, in all caps (like GTK)

 

OBJ_NAME

The bare name of the type, in all caps (like WIDGET)

 

PrerequisiteName

the name of the prerequisite type, in camel case (like GtkWidget)

 

Since: 2.44


G_DEFINE_TYPE()

#define G_DEFINE_TYPE(TN, t_n, T_P)			    G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})

A convenience macro for type implementations, which declares a class initialization function, an instance initialization function (see GTypeInfo for information about these) and a static variable named t_n_parent_class pointing to the parent class. Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

Since: 2.4


G_DEFINE_TYPE_WITH_PRIVATE()

#define G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P)            G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, G_ADD_PRIVATE (TN))

A convenience macro for type implementations, which declares a class initialization function, an instance initialization function (see GTypeInfo for information about these), a static variable named t_n_parent_class pointing to the parent class, and adds private instance data to the type.

Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED() for an example.

Note that private structs added with this macros must have a struct name of the form TN ## Private.

The private instance data can be retrieved using the automatically generated getter function t_n_get_instance_private().

See also: G_ADD_PRIVATE()

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

Since: 2.38


G_DEFINE_TYPE_WITH_CODE()

#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)	    _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()

A convenience macro for type implementations.

Similar to G_DEFINE_TYPE(), but allows you to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

_C_

Custom code that gets inserted in the *_get_type() function.

 

Since: 2.4


G_DEFINE_ABSTRACT_TYPE()

#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P)		    G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})

A convenience macro for type implementations.

Similar to G_DEFINE_TYPE(), but defines an abstract type. See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

Since: 2.4


G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE()

#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P)   G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN))

Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type.

See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

Since: 2.38


G_DEFINE_ABSTRACT_TYPE_WITH_CODE()

#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()

A convenience macro for type implementations.

Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and allows you to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE().

See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

_C_

Custom code that gets inserted in the type_name_get_type() function.

 

Since: 2.4


G_DEFINE_FINAL_TYPE()

#define G_DEFINE_FINAL_TYPE(TN, t_n, T_P)                      G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_FINAL, {}) GLIB_AVAILABLE_MACRO_IN_2_70

A convenience macro for type implementations.

Similar to G_DEFINE_TYPE(), but defines a final type.

See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

the name of the new type, in Camel case

 

t_n

the name of the new type, in lower case, with words separated by _ (snake case)

 

T_P

the GType of the parent type

 

Since: 2.70


G_DEFINE_FINAL_TYPE_WITH_PRIVATE()

#define G_DEFINE_FINAL_TYPE_WITH_PRIVATE(TN, t_n, T_P)         G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_FINAL, G_ADD_PRIVATE (TN)) GLIB_AVAILABLE_MACRO_IN_2_70

A convenience macro for type implementations.

Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines a final type.

See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

the name of the new type, in Camel case

 

t_n

the name of the new type, in lower case, with words separated by _ (snake case)

 

T_P

the GType of the parent type

 

Since: 2.70


G_DEFINE_FINAL_TYPE_WITH_CODE()

#define G_DEFINE_FINAL_TYPE_WITH_CODE(TN, t_n, T_P, _C_)       _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_FINAL) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() GLIB_AVAILABLE_MACRO_IN_2_70

A convenience macro for type implementations.

Similar to G_DEFINE_TYPE_WITH_CODE(), but defines a final type and allows you to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE().

See G_DEFINE_TYPE_EXTENDED() for an example.

Parameters

TN

the name of the new type, in Camel case

 

t_n

the name of the new type, in lower case, with words separated by _ (snake case)

 

T_P

the GType of the parent type

 

_C_

Custom code that gets inserted in the type_name_get_type() function.

 

Since: 2.70


G_ADD_PRIVATE()

#define             G_ADD_PRIVATE(TypeName)

A convenience macro to ease adding private data to instances of a new type in the _C_ section of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE().

For instance:

1
2
3
4
5
6
7
8
9
10
typedef struct _MyObject MyObject;
typedef struct _MyObjectClass MyObjectClass;

typedef struct {
  gint foo;
  gint bar;
} MyObjectPrivate;

G_DEFINE_TYPE_WITH_CODE (MyObject, my_object, G_TYPE_OBJECT,
                         G_ADD_PRIVATE (MyObject))

Will add MyObjectPrivate as the private data to any instance of the MyObject type.

G_DEFINE_TYPE_* macros will automatically create a private function based on the arguments to this macro, which can be used to safely retrieve the private data from an instance of the type; for instance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
gint
my_object_get_foo (MyObject *obj)
{
  MyObjectPrivate *priv = my_object_get_instance_private (obj);

  g_return_val_if_fail (MY_IS_OBJECT (obj), 0);

  return priv->foo;
}

void
my_object_set_bar (MyObject *obj,
                   gint      bar)
{
  MyObjectPrivate *priv = my_object_get_instance_private (obj);

  g_return_if_fail (MY_IS_OBJECT (obj));

  if (priv->bar != bar)
    priv->bar = bar;
}

Since GLib 2.72, the returned MyObjectPrivate pointer is guaranteed to be aligned to at least the alignment of the largest basic GLib type (typically this is guint64 or gdouble). If you need larger alignment for an element in the struct, you should allocate it on the heap (aligned), or arrange for your MyObjectPrivate struct to be appropriately padded.

Note that this macro can only be used together with the G_DEFINE_TYPE_* macros, since it depends on variable names from those macros.

Also note that private structs added with these macros must have a struct name of the form TypeNamePrivate.

It is safe to call the _get_instance_private function on NULL or invalid objects since it's only adding an offset to the instance pointer. In that case the returned pointer must not be dereferenced.

Parameters

TypeName

the name of the type in CamelCase

 

Since: 2.38


G_PRIVATE_OFFSET()

#define             G_PRIVATE_OFFSET(TypeName, field)

Evaluates to the offset of the field inside the instance private data structure for TypeName .

Note that this macro can only be used together with the G_DEFINE_TYPE_* and G_ADD_PRIVATE() macros, since it depends on variable names from those macros.

Parameters

TypeName

the name of the type in CamelCase

 

field

the name of the field in the private data structure

 

Since: 2.38


G_PRIVATE_FIELD()

#define             G_PRIVATE_FIELD(TypeName, inst, field_type, field_name)

Evaluates to the field_name inside the inst private data structure for TypeName .

Note that this macro can only be used together with the G_DEFINE_TYPE_* and G_ADD_PRIVATE() macros, since it depends on variable names from those macros.

Parameters

TypeName

the name of the type in CamelCase

 

inst

the instance of TypeName you wish to access

 

field_type

the type of the field in the private data structure

 

field_name

the name of the field in the private data structure

 

Since: 2.38


G_PRIVATE_FIELD_P()

#define             G_PRIVATE_FIELD_P(TypeName, inst, field_name)

Evaluates to a pointer to the field_name inside the inst private data structure for TypeName .

Note that this macro can only be used together with the G_DEFINE_TYPE_* and G_ADD_PRIVATE() macros, since it depends on variable names from those macros.

Parameters

TypeName

the name of the type in CamelCase

 

inst

the instance of TypeName you wish to access

 

field_name

the name of the field in the private data structure

 

Since: 2.38


G_DEFINE_INTERFACE()

#define G_DEFINE_INTERFACE(TN, t_n, T_P)		    G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)

A convenience macro for GTypeInterface definitions, which declares a default vtable initialization function and defines a *_get_type() function.

The macro expects the interface initialization function to have the name t_n ## _default_init, and the interface structure to have the name TN ## Interface.

The initialization function has signature static void t_n ## _default_init (TypeName##Interface *klass);, rather than the full GInterfaceInitFunc signature, for brevity and convenience. If you need to use an initialization function with an iface_data argument, you must write the GTypeInterface definitions manually.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the prerequisite type for the interface, or G_TYPE_INVALID for no prerequisite type.

 

Since: 2.24


G_DEFINE_INTERFACE_WITH_CODE()

#define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END()

A convenience macro for GTypeInterface definitions.

Similar to G_DEFINE_INTERFACE(), but allows you to insert custom code into the *_get_type() function, e.g. additional interface implementations via G_IMPLEMENT_INTERFACE(), or additional prerequisite types.

See G_DEFINE_TYPE_EXTENDED() for a similar example using G_DEFINE_TYPE_WITH_CODE().

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the prerequisite type for the interface, or G_TYPE_INVALID for no prerequisite type.

 

_C_

Custom code that gets inserted in the *_get_type() function.

 

Since: 2.24


G_IMPLEMENT_INTERFACE()

#define             G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)

A convenience macro to ease interface addition in the _C_ section of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). See G_DEFINE_TYPE_EXTENDED() for an example.

Note that this macro can only be used together with the G_DEFINE_TYPE_* macros, since it depends on variable names from those macros.

Parameters

TYPE_IFACE

The GType of the interface to add

 

iface_init

The interface init function, of type GInterfaceInitFunc.

[type GInterfaceInitFunc]

Since: 2.4


G_DEFINE_TYPE_EXTENDED()

#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)	    _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()

The most general convenience macro for type implementations, on which G_DEFINE_TYPE(), etc are based.

1
2
3
4
5
6
7
G_DEFINE_TYPE_EXTENDED (GtkGadget,
                        gtk_gadget,
                        GTK_TYPE_WIDGET,
                        0,
                        G_ADD_PRIVATE (GtkGadget)
                        G_IMPLEMENT_INTERFACE (TYPE_GIZMO,
                                               gtk_gadget_gizmo_init));

expands to

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
static void     gtk_gadget_init       (GtkGadget      *self);
static void     gtk_gadget_class_init (GtkGadgetClass *klass);
static gpointer gtk_gadget_parent_class = NULL;
static gint     GtkGadget_private_offset;
static void     gtk_gadget_class_intern_init (gpointer klass)
{
  gtk_gadget_parent_class = g_type_class_peek_parent (klass);
  if (GtkGadget_private_offset != 0)
    g_type_class_adjust_private_offset (klass, &GtkGadget_private_offset);
  gtk_gadget_class_init ((GtkGadgetClass*) klass);
}
static inline gpointer gtk_gadget_get_instance_private (GtkGadget *self)
{
  return (G_STRUCT_MEMBER_P (self, GtkGadget_private_offset));
}

GType
gtk_gadget_get_type (void)
{
  static gsize static_g_define_type_id = 0;
  if (g_once_init_enter (&static_g_define_type_id))
    {
      GType g_define_type_id =
        g_type_register_static_simple (GTK_TYPE_WIDGET,
                                       g_intern_static_string ("GtkGadget"),
                                       sizeof (GtkGadgetClass),
                                       (GClassInitFunc) gtk_gadget_class_intern_init,
                                       sizeof (GtkGadget),
                                       (GInstanceInitFunc) gtk_gadget_init,
                                       0);
      {
        GtkGadget_private_offset =
          g_type_add_instance_private (g_define_type_id, sizeof (GtkGadgetPrivate));
      }
      {
        const GInterfaceInfo g_implement_interface_info = {
          (GInterfaceInitFunc) gtk_gadget_gizmo_init
        };
        g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
      }
      g_once_init_leave (&static_g_define_type_id, g_define_type_id);
    }
  return static_g_define_type_id;
}

The only pieces which have to be manually provided are the definitions of the instance and class structure and the definitions of the instance and class init functions.

Parameters

TN

The name of the new type, in Camel case.

 

t_n

The name of the new type, in lowercase, with words separated by _.

 

T_P

The GType of the parent type.

 

_f_

GTypeFlags to pass to g_type_register_static()

 

_C_

Custom code that gets inserted in the *_get_type() function.

 

Since: 2.4


G_DEFINE_BOXED_TYPE()

#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})

A convenience macro for defining a new custom boxed type.

Using this macro is the recommended way of defining new custom boxed types, over calling g_boxed_type_register_static() directly. It defines a type_name_get_type() function which will return the newly defined GType, enabling lazy instantiation.

You might start by putting declarations in a header as follows:

1
2
3
4
5
6
#define MY_TYPE_STRUCT my_struct_get_type ()
GType my_struct_get_type (void) G_GNUC_CONST;

MyStruct *    my_struct_new (void);
void          my_struct_free (MyStruct *self);
MyStruct *    my_struct_copy (MyStruct *self);

And then use this macro and define your implementation in the source file as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
MyStruct *
my_struct_new (void)
{
  // ... your code to allocate a new MyStruct ...
}

void
my_struct_free (MyStruct *self)
{
  // ... your code to free a MyStruct ...
}

MyStruct *
my_struct_copy (MyStruct *self)
{
  // ... your code return a newly allocated copy of a MyStruct ...
}

G_DEFINE_BOXED_TYPE (MyStruct, my_struct, my_struct_copy, my_struct_free)

void 
foo ()
{
  MyStruct *ms;

  ms = my_struct_new ();
  // ... your code ...
  my_struct_free (ms);
}

Parameters

TypeName

The name of the new type, in Camel case

 

type_name

The name of the new type, in lowercase, with words separated by _

 

copy_func

the GBoxedCopyFunc for the new type

 

free_func

the GBoxedFreeFunc for the new type

 

Since: 2.26


G_DEFINE_BOXED_TYPE_WITH_CODE()

#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()

A convenience macro for boxed type implementations.

Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the type_name_get_type() function, e.g. to register value transformations with g_value_register_transform_func(), for instance:

1
2
3
4
G_DEFINE_BOXED_TYPE_WITH_CODE (GdkRectangle, gdk_rectangle,
                               gdk_rectangle_copy,
                               gdk_rectangle_free,
                               register_rectangle_transform_funcs (g_define_type_id))

Similarly to the G_DEFINE_TYPE_* family of macros, the GType of the newly defined boxed type is exposed in the g_define_type_id variable.

Parameters

TypeName

The name of the new type, in Camel case

 

type_name

The name of the new type, in lowercase, with words separated by _

 

copy_func

the GBoxedCopyFunc for the new type

 

free_func

the GBoxedFreeFunc for the new type

 

_C_

Custom code that gets inserted in the *_get_type() function

 

Since: 2.26


G_DEFINE_POINTER_TYPE()

#define G_DEFINE_POINTER_TYPE(TypeName, type_name) G_DEFINE_POINTER_TYPE_WITH_CODE (TypeName, type_name, {})

A convenience macro for pointer type implementations, which defines a type_name_get_type() function registering the pointer type.

Parameters

TypeName

The name of the new type, in Camel case

 

type_name

The name of the new type, in lowercase, with words separated by _

 

Since: 2.26


G_DEFINE_POINTER_TYPE_WITH_CODE()

#define G_DEFINE_POINTER_TYPE_WITH_CODE(TypeName, type_name, _C_) _G_DEFINE_POINTER_TYPE_BEGIN (TypeName, type_name) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()

A convenience macro for pointer type implementations. Similar to G_DEFINE_POINTER_TYPE(), but allows to insert custom code into the type_name_get_type() function.

Parameters

TypeName

The name of the new type, in Camel case

 

type_name

The name of the new type, in lowercase, with words separated by _

 

_C_

Custom code that gets inserted in the *_get_type() function

 

Since: 2.26


G_DEFINE_ENUM_VALUE()

#define             G_DEFINE_ENUM_VALUE(EnumValue, EnumNick)

Defines an enumeration value, and maps it to a "nickname".

This macro can only be used with G_DEFINE_ENUM_TYPE() and G_DEFINE_FLAGS_TYPE().

Parameters

EnumValue

an enumeration value

 

EnumNick

a short string representing the enumeration value

 

Since: 2.74


G_DEFINE_ENUM_TYPE()

#define             G_DEFINE_ENUM_TYPE(TypeName, type_name, ...)

A convenience macro for defining enumeration types.

This macro will generate a *_get_type() function for the given TypeName , using type_name as the function prefix.

1
2
3
G_DEFINE_ENUM_TYPE (GtkOrientation, gtk_orientation,
  G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_HORIZONTAL, "horizontal"),
  G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_VERTICAL, "vertical"))

For projects that have multiple enumeration types, or enumeration types with many values, you should consider using glib-mkenums to generate the type function.

Parameters

TypeName

the enumeration type, in CamelCase

 

type_name

the enumeration type prefixed, in snake_case

 

...

a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()

 

Since: 2.74


G_DEFINE_FLAGS_TYPE()

#define             G_DEFINE_FLAGS_TYPE(TypeName, type_name, ...)

A convenience macro for defining flag types.

This macro will generate a *_get_type() function for the given TypeName , using type_name as the function prefix.

1
2
3
4
5
6
7
G_DEFINE_FLAGS_TYPE (GSettingsBindFlags, g_settings_bind_flags,
  G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_DEFAULT, "default"),
  G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET, "get"),
  G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_SET, "set"),
  G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_NO_SENSITIVITY, "no-sensitivity"),
  G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_GET_NO_CHANGES, "get-no-changes"),
  G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_INVERT_BOOLEAN, "invert-boolean"))

For projects that have multiple enumeration types, or enumeration types with many values, you should consider using glib-mkenums to generate the type function.

Parameters

TypeName

the enumeration type, in CamelCase

 

type_name

the enumeration type prefixed, in snake_case

 

...

a list of enumeration values, defined using G_DEFINE_ENUM_VALUE()

 

Since: 2.74

Types and Values

GType

A numerical value which represents the unique identifier of a registered type.


G_TYPE_FUNDAMENTAL_MAX

#define G_TYPE_FUNDAMENTAL_MAX		(255 << G_TYPE_FUNDAMENTAL_SHIFT)

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


struct GTypeInterface

struct GTypeInterface {
};

An opaque structure used as the base of all interface types.


struct GTypeInstance

struct GTypeInstance {
};

An opaque structure used as the base of all type instances.


struct GTypeClass

struct GTypeClass {
};

An opaque structure used as the base of all classes.


struct GTypeInfo

struct GTypeInfo {
  /* interface types, classed types, instantiated types */
  guint16                class_size;

  GBaseInitFunc          base_init;
  GBaseFinalizeFunc      base_finalize;

  /* interface types, classed types, instantiated types */
  GClassInitFunc         class_init;
  GClassFinalizeFunc     class_finalize;
  gconstpointer          class_data;

  /* instantiated types */
  guint16                instance_size;
  guint16                n_preallocs;
  GInstanceInitFunc      instance_init;

  /* value handling */
  const GTypeValueTable *value_table;
};

This structure is used to provide the type system with the information required to initialize and destruct (finalize) a type's class and its instances.

The initialized structure is passed to the g_type_register_static() function (or is copied into the provided GTypeInfo structure in the g_type_plugin_complete_type_info()). The type system will perform a deep copy of this structure, so its memory does not need to be persistent across invocation of g_type_register_static().

Members

guint16 class_size;

Size of the class structure (required for interface, classed and instantiatable types)

 

GBaseInitFunc base_init;

Location of the base initialization function (optional)

 

GBaseFinalizeFunc base_finalize;

Location of the base finalization function (optional)

 

GClassInitFunc class_init;

Location of the class initialization function for classed and instantiatable types. Location of the default vtable inititalization function for interface types. (optional) This function is used both to fill in virtual functions in the class or default vtable, and to do type-specific setup such as registering signals and object properties.

 

GClassFinalizeFunc class_finalize;

Location of the class finalization function for classed and instantiatable types. Location of the default vtable finalization function for interface types. (optional)

 

gconstpointer class_data;

User-supplied data passed to the class init/finalize functions

 

guint16 instance_size;

Size of the instance (object) structure (required for instantiatable types only)

 

guint16 n_preallocs;

Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the slice allocator now.

 

GInstanceInitFunc instance_init;

Location of the instance initialization function (optional, for instantiatable types only)

 

const GTypeValueTable *value_table;

A GTypeValueTable function table for generic handling of GValues of this type (usually only useful for fundamental types)

 

struct GTypeFundamentalInfo

struct GTypeFundamentalInfo {
  GTypeFundamentalFlags  type_flags;
};

A structure that provides information to the type system which is used specifically for managing fundamental types.

Members

GTypeFundamentalFlags type_flags;

GTypeFundamentalFlags describing the characteristics of the fundamental type

 

struct GInterfaceInfo

struct GInterfaceInfo {
  GInterfaceInitFunc     interface_init;
  GInterfaceFinalizeFunc interface_finalize;
  gpointer               interface_data;
};

A structure that provides information to the type system which is used specifically for managing interface types.

Members

GInterfaceInitFunc interface_init;

location of the interface initialization function

 

GInterfaceFinalizeFunc interface_finalize;

location of the interface finalization function

 

gpointer interface_data;

user-supplied data passed to the interface init/finalize functions

 

struct GTypeValueTable

struct GTypeValueTable {
  void     (*value_init)         (GValue       *value);
  void     (*value_free)         (GValue       *value);
  void     (*value_copy)         (const GValue *src_value,
				  GValue       *dest_value);
  /* varargs functionality (optional) */
  gpointer (*value_peek_pointer) (const GValue *value);
  const gchar *collect_format;
  gchar*   (*collect_value)      (GValue       *value,
				  guint         n_collect_values,
				  GTypeCValue  *collect_values,
				  guint		collect_flags);
  const gchar *lcopy_format;
  gchar*   (*lcopy_value)        (const GValue *value,
				  guint         n_collect_values,
				  GTypeCValue  *collect_values,
				  guint		collect_flags);
};

The GTypeValueTable provides the functions required by the GValue implementation, to serve as a container for values of a type.

Members

value_init ()

Default initialize values contents by poking values directly into the value->data array. The data array of the GValue passed into this function was zero-filled with memset(), so no care has to be taken to free any old contents. E.g. for the implementation of a string value that may never be NULL, the implementation might look like:

1
value->data[0].v_pointer = g_strdup ("");

 

value_free ()

Free any old contents that might be left in the data array of the passed in value . No resources may remain allocated through the GValue contents after this function returns. E.g. for our above string type:

1
2
3
// only free strings without a specific flag for static storage
if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
g_free (value->data[0].v_pointer);

 

value_copy ()

dest_value is a GValue with zero-filled data section and src_value is a properly setup GValue of same or derived type. The purpose of this function is to copy the contents of src_value into dest_value in a way, that even after src_value has been freed, the contents of dest_value remain valid. String type example:

1
dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);

 

value_peek_pointer ()

If the value contents fit into a pointer, such as objects or strings, return this pointer, so the caller can peek at the current contents. To extend on our above string example:

1
return value->data[0].v_pointer;

 

const gchar *collect_format;

A string format describing how to collect the contents of this value bit-by-bit. Each character in the format represents an argument to be collected, and the characters themselves indicate the type of the argument. Currently supported arguments are:

  • 'i' - Integers. passed as collect_values[].v_int.

  • 'l' - Longs. passed as collect_values[].v_long.

  • 'd' - Doubles. passed as collect_values[].v_double.

  • 'p' - Pointers. passed as collect_values[].v_pointer. It should be noted that for variable argument list construction, ANSI C promotes every type smaller than an integer to an int, and floats to doubles. So for collection of short int or char, 'i' needs to be used, and for collection of floats 'd'.

 

collect_value ()

The collect_value() function is responsible for converting the values collected from a variable argument list into contents suitable for storage in a GValue. This function should setup value similar to value_init(); e.g. for a string value that does not allow NULL pointers, it needs to either spew an error, or do an implicit conversion by storing an empty string. The value passed in to this function has a zero-filled data array, so just like for value_init() it is guaranteed to not contain any old contents that might need freeing. n_collect_values is exactly the string length of collect_format , and collect_values is an array of unions GTypeCValue with length n_collect_values , containing the collected values according to collect_format . collect_flags is an argument provided as a hint by the caller. It may contain the flag G_VALUE_NOCOPY_CONTENTS indicating, that the collected value contents may be considered "static" for the duration of the value lifetime. Thus an extra copy of the contents stored in collect_values is not required for assignment to value . For our above string example, we continue with:

1
2
3
4
5
6
7
8
9
10
11
if (!collect_values[0].v_pointer)
value->data[0].v_pointer = g_strdup ("");
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
{
value->data[0].v_pointer = collect_values[0].v_pointer;
// keep a flag for the value_free() implementation to not free this string
value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
}
else
value->data[0].v_pointer = g_strdup (collect_values[0].v_pointer);
return NULL;

It should be noted, that it is generally a bad idea to follow the G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to reentrancy requirements and reference count assertions performed by the signal emission code, reference counts should always be incremented for reference counted contents stored in the value->data array. To deviate from our string example for a moment, and taking a look at an exemplary implementation for collect_value() of GObject:

1
2
3
4
5
6
GObject *object = G_OBJECT (collect_values[0].v_pointer);
g_return_val_if_fail (object != NULL,
g_strdup_printf ("Object passed as invalid NULL pointer"));
// never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types
value->data[0].v_pointer = g_object_ref (object);
return NULL;

The reference count for valid objects is always incremented, regardless of collect_flags . For invalid objects, the example returns a newly allocated string without altering value . Upon success, collect_value() needs to return NULL. If, however, an error condition occurred, collect_value() may spew an error by returning a newly allocated non-NULL string, giving a suitable description of the error condition. The calling code makes no assumptions about the value contents being valid upon error returns, value is simply thrown away without further freeing. As such, it is a good idea to not allocate GValue contents, prior to returning an error, however, collect_values() is not obliged to return a correctly setup value for error returns, simply because any non-NULL return is considered a fatal condition so further program behaviour is undefined.

 

const gchar *lcopy_format;

Format description of the arguments to collect for lcopy_value , analogous to collect_format . Usually, lcopy_format string consists only of 'p's to provide lcopy_value() with pointers to storage locations.

 

lcopy_value ()

This function is responsible for storing the value contents into arguments passed through a variable argument list which got collected into collect_values according to lcopy_format . n_collect_values equals the string length of lcopy_format , and collect_flags may contain G_VALUE_NOCOPY_CONTENTS. In contrast to collect_value(), lcopy_value() is obliged to always properly support G_VALUE_NOCOPY_CONTENTS. Similar to collect_value() the function may prematurely abort by returning a newly allocated string describing an error condition. To complete the string example:

1
2
3
4
5
6
7
gchar **string_p = collect_values[0].v_pointer;
g_return_val_if_fail (string_p != NULL,
g_strdup_printf ("string location passed as NULL"));
if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
*string_p = value->data[0].v_pointer;
else
*string_p = g_strdup (value->data[0].v_pointer);

And an illustrative version of lcopy_value() for reference-counted types:

1
2
3
4
5
6
7
8
9
10
GObject **object_p = collect_values[0].v_pointer;
g_return_val_if_fail (object_p != NULL,
g_strdup_printf ("object location passed as NULL"));
if (!value->data[0].v_pointer)
*object_p = NULL;
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) // always honour
*object_p = value->data[0].v_pointer;
else
*object_p = g_object_ref (value->data[0].v_pointer);
return NULL;

 

G_TYPE_FLAG_RESERVED_ID_BIT

#define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0))

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


enum GTypeDebugFlags

GTypeDebugFlags has been deprecated since version 2.36 and should not be used in newly-written code.

g_type_init() is now done automatically

These flags used to be passed to g_type_init_with_debug_flags() which is now deprecated.

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

Members

G_TYPE_DEBUG_NONE

Print no messages

 

G_TYPE_DEBUG_OBJECTS

Print messages about object bookkeeping

 

G_TYPE_DEBUG_SIGNALS

Print messages about signal emissions

 

G_TYPE_DEBUG_INSTANCE_COUNT

Keep a count of instances of each type

 

G_TYPE_DEBUG_MASK

Mask covering all debug flags

 

struct GTypeQuery

struct GTypeQuery {
  GType		type;
  const gchar  *type_name;
  guint		class_size;
  guint		instance_size;
};

A structure holding information for a specific type.

See also: g_type_query()

Members

GType type;

the GType value of the type

 

const gchar *type_name;

the name of the type

 

guint class_size;

the size of the class structure

 

guint instance_size;

the size of the instance structure

 

enum GTypeFlags

Bit masks used to check or determine characteristics of a type.

Members

G_TYPE_FLAG_NONE

No special flags. Since: 2.74

 

G_TYPE_FLAG_ABSTRACT

Indicates an abstract type. No instances can be created for an abstract type

 

G_TYPE_FLAG_VALUE_ABSTRACT

Indicates an abstract value type, i.e. a type that introduces a value table, but can't be used for g_value_init()

 

G_TYPE_FLAG_FINAL

Indicates a final type. A final type is a non-derivable leaf node in a deep derivable type hierarchy tree. Since: 2.70

 

enum GTypeFundamentalFlags

Bit masks used to check or determine specific characteristics of a fundamental type.

Members

G_TYPE_FLAG_CLASSED

Indicates a classed type

 

G_TYPE_FLAG_INSTANTIATABLE

Indicates an instantiatable type (implies classed)

 

G_TYPE_FLAG_DERIVABLE

Indicates a flat derivable type

 

G_TYPE_FLAG_DEEP_DERIVABLE

Indicates a deep derivable type (implies derivable)

 

G_TYPE_INVALID

#define G_TYPE_INVALID			G_TYPE_MAKE_FUNDAMENTAL (0)

An invalid GType used as error return value in some functions which return a GType.


G_TYPE_NONE

#define G_TYPE_NONE			G_TYPE_MAKE_FUNDAMENTAL (1)

A fundamental type which is used as a replacement for the C void return type.


G_TYPE_INTERFACE

#define G_TYPE_INTERFACE		G_TYPE_MAKE_FUNDAMENTAL (2)

The fundamental type from which all interfaces are derived.


G_TYPE_CHAR

#define G_TYPE_CHAR			G_TYPE_MAKE_FUNDAMENTAL (3)

The fundamental type corresponding to gchar.

The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. This may or may not be the same type a the C type "gchar".


G_TYPE_UCHAR

#define G_TYPE_UCHAR			G_TYPE_MAKE_FUNDAMENTAL (4)

The fundamental type corresponding to guchar.


G_TYPE_BOOLEAN

#define G_TYPE_BOOLEAN			G_TYPE_MAKE_FUNDAMENTAL (5)

The fundamental type corresponding to gboolean.


G_TYPE_INT

#define G_TYPE_INT			G_TYPE_MAKE_FUNDAMENTAL (6)

The fundamental type corresponding to gint.


G_TYPE_UINT

#define G_TYPE_UINT			G_TYPE_MAKE_FUNDAMENTAL (7)

The fundamental type corresponding to guint.


G_TYPE_LONG

#define G_TYPE_LONG			G_TYPE_MAKE_FUNDAMENTAL (8)

The fundamental type corresponding to glong.


G_TYPE_ULONG

#define G_TYPE_ULONG			G_TYPE_MAKE_FUNDAMENTAL (9)

The fundamental type corresponding to gulong.


G_TYPE_INT64

#define G_TYPE_INT64			G_TYPE_MAKE_FUNDAMENTAL (10)

The fundamental type corresponding to gint64.


G_TYPE_UINT64

#define G_TYPE_UINT64			G_TYPE_MAKE_FUNDAMENTAL (11)

The fundamental type corresponding to guint64.


G_TYPE_ENUM

#define G_TYPE_ENUM			G_TYPE_MAKE_FUNDAMENTAL (12)

The fundamental type from which all enumeration types are derived.


G_TYPE_FLAGS

#define G_TYPE_FLAGS			G_TYPE_MAKE_FUNDAMENTAL (13)

The fundamental type from which all flags types are derived.


G_TYPE_FLOAT

#define G_TYPE_FLOAT			G_TYPE_MAKE_FUNDAMENTAL (14)

The fundamental type corresponding to gfloat.


G_TYPE_DOUBLE

#define G_TYPE_DOUBLE			G_TYPE_MAKE_FUNDAMENTAL (15)

The fundamental type corresponding to gdouble.


G_TYPE_STRING

#define G_TYPE_STRING			G_TYPE_MAKE_FUNDAMENTAL (16)

The fundamental type corresponding to nul-terminated C strings.


G_TYPE_POINTER

#define G_TYPE_POINTER			G_TYPE_MAKE_FUNDAMENTAL (17)

The fundamental type corresponding to gpointer.


G_TYPE_BOXED

#define G_TYPE_BOXED			G_TYPE_MAKE_FUNDAMENTAL (18)

The fundamental type from which all boxed types are derived.


G_TYPE_PARAM

#define G_TYPE_PARAM			G_TYPE_MAKE_FUNDAMENTAL (19)

The fundamental type from which all GParamSpec types are derived.


G_TYPE_OBJECT

#define G_TYPE_OBJECT			G_TYPE_MAKE_FUNDAMENTAL (20)

The fundamental type for GObject.


G_TYPE_GTYPE

#define G_TYPE_GTYPE			 (g_gtype_get_type())

The type for GType.


G_TYPE_VARIANT

#define G_TYPE_VARIANT                  G_TYPE_MAKE_FUNDAMENTAL (21)

The fundamental type corresponding to GVariant.

All floating GVariant instances passed through the GType system are consumed.

Note that callbacks in closures, and signal handlers for signals of return type G_TYPE_VARIANT, must never return floating variants.

Note: GLib 2.24 did include a boxed type with this name. It was replaced with this fundamental type in 2.26.

Since: 2.26


G_TYPE_CHECKSUM

#define G_TYPE_CHECKSUM (g_checksum_get_type ())

The GType for a boxed type holding a GChecksum.

Since: 2.36


G_TYPE_RESERVED_GLIB_FIRST

#define G_TYPE_RESERVED_GLIB_FIRST (22)

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


G_TYPE_RESERVED_GLIB_LAST

#define G_TYPE_RESERVED_GLIB_LAST (31)

Last fundamental type number reserved for GLib.


G_TYPE_RESERVED_BSE_FIRST

#define G_TYPE_RESERVED_BSE_FIRST (32)

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


G_TYPE_RESERVED_BSE_LAST

#define G_TYPE_RESERVED_BSE_LAST (48)

Last fundamental type number reserved for BSE.


G_TYPE_RESERVED_USER_FIRST

#define G_TYPE_RESERVED_USER_FIRST (49)

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