gintro
gintro copied to clipboard
TreeModel methods unavailable for ListStore
I confirm that ListStore is incompatible with TreeModel. Normally, as ListStore implements TreeModel, Treemodel methods should be available for ListStore. And it should also be possible to define a handler for the TreeModel signals with a ListStore as sender.
I don’t how "gintro" can manage this. I suppose, however, that some mechanism exists as a Label, for instance, has access to Widget methods.
Yes, we tried already to solve this issue some weeks ago, see
https://mail.gnome.org/archives/gtk-list/2017-July/msg00018.html
From a short inspection of current gtk.nim I have the feeling that the | notation for parameters is not supported for the first parameter of functions/methods. In gen.nim we always have to process the self parameter special for methods, I will check that in more detail this evening. Seems that ListStore can occur as first parameter, so type ListStore maybe should be replaced by something like ListStore|TreeModel or the other direction. Of course, all that needs testing then.
See the new listview example in tutorial. I cloned the proc which returns a TreeModel and let it return a ListStore. This avoids casting. Later we may add the proc to gtk.nim. There is no static type check at compile time unfortunately. But GTK will complain at runtime when it is not really a ListStore.
Yes and as I have kept a reference to the ListStore in my application object, I don’t even need to create a getListStore procedure.
Being able to call the TreeModel procedures from a ListStore object avoids some odd things, for instance using the model to get a value while using the list store to set a value. Now it is consistent again. Thanks!