[gnome-games/applygsoc2009: 19/76] Append underscore to private methods



commit c332c5b5ce9815bf2be1422073b74ea337aff898
Author: Pablo Castellano <pablog src gnome org>
Date:   Sun Aug 1 18:55:47 2010 +0200

    Append underscore to private methods

 gnome-sudoku/src/lib/gsudoku.py |   66 +++++++++++++++++++-------------------
 1 files changed, 33 insertions(+), 33 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gsudoku.py b/gnome-sudoku/src/lib/gsudoku.py
index 0e26db5..3d940c9 100644
--- a/gnome-sudoku/src/lib/gsudoku.py
+++ b/gnome-sudoku/src/lib/gsudoku.py
@@ -89,22 +89,22 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         self.tinfo = tracker_info.TrackerInfo()
         gobject.GObject.__init__(self)
         SudokuNumberGrid.__init__(self, group_size = group_size)
-        self.setup_grid(grid, group_size)
+        self._setup_grid(grid, group_size)
         for e in self.__entries__.values():
             e.show()
-            e.connect('undo-change', self.entry_callback, 'undo-change')
-            e.connect('changed', self.entry_callback)
-            e.connect('focus-in-event', self.focus_callback)
-            e.connect('key-press-event', self.key_press_cb)
-        self.connect('focus-changed', self.highlight_cells)
+            e.connect('undo-change', self._entry_callback, 'undo-change')
+            e.connect('changed', self._entry_callback)
+            e.connect('focus-in-event', self._focus_callback)
+            e.connect('key-press-event', self._key_press_cb)
+        self.connect('focus-changed', self._highlight_cells)
 
-    def key_press_cb (self, widget, event):
+    def _key_press_cb (self, widget, event):
         key = gtk.gdk.keyval_name(event.keyval)
-        dest = self.go_around(widget.x, widget.y, key)
+        dest = self._go_around(widget.x, widget.y, key)
         if dest:
             self.table.set_focus_child(self.__entries__[dest])
 
-    def go_around (self, x, y, direction):
+    def _go_around (self, x, y, direction):
         '''return the coordinate if we should go to the other side of the grid.
         Or else return None.'''
         (limit_min, limit_max) = (0, self.group_size -1)
@@ -125,7 +125,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         self.focused = e
         self.emit('focus-changed')
 
-    def get_highlight_colors (self):
+    def _get_highlight_colors (self):
         entry = self.__entries__.values()[0]
         default_color = gtkcolor_to_rgb(entry.style.bg[gtk.STATE_SELECTED])
         hsv = colors.rgb_to_hsv(*default_color)
@@ -147,20 +147,20 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
 
     def toggle_highlight (self, val):
         self.do_highlight_cells = val
-        self.unhighlight_cells()
+        self._unhighlight_cells()
         if self.focused:
-            self.highlight_cells()
+            self._highlight_cells()
 
-    def unhighlight_cells (self, *args):
+    def _unhighlight_cells (self, *args):
         for e in self.__entries__.values():
             e.set_background_color(None)
 
-    def highlight_cells (self, *args):
+    def _highlight_cells (self, *args):
         if not self.do_highlight_cells:
             return
-        self.unhighlight_cells()
+        self._unhighlight_cells()
         if self.focused:
-            self.get_highlight_colors()
+            self._get_highlight_colors()
         my_x, my_y = self.focused.x, self.focused.y
 
         # col_coords can sometimes be null.
@@ -230,7 +230,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             self.set_hint_square(random.choice(squares))
             self.hints += 1
 
-    def show_hint_for_entry (self, entry, interactive = False):
+    def _show_hint_for_entry (self, entry, interactive = False):
         if interactive:
             set_method = entry.set_note_text_interactive
         else:
@@ -355,7 +355,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         self.update_all_notes()
 
     @simple_debug
