void button_connect_callback( GtkButton* button, const Callback& callback ){ #if 1 g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else g_signal_connect_closure( G_OBJECT( button ), "clicked", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), FALSE ); #endif }
guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ){ #if 1 guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() ); #else guint handler = g_signal_connect_closure( G_OBJECT( button ), "toggled", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), TRUE ); #endif g_object_set_data( G_OBJECT( button ), "handler", gint_to_pointer( handler ) ); return handler; }
GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback<void()>& callback ){ if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) { //globalOutputStream() << "global_accel_connect: " << makeQuoted(accelerator) << "\n"; GClosure* closure = create_cclosure( G_CALLBACK( accel_closure_callback ), callback ); gtk_accel_group_connect( group, accelerator.key, accelerator.modifiers, GTK_ACCEL_VISIBLE, closure ); return closure; } else { special_accelerators_add( accelerator, callback ); return 0; } }
GClosure* accel_group_add_accelerator(GtkAccelGroup* group, Accelerator accelerator, const Callback& callback) { if(accelerator.key != 0 && gtk_accelerator_valid(accelerator.key, accelerator.modifiers)) { //globalOutputStream() << "adding accelerator: " << accelerator.key << " " << accelerator.modifiers << "\n"; GClosure* closure = create_cclosure(G_CALLBACK(accel_closure_callback), callback); gtk_accel_group_connect(group, accelerator.key, accelerator.modifiers, GTK_ACCEL_VISIBLE, closure); return closure; } else { special_accelerators_add(accelerator, callback); return 0; } }