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:
authorsimpoir <simpoir@Luyten.local>2009-03-14 22:59:34 (GMT)
committer simpoir <simpoir@Luyten.local>2009-03-14 22:59:34 (GMT)
commitd8c59c1a13663ed0d09784ca2a37fcf29ceb91ec (patch)
treeae5db4c947a368505528596c3a7003268228fe17 /src/sugar/tutorius/actions.py
parentadd05c487de3aec42801d39220a8f1f969e7c38a (diff)
Functionnal overlay
Conflicts: source/external/source/sugar-toolkit/src/sugar/tutorius/Makefile.am source/external/source/sugar-toolkit/src/sugar/tutorius/actions.py Conflicts: source/activities/Writus.activity/TAbiWordActivity.py
Diffstat (limited to 'src/sugar/tutorius/actions.py')
-rw-r--r--src/sugar/tutorius/actions.py51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py
index 34802c3..7ecf86b 100644
--- a/src/sugar/tutorius/actions.py
+++ b/src/sugar/tutorius/actions.py
@@ -17,7 +17,9 @@
This module defines Actions that can be done and undone on a state
"""
+from sugar.tutorius import gtkutils
from dialog import TutoriusDialog
+import overlayer
class Action(object):
@@ -25,7 +27,7 @@ class Action(object):
def __init__(self):
object.__init__(self)
- def do(self):
+ def do(self, **kwargs):
"""
Perform the action
"""
@@ -58,7 +60,7 @@ class OnceWrapper(object):
self._called = True
self._action.do()
self._need_undo = True
-
+
def undo(self):
"""
Undo the action if it's been done
@@ -97,5 +99,48 @@ class DialogMessage(Action):
if self._dialog:
self._dialog.destroy()
self._dialog = None
-
+
+
+class BubbleMessage(Action):
+ """
+ Shows a dialog with a given text, at the given position on the screen.
+
+ @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
+ """
+ def __init__(self, message, pos=[0,0], speaker=None, tailpos=None):
+ Action.__init__(self)
+ self._message = message
+ self.position = pos
+
+ self.overlay = None
+ self._bubble = None
+ self._speaker = None
+ self._tailpos = tailpos
+
+
+ def do(self):
+ """
+ Show the dialog
+ """
+ # get or inject overlayer
+ self.overlay = gtkutils.activity()._overlayer #FIXME:handle subwin
+
+ if not self._bubble:
+ x, y = self.position
+ self._bubble = overlayer.TextBubble(text=self._message, tailpos=self._tailpos) #TODO: add tail
+ self._bubble.show()
+ self.overlay.put(self._bubble, x, y)
+ self.overlay.queue_draw()
+
+ def undo(self):
+ """
+ Destroy the dialog
+ """
+ if self._bubble:
+## self.overlay.remove(self._bubble)
+## self.overlay.bin_window.clear()
+ self._bubble.destroy()
+ self._bubble = None