Εγγραφή χειριστών σημάτων
Για την εύρεση του τύπου του χειριστή σήματος που μπορείτε να συνδέσετε με ένα σήμα, μπορείτε να το κοιτάξετε στην τεκμηρίωση αναφοράς ή στο αρχείο κεφαλίδας. Ιδού ένα παράδειγμα της δήλωσης σήματος που μπορείτε να δείτε στις κεφαλίδες gtkmm:
Glib::SignalProxy<bool(Gtk::DirectionType)> signal_focus()
Other than the signal's name (focus), the template arguments are important to note here. The first argument, bool, is the type that the signal handler should return; and the type within parentheses, 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.
Οι ίδιες αρχές εφαρμόζονται για σήματα που έχουν περισσότερα ορίσματα. Ιδού ένα με τρία (ελήφθησαν από <gtkmm/textbuffer.h>):
Glib::SignalProxy<void(TextBuffer::iterator&, const Glib::ustrin&, int)> signal_insert();
It follows the same form. The first type 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(TextBuffer::iterator& pos, const Glib::ustring& text, int bytes)