1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
2002-02-16 23:52:30 +00:00
|
|
|
#include <gtk/gtk.h>
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2005-01-03 19:26:36 +00:00
|
|
|
static gboolean close_application( GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data )
|
1998-06-09 23:18:11 +00:00
|
|
|
{
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_main_quit ();
|
2002-02-16 23:52:30 +00:00
|
|
|
return FALSE;
|
1998-03-31 23:43:49 +00:00
|
|
|
}
|
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
int main( int argc,
|
|
|
|
char *argv[] )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
1998-12-07 15:19:00 +00:00
|
|
|
GtkWidget *window = NULL;
|
|
|
|
GtkWidget *box1;
|
|
|
|
GtkWidget *box2;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *separator;
|
|
|
|
GSList *group;
|
2008-08-11 18:36:07 +00:00
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
|
|
|
g_signal_connect (window, "delete-event",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (close_application),
|
2002-02-19 01:25:26 +00:00
|
|
|
NULL);
|
1998-12-07 15:19:00 +00:00
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "radio buttons");
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
box1 = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), box1);
|
|
|
|
gtk_widget_show (box1);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
box2 = gtk_vbox_new (FALSE, 10);
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
|
1998-12-07 15:19:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (box2);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
button = gtk_radio_button_new_with_label (NULL, "button1");
|
|
|
|
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
2002-02-19 01:25:26 +00:00
|
|
|
button = gtk_radio_button_new_with_label (group, "button2");
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
1998-12-07 15:19:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-25 01:47:44 +00:00
|
|
|
button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button),
|
|
|
|
"button3");
|
1998-12-07 15:19:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
separator = gtk_hseparator_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (separator);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
box2 = gtk_vbox_new (FALSE, 10);
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
|
1998-12-07 15:19:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (box2);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
1998-12-07 15:19:00 +00:00
|
|
|
button = gtk_button_new_with_label ("close");
|
2008-08-11 18:36:07 +00:00
|
|
|
g_signal_connect_swapped (button, "clicked",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (close_application),
|
2008-08-11 18:36:07 +00:00
|
|
|
window);
|
1998-12-07 15:19:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
2010-03-02 06:58:05 +00:00
|
|
|
gtk_widget_set_can_default (button, TRUE);
|
1998-12-07 15:19:00 +00:00
|
|
|
gtk_widget_grab_default (button);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
gtk_widget_show (window);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_main ();
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
return 0;
|
1998-03-31 23:43:49 +00:00
|
|
|
}
|