[gnome-sudoku/vala-port] Moved 'Show possible numbers' feature to a CLI option



commit 31fdcb66cebca3a05e2ee7a05daffaf87f681d03
Author: Parin Porecha <parinporecha gmail com>
Date:   Sat May 24 11:03:08 2014 +0530

    Moved 'Show possible numbers' feature to a CLI option

 data/gnome-sudoku-menu.ui |    4 ----
 src/gnome-sudoku.vala     |   14 ++++----------
 src/main.vala             |    8 +++++++-
 3 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/data/gnome-sudoku-menu.ui b/data/gnome-sudoku-menu.ui
index a2d98fe..449b33d 100644
--- a/data/gnome-sudoku-menu.ui
+++ b/data/gnome-sudoku-menu.ui
@@ -26,10 +26,6 @@
       </section>
       <section>
         <item>
-          <attribute name="label" translatable="yes">_Show Possible Numbers</attribute>
-          <attribute name="action">app.possible-numbers</attribute>
-        </item>
-        <item>
           <attribute name="label" translatable="yes">_Warn About Unfillable Squares</attribute>
           <attribute name="action">app.unfillable-squares</attribute>
         </item>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index 9db2005..147d8bf 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -22,12 +22,13 @@ public class Sudoku : Gtk.Application
     private NumberPicker number_picker;
 
     private SudokuStore sudoku_store;
-
     private SudokuSaver saver;
 
     private SimpleAction undo_action;
     private SimpleAction redo_action;
 
+    private bool show_possibilities;
+
     private const GLib.ActionEntry action_entries[] =
     {
         {"new-game", new_game_cb                                    },
@@ -36,16 +37,16 @@ public class Sudoku : Gtk.Application
         {"redo", redo_cb                                            },
         {"print", print_cb                                          },
         {"print-multiple", print_multiple_cb                        },
-        {"possible-numbers",   possible_numbers_cb,   null, "false" },
         {"unfillable-squares", unfillable_squares_cb, null, "false" },
         {"help", help_cb                                            },
         {"about", about_cb                                          },
         {"quit", quit_cb                                            }
     };
 
-    public Sudoku ()
+    public Sudoku (bool show_possibilities = false)
     {
         Object (application_id: "org.gnome.gnome-sudoku", flags: ApplicationFlags.FLAGS_NONE);
+        this.show_possibilities = show_possibilities;
     }
 
     protected override void startup()
@@ -116,7 +117,6 @@ public class Sudoku : Gtk.Application
         undo_action.set_enabled (false);
         redo_action.set_enabled (false);
 
-        var show_possibilities = false;
         var show_warnings = false;
 
         if (view != null) {
@@ -235,12 +235,6 @@ public class Sudoku : Gtk.Application
         printer.run_dialog ();
     }
 
-    public void possible_numbers_cb (SimpleAction action)
-    {
-        view.show_possibilities = !view.show_possibilities;
-        action.set_state (view.show_possibilities);
-    }
-
     public void unfillable_squares_cb (SimpleAction action)
     {
         view.show_warnings = !view.show_warnings;
diff --git a/src/main.vala b/src/main.vala
index 71cba26..71b6215 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -17,12 +17,18 @@
  */
 
 private static bool show_version;
+private static bool show_possibilities;
 
 private static const OptionEntry[] options =
 {
     { "version", 'v', 0, OptionArg.NONE, ref show_version,
     /* Help string for command line --version flag */
     N_("Show release version"), null},
+
+    { "show-possible-values", 's', 0, OptionArg.NONE, ref show_possibilities,
+    /* Help string for command line --show-possible flag */
+    N_("Show the possible values for each cell"), null},
+
     { null }
 };
 
@@ -79,7 +85,7 @@ public static int main (string[] args)
         return Posix.EXIT_SUCCESS;
     }
 
-    var app = new Sudoku ();
+    var app = new Sudoku (show_possibilities);
 
     return app.run ();
 }


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