Re: getting the listStore out of tree view
Duncan Coutts <duncan.coutts <at> worc.ox.ac.uk>
2008-06-16 09:10:10 GMT
On Sat, 2008-06-14 at 16:44 -0700, Hristo Asenov wrote:
> Hello, I am new to gtk and haskell. I have already gotten to the point
> of filling a a tree view with objects, but now need to get the
> contents of a row when I click on it. In other words, everytime I
> right-click on a row, it is highlighted and a menu pops up, then when
> I select that menu, I want to access the list under which I have
> selected. I have found a tutorial for C in
> http://scentric.net/tutorial/treeview-tutorial.html and says to use
> gtk_tree_model_get but I haven't been able to find that function. The
> closest I have found is treeModelGetValue, which returns a
> GenericValue, but I don't think I'm supposed to work with it. It also
> asks for an Int, which is a column num, but when I try to do it, it
> says that it is invalid. I can get a reference both to treePath and
> treeIter, but I can't do anything with them. Could someone let me know
> what function I need to use?
The answer is to keep a reference to the underlying model rather than
trying to recover it using treeViewGetModel. The reason is that
treeViewGetModel can only get you a generic TreeModel and not the
specific type ListStore etc. Yes it is possible to get info out of a
TreeModel but as you see it is not a convenient typed interface and has
to go via the variant type GenericValue.
So when you construct the list store, keep hold of it. Set it as the
model for the tree view to use, but keep the list store too so that you
can use the convenient list store api.
Duncan
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php