[Gtk-sharp-list] Adding Managed Data to Trees

Jonathan Pryor jonpryor@vt.edu
09 Jan 2003 16:08:36 -0500

I'm wondering how (assuming that it's possible) "managed"
(mono-maintained) data can be added to a Gtk# TreeStore or TreeView.

For example, suppose that you're writing a file manager (Nautilus#?). 
You don't want to load the entire file system tree all at once.  Rather,
when a node is selected, at *that* point you want to be able to search
for child directories/files and add them to the tree view.

I'm facing a similar situation with the Gtk# front-end for
type-reflector.  There is extra data I want associated with each node in
the tree view, which would be used to determine the child nodes.

With System.Windows.Forms this is straightforward: I subclass
System.Windows.Forms.TreeNode, and add instances of my subclass to the
TreeView.Nodes collection.  Simple.  (In fact, this is what I did for my
"swf" front-end on type-reflector, which behaves the way I'd like the
Gtk# front-end to behave.)

I can't figure out how to do the same (or similar) with Gtk#.  I tried
subclassing GLib.Value to add extra data and adding my new class to the
tree node in the TreeStore.SetValue(TreeIter, int, GLib.Value) method
call.  However, doing this resulted in warning messages printed to the
console and didn't work the way I expected.

A cursory glance (read: several hours of looking and testing) through
the Gtk# source and examples did not enlighten me.

Is this possible right now?  If so, how?

 - Jon