gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

Add iter_next? #216

Closed InfiniteRegression closed 7 years ago

InfiniteRegression commented 7 years ago

Would like to iterate through a liststore but there seems to be no iter_next:

see

https://www.linuxquestions.org/questions/programming-9/gtk-liststore-python-retrieving-the-list-values-506215/

MikeWey commented 7 years ago

iterNext is part of the TreeModel interface which both the treestore and the liststore implement.

You should be able to call: yourListStore.iterNext(yourIter);.

InfiniteRegression commented 7 years ago

Thanks, I thought I tried that but I guess not, I remember even searching for it ;/ Guess I was looking in the wrong place.

Another thing: I am trying to use selectionForeach and it mixes GtkD with Gtk. I'm having to do a lot of prep work to get it to work like creating the GtkD types that wrap the Gtk ones:

index.selectedForeach((model, path, iter, data) { auto tm = new TreeModel(model); auto vl = new GValue(); tm.customTreeModelGetValue(model, iter, 0, vl); }

I can't seem to get the value directly from the tm. I looked at stuff like tm.getString but nothing, closest was the above.

Am I doing it wrong?

MikeWey commented 7 years ago

All the functionality of the TreeModel interface is mixed in, so you should be able to use getValueString:

index.selectedForeach((model, path, iter, data)
{
    auto tm = new TreeModel(model);
    auto i = new TreeIter(iter);

    string s = tm.getValueString(i, 0)
}

Tough the mix of Gtk and GtkD for callbacks should be fixed at some point.