[gnome-sudoku] Hook unfillable squares warning up to gsettings



commit 4c33bbeb6993f1699a409c7a80150f2b6fb321e1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat May 31 11:38:06 2014 -0500

    Hook unfillable squares warning up to gsettings

 data/gnome-sudoku-menu.ui         |    2 +-
 data/org.gnome.sudoku.gschema.xml |    4 +++-
 src/gnome-sudoku.vala             |   19 +++++++++----------
 3 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/data/gnome-sudoku-menu.ui b/data/gnome-sudoku-menu.ui
index 449b33d..0589b9e 100644
--- a/data/gnome-sudoku-menu.ui
+++ b/data/gnome-sudoku-menu.ui
@@ -27,7 +27,7 @@
       <section>
         <item>
           <attribute name="label" translatable="yes">_Warn About Unfillable Squares</attribute>
-          <attribute name="action">app.unfillable-squares</attribute>
+          <attribute name="action">app.unfillable-squares-warning</attribute>
         </item>
       </section>
       <section>
diff --git a/data/org.gnome.sudoku.gschema.xml b/data/org.gnome.sudoku.gschema.xml
index ce1733d..bb05284 100644
--- a/data/org.gnome.sudoku.gschema.xml
+++ b/data/org.gnome.sudoku.gschema.xml
@@ -82,8 +82,10 @@
       <summary>Show the application toolbar</summary>
       <description>Show the application toolbar</description>
     </key>
-    <key name="show-impossible-implications" type="b">
+    <key name="unfillable-squares-warning" type="b">
       <default>false</default>
+      <summary>Warn about unfillable squares</summary>
+      <description>Displays a big red X in a square if it cannot possibly be filled by any 
number</description>
     </key>
     <key name="always-show-hints" type="b">
       <default>false</default>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index b26f09d..0d2c866 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -7,6 +7,7 @@ using Gdk;
 public class Sudoku : Gtk.Application
 {
     private GLib.Settings settings;
+
     private Builder builder;
 
     private ApplicationWindow window;
@@ -37,7 +38,6 @@ public class Sudoku : Gtk.Application
         {"redo", redo_cb                                            },
         {"print", print_cb                                          },
         {"print-multiple", print_multiple_cb                        },
-        {"unfillable-squares", unfillable_squares_cb, null, "false" },
         {"help", help_cb                                            },
         {"about", about_cb                                          },
         {"quit", quit_cb                                            }
@@ -53,6 +53,13 @@ public class Sudoku : Gtk.Application
     {
         base.startup ();
         add_action_entries (action_entries, this);
+
+        settings = new GLib.Settings ("org.gnome.sudoku");
+        var action = settings.create_action ("unfillable-squares-warning");
+        action.notify["state"].connect (() =>
+            view.show_warnings = settings.get_boolean ("unfillable-squares-warning"));
+        add_action (action);
+
         Gtk.Window.set_default_icon_name ("gnome-sudoku");
     }
 
@@ -62,8 +69,6 @@ public class Sudoku : Gtk.Application
         Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
         Intl.textdomain (GETTEXT_PACKAGE);
 
-        settings = new GLib.Settings ("org.gnome.sudoku");
-
         builder = new Builder ();
         try
         {
@@ -139,7 +144,7 @@ public class Sudoku : Gtk.Application
         view = new SudokuView (game);
 
         view.show_possibilities = show_possibilities;
-        view.show_warnings = show_warnings;
+        view.show_warnings = settings.get_boolean ("unfillable-squares-warning");
 
         view.show ();
         grid_box.pack_start (view);
@@ -240,12 +245,6 @@ public class Sudoku : Gtk.Application
         printer.run_dialog ();
     }
 
-    private void unfillable_squares_cb (SimpleAction action)
-    {
-        view.show_warnings = !view.show_warnings;
-        action.set_state (view.show_warnings);
-    }
-
     private void quit_cb ()
     {
         saver.save_game (game);


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