On 06-11-18 16:18, aedt wrote:
On Tue, 06 Nov 2018 15:17:01 GMT, aedt wrote:
On Sun, 4 Nov 2018 19:04:20 +0100, Mike Wey wrote:
On 01-11-18 22:58, Mike Wey wrote:
[...]
Also, regarding the filter, the compiler complains that the nested function is unable to access the enclosing function, probably because the nested function is static. How can I send a string tofn
? I still don't understand howfn
itself works too. It seems thatfn
expects 3 arguments yet when I callfilter.setVisibleFunc(&fn, null, cast(GDestroyNotify) null);
, I don't see any arguments provided to it.
Gtk itself will be calling the function, with the correct parameters.
you can use the data parameter to send data to the callback.
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(&fn, cast(void*)artistName, cast(GDestroyNotify)
null);
return filter;
}