How I can put a GtkPopOver in a cell of Gtk TreeView. When I click in the cell I need that Popover appears. I can not find any examples in GTKMM than associating a cell of GtkTreeView with one GtkPopover.
Thanks.
Having gone through a similar situation, I was able to solve this with (simplified version in python):
def click_callback(..., event):
rect = Gdk.Rectangle()
rect.x = event.button.x
rect.y = event.button.y
rect.width = rect.height = 1
popover = Gtk.Popover.new_from_model(treeview, model)
popover.set_pointing_to(rect)
popover.show()
I've solved it and here is a simplified version from the code that I used:
class Table(Gtk.TreeView):
# Gtk stuff ...
@GtkTemplate.Callback
def on_button_press_event(self, widget, event):
path, path_iter, col = self.__get_path_at_position(event)
btn = event.button
if btn == 3:
pop = Gtk.Popover()
# Customize
pop.set_pointing_to(self.get_cell_area(path, col))
pop.set_relative_to(self)
pop.popup()
return True
return False
def __get_path_at_position(self, event):
path_info = self.get_path_at_pos(event.x, event.y)
if path_info:
path, column, cell_relative_x, cell_relative_y = path_info
path_iter = self.__model.get_iter(path)
return path, path_iter, column,
return None, None, None
It is not C++ though but I think it should be enough to do it in C++. It turned out that both functions
pop.set_pointing_to(self.get_cell_area(path, col))
pop.set_relative_to(self)
are required.