ofey aikon said:
[want to change the mouse cursor based on the contents of the cell] The way I achieve this is by trapping the 'motion-notify-event' of the treeview and then calling the treeview->get_path_at_pos to identify the cell (always a CellRendererText for me) on which the mouse is. Then I look at the contents of the CellRendererText and then change the mouse pointer accordingly. The event is getting trapped correctly. But when I try to look at the contents of the $cell, I always don't get the correct value. Sometimes, it seems to be retrieving the value of the previous cell that I visited.. sometimes it works fine. The problem is detected randomly.
You're getting the data from the wrong place. The GtkCellRenderer object does not represent a single cell in the view; it *draws* each cell in the column. The TreeView tells the TreeViewColumn that it needs to render some area, and the column sets up the renderer to render each row in turn. This is why you're "randomly" seeing a previous cell's data -- that happens to have been the most recently drawn cell! The correct way to get the data is to fetch it directly from the model. You get the path, and you get the column. When you set up the view, you tied the column to the model in some fashion, and you use that relation to know where to find the data in the model. (Unfortunately, you can't query the column for the list of attributes you set up. They are stored in opaque data structures in an off-limits member of the instance structure, so we can't even hack something up.)
I have replicated the problem in a small piece of code and attaching it. Move your mouse on the numbers '0.2 and '0.9' on the tree a few times randomly and you'll see what the issue is.
Patch attached. -- muppet <scott at asofyet dot org>
Attachment:
diff
Description: Binary data