// Compile with: valac --pkg=gtk+-2.0 ./treeview-editable.vala using Gtk; public class MyWindow : Window { private TreeView treeview; private ListStore model; public MyWindow() { GLib.Object( type: WindowType.TOPLEVEL, default_height: 240, default_width: 140 ); } construct { // Treeview model = new ListStore(2, typeof(int), typeof(bool)); fill_model(); treeview = new TreeView(); treeview.set_model(model); var cell = new CellRendererText(); treeview.insert_column_with_attributes(-1, "Text", cell, "text", 0, "editable", 1, null); // Scrolled window var scrolled_window = new ScrolledWindow(null, null); scrolled_window.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); scrolled_window.add(treeview); // VBox var vbox = new VBox(false, 5); vbox.pack_start(scrolled_window, true, true, 0); // Test buttons var button = new Button.with_label("Set cell editable..."); vbox.pack_start(button, false, false, 0); button.clicked.connect(button_cb); // Pack the widget in the window this.add(vbox); } private void fill_model() { TreeIter iter; for (var i = 1; i <= 100; i++) { model.append(out iter); model.set(iter, 0, i, -1); } } private void button_cb() { TreeIter iter; treeview.get_selection().get_selected(null, out iter); model.set(iter, 1, true); } public static int main(string[] args) { Gtk.init(ref args); var window = new MyWindow(); window.show_all(); window.delete_event.connect(() => { Gtk.main_quit(); return false; }); Gtk.main(); return 0; } }