On 07-11-18 02:46, aedt wrote:
Unfortunately that produces an error too:
Error: function gtk.TreeModelFilter.TreeModelFilter.setVisibleFunc(extern (C) int function(GtkTreeModel* model, GtkTreeIter* iter, void* data) func, void* data, extern (C) void function(void* data) destroy) is not callable using argument types (extern (C) int function(GtkTreeModel* m, GtkTreeIter* i, string artistName) @system, void*, extern (C) void function(void* data)) source/app.d(69,24): cannot pass argument & fn of type extern (C) int function(GtkTreeModel* m, GtkTreeIter* i, string artistName) @system to parameter extern (C) int function(GtkTreeModel* model, GtkTreeIter* iter, void* data) func /usr/bin/dmd failed with exit code 1.
Full code: https://pastebin.com/Ei7MDZzJ
I forgot a cast in there:
TreeModelFilter generateArtistFilter(in string artistName) {
// nested private function
static extern (C) int fn(GtkTreeModel* m, GtkTreeIter* i, string
artistName) {
TreeModel model_ = new TreeModel(m);
TreeIter iter = new TreeIter(i);
string name = model_.getValue(iter, COLUMNS.ARTIST).getString();
return name == artistName;
}
auto filter = new TreeModelFilter(model, null);
filter.setVisibleFunc(cast(GtkTreeModelFilterVisibleFunc)&fn,
cast(void*) artistName, cast(GDestroyNotify) null);
return filter;
}