using System; using System.Collections; using System.Reflection; using System.Runtime.InteropServices; using Gtk; namespace AdaptorTest { public class TreeViewAdaptor : TreeView { ListAdaptor store; public ArrayList column_mappings = new ArrayList (); public ArrayList column_types = new ArrayList (); public TreeViewAdaptor (ListAdaptor store) : base (IntPtr.Zero) { string[] names = { "model" }; GLib.Value[] vals = { new GLib.Value (store) }; CreateNativeObject (names, vals); vals [0].Dispose (); this.ListAdaptor = store; } public TreeViewAdaptor () : base () {} [DllImport("/usr/lib/libgtk-x11-2.0.so")] static extern void gtk_tree_view_set_model(IntPtr raw, IntPtr model); ~TreeViewAdaptor () { // Make it more easy for the garbage collector if (this.store != null) this.store.TreeViewAdaptor = null; } public ListAdaptor ListAdaptor { get { return store; } set { // Make it more easy for the garbage collector if (this.store != null) this.store.TreeViewAdaptor = null; value.TreeViewAdaptor = this; store = value; gtk_tree_view_set_model (Handle, store == null ? IntPtr.Zero : store.Handle); } } public Gtk.TreeViewColumn AppendColumn (string title, string MappingName, GLib.GType ctype, Gtk.CellRenderer cell, Gtk.NodeCellDataFunc cell_data) { Gtk.TreeViewColumn col = new Gtk.TreeViewColumn (title,cell, new object[0]); AppendColumn (col); this.column_mappings.Add (MappingName); this.column_types.Add (ctype); return col; } } }