[gnome-games] sudoku: Check for completeness on undo clear notes
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] sudoku: Check for completeness on undo clear notes
- Date: Sun, 18 Apr 2010 20:36:48 +0000 (UTC)
commit 26d0adb1ff7f6bd3f1b09196f1a36dfc1fb1ea3e
Author: Jim Ross <jimbo dimensia com>
Date: Thu Apr 8 23:40:42 2010 -0400
sudoku: Check for completeness on undo clear notes
gnome-sudoku/src/lib/main.py | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index bf1b929..3d1cf66 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -410,6 +410,11 @@ class UI (gconf_wrapper.GConfWrapper):
self.dancer.stop_dancing()
delattr(self, 'dancer')
+ def start_dancer (self):
+ import dancer
+ self.dancer = dancer.GridDancer(self.gsd)
+ self.dancer.start_dancing()
+
@simple_debug
def you_win_callback (self, grid):
if hasattr(self, 'dancer'):
@@ -437,9 +442,7 @@ class UI (gconf_wrapper.GConfWrapper):
sublabel += ngettext("You used the auto-fill %(n)s time.",
"You used the auto-fill %(n)s times.",
self.gsd.auto_fills) % {'n':self.gsd.auto_fills}
- import dancer
- self.dancer = dancer.GridDancer(self.gsd)
- self.dancer.start_dancing()
+ self.start_dancer()
dialog_extras.show_message(_("You win!"), label = _("You win!"),
sublabel = sublabel
)
@@ -563,13 +566,20 @@ class UI (gconf_wrapper.GConfWrapper):
def clear_notes_cb (self, *args):
clearer = Undo.UndoableObject(
lambda *args: self.cleared_notes.append(self.gsd.clear_notes()), #action
- # clear_notes returns a list of tuples indicating the cleared notes...
- # (x,y,(top,bottom)) -- this is what we need for undoing
- lambda *args: [self.gsd.__entries__[t[0], t[1]].set_notes(t[2]) for t in self.cleared_notes.pop()], #inverse
+ self.undo_clear_notes, #inverse
self.history
)
clearer.perform()
+ # add a check for finish in the undo to clear notes
+ def undo_clear_notes (self, *args):
+ # clear_notes returns a list of tuples indicating the cleared notes...
+ # (x,y,(top,bottom)) -- this is what we need for undoing
+ for entry in self.cleared_notes.pop():
+ self.gsd.__entries__[entry[0], entry[1]].set_notes(entry[2])
+ if self.gsd.grid.check_for_completeness():
+ self.start_dancer()
+
@simple_debug
def show_hint_cb (self, *args):
self.gsd.show_hint()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]