GObject

G-Golf GObject interfaces.
The G-Golf integration with the GLib Object System.


_ SPECIAL NOTE _

For completion, this section exposes the definition of the classes and metaclasses involved in the G-Golf integration of the GLib Object System. From a (strict) user point of view however, these are actually G-Golf internals and, unless you are interested of course, might be ignored.

What you actually really need to know, as a G-Golf user, is mostly (a) the upstream reference manual of the GNOME library(ies) you intend to use, (b) how to program in Guile Scheme of course, and (c) the basics of the Guile Object Oriented System.

It doesn’t hurt if you are, or if you are willing to become one, but we would like to emphasize that you do not need to be a Guile Object Oriented System expert to use G-Golf. What you need to know, with that respect, is somehow largely covered by the Getting Started with G-Golf sections, the description of this (and related) sections and in the examples that come with G-Golf.


Classes

<gobject>
<ginterface>
<gobject-class>
<gtype-class>
<gtype-instance>

Procedures, Accessors and Methods

gobject-class?
!info
!derived
!namespace
!g-type
!g-name (2)
!g-class
!g-inst
unref

Description

GObject17 is the GLib Object System.

The GLib Object System - a C based object-oriented framework and APIs - is composed of three principal elements: (1) GType18, the lower-level GLib Dynamic Type System, (2) GObject, the base object type and (3) the GObject closures and signals messaging system.

All the GNOME libraries that use the GLib type system inherit from GObject, the base object type, which provides methods for object construction and destruction, property access methods, and signal support.

G-Golf uses GOOPS19 and defines the <gobject> class, from which all imported GNOME libraries inherit, as their class hierarchy is being built in Guile Scheme.

Classes

Class: <gobject>

The base class of the GLib Object System.

It is an instance of <gobject-class>.

Superclasses are:

<gtype-instance>

Class Precedence List:

<gobject>
<gtype-instance>
<object>
<top>

(No direct slot)

Class: <ginterface>

The base class for GLib’s interface types. Not derivable in Scheme.

It is an instance of <gobject-class>.

Superclasses are:

<gtype-instance>

Class Precedence List:

<ginterface>
<gtype-instance>
<object>
<top>

(No direct slot)

Class: <gobject-class>

The metaclass of the <gobject> and <ginterface> classes.

It is an instance of <class>.

Superclasses are:

<gtype-class>

Class Precedence List:

<gobject-class>
<gtype-class>
<class>
<object>
<top>

(No direct slot)

Class: <gtype-class>

The metaclass of all GType classes. Ensures that GType classes have an info slot, holding a pointer to either a GIObjectInfo or a GIInterfaceInfo.

It is an instance of <class>.

Superclasses are:

<class>

Class Precedence List:

<gtype-class>
<class>
<object>
<top>

Direct slots are:

info

#:accessor !info
#:init-keyword #:info

derived

#:accessor !derived
#:init-keyword #:derived
#:init-value #f

A class is derived when it is user defined (not imported), and inherit a <gobject> subclass.

namespace

#:accessor !namespace

g-type

#:accessor !g-type

g-name

#:accessor !g-name

g-class

#:accessor !g-class

The #:info #:init-keyword is mandatory, other slots are initialized automatically. All slots are immutable (to be precise, they are not meant to be mutated, see GOOPS Notes and Conventions, ’Slots are not Immutable’).

Accessor: !info (inst <gtype-class>)
Accessor: !derived (inst <gtype-class>)
Accessor: !namespace (inst <gtype-class>)
Accessor: !g-type (inst <gtype-class>)
Accessor: !g-name (inst <gtype-class>)
Accessor: !g-class (inst <gtype-class>)

Returns the content of their respective slot for inst.

Class: <gtype-instance>

The root class of all instantiable GType classes. Adds a slot, g-inst, to instances, which holds a pointer to the C value.

It is an instance of <gtype-class>.

Superclasses are:

<object>

Class Precedence List:

<gtype-instance>
<object>
<top>

Direct slots are:

g-inst

#:accessor !g-inst

The g-inst slot is initialized automatically and immutable (to be precise, it is not meant to be mutated, see GOOPS Notes and Conventions, ’Slots are not Immutable’).

Accessor: !g-inst (inst <gtype-instance>)

Returns the content of the g-inst slot for instance.

Method: unref (inst <gtype-instance>)

Returns nothing.

This method calls g-object-unref on the g-inst of instance.

When the reference count for the g-inst reaches 0 (zero), it sets the g-inst slot value for instance to #f and removes instance from the %g-inst-cache.

Note that it used to be mandatory to call this method upon unreachable instances, so that their memory could be freed by the next gc (garbage collector) occurrence, but this is not the case anymore, as auto gc of unreachable <gobject> instances is a now feature [since August 2021].

Procedures

Procedure: gobject-class? val

Returns #t if val is a class and if <gobject> is a member of its class precedence list. Otherwise, it returns #f.


Footnotes

(17)

The name GObject, depending on the context, can actually be used and refer to the GLib Object System language system as a all, or be used and refer to the fundamental type implementation, the base object type, upon which GNOME libraries object hierarchies are based.

(18)

The name GType, depending on the context, can actually be used and refer to the The GLib Dynamic Type System, or be used and refer to the type it denotes, a unique ID (Identifier) - an unsigned-long to be precise.

(19)

The Guile Object Oriented System (see GOOPS in The GNU Guile Reference Manual). If you haven’t done so already, please make sure you read both the Naming Conventions and GOOPS Notes and Conventions sections.