use GtkToolItem in toolbars

This commit is contained in:
Garux
2020-05-22 00:23:41 +03:00
parent 495e90e6a9
commit 95809d79f5
11 changed files with 102 additions and 81 deletions

View File

@@ -41,6 +41,9 @@ void button_connect_callback( GtkButton* button, const Callback& callback ){
g_signal_connect_closure( G_OBJECT( button ), "clicked", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), FALSE );
#endif
}
void button_connect_callback( GtkToolButton* button, const Callback& callback ){
g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
}
guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ){
#if 1
@@ -51,6 +54,11 @@ guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& c
g_object_set_data( G_OBJECT( button ), "handler", gint_to_pointer( handler ) );
return handler;
}
guint toggle_button_connect_callback( GtkToggleToolButton* button, const Callback& callback ){
guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
g_object_set_data( G_OBJECT( button ), "handler", gint_to_pointer( handler ) );
return handler;
}
void button_set_icon( GtkButton* button, const char* icon ){
GtkImage* image = new_local_image( icon );
@@ -69,6 +77,12 @@ void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean activ
gtk_toggle_button_set_active( button, active );
g_signal_handler_unblock( G_OBJECT( button ), handler_id );
}
void toggle_button_set_active_no_signal( GtkToggleToolButton* button, gboolean active ){
guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) );
g_signal_handler_block( G_OBJECT( button ), handler_id );
gtk_toggle_tool_button_set_active( button, active );
g_signal_handler_unblock( G_OBJECT( button ), handler_id );
}
void radio_button_print_state( GtkRadioButton* button ){