[gnome-games/sudoku-tube] Properly do post-open setup



commit 480fc3e11b6f8de96e10b775ada66cba280bd08e
Author: Zhang Sen <zh jesse gmail com>
Date:   Fri May 29 17:52:38 2009 +0800

    Properly do post-open setup
---
 gnome-sudoku/src/lib/main.py |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 14e71e8..b73c483 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -150,6 +150,10 @@ class UI (gconf_wrapper.GConfWrapper):
         self._auto_load_saved()
         if not self._game: # no game loaded
             self._auto_load_new()
+        if self._game:
+            self._post_open_setup()
+        else:
+            print 'No game opened, should die'
 
         self.show()
         # generate puzzles while our use is working...
@@ -164,7 +168,6 @@ class UI (gconf_wrapper.GConfWrapper):
         if saved_games:
             self._game = saved_games[0]
             saver.open_game(self, self._game)
-            self.update_statusbar()
 
     def _auto_load_new(self):
         """Automatically open a new game"""
@@ -174,6 +177,15 @@ class UI (gconf_wrapper.GConfWrapper):
         # process self._game==None
         self.gsd.change_grid(self._game, 9)
 
+    def _post_open_setup(self):
+        """Properly do the setup after entering game
+
+        Like show highlight, update hints, start timer, etc."""
+        self.timer.start_timing()
+        self.update_statusbar()
+        if self.gconf['always_show_hints']:
+            self.gsd.update_all_hints()
+
     def _run_background_generator (self):
         """Generate puzzles in background"""
         if self.gconf['generate_puzzles_in_background']:
@@ -187,15 +199,11 @@ class UI (gconf_wrapper.GConfWrapper):
         selector.dialog.destroy()
         if not choice:
             return True
-        self.timer.start_timing()
         if choice[0] == game_selector.NewOrSavedGameSelector.NEW_GAME:
             self.gsd.change_grid(choice[1], 9)
-            self.update_statusbar()
         if choice[0] == game_selector.NewOrSavedGameSelector.SAVED_GAME:
             saver.open_game(self, choice[1])
-            self.update_statusbar()
-        if self.gconf['always_show_hints']:
-            self.gsd.update_all_hints()
+        self._post_open_setup()
 
     def _activate_in_game_actions (self, sensitive):
         """Inactivate some actions if we are in game-selector



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