summaryrefslogtreecommitdiff
path: root/examples/radiobuttons
diff options
context:
space:
mode:
authorShawn Amundson <amundson@src.gnome.org>1998-03-31 23:43:49 +0000
committerShawn Amundson <amundson@src.gnome.org>1998-03-31 23:43:49 +0000
commitc36ca76bb84879ed1e2ba51541c95eacd56e550e (patch)
tree8a01644357246180f22165e28d7f0cdf8cf67afe /examples/radiobuttons
parent30f22e0208593dba5ca5d3b824d8d03519414296 (diff)
downloadgdk-pixbuf-c36ca76bb84879ed1e2ba51541c95eacd56e550e.tar.gz
Tue Mar 31 15:41:57 PST 1998 Shawn T. Amundson
* Makefile.am: * examples/*: added the rest of the tutorial examples
Diffstat (limited to 'examples/radiobuttons')
-rw-r--r--examples/radiobuttons/Makefile8
-rw-r--r--examples/radiobuttons/radiobuttons.c76
2 files changed, 84 insertions, 0 deletions
diff --git a/examples/radiobuttons/Makefile b/examples/radiobuttons/Makefile
new file mode 100644
index 000000000..96d0a19ca
--- /dev/null
+++ b/examples/radiobuttons/Makefile
@@ -0,0 +1,8 @@
+
+CC = gcc
+
+radiobuttons: radiobuttons.c
+ $(CC) `gtk-config --cflags` `gtk-config --libs` radiobuttons.c -o radiobuttons
+
+clean:
+ rm -f *.o radiobuttons
diff --git a/examples/radiobuttons/radiobuttons.c b/examples/radiobuttons/radiobuttons.c
new file mode 100644
index 000000000..88038acc2
--- /dev/null
+++ b/examples/radiobuttons/radiobuttons.c
@@ -0,0 +1,76 @@
+/* This file extracted from the GTK tutorial. */
+
+/* radiobuttons.c */
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+void close_application( GtkWidget *widget, gpointer *data ) {
+ gtk_main_quit();
+}
+
+int main(int argc,char *argv[])
+{
+ static GtkWidget *window = NULL;
+ GtkWidget *box1;
+ GtkWidget *box2;
+ GtkWidget *button;
+ GtkWidget *separator;
+ GSList *group;
+
+ gtk_init(&argc,&argv);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_signal_connect (GTK_OBJECT (window), "delete_event",
+ GTK_SIGNAL_FUNC(close_application),
+ NULL);
+
+ gtk_window_set_title (GTK_WINDOW (window), "radio buttons");
+ gtk_container_border_width (GTK_CONTAINER (window), 0);
+
+ box1 = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), box1);
+ gtk_widget_show (box1);
+
+ box2 = gtk_vbox_new (FALSE, 10);
+ gtk_container_border_width (GTK_CONTAINER (box2), 10);
+ gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
+ gtk_widget_show (box2);
+
+ button = gtk_radio_button_new_with_label (NULL, "button1");
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
+ button = gtk_radio_button_new_with_label(group, "button2");
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
+ button = gtk_radio_button_new_with_label(group, "button3");
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ separator = gtk_hseparator_new ();
+ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
+ gtk_widget_show (separator);
+
+ box2 = gtk_vbox_new (FALSE, 10);
+ gtk_container_border_width (GTK_CONTAINER (box2), 10);
+ gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
+ gtk_widget_show (box2);
+
+ button = gtk_button_new_with_label ("close");
+ gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(close_application),
+ GTK_OBJECT (window));
+ gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_show (window);
+
+ gtk_main();
+ return(0);
+}