I have a list of items(a GtkTreeView) and I'm trying to get the selected item when clicked.
What I'd really like to do is get get the index of the item under the mouse when it is clicked.
I could do this if, say, I had the position of the cursor and new the height's of the items and the exact layout. e.g.,
but that makes a lot of assumptions that may not hold.
Do you see where I'm going with this? ;)
The reason I'd like to do this is because my code is a little more complicated. What is happening is that when I click the selection change is updated after I get the selection and so is always out of sync.
I click and my code is ran and then the internals change the selection item(I guess because I'm returning false from the button press handler).
- get selection(but it hasn't changed yet)
- act on selection(but acts wrong).
- selection is changed(internally by gtk)
when it's repeated the 3 then acts on the previous selection which was correct previously.
But I don't know how to do 4 myself except hacking it which may be invalid.
In the button handler I do get the x and y and if they are correct and I can get the true height of the rows(including padding, etc) then I could do the calculation myself.
I think technically I would have to iterate through them and add up the individual row heights since they could all be different.
Maybe I am going about it wrong or there is a simpler way?