Wiki
Version 2 (modified by pyros2097, 11 years ago)

--

GtkNodeView

This is how we create a node view in cobra Just run: cobra nodeview.cobra This was taken from the mono Gtk samples  http://www.mono-project.com/GtkSharpNodeViewTutorialExamples

use System
use Gtk

#uncomment the below line because it doesn't show properly in this wiki 
#@args -pkg:gtk-sharp-2.0


class MyTreeNode inherits TreeNode
    has TreeNode(listOnly=true)
    var artist as String
        has TreeNodeValue(column=0)
    var songTitle as String
        has TreeNodeValue(column=1)

    cue init(artist,song_title)
        base.init
        .artist = artist
        .songTitle = song_title

    def main is shared has STAThread
        Application.init
        store = NodeStore(MyTreeNode("", "").typeOf)
        store.addNode(MyTreeNode("The Beatles", "Yesterday"))
        view = NodeView(store)
        view.appendColumn("Artist", CellRendererText(), "text", 0)
        view.appendColumn("Song Title", CellRendererText(), "text", 1)
        win = Window("node")
        listen win.deleteEvent, ref .quit
        win.add(view)
        win.showAll
        store.addNode(MyTreeNode("The Beatles", "Yesterday"))
        store.addNode(MyTreeNode("The Beatles", "Yesterday"))
        Application.run
        
    def quit(sender ,e) is shared
        Application.quit