Re: AbstractTreeModel, AbstractListModel



Joel Becker <jlbec evilplan org> writes:

> Folks,
> 	I was poking at the TreeView code today, and I saw that the
> implementation of the models is not quite trivial.  I have recently
> gotten used to the ease of implementing the AbstractTreeModel and
> AbstratTableModel interfaces in Swing, and I was wondering if there was
> any such plan for GTK+.
> 	Basically, I was looking a TreeView displaying an XML tree.  In
> the current available code, I have to build a TreeStore, populate it
> with the tags, and then for every XML change I have to wrapper like:
> 
> add_child()
> {
>     xmlAddChild(parent, child);
>     treeViewAddChild(itr, child->name);
> }
> 
> or the like.  In Java, I just add to the XML, and because I've built a
> Model based on the XML as the backend, the view is happpily up to date.
> 	I looked at GtkTreeStore, and judging by that, implementing all
> of the given interfaces is a lot of work.  Am I wrong in this?
> 	Just curious.

It's not a trivial amount of work, but it's not impossible to implement
a GtkTreeModel interface in a fairly small amount of code (especially if
you have a good data store like you already do.)  GtkTreeStore is
particularly long as it supports things like sorting and Drag and Drop
reordering, both of which are somewhat dubious for an xml view.  There
is a stupid evil wrapper class in testtreecolumns to represent columns
as rows[*], that was written in ~350 lines of code.

Anyway, I think that the gtkhtml2 guys did something like this once
already, though I might be mis-remembering.

Good luck,
-Jonathan

[*] do not look at this code, it might fry your brain. 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]