1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
#include <stdlib.h>
|
1998-03-31 23:43:49 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
1999-11-13 23:06:46 +00:00
|
|
|
int main( int argc,
|
|
|
|
char *argv[] )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *event_box;
|
|
|
|
GtkWidget *label;
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_init (&argc, &argv);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Event Box");
|
2008-08-11 18:36:07 +00:00
|
|
|
|
|
|
|
g_signal_connect (window, "destroy",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (exit), NULL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
/* Create an EventBox and add it to our toplevel window */
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
event_box = gtk_event_box_new ();
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), event_box);
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_widget_show (event_box);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
/* Create a long label */
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
label = gtk_label_new ("Click here to quit, quit, quit, quit, quit");
|
|
|
|
gtk_container_add (GTK_CONTAINER (event_box), label);
|
|
|
|
gtk_widget_show (label);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
/* Clip it short. */
|
2002-02-16 23:52:30 +00:00
|
|
|
gtk_widget_set_size_request (label, 110, 20);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
/* And bind an action to it */
|
|
|
|
gtk_widget_set_events (event_box, GDK_BUTTON_PRESS_MASK);
|
2008-08-11 18:36:07 +00:00
|
|
|
g_signal_connect (event_box, "button-press-event",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (exit), NULL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
/* Yet one more thing you need an X window for ... */
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_widget_realize (event_box);
|
|
|
|
gdk_window_set_cursor (event_box->window, gdk_cursor_new (GDK_HAND1));
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_widget_show (window);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_main ();
|
2008-08-11 18:36:07 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
return 0;
|
1998-03-31 23:43:49 +00:00
|
|
|
}
|