[gnome-sudoku] Add accelerators for Undo, Redo and Print actions



commit ce459c256d3679b85b3cd4521f10e70195da3c7a
Author: Parin Porecha <parinporecha gmail com>
Date:   Thu Jun 5 11:49:36 2014 +0530

    Add accelerators for Undo, Redo and Print actions
    
    Move Help and Quit accels from data/gnome-sudoku-menu.ui
    to src/gnome-sudoku.vala

 data/gnome-sudoku-menu.ui |    2 --
 src/gnome-sudoku.vala     |   12 ++++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/data/gnome-sudoku-menu.ui b/data/gnome-sudoku-menu.ui
index bc5fd41..109c7b5 100644
--- a/data/gnome-sudoku-menu.ui
+++ b/data/gnome-sudoku-menu.ui
@@ -22,7 +22,6 @@
         <item>
           <attribute name="label" translatable="yes">_Help</attribute>
           <attribute name="action">app.help</attribute>
-          <attribute name="accel">F1</attribute>
         </item>
         <item>
           <attribute name="label" translatable="yes">_About</attribute>
@@ -31,7 +30,6 @@
         <item>
           <attribute name="label" translatable="yes">_Quit</attribute>
           <attribute name="action">app.quit</attribute>
-          <attribute name="accel">&lt;Primary&gt;q</attribute>
         </item>
       </section>
     </menu>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index be305d1..8452e05 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -114,6 +114,12 @@ public class Sudoku : Gtk.Application
             view.show_warnings = settings.get_boolean ("unfillable-squares-warning"));
         add_action (action);
 
+        add_accelerator ("<Primary>z", "app.undo", null);
+        add_accelerator ("<Primary><Shift>z", "app.redo", null);
+        add_accelerator ("<Primary>p", "app.print", null);
+        add_accelerator ("<Primary>q", "app.quit", null);
+        add_accelerator ("F1", "app.help", null);
+
         Gtk.Window.set_default_icon_name ("gnome-sudoku");
     }
 
@@ -366,6 +372,8 @@ public class Sudoku : Gtk.Application
 
     private void undo_cb ()
     {
+        if (!game_box.visible)
+            return;
         game.undo ();
         undo_action.set_enabled (!game.is_undostack_null ());
         view.queue_draw ();
@@ -373,6 +381,8 @@ public class Sudoku : Gtk.Application
 
     private void redo_cb ()
     {
+        if (!game_box.visible)
+            return;
         game.redo ();
         redo_action.set_enabled (!game.is_redostack_null ());
         view.queue_draw ();
@@ -380,6 +390,8 @@ public class Sudoku : Gtk.Application
 
     private void print_cb ()
     {
+        if (!game_box.visible)
+            return;
         var printer = new SudokuPrinter ({game.board.clone ()}, ref window);
         printer.print_sudoku ();
     }


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