-    def blank_grid (self):
+    def _blank_grid (self):
         '''Wipe out everything on the grid.
 
         This blanks all values, notes, tracked values, virgin values.  You end
@@ -378,8 +378,8 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
     def change_grid (self, grid, group_size):
         self.hints = 0
         self.impossible_hints = 0
-        self.blank_grid()
-        self.setup_grid(grid, group_size)
+        self._blank_grid()
+        self._setup_grid(grid, group_size)
 
     @simple_debug
     def load_game (self, game):
@@ -388,7 +388,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         A game is simply a two lined string where the first line represents our
         virgin self and line two represents our game-in-progress.
         """
-        self.blank_grid()
+        self._blank_grid()
         if '\n' in game:
             virgin, in_prog = game.split('\n')
         else:
@@ -405,7 +405,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
                         self.add_value(col, row, values[index])
 
     @simple_debug
-    def setup_grid (self, grid, group_size):
+    def _setup_grid (self, grid, group_size):
         self.doing_initial_setup = True
         if isinstance(grid, sudoku.SudokuGrid):
             self.grid = sudoku.InteractiveSudoku(grid.grid, group_size = grid.group_size)
@@ -419,14 +419,14 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         self.doing_initial_setup = False
 
     @simple_debug
-    def entry_callback (self, widget, *args):
+    def _entry_callback (self, widget, *args):
         if not widget.get_text():
             self.remove(widget.x, widget.y, *args)
             # Trackers need to be redisplayed on an undo
             if args and args[0] == 'undo-change':
                 self.show_track()
         else:
-            self.entry_validate(widget, *args)
+            self._entry_validate(widget, *args)
 
     def update_all_hints (self):
         for x in range(self.group_size):
@@ -437,7 +437,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
                 elif e.get_text():
                     e.set_note_text(bottom_text = '')
                 else:
-                    self.show_hint_for_entry(e)
+                    self._show_hint_for_entry(e)
 
     def update_all_notes (self):
         '''Display the notes for all the cells
@@ -450,12 +450,12 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
                 self.__entries__[(x, y)].show_note_text()
 
     @simple_debug
-    def entry_validate (self, widget, *args):
+    def _entry_validate (self, widget, *args):
         val = widget.get_value()
         if (args and args[0] == 'undo-change'):
             # When undoing from one value to another - remove the errors from
             # the previous value and add the new value to the proper tracker
-            self.remove_error_highlight()
+            self._remove_error_highlight()
             self.add_value(widget.x, widget.y, val, widget.tracker_id)
         else:
             self.add_value(widget.x, widget.y, val)
@@ -527,7 +527,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         if self.always_show_hints and not self.doing_initial_setup:
             self.update_all_hints()
         if not self.doing_initial_setup:
-            self.mark_impossible_implications(x, y)
+            self._mark_impossible_implications(x, y)
 
     @simple_debug
     def remove (self, x, y, *args):
@@ -539,7 +539,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         # Always call the grid's remove() for proper conflict resolution
         if self.grid:
             self.grid.remove(x, y)
-            self.remove_error_highlight()
+            self._remove_error_highlight()
         # Remove it from the tracker.  When removing via undo, the trace
         # manipulation is handled at a higher level
         if not args or args[0] != 'undo-change':
@@ -551,9 +551,9 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         if self.grid and self.always_show_hints and not self.doing_initial_setup:
             self.update_all_hints()
         if not self.doing_initial_setup:
-            self.mark_impossible_implications(x, y)
+            self._mark_impossible_implications(x, y)
 
-    def remove_error_highlight (self):
+    def _remove_error_highlight (self):
         '''remove error highlight from [x, y] and also all errors caused by it
 
         Conflict resolution is now handled within the InteractiveSudoku class.
@@ -620,7 +620,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             self.update_all_hints()
 
     @simple_debug
-    def mark_impossible_implications (self, x, y, check_conflicts = True):
+    def _mark_impossible_implications (self, x, y, check_conflicts = True):
         '''Mark cells with X if they have no possible values
 
         The hint this method provides can be turned on and off from the
@@ -702,7 +702,7 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             for coord in track.keys():
                 self.__entries__[coord].set_value(0, tracker_info.NO_TRACKER)
                 self.grid.remove(*coord)
-                self.remove_error_highlight()
+                self._remove_error_highlight()
                 self.mark_impossible_implications(*coord)
         if hide:
             self.tinfo.hide_tracker()



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