From 034e36d4983da0c2d44c56d4efd9af922b2cab4e Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Mon, 07 Dec 2009 20:50:52 +0000 Subject: pass the overlayer as a keyword argument for do, enter_editmode and subscribe, remove object store references --- (limited to 'addons/bubblemessagewimg.py') diff --git a/addons/bubblemessagewimg.py b/addons/bubblemessagewimg.py index 9fe9512..974dd19 100644 --- a/addons/bubblemessagewimg.py +++ b/addons/bubblemessagewimg.py @@ -13,10 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from sugar.tutorius.actions import Action, DragWrapper -from sugar.tutorius.properties import TStringProperty, TResourceProperty, TArrayProperty -from sugar.tutorius import overlayer -from sugar.tutorius.services import ObjectStore +from ..actions import Action, DragWrapper +from ..properties import TStringProperty, TResourceProperty, TArrayProperty +from ..overlayer import TextBubbleWImg class BubbleMessageWImg(Action): message = TStringProperty("Message") @@ -43,24 +42,25 @@ class BubbleMessageWImg(Action): self._bubble = None self._speaker = None - def do(self, **kwargs): + def do(self, overlayer=None, **kwargs): """ Show the dialog + @param overlayer Overlayer to draw on """ - # get or inject overlayer - self.overlay = ObjectStore().activity._overlayer + if overlayer is None: + raise TypeError("Missing overlayer") + + self.overlay = overlayer # FIXME: subwindows, are left to overlap this. This behaviour is # undesirable. subwindows (i.e. child of top level windows) should be # handled either by rendering over them, or by finding different way to # draw the overlay. - if not self.overlay: - self.overlay = ObjectStore().activity._overlayer if not self._bubble: 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.TextBubbleWImg(text=self.message, + self._bubble = TextBubbleWImg(text=self.message, tailpos=self.tail_pos,imagepath=self.imgpath.default) self._bubble.show() self.overlay.put(self._bubble, x, y) @@ -75,16 +75,19 @@ class BubbleMessageWImg(Action): self._bubble.destroy() self._bubble = None - def enter_editmode(self, *args): + def enter_editmode(self, overlayer=None, *args, **kwargs): """ Enters edit mode. The action should display itself in some way, without affecting the currently running application. + @param overlay Overlayer to draw on """ - if not self.overlay: - self.overlay = ObjectStore().activity._overlayer + if overlayer is None: + raise TypeError("Missing overlayer") + + self.overlay = overlayer assert not self._drag, "bubble action set to editmode twice" x, y = self.position - self._bubble = overlayer.TextBubbleWImg(text=self.message, + self._bubble = TextBubbleWImg(text=self.message, tailpos=self.tail_pos,imagepath=self.imgpath) self.overlay.put(self._bubble, x, y) self._bubble.show() -- cgit v0.9.1