[cells-gtk-devel] tree-view children

Peter Denno peter.denno at nist.gov
Thu Feb 3 01:25:36 UTC 2005


On Wednesday 02 February 2005 17:29, Kenny Tilton wrote:
> ΜΑΡΓΙΟΥΛΑΣ ΒΑΣΙΛΕΙΟΣ wrote:
> >
> >gtk-tree-store-set-kids traverse family-kids hierarchy and sets tree-store
> >model.
> >forcing :items to be of type family was propably a bad idea
>
> Well, not too bad looking at this:
> > (defun gtk-tree-store-set-kids (model val-tree par-iter index
> > column-types items-factory &optional path)
> >   (with-tree-iter (iter)
> >     (gtk-ffi::gtk-tree-store-append model iter par-iter)
> >     (gtk-ffi::gtk-tree-store-set model iter
> >       column-types
> >       (append
> >        (funcall items-factory val-tree)
> >        (list (format nil "(~{~d ~})" (reverse (cons index path))))))
> >     (when (subtypep (class-name (class-of val-tree)) 'cells:family)
> >       (loop for sub-tree in (cells:kids val-tree)
> >           for pos from 0 do
> >             (gtk-tree-store-set-kids model sub-tree iter
> >               pos column-types items-factory (cons index path))))))
>
> It looks as if we simply need to work in a GF (gtk-tree-kids?)
> specialized on Family and do some relatively trivial refactoring. Then
> if someone wants a different source of tree branches they simply
> specialize gtk-tree-kids on their class.
>
>     (defmethod gtk-tree-kids ((self family)) (^kids))
>
> and:
> .....
>     (loop for sub-tree in (gtk-tree-kids val-tree)....
>
> kt

Yeah, but is it really necessary for the things in the tree to be CLOS 
objects, and subclasses of family? My trees have over 1000 objects in them. I 
have been using structs. 

I eliminated the test (when (subtypep (class-name (class-of val-tree)) 
'cells:family) and wrote a method on cells:kids for my structs. Seems to 
work. Am I violating the cells model by doing that? Will I pay a price later? 
(I don't know, I have 0 experience with this). If my approach is OK, it is 
better (faster, more flexible) to allow the user to provide a children 
function and not use cells:kids at all --- or allow cells:kids to be the 
default if the child function isn't supplied.

-- 
Best Regards, 
- Peter 

Peter Denno 
National Institute of Standards and Technology, 
Manufacturing System Integration Division, 
100 Bureau Drive, Mail Stop 8264             Tel: +1 301-975-3595 
Gaithersburg, MD, USA 20899-8264          FAX: +1 301-975-4694



More information about the cells-gtk-devel mailing list