diff options
author | charles <iso.swiffer@gmail.com> | 2009-04-15 15:22:45 (GMT) |
---|---|---|
committer | Vincent Vinet <vince.vinet@gmail.com> | 2009-04-16 15:29:14 (GMT) |
commit | 78de92cde03264725093868231bdb539feb4f56b (patch) | |
tree | 6da8245abeabb699e7cc06ee965ee8ea6ef3468b /src/sugar/tutorius/actions.py | |
parent | 8ab1e32a479c018766f330ecf71670ef71492300 (diff) |
Added ClickAction and TypeTextAction + support for initial state
Diffstat (limited to 'src/sugar/tutorius/actions.py')
-rw-r--r-- | src/sugar/tutorius/actions.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py index 2c76bd7..ad91fb4 100644 --- a/src/sugar/tutorius/actions.py +++ b/src/sugar/tutorius/actions.py @@ -250,3 +250,56 @@ class DisableWidgetAction(Action): """Action undo""" if self._widget: self._widget.set_sensitive(True) + +class TypeTextAction(Action): + """ + Simulate a user typing text in a widget + Work on any widget that implements a insert_text method + + @param widget The treehish representation of the widget + @param text the text that is typed + """ + def __init__(self, widget, text): + Action.__init__(self) + + self._widget = widget + self._text = text + + def do(self, **kwargs): + """ + Type the text + """ + widget = gtkutils.find_widget(ObjectStore().activity, self._widget) + if hasattr(widget, "insert_text"): + widget.insert_text(self._text, -1) + + def undo(self): + """ + no undo + """ + pass + +class ClickAction(Action): + """ + Action that simulate a click on a widget + Work on any widget that implements a clicked() method + + @param widget The threehish representation of the widget + """ + def __init__(self, widget): + Action.__init__(self) + self._widget = widget + + def do(self): + """ + click the widget + """ + widget = gtkutils.find_widget(ObjectStore().activity, self._widget) + if hasattr(widget, "clicked"): + widget.clicked() + + def undo(self): + """ + No undo + """ + pass |