gnome-games r8904 - trunk/gnomine



Author: thomashpa
Date: Wed Mar 25 16:47:31 2009
New Revision: 8904
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8904&view=rev

Log:
Pause/resume on pause key. Patch by Jack Cheney. Fixes bug #575765

Modified:
   trunk/gnomine/gnomine.c

Modified: trunk/gnomine/gnomine.c
==============================================================================
--- trunk/gnomine/gnomine.c	(original)
+++ trunk/gnomine/gnomine.c	Wed Mar 25 16:47:31 2009
@@ -30,6 +30,7 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 #include <libgames-support/games-clock.h>
 #include <libgames-support/games-conf.h>
@@ -87,6 +88,7 @@
 gboolean use_question_marks = TRUE;
 gboolean use_overmine_warning = TRUE;
 gboolean use_autoflag = FALSE;
+gboolean game_paused = FALSE;
 
 GtkAction *hint_action;
 GtkAction *fullscreen_action;
@@ -348,6 +350,7 @@
 
     gtk_action_set_visible (pause_action, FALSE);
     gtk_action_set_visible (resume_action, TRUE);
+    game_paused = TRUE;
   }
 }
 
@@ -361,6 +364,7 @@
 
   gtk_action_set_visible (pause_action, TRUE);
   gtk_action_set_visible (resume_action, FALSE);
+  game_paused = FALSE;
 }
 
 static void
@@ -636,6 +640,23 @@
   return FALSE;
 }
 
+
+static void
+pause_key_callback(GtkWidget *widget, GdkEventKey *event,
+gpointer data )
+{
+
+  if(event->keyval == GDK_Pause)
+  {
+    if(game_paused)
+      resume_game_cb(NULL, NULL); // Resume the game
+    else
+      pause_callback(NULL, NULL, NULL); // Pause the game
+  }
+			
+}
+
+
 static void
 create_preferences (void)
 {
@@ -773,6 +794,7 @@
   gtk_widget_show_all (GTK_WIDGET (table));
 }
 
+
 static void
 preferences_callback (void)
 {
@@ -1054,6 +1076,10 @@
   g_signal_connect (G_OBJECT (window), "window_state_event",
 		    G_CALLBACK (window_state_callback), NULL);
 
+  // For pause/resume with the keyboard pause key
+  g_signal_connect (G_OBJECT (window), "key_press_event", 
+                    G_CALLBACK (pause_key_callback), NULL); 
+
   all_boxes = gtk_vbox_new (FALSE, 0);
 
   gtk_container_add (GTK_CONTAINER (window), all_boxes);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]