#include <gtk/gtk.h> static gboolean window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer data); static void cbcb( GtkWidget *widget, gpointer data); GtkWidget *label; char deny[] ="You live in denial!"; char admit[] ="That's right."; int main( int argc, char **argv) { GtkWidget *window, *vbox, *checkbutton; gtk_set_locale( ); gtk_init( &argc, &argv); window =gtk_window_new( GTK_WINDOW_TOPLEVEL); gtk_window_set_title( GTK_WINDOW( window), "I am the Walrus"); g_signal_connect( G_OBJECT( window), "delete_event", G_CALLBACK( window_delete_event), NULL); vbox =gtk_vbox_new( FALSE, 8); gtk_container_add( GTK_CONTAINER( window), vbox); checkbutton =gtk_check_button_new_with_label( "Soylent Green is made of people?"); gtk_box_pack_start( GTK_BOX( vbox), checkbutton, FALSE, TRUE, 8); // "toggled" inherited from GtkToggleButton g_signal_connect( checkbutton, "toggled", G_CALLBACK( cbcb), NULL); label =gtk_label_new( deny); gtk_box_pack_start( GTK_BOX( vbox), label, FALSE, TRUE, 8); gtk_widget_show_all( window); gtk_main( ); return 0; } static gboolean window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer data) { exit( 0); } static void cbcb( GtkWidget *widget, gpointer data) { if( FALSE ==gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget))) gtk_label_set_text( GTK_LABEL( label), deny); else gtk_label_set_text( GTK_LABEL( label), admit); }
2006-08-18
GtkCheckButton stuff
main.c: