[gnome-mines/gnome-3-18] Added extra keyboard shortcuts for starting/stopping games



commit fe0d0998bea2603430953d25484fdccbcca43a00
Author: Isaac Lenton <isaac isuniversal com>
Date:   Sat Oct 31 19:34:11 2015 +1000

    Added extra keyboard shortcuts for starting/stopping games
    
        - Numbers 1-4 launch small, medium, large and custom games
        - Escape key returns to new game screen if game hasn't started
    
        https://bugzilla.gnome.org/show_bug.cgi?id=757406

 src/gnome-mines.vala |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index f372079..886bbb4 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -95,7 +95,12 @@ public class Mines : Gtk.Application
     private const GLib.ActionEntry[] action_entries =
     {
         { "new-game",           new_game_cb                                 },
+        { "silent-new-game",    silent_new_game_cb                          },
         { "repeat-size",        repeat_size_cb                              },
+        { "small-size",         small_size_clicked_cb                       },
+        { "medium-size",        medium_size_clicked_cb                      },
+        { "large-size",         large_size_clicked_cb                       },
+        { "custom-size",        show_custom_game_screen                     },
         { "pause",              toggle_pause_cb                             },
         { "scores",             scores_cb                                   },
         { "preferences",        preferences_cb                              },
@@ -264,7 +269,12 @@ public class Mines : Gtk.Application
         }
 
         set_accels_for_action ("app.new-game", {"<Primary>n"});
+        set_accels_for_action ("app.silent-new-game", {"Escape"});
         set_accels_for_action ("app.repeat-size", {"<Primary>r"});
+        set_accels_for_action ("app.small-size", {"1"});
+        set_accels_for_action ("app.medium-size", {"2"});
+        set_accels_for_action ("app.large-size", {"3"});
+        set_accels_for_action ("app.custom-size", {"4"});
         set_accels_for_action ("app.pause", {"Pause"});
         set_accels_for_action ("app.help", {"F1"});
         set_accels_for_action ("app.quit", {"<Primary>q", "<Primary>w"});
@@ -533,6 +543,9 @@ public class Mines : Gtk.Application
 
     private void show_custom_game_screen ()
     {
+        if (minefield != null)
+            return;
+
         stack.visible_child_name = "custom_game";
     }
 
@@ -670,6 +683,12 @@ public class Mines : Gtk.Application
             show_new_game_screen ();
     }
 
+    private void silent_new_game_cb ()
+    {
+        if (minefield == null || minefield.n_cleared == 0)
+            show_new_game_screen ();
+    }
+
     private void repeat_size_cb ()
     {
         if (can_start_new_game ())
@@ -844,6 +863,9 @@ public class Mines : Gtk.Application
 
     private void set_mode (int mode)
     {
+        if (minefield != null)
+            return;
+
         if (mode != settings.get_int (KEY_MODE))
             settings.set_int (KEY_MODE, mode);
 


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