Draft in progress:

If you want to implement a tree model in guile-gnome, you might think you should use the class <gtk-tree-model> -- but you would be wrong. The class you need is the undocumented <guile-gtk-tree-model>.

To make your own tree model, subclass <guile-gtk-tree-model> and then define the following methods on your class. Here we use <tm> for your class. For these methods, an iter can be any scheme type -- it is opaque to everything outside these methods. Below, the method arguments "iter" and "parent" are of this type. A path is represented as a list.

(on-get-n-columns (tm <tm>))

Return the number of columns in the model.

(on-get-column-type (tm <tm>) index)

Returns a class such as <gint>, <gchararray>, etc. corresponding to the type of the column. These classes are defined in the module (gnome gobject)

(on-get-iter (tm <tm>) path)

Return the iter of the row corresponding to path.

(on-get-path (tm <tm>) iter)

Return the path leading to iter.

(on-get-value (tm <tm>) iter index)

Returns the value of the column. Note that the returned value is not actually of the class returned by on-get-column-type, but is of the corresponding scheme type.

(on-iter-next (tm <tm>) iter)

Return the next iter, or #f if there is no next iter.

(on-iter-children (tm <tm>) parent)

Return iter of first child of parent. If parent is #f, return first parentless row. In either case, if there is no such row, return #f.

(on-iter-has-child (tm <tm>) parent)

Return #t if parent has a child, #f if not.

(on-iter-n-children (tm <tm>) parent)

Return number of children of parent. If parent is #f, return number of parentless rows.

(on-iter-nth-child (tm <tm>) parent)

Return iter of nth child of parent. If parent is #f, return iter of nth parentless row.

(on-iter-parent (tm <tm>) iter)

Return iter of parent, or #f if there is no parent.

(on-get-flags (tm <tm>))

Returns type <gtk-tree-model-flags>

Attic/GuileGtkTreeModel (last edited 2013-12-04 19:52:00 by WilliamJonMcCann)