UIManager
Prev | Chapter 10. Menus and Toolbars | Next

## UIManager

Next you should create a UIManager and add the ActionGroup to the UIManager with `insert_action_group()`. For instance,

    Glib::RefPtr<Gtk::UIManager> m_refUIManager = Gtk::UIManager::create();
    m_refUIManager->insert_action_group(m_refActionGroup);
    add_accel_group(m_refUIManager->get_accel_group());

Then, you can define the actual visible layout of the menus and toolbars, and add the UI layout to the UIManager:

        Glib::ustring ui_info =
            "<ui>"
            "  <menubar name='MenuBar'>"
            "    <menu action='MenuFile'>"
            "      <menuitem action='New'/>"
            "      <menuitem action='Open'/>"
            "      <separator/>"
            "      <menuitem action='Quit'/>"
            "    </menu>"
            "    <menu action='MenuEdit'>"
            "      <menuitem action='Cut'/>"
            "      <menuitem action='Copy'/>"
            "      <menuitem action='Paste'/>"
            "    </menu>"
            "  </menubar>"
            "  <toolbar  name='ToolBar'>"
            "    <toolitem action='Open'/>"
            "    <toolitem action='Quit'/>"
            "  </toolbar>"
            "</ui>";

        m_refUIManager->>add_ui_from_string(ui_info);

Prev | Up | Next
Chapter 10. Menus and Toolbars | Home | Menus