Writing signal handlers

To find out what type of signal handler you can connect to a signal, you can look it up in the reference documentation or the header file. Here's an example of a signal declaration you might see in the gtkmm headers:

Glib::SignalProxy1<bool, Gtk::DirectionType> signal_focus()

Other than the signal's name (focus), two things are important to note here: the number following the word SignalProxy at the beginning (1, in this case), and the types in the list (bool and Gtk::DirectionType). The number indicates how many arguments the signal handler should have; the first type, bool, is the type that the signal handler should return; and the next type, Gtk::DirectionType, is the type of this signal's first, and only, argument. By looking at the reference documentation, you can see the names of the arguments too.

The same principles apply for signals which have more arguments. Here's one with three (taken from <gtkmm/textbuffer.h>):

Glib::SignalProxy3<void, const TextBuffer::iterator&, const Glib::ustrin&, int> signal_insert();

It follows the same form. The number 3 at the end of the type's name indicates that our signal handler will need three arguments. The first type in the type list is void, so that should be our signal handler's return type. The following three types are the argument types, in order. Our signal handler's prototype could look like this:

void on_insert(const TextBuffer::iterator& pos, const Glib::ustring& text, int bytes)