[cells-gtk-devel] tree-view children

Kenny Tilton ktilton at nyc.rr.com
Wed Feb 2 18:42:45 UTC 2005



Peter Denno wrote:

>Hi,
>
>Does anyone here know how the tree-view widget in the example 
>test-gtk/test-tree-view.lisp gets its children? I'd expect that you'd have to 
>supply it with a function which takes an element of the tree and returns a 
>list of its children. By the name of it, :items-factory seems to fit that 
>description, but apparently it only provides the printed representation.
>
>:items (c? (list (upper self gtk-app)))
>:items-factory #'(lambda (item) 
>                   (list 
>                    (format nil "~a" (class-name (class-of item)))
>                    (case (class-name (class-of item))
>                      (gtk-app "home")
>                      (vbox "open")
>                      (hbox "open")
>                      (window "index")
>                      (t "jump-to"))
>                    (length (kids item))
>                    (format nil "~a"
>                            (when (subtypep (class-name (class-of item)) 
>                                            'cells-gtk::gtk-object)
>                              (cells-gtk::id item)))))
>
>
>  
>
Right, items-factory might be better named "item-label-factory", since 
what it does is return the string to be displayed in the widget to 
describe the corresponding underlying item, which can be any arbitrary 
object.

Now, as for where the items come from, well, we can see above the root 
items being defined, so I am guessing you mean where does the subtree of 
items come from once you "open" the tree item.

Damned if I know. :) I have been poking around treebox and tree-view for 
a while, cannot spot anything. My guess, therefore, is that eventually 
we get a callback from Gtk which asks "what are the children of this 
object?". Then some GF is being dispatched on that object. So we have to 
find the callback and then the GF. My guess is that the ubiquitous 
"kids" slot is being sampled in this example, which would be a 
reasonable default for a Cells app. But I would expect an override (what 
"items-factory" sounds like but is not), so perhaps there is some GF 
which calls kids but can be overrode, or some other factory slot is 
being bound to #'kids.

I will look around a little more later on.

kt

-- 
Cells? Cello? Cells-Gtk?: http://www.common-lisp.net/project/cells/
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film

"Doctor, I wrestled with reality for forty years, and I am happy to state that I finally won out over it." -- Elwood P. Dowd





More information about the cells-gtk-devel mailing list