Previous: , Up: Working with GObjects   [Contents][Index]


2.5.5 Defining new GObject classes

Usually any GObjects you use will be created by procedures such as window:new, and those GObject types will have been predefined in the typelib. But, it is possible to make custom GObject object classes using the register-type procedure.

Bear in mind, that while Guile-GI internally uses GOOPS, GObjects implemented in it are not quite as flexible. For instance, you cannot meaningfully redefine a GObject-based type, which you could if you just used GOOPS types. On the other hand, you can make use of the features of the GObject infrastructure, such as signals.

Defining a new GObject class is rather complicated.

Procedure: register-type type-name parent-type [list-of-properties] [list-of-signals]

This procedure creates and returns a new <GType> of a GObject object.

type-name is the string name of the new type. Note, that it will be turned into a symbol internally.

parent-type is the <GType> of the parent class to this class. The parent class needs to be <GObject> or a GObject class that descends from it.

list-of-properties is a list of parameter specifications. These parameter specifications can be created using the param-spec-TYPE methods found in the GObject typelib.

list-of-signals is a list of signal specifications. See GObject Signals.

To then make instances of your custom GObject type, use make.