[gnome-games/sudoku-tube] Trivial refactoring
- From: Zhang Sen <zhangsen src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games/sudoku-tube] Trivial refactoring
- Date: Sun, 9 Aug 2009 13:43:34 +0000 (UTC)
commit ed2d83543dedd32788fc512bd5b39ff893e5eb8b
Author: Zhang Sen <zh jesse gmail com>
Date: Sun Aug 9 20:58:34 2009 +0800
Trivial refactoring
gnome-sudoku/src/lib/main.py | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index a8c3fb4..e678d61 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -69,6 +69,7 @@ class UI (gconf_wrapper.GConfWrapper):
self._main_grid_vew = None
self._history_manager = None
self._tube = None
+ self._peer = None
self._is_initiator = None
self._is_waiting_for_response = None # this should be extraced out
@@ -89,14 +90,16 @@ class UI (gconf_wrapper.GConfWrapper):
self._run_background_generator()
def _auto_open_game(self, check_saved=True):
- game = None
+ game, game_type = None, None
if check_saved:
game = self._auto_load_saved()
+ game_type = game_selector.NewOrSavedGameSelector.SAVED_GAME
if not game:
game = self._auto_load_new()
+ game_type = game_selector.NewOrSavedGameSelector.NEW_GAME
if game:
- self._open_game(*game)
+ self._open_game(game_type, game)
else:
logger.error("can't open game")
self.quit_cb()
@@ -108,8 +111,7 @@ class UI (gconf_wrapper.GConfWrapper):
save *one* game in the future. And auto load this one game on launch"""
saved_games = self.sudoku_tracker.list_saved_games()
if saved_games:
- return (game_selector.NewOrSavedGameSelector.SAVED_GAME,
- saved_games[0])
+ return saved_games[0]
else:
logger.info("no saved game found")
return None
@@ -122,8 +124,7 @@ class UI (gconf_wrapper.GConfWrapper):
if new_puzzle:
# new_puzzle is a list, with the form of (<puzzle>, <difficulty>)
logger.info("%s game generated" % level)
- return (game_selector.NewOrSavedGameSelector.NEW_GAME,
- new_puzzle[0][0])
+ return new_puzzle[0][0]
else:
logger.warning("failed to genereate new puzzle")
return None
@@ -219,7 +220,6 @@ class UI (gconf_wrapper.GConfWrapper):
self.setup_actions()
self.setup_autosave()
return
- #TODO
# self.w.add_accel_group(self.uimanager.get_accel_group())
def initialize_prefs (self):
@@ -386,7 +386,7 @@ class UI (gconf_wrapper.GConfWrapper):
return sublabel
- def you_win_callback(self, model):
+ def you_win_callback(self, sudoku_model):
if hasattr(self, 'dancer'):
return
self.won = True
@@ -448,10 +448,6 @@ class UI (gconf_wrapper.GConfWrapper):
self._auto_open_game()
return
- choice = self._select_game()
- if choice:
- self._open_game(choice[0], choice[1])
-
def _new_with_contact_cb(self, action):
assert self._is_initiator is None
self._is_initiator = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]