This one should work:
import gtk.Main;
import gtk.MainWindow;
import gtk.Box;
import gtk.Entry;
import gtk.EditableIF;
import gtk.TreeModelFilter;
import gtk.TreeView;
import gtk.HBox;
import gtk.VBox;
import gtk.Label;
import gtk.ListStore;
import gtk.TreeViewColumn;
import gtk.CellRendererText;
import gtk.TreeModel;
import gtk.TreeIter;
import std.conv;
import std.stdio;
class MyWindow: MainWindow
{
Box mainBox;
Entry filterEntry;
TreeModelFilter filter;
TreeIter iter;
this()
{
super("TreeView Example");
setSizeRequest(500, 200);
filterEntry = new Entry();
auto filterLabel= new Label("Artist search");
auto tree = new TreeView();
auto box = new VBox(false, 0);
auto dataModel = new ListStore([GType.STRING, GType.STRING]);
auto artistColumn = new TreeViewColumn("Artist", new
CellRendererText(), "text", 0);
tree.appendColumn(artistColumn);
auto songColumn = new TreeViewColumn("Song title", new
CellRendererText(), "text", 1);
tree.appendColumn(songColumn);
iter = dataModel.createIter();
dataModel.setValue(iter, 0, "This is a test");
dataModel.setValue(iter, 1, "Sample song");
iter = dataModel.createIter();
dataModel.setValue(iter, 0, "This is a test");
dataModel.setValue(iter, 1, "Another song");
iter = dataModel.createIter();
dataModel.setValue(iter, 0, "Another artist");
dataModel.setValue(iter, 1, "Test song");
filter = new TreeModelFilter(dataModel, null);
filter.setVisibleFunc(cast(GtkTreeModelFilterVisibleFunc)
&filterTree, null, null);
tree.setModel(filter);
auto mainBox = new HBox(false, 0);
mainBox.packStart(filterLabel, false, false, 5);
mainBox.packStart(filterEntry, true, true, 5);
box.packStart(mainBox, false, false, 5);
box.packStart(tree, true, true, 5);
add(box);
showAll();
}
static extern(C) int filterTree(GtkTreeModel* gtkModel,
GtkTreeIter* gtkIter, void* data)
{
auto model1 = new TreeModel(gtkModel, false);
auto it1 = new TreeIter(gtkIter, false);
string artistName = to!string(model1.getValue(it1, 0));
return true;
}
void onFilterEntryTextChanged(EditableIF filterEntry)
{
filter.refilter();
}
// void onFilterEntryTextChanged(ParamSpec param, ObjectG object)
// {
// filter.refilter();
// }
}
void main(string[] args)
{
Main.init(args);
new MyWindow();
Main.run();
}