Next: , Up: Generating type definitions by introspection


4.13.1 define-g-object-class

— Macro: define-g-object-class
     (define-g-object-class g-type-name name
       (&key (superclass 'g-object) (export t) interfaces type-initializer)
       (&rest property*))
     
     property ::= (name accessor gname type readable writable)
     property ::= (:cffi name acessor type reader writer)

Parameters of define-g-object-class

superclass
A symbol naming the superclass of this class
export
Whether to export the name of the class and names of autogenerated properties names from the current package.
interfaces
A list of interfaces the this class implements
type-initializer
A string naming the type initiliazer function. It is usually named class_get_type.
properties
A list of slots of a class

Parameters of property:

name
A symbol naming the slot
accessor
A symbol naming the accessor function for this slot
gname
A string naming the property of GObject
type
A string naming the type of property of GObject (for GObject properties); or a symbol naming CFFI foreign type (for slots mapped to foreign accessors)
readable
A boolean specifying whether the slot can be read
writable
A boolean specifying whether the slot can be assigned to
reader
A string or a symbol naming getter function. See description of gobject-class metaclass for information.
writter
A string or a symbol naming setter function. See description of gobject-class metaclass for information.

Macro that expands to defclass for specified class. Additionally, if export is true, it exports accessor names and name of a class.

Example:

     (define-g-object-class "GtkContainer" container
       (:superclass widget :export t :interfaces
                    ("AtkImplementorIface" "GtkBuildable")
                    :type-initializer "gtk_container_get_type")
       ((border-width container-border-width "border-width" "guint" t t)
        (resize-mode container-resize-mode "resize-mode" "GtkResizeMode" t t)
        (child container-child "child" "GtkWidget" nil t)
        (:cffi focus-child container-focus-child g-object "gtk_container_get_focus_child" "gtk_container_set_focus_child")
        (:cffi focus-vadjustment container-focus-vadjustment (g-object adjustment) "gtk_container_get_focus_vadjustment" "gtk_container_set_focus_vadjustment")
        (:cffi focus-hadjustment container-focus-hadjustment (g-object adjustment) "gtk_container_get_focus_hadjustment" "gtk_container_set_focus_hadjustment")))