| 1 | == GtkNodeView == |
| 2 | This is how we create a node view in cobra |
| 3 | Just run: cobra nodeview.cobra |
| 4 | This was taken from the mono Gtk samples |
| 5 | http://www.mono-project.com/GtkSharpNodeViewTutorialExamples |
| 6 | {{{ |
| 7 | #!cobra |
| 8 | use System |
| 9 | use Gtk |
| 10 | |
| 11 | @args -pkg:gtk-sharp-2.0 |
| 12 | |
| 13 | class MyTreeNode inherits TreeNode |
| 14 | has TreeNode(listOnly=true) |
| 15 | var artist as String |
| 16 | has TreeNodeValue(column=0) |
| 17 | var songTitle as String |
| 18 | has TreeNodeValue(column=1) |
| 19 | |
| 20 | cue init(artist,song_title) |
| 21 | base.init |
| 22 | .artist = artist |
| 23 | .songTitle = song_title |
| 24 | |
| 25 | def main is shared has STAThread |
| 26 | Application.init |
| 27 | store = NodeStore(MyTreeNode("", "").typeOf) |
| 28 | store.addNode(MyTreeNode("The Beatles", "Yesterday")) |
| 29 | view = NodeView(store) |
| 30 | view.appendColumn("Artist", CellRendererText(), "text", 0) |
| 31 | view.appendColumn("Song Title", CellRendererText(), "text", 1) |
| 32 | win = Window("node") |
| 33 | listen win.deleteEvent, ref .quit |
| 34 | win.add(view) |
| 35 | win.showAll |
| 36 | store.addNode(MyTreeNode("The Beatles", "Yesterday")) |
| 37 | store.addNode(MyTreeNode("The Beatles", "Yesterday")) |
| 38 | Application.run |
| 39 | |
| 40 | def quit(sender ,e) is shared |
| 41 | Application.quit |
| 42 | }}} |