Σύνδεση πρόσθετων ορισμάτων

If you use one signal handler to catch the same signal from several widgets, you might like that signal handler to receive some extra information. For instance, you might want to know which button was clicked. You can do this with sigc::bind(). Here's some code from the helloworld2 example.

m_button1.signal_clicked().connect( sigc::bind<Glib::ustring>( sigc::mem_fun(*this, &HelloWorld::on_button_clicked), "button 1") );
This says that we want the signal to send an extra Glib::ustring argument to the signal handler, and that the value of that argument should be "button 1". Of course we will need to add that extra argument to the declaration of our signal handler:
virtual void on_button_clicked(Glib::ustring data);
Of course, a normal "clicked" signal handler would have no arguments.

Η sigc::bind() δεν χρησιμοποιείται συνήθως, αλλά μπορείτε να την βρείτε χρήσιμη μερικές φορές. Αν είσαστε εξοικειωμένος με τον προγραμματισμό της GTK+, τότε θα έχετε προφανώς σημειώσει ότι αυτό είναι παρόμοιο με τα πρόσθετα ορίσματα gpointer data που όλα έχουν επανακλήσεις GTK+. Αυτό γενικά υπερχρησιμοποιείται στην GTK+ για το πέρασμα πληροφοριών που πρέπει να αποθηκευτούν ως μέλη δεδομένων σε ένα παράγωγο γραφικό συστατικό, αλλά μια παραγωγή γραφικού συστατικού είναι πολύ δύσκολη στη C. Έχουμε πολύ λιγότερη ανάγκη αυτής της επέμβασης στην gtkmm.