The short answer is: you cannot add a GtkPopover
to random widgets and expect it to work.
If you want to add a GtkPopover
to a GtkButton
you will need to:
- create a new class that inherits from
GtkButton
- create a new
GtkPopover
instance inside the instance initialisation function of your derived button class, and keep a reference to it:button->popover = gtk_popover_new()
- call
gtk_widget_set_parent(button->popover, button)
inside the instance initialisation function of your derived button class - override
GObjectClass.dispose
and callgtk_widget_unparent(button->popover)
inside the dispose implementation
For more information on how to derive GObject
types like GtkWidget
, you should read the GObject
tutorial.