[gnome-games/applygsoc2009: 63/76] XXX: Trivial refactoring



commit b4b778bdde27d6a080e51af0fbc5679450b8f7e1
Author: Pablo Castellano <pablog src gnome org>
Date:   Wed Sep 1 05:12:42 2010 +0200

    XXX: Trivial refactoring

 gnome-sudoku/src/lib/main.py |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 1e33ea1..2839c02 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -34,7 +34,7 @@ logging.basicConfig()
 logger = logging.getLogger("main")
 
 
-class UI (gconf_wrapper.GConfWrapper):
+class SudokuGame (gconf_wrapper.GConfWrapper):
 
     initial_prefs = {'group_size':9,
                      'always_show_hints':False,
@@ -62,6 +62,7 @@ class UI (gconf_wrapper.GConfWrapper):
         self.sudoku_maker = sudoku_maker.SudokuMaker()
         self.sudoku_tracker = saver.SudokuTracker()
         self._main_model = None
+        self._notes_model = None
         self._main_grid_vew = None
         self._history_manager = None
         self.setup_gui()
@@ -291,14 +292,13 @@ class UI (gconf_wrapper.GConfWrapper):
             action = self.builder.get_object(action_name)
             action.connect("activate", callback)
 
-	def clear_cb (self, *args)
+	def clear_cb (self, action)
 		self._main_model.reset_grid()
 		
-#    def clear_notes_cb (self, *args): #?!?!?
+    def clear_notes_cb(self, action):
+        self._notes_model.clear_notes()
 
     def setup_undo (self):
-        self.cleared = [] # used for Undo memory
-        self.cleared_notes = [] # used for Undo memory
         undo_action = self.builder.get_object('Undo')
         redo_action = self.builder.get_object('Redo')
         self._history_manager = undo.HistoryManager(undo_action, redo_action)
@@ -326,7 +326,7 @@ class UI (gconf_wrapper.GConfWrapper):
               self.builder.get_object('ToggleTracker')),
              ])
 
-    def start_worker_thread (self, *args):
+    def start_worker_thread (self):
         n_new_puzzles = self.sudoku_maker.n_puzzles(new = True)
         try:
             if n_new_puzzles < self.gconf['minimum_number_of_new_puzzles']:
@@ -340,13 +340,13 @@ class UI (gconf_wrapper.GConfWrapper):
             pass # assume we have enough new puzzles
         return True
 
-    def stop_worker_thread (self, *args):
+    def stop_worker_thread (self):
         if hasattr(self, 'worker'):
             self.sudoku_maker.stop()
             for c in self.worker_connections:
                 self.timer.disconnect(c)
 
-    def stop_dancer (self, *args):
+    def stop_dancer (self):
         if hasattr(self, 'dancer'):
             self.dancer.stop_dancing()
             delattr(self, 'dancer')
@@ -459,7 +459,7 @@ class UI (gconf_wrapper.GConfWrapper):
 
         return jar
 
-    def full_screen_cb (self, *args):
+    def full_screen_cb (self):
         if self.is_fullscreen:
             self.w.unfullscreen()
             self.is_fullscreen = False
@@ -543,7 +543,7 @@ class UI (gconf_wrapper.GConfWrapper):
         if self._main_model.grid.check_for_completeness():
             self.start_dancer()
 
-    def show_hint_cb (self, *args):
+    def show_hint_cb (self, action):
         current = self._main_grid_vew.get_focus()
         self._notes_model.show_hint(current.x, current.y)
 
@@ -585,7 +585,7 @@ class UI (gconf_wrapper.GConfWrapper):
         else:
             self.gsd.toggle_highlight(False)
 
-    def show_info_cb (self, *args):
+    def show_info_cb (self, action):
         if not self._main_model.grid:
             dialog_extras.show_message(parent = self.w,
                                        title = _("Puzzle Information"),
@@ -618,7 +618,7 @@ class UI (gconf_wrapper.GConfWrapper):
             self._save_game()
         return True
 
-    def show_about (self, *args):
+    def show_about (self, action):
         about = gtk.AboutDialog()
         about.set_transient_for(self.w)
         about.set_name(APPNAME)
@@ -635,17 +635,17 @@ class UI (gconf_wrapper.GConfWrapper):
         about.connect("response", lambda d, r: d.destroy())
         about.show()
 
-    def show_help (self, *args):
+    def show_help (self, action):
         try:
             gtk.show_uri(self.w.get_screen(), "ghelp:gnome-sudoku", gtk.get_current_event_time())
         except gobject.GError, error:
             # FIXME: This should create a pop-up dialog
             print _('Unable to display help: %s') % str(error)
 
-    def print_game (self, *args):
+    def print_game (self, action):
         printing.print_sudokus([self.gsd], self.w)
 
-    def print_multiple_games (self, *args):
+    def print_multiple_games (self, action):
         gp = printing.GamePrinter(self.sudoku_maker, self.gconf)
         gp.run_dialog()
 
@@ -661,9 +661,9 @@ def start_game (debug=False):
     ##  functions in a threaded GLib program.
     gobject.threads_init()
 
-    u = UI()
+    game = SudokuGame()
     try:
     	gtk.main()
     except KeyboardInterrupt:
         # properly quit on a keyboard interrupt...
-        u.quit_cb()
+        game.quit_cb()



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