Re: getting the listStore out of tree view
Hristo Asenov <njvsny <at> yahoo.com>
2008-06-16 21:16:22 GMT
You know, I did pass the reference of the model and was thinking of using that at one point, but got confused when I searched "listStoreNew" on hoogle and came up with the one in Graphics.UI.Gtk.TreeList.ListStore, and couldn't find any function that could get its value. When you mentioned that listStore can be used, I looked under Graphics.UI.Gtk.ModelView.ListStore and found "listStoreGetValue", which I can use with my reference to TreePath. I tried it out and it worked. Thanx, &n
bsp;
Hristo
--- On Mon, 6/16/08, Duncan Coutts <duncan.coutts <at> worc.ox.ac.uk> wrote:
From: Duncan Coutts <duncan.coutts <at> worc.ox.ac.uk> Subject: Re: [Gtk2hs-users] getting the listStore out of tree view To: njvsny <at> yahoo.com Cc: gtk2hs-users <at> lists.sourceforge.net Date: Monday, June 16, 2008, 5:10 AM
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 clic
k 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 treeViewGetM
odel 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
_______________________________________________
Gtk2hs-users mailing list
Gtk2hs-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-users