1

I have a GtkTreeView representing some data, and I want to have a GtkPopover appear on some action, pointing to that row. I have the popover working all but for the position.

How do you retrieve a widget for the currently selected row (or rows I suppose, but I will only deal with a selection of size == 1). I can get the models and the iterator, but I can't see how to get a row widget to pass into gtk_popover_set_relative_to.

So far I have:

GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;

selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
gtk_tree_selection_get_selected(selection, &model, &iter);

gtk_tree_model_get (model, &iter, ...);

GtkWidget *row; // need to fill this in

gtk_popover_set_relative_to (GTK_POPOVER (popover), GTK_WIDGET (row));

How can I fill in row?

This question seems to sort-of meet the reverse (get row for position).

Inductiveload
  • 6,094
  • 4
  • 29
  • 55
  • 2
    GtkTreeView rows are not widgets. Here are some hints: `gtk_tree_view_get_cell_area()`, `gtk_popover_set_pointing_to()`. – andlabs Jul 03 '15 at 13:05
  • Isn't it something like `gtk_tree_selection_get_selected_rows ()` Source: https://developer.gnome.org/gtk3/stable/GtkTreeSelection.html? – tobias47n9e Jul 04 '15 at 20:23
  • 2
    @tobias47n9e that's for getting a list of GtkTreePaths to all the selected rows. It doesn't tell you anything about where the row is on screen. The functions I said should be what the OP is looking for; they show where on screen the cell of a row is and put the popover there, respectively. – andlabs Jul 04 '15 at 21:03
  • @andlabs: Now I get it. Thanks for clearing that up in my head. – tobias47n9e Jul 04 '15 at 22:21

0 Answers0