Use g_signal_connect_swapped to simplify the callbacks