[gnome-games/applygsoc2009: 62/76] XXX: Trivial refactoring
- From: Pablo Castellano <pablog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/applygsoc2009: 62/76] XXX: Trivial refactoring
- Date: Mon, 6 Sep 2010 02:52:25 +0000 (UTC)
commit 3276edbfa6cd549557fa3dc3eb4cb80aba397bbe
Author: Pablo Castellano <pablog src gnome org>
Date: Wed Sep 1 05:08:23 2010 +0200
XXX: Trivial refactoring
gnome-sudoku/src/lib/main.py | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index ff22765..1e33ea1 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -77,10 +77,18 @@ class UI (gconf_wrapper.GConfWrapper):
# generate puzzles while our use is working...
self._run_background_generator()
- def _auto_open_game(self):
- game = self._auto_load_saved() or self._auto_load_new()
+ def _auto_open_game(self, check_saved=True):
+ 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()
@@ -92,8 +100,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
@@ -106,7 +113,7 @@ class UI (gconf_wrapper.GConfWrapper):
if new_puzzle:
# get_puzzles returns a list 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
@@ -203,7 +210,6 @@ class UI (gconf_wrapper.GConfWrapper):
self._setup_actions()
return
self.setup_autosave()
- #TODO
# self.w.add_accel_group(self.uimanager.get_accel_group())
self.setup_main_boxes()
self.setup_tracker_interface()
@@ -372,7 +378,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
@@ -386,10 +392,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 _close_current_game (self):
"""Close current running game
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]