Hello
When I run this program, instead of showing me a list of 3 rows, the treeview is showing me only 1 row. I'm guessing the iter is not pointing to the new row in buildModel()? If not, what's causing this?
int main(string[] args) {
import gtk.Application : Application;
import gtkc.gtktypes : GApplicationFlags;
import gio.Application : GioApp = Application;
auto app = new Application("org.gtkdnotes.cellrenders", GApplicationFlags.FLAGS_NONE);
app.addOnActivate(delegate void(GioApp _) {
import gtk.ApplicationWindow : ApplicationWindow;
auto aw = new ApplicationWindow(app);
scope (success)
aw.showAll();
aw.setDefaultSize(320, 200);
aw.setTitle("CellRendererText Example");
aw.add(buildUi());
});
return app.run(args);
}
enum Columns {
TEXT,
EDITABLE_TEXT
}
import gtk.Box : Box;
import gtk.TreeView : TreeView;
Box buildUi() {
import gtkc.gtktypes : GtkOrientation;
auto vbox = new Box(GtkOrientation.VERTICAL, 5);
vbox.packStart(buildView(buildModel), true, true, 0);
return vbox;
}
import gtk.ListStore : ListStore;
ListStore buildModel() {
import gtk.ListStore : ListStore;
import gtkc.gobjecttypes : GType;
auto ls = new ListStore([GType.STRING, GType.STRING]);
import gtk.TreeIter : TreeIter;
auto ti = ls.createIter();
ls.setValue(ti, Columns.TEXT, "Arch");
ls.setValue(ti, Columns.EDITABLE_TEXT, "https://www.archlinux.org/");
ls.setValue(ti, Columns.TEXT, "Debian");
ls.setValue(ti, Columns.EDITABLE_TEXT, "https://www.debian.org/");
ls.setValue(ti, Columns.TEXT, "Fedora");
ls.setValue(ti, Columns.EDITABLE_TEXT, "https://getfedora.org/");
return ls;
}
TreeView buildView(ListStore ls) {
import gtk.CellRendererText : CellRendererText;
auto tv = new TreeView();
import gtk.TreeViewColumn : TreeViewColumn;
tv.appendColumn(new TreeViewColumn("Text", new CellRendererText(), "text", Columns.TEXT));
auto cellRendererEditableText = new CellRendererText();
cellRendererEditableText.setProperty("editable", true);
tv.appendColumn(new TreeViewColumn("Editable text",
cellRendererEditableText, "text", Columns.EDITABLE_TEXT));
tv.setModel(ls);
return tv;
}