[gnome-sudoku/gnome-3-16] Clear earmarks when a cell is filled



commit 1b8928d631fca0b28dbb4d2313839c27dba44f16
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Sun Mar 1 14:58:02 2015 +0200

    Clear earmarks when a cell is filled
    
    If the user inputs a number in a cell that contains earmarks, the
    earmarks should automatically hide.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724603

 lib/sudoku-board.vala |    8 ++++++++
 src/sudoku-view.vala  |    4 ++++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/lib/sudoku-board.vala b/lib/sudoku-board.vala
index b36d694..9a9f02e 100644
--- a/lib/sudoku-board.vala
+++ b/lib/sudoku-board.vala
@@ -211,6 +211,14 @@ public class SudokuBoard : Object
         }
     }
 
+    public void disable_all_earmarks (int row, int column)
+        ensures (n_earmarks >= 0)
+    {
+        for (var i = 1; i <= max_val; i++)
+            if (earmarks[row, column, i-1])
+                disable_earmark (row, column, i);
+    }
+
     public bool is_earmark_enabled (int row, int column, int digit)
     {
         return earmarks[row, column, digit-1];
diff --git a/src/sudoku-view.vala b/src/sudoku-view.vala
index 2111c59..eabb37e 100644
--- a/src/sudoku-view.vala
+++ b/src/sudoku-view.vala
@@ -123,6 +123,7 @@ private class SudokuCellView : Gtk.DrawingArea
             value = number;
             if (number == 0)
                 notify_property ("value");
+            this.game.board.disable_all_earmarks (row, col);
 
             popover.hide ();
         });
@@ -259,7 +260,10 @@ private class SudokuCellView : Gtk.DrawingArea
                 }
             }
             else
+            {
                 value = k_no;
+                this.game.board.disable_all_earmarks (row, col);
+            }
             return true;
         }
         if (k_no == 0 || k_name == "BackSpace" || k_name == "Delete")


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