`g_signal_connect_swapped(instance, detailed_signal, c_handler, data);`
connects a GCallback
function to a signal for a particular object. The instance on which the signal is emitted and data will be swapped when calling the handler.
好处是可以实现下面的trick:
g_signal_connect_swapped(button, 'clicked', G_CALLBACK(gtk_widget_hide), textview);
等效于:
static void
on_button_clicked(GtkButton *button, GtkWidget *textview)
{
gtk_widget_hide(textview);
}
g_signal_connect(button, 'clicked', G_CALLBACK(on_button_clicked), textview);