diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-04-06 02:41:41 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-04-06 17:18:13 (GMT) |
commit | bbc61e78c1f47537f9a7118073ca89f06ad53ea9 (patch) | |
tree | 2f7a47edb6edd387bf789eae282457563105bcc2 /src/sugar/tutorius/actions.py | |
parent | 217ea2dca4f69def9811cf3ad09fc0888178b192 (diff) |
LP 353185 Core : Create chain action
Diffstat (limited to 'src/sugar/tutorius/actions.py')
-rw-r--r-- | src/sugar/tutorius/actions.py | 15 |
1 files changed, 15 insertions, 0 deletions
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() |