GtkD: Best way to get TreeStore out of TreeView.Model

Alex Horvat alexh at gmail.com
Tue Jun 11 08:56:10 PDT 2013


I'm trying to get a TreeStore object back out of a TreeView in 
GtkD.

The reason for this is so that I can change the value of a cell 
in the TreeView - in this case changing one image for another.

I can't use a TreeModel for this as it does not have a setValue 
function.

I've got this working with the following code:

private bool tvTreeView_ButtonRelease(Event e, Widget sender) {
   TreeIter selectedItem = tvTreeView.getSelectedIter();
   TreeStore store = new 
TreeStore(cast(GtkTreeStore*)selectedItem.gtkTreeModel);

   store.setValue(selectedItem, 2, newPixbuf);
}

But this seems like a really ugly way to do this, I'm sure I'm 
missing something.

I've also tried:

TreeStore store = 
ObjectG.getDObject!(TreeStore)(cast(GtkTreeStore*)selectedItem.gtkTreeModel);
This creates a TreeModel not a TreeStore

TreeStore store = cast(TreeStore)tvTreeView.getModel();
In this case store == null

Does anyone know a better way of doing this?
Or is this something missing from GtkD?

Thanks


More information about the Digitalmars-d-learn mailing list