[gnome-games/applygsoc2009: 5/76] Make function-decorator into a method
- From: Pablo Castellano <pablog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/applygsoc2009: 5/76] Make function-decorator into a method
- Date: Mon, 6 Sep 2010 02:47:38 +0000 (UTC)
commit 2eb9f037ec1c73577b748383443299844bb0500c
Author: Pablo Castellano <pablog src gnome org>
Date: Thu Aug 26 04:31:30 2010 +0200
Make function-decorator into a method
gnome-sudoku/src/lib/main.py | 64 +++++++++++++++++++----------------------
1 files changed, 30 insertions(+), 34 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 4a3cc03..7affa80 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -44,39 +44,6 @@ gtk.stock_add([('tracks',
_('Track moves'),
0, 0, ""), ])
-def activate_actions (uimanager, action_paths, sensitive):
- for path in action_paths:
- action = uimanager.get_action(path)
- if not action:
- action = uimanager.get_widget(path)
- if not action:
- print 'No action at path', path
- else:
- action.set_sensitive(sensitive)
-
-def inactivate_new_game_etc (fun):
- def inactivate_new_game_etc_ (ui, *args, **kwargs):
- paths = [
- '/MenuBar/Game/New',
- '/MenuBar/Game/Reset',
- '/MenuBar/Game/PuzzleInfo',
- '/MenuBar/Game/Print',
- # undo/redo is handled elsewhere as it can't simply be turned on/off.
- '/MenuBar/Settings/ToggleToolbar',
- '/MenuBar/Settings/ToggleHighlight',
- '/MenuBar/Settings/AlwaysShowPossible',
- '/MenuBar/Settings/ShowImpossibleImplications',
- '/MenuBar/Tools/ShowPossible',
- '/MenuBar/Tools/ClearTopNotes',
- '/MenuBar/Tools/ClearBottomNotes',
- '/MenuBar/Tools/Tracker',
- ]
- activate_actions(ui.uimanager, paths, False)
- ret = fun(ui, *args, **kwargs)
- activate_actions(ui.uimanager, paths, True)
- return ret
- return inactivate_new_game_etc_
-
class UI (gconf_wrapper.GConfWrapper):
ui = '''<ui>
<menubar name="MenuBar">
@@ -173,8 +140,8 @@ class UI (gconf_wrapper.GConfWrapper):
# Generate puzzles in background...
gobject.timeout_add_seconds(1, lambda *args: self.start_worker_thread() and True)
- @inactivate_new_game_etc
def select_game (self):
+ self._activate_in_game_actions(False)
self.tb.hide()
choice = game_selector.NewOrSavedGameSelector().run_swallowed_dialog(self.swallower)
if not choice:
@@ -190,7 +157,36 @@ class UI (gconf_wrapper.GConfWrapper):
self.gsd.update_all_hints()
if self.gconf['highlight']:
self.gsd.toggle_highlight(True)
+ self._activate_in_game_actions(True)
+ def _activate_in_game_actions (self, sensitive):
+ """Inactivate some actions if we are in game-selector
+
+ Some actions should only be active during a game, and be disabled when
+ we are choosing game. We call them 'in-game actions'."""
+ in_game_actions = [
+ '/MenuBar/Game/New',
+ '/MenuBar/Game/NewWithContact',
+ '/MenuBar/Game/Reset',
+ '/MenuBar/Game/PuzzleInfo',
+ '/MenuBar/Game/Print',
+ # undo/redo is handled elsewhere as it can't simply be turned on/off.
+ '/MenuBar/Settings/ToggleToolbar',
+ '/MenuBar/Settings/ToggleHighlight',
+ '/MenuBar/Settings/AlwaysShowPossible',
+ '/MenuBar/Settings/ShowImpossibleImplications',
+ '/MenuBar/Tools/ShowPossible',
+ '/MenuBar/Tools/ClearTopNotes',
+ '/MenuBar/Tools/ClearBottomNotes',
+ '/MenuBar/Tools/Tracker']
+ for path in in_game_actions:
+ action = uimanager.get_action(path)
+ if not action:
+ action = uimanager.get_widget(path)
+ if action:
+ action.set_sensitive(sensitive)
+ else:
+ print 'No action at path', path
def show (self):
self.gsd.show()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]