]> Pileus Git - ~andy/gtk/blob - examples/radiobuttons/radiobuttons.c
Removed g_object_pointer_hash, which was just g_direct_hash.
[~andy/gtk] / examples / radiobuttons / radiobuttons.c
1 /* This file extracted from the GTK tutorial. */
2
3 /* radiobuttons.c */
4
5 #include <gtk/gtk.h>
6 #include <glib.h>
7
8 void close_application( GtkWidget *widget, GdkEvent *event, gpointer data ) 
9 {
10   gtk_main_quit();
11 }
12
13 int main(int argc,char *argv[])
14 {
15   static GtkWidget *window = NULL;
16   GtkWidget *box1;
17   GtkWidget *box2;
18   GtkWidget *button;
19   GtkWidget *separator;
20   GSList *group;
21   
22   gtk_init(&argc,&argv);          
23   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
24   
25   gtk_signal_connect (GTK_OBJECT (window), "delete_event",
26                       GTK_SIGNAL_FUNC(close_application),
27                       NULL);
28
29   gtk_window_set_title (GTK_WINDOW (window), "radio buttons");
30   gtk_container_border_width (GTK_CONTAINER (window), 0);
31
32   box1 = gtk_vbox_new (FALSE, 0);
33   gtk_container_add (GTK_CONTAINER (window), box1);
34   gtk_widget_show (box1);
35
36   box2 = gtk_vbox_new (FALSE, 10);
37   gtk_container_border_width (GTK_CONTAINER (box2), 10);
38   gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
39   gtk_widget_show (box2);
40
41   button = gtk_radio_button_new_with_label (NULL, "button1");
42   gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
43   gtk_widget_show (button);
44
45   group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
46   button = gtk_radio_button_new_with_label(group, "button2");
47   gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
48   gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
49   gtk_widget_show (button);
50
51   group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
52   button = gtk_radio_button_new_with_label(group, "button3");
53   gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
54   gtk_widget_show (button);
55
56   separator = gtk_hseparator_new ();
57   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
58   gtk_widget_show (separator);
59
60   box2 = gtk_vbox_new (FALSE, 10);
61   gtk_container_border_width (GTK_CONTAINER (box2), 10);
62   gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
63   gtk_widget_show (box2);
64
65   button = gtk_button_new_with_label ("close");
66   gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
67                              GTK_SIGNAL_FUNC(close_application),
68                              GTK_OBJECT (window));
69   gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
70   GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
71   gtk_widget_grab_default (button);
72   gtk_widget_show (button);
73   gtk_widget_show (window);
74           
75   gtk_main();
76   return(0);
77 }