[gnome-games/applygsoc2009: 3/76] Extract method of (de-)activate actions



commit c6d728886cfcb8017458cce0367b22744cee1527
Author: Pablo Castellano <pablog src gnome org>
Date:   Thu Aug 26 04:28:29 2010 +0200

    Extract method of (de-)activate actions

 gnome-sudoku/src/lib/main.py |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index bb13f13..60a9e00 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -44,6 +44,16 @@ 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 = [
@@ -61,23 +71,9 @@ def inactivate_new_game_etc (fun):
             '/MenuBar/Tools/ClearBottomNotes',
             '/MenuBar/Tools/Tracker',
             ]
-        for p in paths:
-            action = ui.uimanager.get_action(p)
-            if not action:
-                action = ui.uimanager.get_widget(p)
-            if not action:
-                print 'No action at path', p
-            else:
-                action.set_sensitive(False)
+		activate_actions(ui.uimanager, paths, False)
         ret = fun(ui, *args, **kwargs)
-        for p in paths:
-            action = ui.uimanager.get_action(p)
-            if not action:
-                action = ui.uimanager.get_widget(p)
-            if not action:
-                print 'No action at path', p
-            else:
-                action.set_sensitive(True)
+		activate_actions(ui.uimanager, paths, True)
         return ret
     return inactivate_new_game_etc_
 



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