[gnome-games/applygsoc2009: 42/76] XXX: Use a simple list for updating notes instead of NumberBoxModel



commit b7040dd5ee4ec8088d3be8ee7552f1fd80406d5a
Author: Pablo Castellano <pablog src gnome org>
Date:   Thu Aug 26 16:06:10 2010 +0200

    XXX: Use a simple list for updating notes instead of NumberBoxModel

 gnome-sudoku/src/lib/gsudoku.py |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gsudoku.py b/gnome-sudoku/src/lib/gsudoku.py
index 86e1941..4cef1af 100644
--- a/gnome-sudoku/src/lib/gsudoku.py
+++ b/gnome-sudoku/src/lib/gsudoku.py
@@ -127,8 +127,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)
 
@@ -137,9 +135,11 @@ 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):
         print "user input: number", (widget.x, widget.y, new_number)
@@ -244,13 +244,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
 
 
@@ -283,7 +280,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:
@@ -294,8 +291,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=top_note, bottom_note=bottom_note)
         self._signal_observers([change])
 
     def update(self, changes):



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