diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/tutorial/src/include/cairo-tutorial-gtk.h | 17 |
2 files changed, 22 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2006-01-26 Carl Worth <cworth@cworth.org> + + * doc/tutorial/src/include/cairo-tutorial-gtk.h: Add a CONTROL-Q + keybinding to quit. + 2006-01-26 Keith Packard <keithp@keithp.com> reviewed by: cworth diff --git a/doc/tutorial/src/include/cairo-tutorial-gtk.h b/doc/tutorial/src/include/cairo-tutorial-gtk.h index 7be74e21d..cdf96e20a 100644 --- a/doc/tutorial/src/include/cairo-tutorial-gtk.h +++ b/doc/tutorial/src/include/cairo-tutorial-gtk.h @@ -17,6 +17,8 @@ */ #include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> + #include <cairo.h> #ifndef WIDTH @@ -87,6 +89,18 @@ handle_expose (GtkWidget *widget, return FALSE; } +static gboolean +handle_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data) +{ + if ((event->keyval == GDK_Q || + event->keyval == GDK_q) && (event->state & GDK_CONTROL_MASK)) + gtk_main_quit (); + + return FALSE; +} + int main (int argc, char **argv) { @@ -108,6 +122,9 @@ main (int argc, char **argv) g_signal_connect (drawing_area, "expose-event", G_CALLBACK (handle_expose), NULL); + g_signal_connect (window, "key-press-event", + G_CALLBACK (handle_key_press), NULL); + gtk_widget_show_all (window); gtk_main (); |