Search code examples
gtkmm

How to attach Gtk::Menu to Gtk::Widget


Gtk::Menu has

void Gtk::Menu::attach_to_widget(Widget& attach_widget,
                                 GtkMenuDetachFunc detacher)

void Gtk::Menu::attach_to_widget (Widget& attach_widget)

wrapper methods for

void gtk_menu_attach_to_widget(GtkMenu *menu,
                               GtkWidget *attach_widget,
                               GtkMenuDetachFunc detacher)

But why are they protected?

If I want to make a pop-up menu on a widget, how, then, can I get access to it from the menu's activate call-back if not via these methods?


Solution

  • I guess it was protected because we misunderstood how it should be used. In the very latest gtkmm versions it is now public: https://git.gnome.org/browse/gtkmm/commit/?id=329d7c59bb3f75f79142600872221ae946c7c3a1

    In the meantime, you can call the C function, using yourmenu->gobj() and yourwidget->gobj().