Actions

First create the Actions and add them to an ActionGroup, with ActionGroup::add().

The arguments to Action::create() specify the action's name and how it will appear in menus and toolbars. Use stock items where possible so that you don't need to specify the label, accelerator, icon, and tooltips, and so you can use pre-existing translations.

You can also specify a signal handler when calling ActionGroup::add(). This signal handler will be called when the action is activated via either a menu item or a toolbar button.

Note that you must specify actions for sub menus as well as menu items.

For instance:

m_refActionGroup = Gtk::ActionGroup::create();

m_refActionGroup->add( Gtk::Action::create("MenuFile", "_File") );
m_refActionGroup->add( Gtk::Action::create("New", Gtk::Stock::NEW),
  sigc::mem_fun(*this, &ExampleWindow::on_action_file_new) );
m_refActionGroup->add( Gtk::Action::create("ExportData", "Export Data"),
  sigc::mem_fun(*this, &ExampleWindow::on_action_file_open) );
m_refActionGroup->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
  sigc::mem_fun(*this, &ExampleWindow::on_action_file_quit) );

Note that this is where we specify the names of the actions as they will be seen by users in menus and toolbars. Therefore, this is where you should make strings translatable, by putting them inside the _() macro. When we use the Gtk::Stock items, of course, translations are automatically available.