Search code examples
gtkgtktreeview

How to get the coordinates of a GtkTreeView row


I'm using a GtkTreeView widget. If I have a row's GtkTreeIter, how can I then get that row's current position (vertical pixel coordinate) within the entire GtkTreeView window?

My underlying problem is that I need to get a GtkTreeIter for whatever row is currently placed at a given vertical coordinate relative to the entire GtkTreeView window, but I don't know how.

Any help would be greatly appreciated!! Thanks in advance :-)


Solution

  • This function:

    gtk_tree_view_get_path_at_pos (GtkTreeView        *tree_view,
                                   gint                x,
                                   gint                y,
                                   GtkTreePath       **path,
                                   GtkTreeViewColumn **column,
                                   gint               *cell_x,
                                   gint               *cell_y)
    

    will give you a path that you can pass to

    gtk_tree_model_get_iter()
    

    to get an iterator.