In gtkmm I can use something like this in the constructor:
// Gtk::ImageMenuItem *iQuit;
iQuit->signal_activate().connect (sigc::mem_fun (*this, &FormUI::on_quit_activated) );
But I'd like to use a method to set item's properties, for example:
void FormUI::SetItemProps (Gtk::ImageMenuItem *i, const Glib::ustring& _l, ?what should I put here?)
{
i->set_use_stock (true);
i->set_label (_l);
i->signal_activate().connect (sigc::mem_fun (*this, ???) ); <-- what to pass there
}
so I can use something like this in the constructor:
SetItemProps (iQuit, "gtk-quit", &FormUI::on_quit_activated);
Any ideas please?
You may like in this using typedef:
typedef void (FormUI::*function_ptr)();
void FormUI::SetItemProps (Gtk::ImageMenuItem *i, const Glib::ustring& _l, function_ptr fun)
{
i->set_use_stock (true);
i->set_label (_l);
i->signal_activate().connect (sigc::mem_fun (*this, fun) );
}
And the method on_quit_activated() has to be as declared type.
To call, use
SetItemProps (iQuit, "gtk-quit", &FormUI::on_quit_activated);