I would like to display icons in the first column of the treeview.
import gtk.Main;
import gtk.MainWindow;
import gtk.Box;
import gtk.TreeView;
import gtk.ListStore;
import gtk.CellRendererPixbuf;
import gtk.TreeViewColumn;
import gtk.CellRendererText;
import gdk.Pixbuf;
import gobject.Value;
class MyWindow: MainWindow
{
this()
{
super("Drawing icons in rows");
setSizeRequest(500, 200);
auto tree = new TreeView();
auto dataModel = new ListStore([GType.STRING, GType.STRING, GType.STRING]);
auto iconColumn = new TreeViewColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0);
tree.appendColumn(iconColumn);
auto nameColumn = new TreeViewColumn("Name", new CellRendererText(), "text", 1);
tree.appendColumn(nameColumn);
auto descriptionColumn = new TreeViewColumn("Description", new CellRendererText(), "text", 2);
tree.appendColumn(descriptionColumn);
auto iter = dataModel.createIter();
dataModel.setValue(iter, 0, new Value(new Pixbuf("icon.png")));
tree.setModel(dataModel);
add(tree);
showAll();
}
}
void main(string[] args)
{
Main.init(args);
auto myWindow = new MyWindow();
Main.run();
}
But the program gives some warning messages:
GLib-GObject-WARNING **: unable to set property
pixbuf' of type
GdkPixbuf' from value of type `gchararray'
Also I shouldn't figured out what kind of data type to ListStore's constructor. So I simly passed a GType.STRING.