[gtkmm] Adding menu items to the context menu of TextView



Hi,

I am trying to add an menu item to the context menu of a TextView. In
gtkmm 2.2, I did this by doing roughly something like this:

_textview.signal_populate_popup().connect(SigC::slot(*this, populateMenu));

[...]
void populateMenu(Gtk::Menu *contextmenu) {
    Gtk::Menu::MenuList& menulist = contextmenu->items();

    menulist.push_back(Gtk::Menu_Helpers::MenuElem(
                      _("My menuitem"));
[...]

However, in gtkmm 2.4, I have switched to the UIManager/ActionGroup
concept. How can I do it using UIManager? Being optimistic, I tried the
following, but it didn't work:

menulist.push_back(*dynamic_cast<Gtk::Menu_Helpers::Element*>(getUIManager()->get_widget("/MenuBar/MenuItem")));


Thanks in advance.

  - Morten.

-- 
http://mbrix.dk/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]