Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/actions.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-03-25 18:30:22 (GMT)
committer Vincent Vinet <vince.vinet@gmail.com>2009-03-30 20:20:42 (GMT)
commit7f030fd302c0be7ca7dc38863e1d9250df00ca31 (patch)
treed5ebcb2f352d0ac9efc1c3552cc41e43bfc01d5f /src/sugar/tutorius/actions.py
parentf14b5e3e41af68866edd706c9d48db61f3e0da4f (diff)
(bug 348570) TutoriusV2 : Adding properties and minimal introspection on Actions
Diffstat (limited to 'src/sugar/tutorius/actions.py')
-rw-r--r--src/sugar/tutorius/actions.py51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py
index 12de298..60ccd8b 100644
--- a/src/sugar/tutorius/actions.py
+++ b/src/sugar/tutorius/actions.py
@@ -42,6 +42,13 @@ class Action(object):
"""
pass #Should raise NotImplemented?
+ def get_properties(self):
+ if not hasattr(self, "_props") or self._props is None:
+ self._props = []
+ for i in dir(self.__class__):
+ if type(getattr(self.__class__,i)) is property:
+ self._props.append(i)
+ return self._props
class OnceWrapper(object):
"""
@@ -71,6 +78,9 @@ class OnceWrapper(object):
if self._need_undo:
self._action.undo()
self._need_undo = False
+
+ def get_properties(self):
+ return self._action.get_properties()
class DialogMessage(Action):
"""
@@ -82,9 +92,25 @@ class DialogMessage(Action):
def __init__(self, message, pos=[0,0]):
super(DialogMessage, self).__init__()
self._message = message
- self.position = pos
+ self._position = pos
self._dialog = None
+ def set_message(self, msg):
+ self._message = msg
+
+ def get_message(self):
+ return self._message
+
+ message = property(fget=get_message, fset=set_message)
+
+ def set_pos(self, x, y):
+ self._position = [x, y]
+
+ def get_pos(self):
+ return self._position
+
+ position = property(fget=get_pos, fset=set_pos)
+
def do(self):
"""
Show the dialog
@@ -115,14 +141,31 @@ class BubbleMessage(Action):
def __init__(self, message, pos=[0,0], speaker=None, tailpos=None):
Action.__init__(self)
self._message = message
- self.position = pos
+ self._position = pos
self.overlay = None
self._bubble = None
self._speaker = None
self._tailpos = tailpos
-
+ def set_message(self, msg):
+ self._message = msg
+ def get_message(self):
+ return self._message
+ message = property(fget=get_message, fset=set_message, doc="Message displayed to the user")
+
+ def set_pos(self, x, y):
+ self._position = [x, y]
+ def get_pos(self):
+ return self.position
+ position = property(fget=get_pos, fset=set_pos, doc="Position in [x, y] on the screen")
+
+ def set_tail_pos(self, x, y):
+ self._tailpos = [x, y]
+ def get_tail_pos(self):
+ return self._tailpos
+ tail_pos = property(fget=get_tail_pos, fset=set_tail_pos, doc="Position the tail of the bubble must point to")
+
def do(self):
"""
Show the dialog
@@ -135,7 +178,7 @@ class BubbleMessage(Action):
# draw the overlay.
if not self._bubble:
- x, y = self.position
+ x, y = self._position
# TODO: tails are relative to tailpos. They should be relative to
# the speaking widget. Same of the bubble position.
self._bubble = overlayer.TextBubble(text=self._message,