GObject

G-Golf GObject low level API.
GObject — The base object type

Procedures

g-object-class-install-property
g-object-class-find-property
g-object-class-list-properties
g-object-new
g-object-new-with-properties
g-object-ref
g-object-unref
g-object-ref-sink
g-object-ref-count
g-object-is-floating
g-object-add-toggle-ref
g-object-remove-toggle-ref
g-object-type
g-object-type-name
g-object-get-property
g-object-set-property

Object Hierarchy

GObject
  +— GBinding
  +— GInitiallyUnowned
  +— GTypeModule

Description

GObject is the fundamental type providing the common attributes and methods for all object types in GTK+, Pango and other libraries based on GObject. The GObject class provides methods for object construction and destruction, property access methods, and signal support.

Please read the GObject section from the GObject reference manual for a complete description.

Procedures

Note: in this section, unless otherwise specified, the object argument is [must be] a pointer to a GObject (instance).

Procedure: g-object-class-install-property g-class p-id p-spec

Returns nothing.

Installs a new property.

The arguments are g-class a (pointer to a) GObjectClass), p-id the id for the new property, and p-spec the (a pointer to the) GParamSpec for the new property.

All properties should be installed during the class initializer. It is possible to install properties after that, but doing so is not recommend, and specifically, is not guaranteed to be thread-safe vs. use of properties on the same type on other threads.

Note that it is possible to redefine a property in a derived class, by installing a property with the same name. This can be useful at times, e.g. to change the range of allowed values or the default value.

Procedure: g-object-class-find-property g-class name

Returns a pointer or #f.

Obtains and returns (a pointer to) the GParamSpec for name, or #f if g-class (a pointer to a GObjectClass) doesn’t have a property of that name.

Procedure: g-object-class-list-properties g-class

Returns two values.

Obtains and returns (1) the (possibly empty) list of GParamSpec pointers for g-class and (2) its length (the number of properties for g-class).

Procedure: g-object-new gtype

Returns a pointer.

Creates and returns a (pointer to) a new instance of a GObject subtype gtype. All properties are set to there default values.

Procedure: g-object-new-with-properties gtype n-prop names g-values

Returns a pointer.

Creates and returns a (pointer to) a new instance of a GObject subtype gtype. The other arguments are n-prop the number of properties, names a pointer to an array of pointers to strings with the names of each property to be set and values an array of GValue containing the values of each property to be set.

Properties that are not explicitly specified are set to there default values.

Procedure: g-object-ref object

Returns a pointer.

Increases the reference count of object.

Procedure: g-object-unref object

Returns nothing.

Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

Procedure: g-object-ref-sink object

Returns a pointer.

If object has a floating reference, then this call ‘assumes ownership’ of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged.

If object is not floating, then this call adds a new normal reference increasing the reference count by one.

Procedure: g-object-ref-count object

Returns an integer.

Obtains and returns the (public GObject struct field) ref_count value for object.

Procedure: g-object-is-floating object

Returns #t if object has a floating reference, otherwise it returns #f.

Procedure: g-object-add-toggle-ref object notify data

Returns nothing.

Increases the reference count of object by one and sets a callback, notify, to be called when all other references to object are dropped, or when this is already the last reference to object and another reference is established.

Please refer to the GObject g_object_add_toggle_ref documentation for a complete description.

Multiple toggle references may be added to the same gobject, however if there are multiple toggle references to an object, none of them will ever be notified until all but one are removed.

object is (a pointer to) a GObject, notify is a function to call when this reference is the last reference to the object, or is no longer the last reference, and data is (a pointer to) the data to pass to notify. The data argument can be #f.

Procedure: g-object-remove-toggle-ref object notify data

Returns nothing.

Removes a reference added with g-object-add-toggle-ref. The reference count of object is decreased by one.

object is (a pointer to) a GObject, notify is a function to call when this reference is the last reference to the object, or is no longer the last reference, and data is (a pointer to) the data to pass to notify. The data argument can be #f.

Procedure: g-object-type object

Returns the GType (the type id) for object.

Procedure: g-object-type-name object

Returns the GType name for object.

Procedure: g-object-get-property object property [g-type #f]

Returns the property value for object.

The property argument is (must be) a pointer to a valid GIPropertyInfo (property must point to one of the properties infos of the class of object). The g-type argument must be a valid GType value. If #f, which is the default, gi-property-g-type is called.

Procedure: g-object-set-property object property value [g-type #f]

Returns value.

Sets the object property to value. The property argument is (must be) a pointer to a valid GIPropertyInfo (property must point to one of the properties infos of the class of object). The g-type argument must be a valid GType value. If #f, which is the default, gi-property-g-type is called.