gnome-games r7853 - trunk/gnome-sudoku/src/lib
- From: thomashpa svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r7853 - trunk/gnome-sudoku/src/lib
- Date: Mon, 1 Sep 2008 15:29:04 +0000 (UTC)
Author: thomashpa
Date: Mon Sep 1 15:29:04 2008
New Revision: 7853
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7853&view=rev
Log:
Stop the dancer when undoing after win. Bug #532357. Patch by Zhang Sen/Thomas H.P. Andersen
Modified:
trunk/gnome-sudoku/src/lib/gsudoku.py
trunk/gnome-sudoku/src/lib/main.py
Modified: trunk/gnome-sudoku/src/lib/gsudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/gsudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/gsudoku.py Mon Sep 1 15:29:04 2008
@@ -119,6 +119,7 @@
top_note_text = ''
bottom_note_text = ''
read_only = False
+ read_only_hidden = False
_layout = None
_top_note_layout = None
_bottom_note_layout = None
@@ -1319,7 +1320,9 @@
self.grid = grid
self.dancing = False
for box in self.grid.__entries__.values():
- box.read_only = False
+ if box.read_only == True:
+ box.read_only = False
+ box.read_only_hidden = True
box.queue_draw()
def start_dancing (self):
@@ -1333,6 +1336,9 @@
self.dancing = False
for box in self.grid.__entries__.values():
box.props.can_focus = True
+ if box.read_only_hidden == True:
+ box.read_only = True
+ box.read_only_hidden = False
self.grid.unhighlight_cells()
def do_dance_step (self):
Modified: trunk/gnome-sudoku/src/lib/main.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/main.py (original)
+++ trunk/gnome-sudoku/src/lib/main.py Mon Sep 1 15:29:04 2008
@@ -329,7 +329,7 @@
self.edit_actions = gtk.ActionGroup('EditActions')
self.edit_actions.add_actions(
[('Edit',None,_('_Edit')),
- ('Undo',gtk.STOCK_UNDO,_('_Undo'),'<Control>z',_('Undo last action')),
+ ('Undo',gtk.STOCK_UNDO,_('_Undo'),'<Control>z',_('Undo last action'), self.stop_dancer),
('Redo',gtk.STOCK_REDO,_('_Redo'),'<Shift><Control>z',_('Redo last action')),
('Clear',gtk.STOCK_CLEAR,_('_Clear'),'<Control>b',_("Clear entries you've filled in"),self.clear_cb),
('ClearNotes',None,_('Clear _Notes'),None,_("Clear notes and hints"),self.clear_notes_cb),
@@ -456,6 +456,11 @@
for c in self.worker_connections:
self.timer.disconnect(c)
+ def stop_dancer (self, *args):
+ if hasattr(self, 'dancer'):
+ self.dancer.stop_dancing()
+ delattr(self, 'dancer')
+
@simple_debug
def you_win_callback (self,grid):
self.won = True
@@ -538,9 +543,7 @@
self.do_stop()
def do_stop (self):
- if hasattr(self,'dancer'):
- self.dancer.stop_dancing()
- delattr(self,'dancer')
+ self.stop_dancer()
self.gsd.grid = None
self.tracker_ui.reset()
self.history.clear()
@@ -653,12 +656,24 @@
@simple_debug
def clear_cb (self,*args):
clearer=Undo.UndoableObject(
- lambda *args: self.cleared.append(self.gsd.reset_grid()), #action
- lambda *args: [self.gsd.add_value_to_ui(*entry) for entry in self.cleared.pop()], #inverse
+ self.do_clear, #action
+ self.undo_clear, #inverse
self.history #history
)
clearer.perform()
+ # add a check to stop the dancer if she is dancing
+ def do_clear (self, *args):
+ self.cleared.append(self.gsd.reset_grid())
+ self.stop_dancer()
+
+ # add a check for finish in the undo to clear
+ def undo_clear (self, *args):
+ for entry in self.cleared.pop():
+ self.gsd.add_value_to_ui(*entry)
+ if self.gsd.grid.check_for_completeness():
+ self.gsd.emit('puzzle-finished')
+
def clear_notes_cb (self, *args):
clearer = Undo.UndoableObject(
lambda *args: self.cleared_notes.append(self.gsd.clear_notes()), #action
@@ -694,12 +709,23 @@
if not hasattr(self,'autofilled'): self.autofilled=[]
if not hasattr(self,'autofiller'):
self.autofiller = Undo.UndoableObject(
- lambda *args: self.autofilled.append(self.gsd.auto_fill()),
- lambda *args: [self.gsd.remove(entry[0],entry[1],do_removal=True) for entry in self.autofilled.pop()],
+ self.do_auto_fill,
+ self.undo_auto_fill,
self.history
)
self.autofiller.perform()
+ def do_auto_fill (self, *args):
+ self.autofilled.append(self.gsd.auto_fill())
+ if self.gconf['always_show_hints']:
+ self.gsd.update_all_hints()
+
+ def undo_auto_fill (self, *args):
+ for entry in self.autofilled.pop():
+ self.gsd.remove(entry[0],entry[1],do_removal=True)
+ if self.gconf['always_show_hints']:
+ self.gsd.update_all_hints()
+
@simple_debug
def auto_fill_current_square_cb (self, *args):
self.gsd.auto_fill_current_entry()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]