Hello,

I' trying to use pigment/elisa in a keyboardless environment. When I
tried the pigment examples I could not quit these examples easily with
the keyboard.
The applied patch fixes this and allows quiting via the keyboard.

Gr,
Thijs
Index: examples/pgm/text.c
===================================================================
--- examples/pgm/text.c	(revision 626)
+++ examples/pgm/text.c	(working copy)
@@ -37,6 +37,20 @@
   len = g_unichar_to_utf8 (unicode, buffer);
   buffer[len] = '\0';
   g_print ("keyval:0x%x  ucs:%d  char:'%s'\n", event->keyval, unicode, buffer);
+  if (event->type == PGM_KEY_PRESS)
+    {
+      switch (event->keyval)
+        {
+            /* Quit */
+        case PGM_q:
+        case PGM_Escape:
+          pgm_main_quit ();
+          break;
+
+        default:
+          break;
+        }
+    }
 }
 
 static void
Index: examples/pgm/video.c
===================================================================
--- examples/pgm/video.c	(revision 626)
+++ examples/pgm/video.c	(working copy)
@@ -24,6 +24,27 @@
 
 #include <pgm/pgm.h>
 
+static void
+keypress_event_cb (PgmViewport *viewport,
+                   PgmEventKey *event,
+                   gpointer data)
+{
+  if (event->type == PGM_KEY_PRESS)
+    {
+      switch (event->keyval)
+        {
+          /* Quit */
+        case PGM_q:
+        case PGM_Escape:
+          pgm_main_quit ();
+          break;
+
+        default:
+          break;
+        }
+    }
+}
+
 static gboolean
 update (gpointer data)
 {
@@ -101,6 +122,8 @@
   gst_element_set_state (pipeline, GST_STATE_PLAYING);
 
   /* Main loop */
+  g_signal_connect (G_OBJECT (gl), "key-press-event",
+                    G_CALLBACK (keypress_event_cb), NULL);
   g_signal_connect (G_OBJECT (gl), "delete-event",
                     G_CALLBACK (pgm_main_quit), NULL);
   g_timeout_add (10, update, gl);

Reply via email to