* lablgtk GTree problem
@ 2007-03-06 0:22 Ewen Maclean
2007-03-06 0:31 ` [Caml-list] " Jacques Garrigue
0 siblings, 1 reply; 2+ messages in thread
From: Ewen Maclean @ 2007-03-06 0:22 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]
Hello,
I have tried looking for this information on the web but unfortunately have
not been successful and any help would be greatly appreciated. I'm using a
GTree.list_store as a model for a GTree.view. Everything is working fine and
the documentation has really helped. The problem I have is that I am
attributing a double-click event to each item in the GTree.list_store:
gtreeview#connect#row_activated ~callback:(fun m n -> on_row_activated
greetreeview nps m n)
which calls the function on_row_activated:
let on_row_activated (view:GTree.view) nps path column =
let model = view#model in
let row = model#get_iter path in
let name = model#get ~row ~column:str_col in
uprint ("Double-clicked row contains name " ^ name) ()
what I want is to work out is the integer index of row in the path. I read
somewhere that I could use path#get_indices to return an array of integers
which would tell me, but it tells me that path has no method get_indices.
The point is that the row of the double clicked object is the index of the
element I want from the list nps. I know that I can return a row_reference,
but it would be really useful to get the index as an integer from the path.
Any help would be much appreciated.
Many thanks in advance and apologies if this is a very simple problem
Ewen
[-- Attachment #2: Type: text/html, Size: 1414 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] lablgtk GTree problem
2007-03-06 0:22 lablgtk GTree problem Ewen Maclean
@ 2007-03-06 0:31 ` Jacques Garrigue
0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2007-03-06 0:31 UTC (permalink / raw)
To: E.Maclean; +Cc: caml-list
From: "Ewen Maclean" <E.Maclean@ed.ac.uk>
> let on_row_activated (view:GTree.view) nps path column =
> let model = view#model in
> let row = model#get_iter path in
> let name = model#get ~row ~column:str_col in
> uprint ("Double-clicked row contains name " ^ name) ()
>
> what I want is to work out is the integer index of row in the path. I read
> somewhere that I could use path#get_indices to return an array of integers
> which would tell me, but it tells me that path has no method get_indices.
Not surprising: a path is not an object :-)
You should use the function GTree.Path.get_indices.
Jacques Garrigue
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-06 0:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-06 0:22 lablgtk GTree problem Ewen Maclean
2007-03-06 0:31 ` [Caml-list] " Jacques Garrigue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox