Defining new classes in GObject

I figured out how to create classes that subclass from GObject and how to implement interfaces on them. A single macro uses interface description to generate code for interface initialization, callbacks (to redirect interface method call to generic function call), and generic functions.

I've tried it out on the GtkTreeModel interfaces and it's working.

This seems to be one of the non-trivial aspects of it.

An example:

(defun test-treeview ()
  (let* ((window (make-instance 'gtk:gtk-window :type :toplevel :title "Treeview" :border-width 30))
         (model (make-instance 'tree-model))
         (tv (make-instance 'gtk:tree-view :model model :headers-visible t)))
    (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk:gtk-main-quit)))
    (let ((column (make-instance 'gtk:tree-view-column :title "Number"))
          (renderer (make-instance 'gtk:cell-renderer-text :text "A text")))
      (%gtk-tree-view-column-pack-start column renderer t)
      (%gtk-tree-view-column-add-attribute column renderer "text" 0)
      (%gtk-tree-view-append-column tv column))
    (gtk:container-add window tv)
    (gtk:gtk-widget-show-all window)
    (gtk:gtk-main)))

treeview