Next: , Previous: , Up: Tutorial   [Contents][Index]


2.5 Working with GObjects

GObject is GLib’s class system. It provides many of the facilities one would expect for object-oriented programming in the context of GUIs.

For each custom GObject type, Guile-GI creates a variable that holds the GOOPS type. That variable has the form <TYPE>, where TYPE is the GObject type name. To check whether an object has a given type, use the is-a? procedure found in GOOPS, which Guile-GI re-exports.

(use-modules (gi))
(use-typelibs ("GObject" "2.0") ("Gio" "2.0"))
(is-a? (make <GApplication>) <GObject>)
;; => #t

Each GObject struct, union, or object has a place in the GObject single-inheritance class structure. A RadioButton is a type of Button is a type of Widget, for example.

The native pointer is “hidden” inside a slot of the object. If you need to access it, see Compatibility.