#7 Implementing a TreeModel in Ruby

open
Masao Mutoh
None
5
2006-09-13
2006-08-30
Gustav Munkby
No

I currently have an implementation of a directed
adjacency graph, which I would like to display in a
TreeView.

Currently, I'm forced to copy my values and the
adjacency information into a TreeStore. The TreeStore
however does not know that the the same node can be
reached by many different paths in a graph, and
therefore synchronizing the content of the treestore
with the graph becomes burdensome.

In this case it would be more natural with a new
implementation of TreeModel, which would allow me to
define the appropriate behaviour for the different methods.

A straight-forward implementation of such a device
would mean implementing the GtkTreeModel interface and
delegating all functions to a Ruby object. Since I know
very little about both Ruby C programming as well as
GTK C programming, I don't know how complicated this
request is. Judging by the following tutorial, the
second part doesn't seem so complicated.

http://scentric.net/tutorial/sec-custom-models.html

In a dream world, the interface would be "Rubyfied" and
one would be able to write a nice "Rubyish"
implementation of a tree model, where iters would be
replaced by normal Ruby objects, and get_children
should return an enumeration rather than a pointer, and
so on. This I guess would be more complicated, and not
really "neccessary".

I'm writing this as a feature request because a search
for TreeModel on the mailing lists returned lots of
threads about other people wanting to implement
TreeModels in Ruby.

Discussion

  • Gustav Munkby
    Gustav Munkby
    2006-09-13

    • assigned_to: nobody --> mutoh