From cf40c1951f4f0f26090226fb4969ca147341a031 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 02 Oct 2009 22:24:56 +0000 Subject: LP 439980 : Refactored the XMLSerializer to support complex components; Corrected specs for the addons properties and constructor parameters names; Moved all existing actions and events to components (except a few left in code for testing purposes) --- (limited to 'tutorius/actions.py') diff --git a/tutorius/actions.py b/tutorius/actions.py index 4269cd7..0db7988 100644 --- a/tutorius/actions.py +++ b/tutorius/actions.py @@ -176,149 +176,149 @@ class Action(TPropContainer): x, y = self._drag.position self.position = [int(x), int(y)] self.__edit_img.destroy() - -class OnceWrapper(Action): - """ - Wraps a class to perform an action once only - - This ConcreteActions's do() method will only be called on the first do() - and the undo() will be callable after do() has been called - """ - - _action = TAddonProperty() - - def __init__(self, action): - Action.__init__(self) - self._called = False - self._need_undo = False - self._action = action - - def do(self): - """ - Do the action only on the first time - """ - if not self._called: - self._called = True - self._action.do() - self._need_undo = True - - def undo(self): - """ - Undo the action if it's been done - """ - if self._need_undo: - self._action.undo() - self._need_undo = False - -class WidgetIdentifyAction(Action): - def __init__(self): - Action.__init__(self) - self.activity = None - self._dialog = None - - def do(self): - os = ObjectStore() - if os.activity: - self.activity = os.activity - - self._dialog = WidgetIdentifier(self.activity) - self._dialog.show() - - - def undo(self): - 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""" - Action.__init__(self) - 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() - -class DisableWidgetAction(Action): - def __init__(self, target): - """Constructor - @param target target treeish - """ - Action.__init__(self) - self._target = target - self._widget = None - - def do(self): - """Action do""" - os = ObjectStore() - if os.activity: - self._widget = gtkutils.find_widget(os.activity, self._target) - if self._widget: - self._widget.set_sensitive(False) - - def undo(self): - """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 OnceWrapper(Action): +## """ +## Wraps a class to perform an action once only +## +## This ConcreteActions's do() method will only be called on the first do() +## and the undo() will be callable after do() has been called +## """ +## +## _action = TAddonProperty() +## +## def __init__(self, action): +## Action.__init__(self) +## self._called = False +## self._need_undo = False +## self._action = action +## +## def do(self): +## """ +## Do the action only on the first time +## """ +## if not self._called: +## self._called = True +## self._action.do() +## self._need_undo = True +## +## def undo(self): +## """ +## Undo the action if it's been done +## """ +## if self._need_undo: +## self._action.undo() +## self._need_undo = False +## +##class WidgetIdentifyAction(Action): +## def __init__(self): +## Action.__init__(self) +## self.activity = None +## self._dialog = None + +## def do(self): +## os = ObjectStore() +## if os.activity: +## self.activity = os.activity + +## self._dialog = WidgetIdentifier(self.activity) +## self._dialog.show() + + +## def undo(self): +## 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""" +## Action.__init__(self) +## 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() + +##class DisableWidgetAction(Action): +## def __init__(self, target): +## """Constructor +## @param target target treeish +## """ +## Action.__init__(self) +## self._target = target +## self._widget = None + +## def do(self): +## """Action do""" +## os = ObjectStore() +## if os.activity: +## self._widget = gtkutils.find_widget(os.activity, self._target) +## if self._widget: +## self._widget.set_sensitive(False) -class ClickAction(Action): - """ - Action that simulate a click on a widget - Work on any widget that implements a clicked() method +## def undo(self): +## """Action undo""" +## if self._widget: +## self._widget.set_sensitive(True) - @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 +##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 -- cgit v0.9.1