From 3e92e7a3ab862901e473e5f3a05d08d9af185f68 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 06 Apr 2009 02:41:41 +0000 Subject: Create chain action --- (limited to 'src/sugar/tutorius/actions.py') diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py index 60ccd8b..7681dea 100644 --- a/src/sugar/tutorius/actions.py +++ b/src/sugar/tutorius/actions.py @@ -213,4 +213,19 @@ class WidgetIdentifyAction(Action): if self._dialog: self._dialog.destroy() +class ChainAction(Action): + """Utility class to allow executing actions in a specific order""" + def __init__(self, *actions): + """ChainAction(action1, ... ) builds a chain of actions""" + self._actions = actions + + def do(self,**kwargs): + """do() each action in the chain""" + for act in self._actions: + act.do(**kwargs) + + def undo(self): + """undo() each action in the chain, starting with the last""" + for act in reversed(self._actions): + act.undo() -- cgit v0.9.1