From 0cad6dc96afc2ebd4d03beb14ed01bc155dfa322 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 06 Apr 2009 02:38:10 +0000 Subject: LP 348570 Core : Extending actions with the new properties, adding min / max size to arrays --- (limited to 'src/sugar/tutorius/actions.py') diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py index 2c76bd7..b8c21e0 100644 --- a/src/sugar/tutorius/actions.py +++ b/src/sugar/tutorius/actions.py @@ -23,7 +23,7 @@ from dialog import TutoriusDialog import overlayer from sugar.tutorius.editor import WidgetIdentifier from sugar.tutorius.services import ObjectStore - +from sugar.tutorius.properties import * class Action(object): """Base class for Actions""" @@ -45,8 +45,8 @@ class Action(object): 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: + for i in dir(self): + if isinstance(getattr(self,i), TutoriusProperty): self._props.append(i) return self._props @@ -94,31 +94,18 @@ class DialogMessage(Action): self._message = message 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) + self.message = TStringProperty("") + self.position = TArrayProperty([0,0], 2) def do(self): """ Show the dialog """ - self._dialog = TutoriusDialog(self._message) + self._dialog = TutoriusDialog(self.message.value) self._dialog.set_button_clicked_cb(self._dialog.close_self) self._dialog.set_modal(False) - self._dialog.move(self.position[0], self.position[1]) + self._dialog.move(self.position.value[0], self.position.value[1]) self._dialog.show() def undo(self): @@ -137,34 +124,20 @@ class BubbleMessage(Action): @param message A string to display to the user @param pos A list of the form [x, y] @param speaker treeish representation of the speaking widget + @param tailpos The position of the tail of the bubble; useful to point to + specific elements of the interface """ def __init__(self, message, pos=[0,0], speaker=None, tailpos=None): Action.__init__(self) - self._message = message - self._position = pos - + self.message = TStringProperty(message) + # Create the position as an array of fixed-size 2 + self.position = TArrayProperty(pos, 2, 2) + # Do the same for the tail position + self.tail_pos = TArrayProperty(tailpos, 2, 2) + 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): """ -- cgit v0.9.1