[gnome-games/sudoku-tube] Use a simple list for updating notes
- From: Zhang Sen <zhangsen src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/sudoku-tube] Use a simple list for updating notes
- Date: Fri, 17 Jul 2009 11:04:46 +0000 (UTC)
commit 4acb5217ca4ecaaa19485dd66ed739be9028279e
Author: Zhang Sen <zh jesse gmail com>
Date: Fri Jul 17 07:08:23 2009 +0800
Use a simple list for updating notes
instead of NumberBoxModel
gnome-sudoku/src/lib/gsudoku.py | 24 +++++++-----------------
1 files changed, 7 insertions(+), 17 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gsudoku.py b/gnome-sudoku/src/lib/gsudoku.py
index ffcd05b..0b21778 100644
--- a/gnome-sudoku/src/lib/gsudoku.py
+++ b/gnome-sudoku/src/lib/gsudoku.py
@@ -196,8 +196,6 @@ class SudokuView(SudokuNumberGrid, gobject.GObject):
if box.value is not None:
self.set_value(x, y, box.value)
self.emit("view-updated", x, y, box.value)
- if box.top_note is not None or box.bottom_note is not None:
- self._set_notes(x, y, box.top_note, box.bottom_note)
if box.conflict is not None:
self._show_conflict(x, y, box.conflict)
@@ -207,8 +205,10 @@ class SudokuView(SudokuNumberGrid, gobject.GObject):
def _show_conflict(self, x, y, conflict):
self.__entries__[(x, y)].set_error_highlight(conflict)
- def _set_notes(self, x, y, top_note, bottom_note):
- self.__entries__[(x, y)].set_notes((top_note, bottom_note))
+ def update_notes(self, notes_list):
+ for notes in notes_list:
+ x, y, top_note, bottom_note = notes
+ self.__entries__[(x, y)].set_notes((top_note, bottom_note))
def _number_changed_cb(self, widget, new_number):
self.update_model(widget.x, widget.y, new_number)
@@ -303,13 +303,10 @@ class SudokuView(SudokuNumberGrid, gobject.GObject):
class NumberBoxModel:
- def __init__(self, x, y, value=None, top_note=None, bottom_note=None,
- conflict=None):
+ def __init__(self, x, y, value=None, conflict=None):
self.x = x
self.y = y
self.value = value
- self.top_note = top_note
- self.bottom_note = bottom_note
self.conflict = conflict
@@ -343,7 +340,7 @@ class NotesModel:
def _signal_observers(self, changes):
for observer in self._observers:
- observer.update(changes)
+ observer.update_notes(changes)
def set_notes(self, x, y, top_note=None, bottom_note=None):
if (x, y) not in self._notes:
@@ -354,8 +351,7 @@ class NotesModel:
if bottom_note is not None:
self._notes[(x, y)][0] = bottom_note
- change = NumberBoxModel(x, y,
- top_note=top_note, bottom_note=bottom_note)
+ change = (x, y, top_note, bottom_note)
self._signal_observers([change])
def update(self, changes):
@@ -513,12 +509,6 @@ class SudokuModel:
def get_value(self, x, y):
return self.grid._get_(x, y)
- def set_notes(self, x, y, top_note, bottom_note):
- # should first add notes to model
- change = NumberBoxModel(x, y,
- top_note=top_note, bottom_note=bottom_note)
- self._signal_observers([change])
-
def _remove_old_conficts(self, x, y):
result = []
old_conflicts = self._remove_related_conflicts(x, y)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]