summaryrefslogtreecommitdiff
path: root/examples/eventbox
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/eventbox
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/eventbox')
-rw-r--r--examples/eventbox/Makefile8
-rw-r--r--examples/eventbox/eventbox.c55
2 files changed, 63 insertions, 0 deletions
diff --git a/examples/eventbox/Makefile b/examples/eventbox/Makefile
new file mode 100644
index 000000000..e010b9c2d
--- /dev/null
+++ b/examples/eventbox/Makefile
@@ -0,0 +1,8 @@
+
+CC = gcc
+
+eventbox: eventbox.c
+ $(CC) `gtk-config --cflags` `gtk-config --libs` eventbox.c -o eventbox
+
+clean:
+ rm -f *.o eventbox
diff --git a/examples/eventbox/eventbox.c b/examples/eventbox/eventbox.c
new file mode 100644
index 000000000..c3ec105ee
--- /dev/null
+++ b/examples/eventbox/eventbox.c
@@ -0,0 +1,55 @@
+/* This file extracted from the GTK tutorial. */
+
+/* eventbox.c */
+
+#include <gtk/gtk.h>
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *event_box;
+ GtkWidget *label;
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Event Box");
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC (gtk_exit), NULL);
+
+ gtk_container_border_width (GTK_CONTAINER (window), 10);
+
+ /* Create an EventBox and add it to our toplevel window */
+
+ event_box = gtk_event_box_new ();
+ gtk_container_add (GTK_CONTAINER(window), event_box);
+ gtk_widget_show (event_box);
+
+ /* Create a long label */
+
+ label = gtk_label_new ("Click here to quit, quit, quit, quit, quit");
+ gtk_container_add (GTK_CONTAINER (event_box), label);
+ gtk_widget_show (label);
+
+ /* Clip it short. */
+ gtk_widget_set_usize (label, 110, 20);
+
+ /* And bind an action to it */
+ gtk_widget_set_events (event_box, GDK_BUTTON_PRESS_MASK);
+ gtk_signal_connect (GTK_OBJECT(event_box), "button_press_event",
+ GTK_SIGNAL_FUNC (gtk_exit), NULL);
+
+ /* Yet one more thing you need an X window for ... */
+
+ gtk_widget_realize (event_box);
+ gdk_window_set_cursor (event_box->window, gdk_cursor_new (GDK_HAND1));
+
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
+}