Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/bubblemessage.py28
-rw-r--r--addons/bubblemessagewimg.py31
-rw-r--r--addons/clickaction.py4
-rw-r--r--addons/disablewidget.py19
-rw-r--r--addons/gtkwidgettypefilter.py9
-rw-r--r--addons/messagebuttonnext.py16
-rw-r--r--addons/readfile.py5
-rw-r--r--addons/typetextaction.py4
-rw-r--r--addons/widgetidentifyaction.py11
9 files changed, 66 insertions, 61 deletions
diff --git a/addons/bubblemessage.py b/addons/bubblemessage.py
index 4e37274..1b495d4 100644
--- a/addons/bubblemessage.py
+++ b/addons/bubblemessage.py
@@ -15,8 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from ..actions import Action, DragWrapper
from ..properties import TStringProperty, TArrayProperty
-from .. import overlayer
-from ..services import ObjectStore
+from ..overlayer import TextBubble
class BubbleMessage(Action):
message = TStringProperty("Message")
@@ -42,21 +41,22 @@ class BubbleMessage(Action):
self._bubble = None
self._speaker = None
- def do(self, activity=None, **kwargs):
+ def do(self, overlayer=None, **kwargs):
"""
- Show the dialog
+ Show the dialog
+ @param overlayer Overlayer to draw on
"""
- if activity is None:
- raise TypeError("Missing argument activity")
+ if overlayer is None:
+ raise TypeError("Missing argument overlayer")
# get overlayer
- self.overlay = activity._overlayer
+ self.overlay = 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.TextBubble(text=self.message,
+ self._bubble = TextBubble(text=self.message,
tailpos=self.tail_pos)
self._bubble.show()
self.overlay.put(self._bubble, x, y)
@@ -71,16 +71,20 @@ class BubbleMessage(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 overlayer Overlayer to draw on
"""
- if not self.overlay:
- self.overlay = ObjectStore().activity._overlayer
+ if not overlayer:
+ raise TypeError("Missing argument overlayer")
+
+ self.overlay = overlayer
+
assert not self._drag, "bubble action set to editmode twice"
x, y = self.position
- self._bubble = overlayer.TextBubble(text=self.message,
+ self._bubble = TextBubble(text=self.message,
tailpos=self.tail_pos)
self.overlay.put(self._bubble, x, y)
self._bubble.show()
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()
diff --git a/addons/clickaction.py b/addons/clickaction.py
index eae713e..50726c6 100644
--- a/addons/clickaction.py
+++ b/addons/clickaction.py
@@ -30,7 +30,9 @@ class ClickAction(Action):
"""
click the widget
"""
- realWidget = gtkutils.find_widget(ObjectStore().activity, self.widget)
+ if not "activity" in kwargs:
+ raise TypeError("Missing activity")
+ realWidget = gtkutils.find_widget(kwargs["activity"], self.widget)
if hasattr(realWidget, "clicked"):
realWidget.clicked()
diff --git a/addons/disablewidget.py b/addons/disablewidget.py
index 15e07f2..3d392e9 100644
--- a/addons/disablewidget.py
+++ b/addons/disablewidget.py
@@ -16,7 +16,6 @@
from ..actions import *
from .. import gtkutils
-from ..services import ObjectStore
class DisableWidgetAction(Action):
target = TStringProperty("0")
@@ -31,15 +30,15 @@ class DisableWidgetAction(Action):
def do(self, **kwargs):
"""Action do"""
- os = ObjectStore()
- if os.activity:
- self._widget = gtkutils.find_widget(os.activity, self.target)
- if self._widget:
- # If we have an object whose sensitivity we can query, we will
- # keep it to reset it in the undo() method
- if hasattr(self._widget, 'get_sensitive') and callable(self._widget.get_sensitive):
- self._previous_sensitivity = self._widget.get_sensitive()
- self._widget.set_sensitive(False)
+ if not "activity" in kwargs:
+ raise TypeError("Missing activity")
+ self._widget = gtkutils.find_widget(kwargs["activity"], self.target)
+ if self._widget:
+ # If we have an object whose sensitivity we can query, we will
+ # keep it to reset it in the undo() method
+ if hasattr(self._widget, 'get_sensitive') and callable(self._widget.get_sensitive):
+ self._previous_sensitivity = self._widget.get_sensitive()
+ self._widget.set_sensitive(False)
def undo(self):
"""Action undo"""
diff --git a/addons/gtkwidgettypefilter.py b/addons/gtkwidgettypefilter.py
index 7b2e15e..01e6ad3 100644
--- a/addons/gtkwidgettypefilter.py
+++ b/addons/gtkwidgettypefilter.py
@@ -16,7 +16,6 @@
from ..filters import *
from ..properties import TStringProperty, TSequenceProperty
-from ..services import ObjectStore
from ..gtkutils import find_widget
import logging
@@ -49,12 +48,12 @@ class GtkWidgetTypeFilter(EventFilter):
"""install handlers
@param callback default EventFilter callback arg
"""
+ if not "activity" in kwargs:
+ raise TypeError("Missing activity argument")
+
super(GtkWidgetTypeFilter, self).install_handlers(callback, **kwargs)
logger.debug("~~~GtkWidgetTypeFilter install")
- activity = ObjectStore().activity
- if activity is None:
- logger.error("No activity")
- raise RuntimeWarning("no activity in the objectstore")
+ activity = kwargs["activity"]
self._widget = find_widget(activity, self.object_id)
if self._widget:
diff --git a/addons/messagebuttonnext.py b/addons/messagebuttonnext.py
index 058ef41..40e55c2 100644
--- a/addons/messagebuttonnext.py
+++ b/addons/messagebuttonnext.py
@@ -16,9 +16,8 @@
import gtk, gtk.gdk
-from sugar.tutorius.filters import EventFilter
-from sugar.tutorius.properties import TStringProperty, TArrayProperty
-from sugar.tutorius import overlayer
+from ..filters import EventFilter
+from ..properties import TStringProperty, TArrayProperty
from sugar import profile
@@ -57,17 +56,12 @@ class MessageButtonNext(EventFilter):
"""install_handlers creates the message button next and shows it"""
super(MessageButtonNext,self).install_handlers(callback, **kwargs)
- if not "activity" in kwargs:
- raise TypeError("activity argument is Mandatory")
+ if not "overlayer" in kwargs:
+ raise TypeError("overlayer argument is Mandatory")
- # get activity instance
- self.activity = kwargs["activity"]
-
# get or inject overlayer
- self.overlay = self.activity._overlayer
+ self.overlay = kwargs["overlayer"]
- if not self.overlay:
- self.overlay = self.activity._overlayer
btntext = "NEXT"
diff --git a/addons/readfile.py b/addons/readfile.py
index 81385ba..494483c 100644
--- a/addons/readfile.py
+++ b/addons/readfile.py
@@ -18,7 +18,6 @@ import os
from ..actions import Action
from ..properties import TFileProperty
-from ..services import ObjectStore
class ReadFile(Action):
"""
@@ -32,8 +31,10 @@ class ReadFile(Action):
"""
Perform the action, call read_file on the activity
"""
+ if not "activity" in kwargs:
+ raise TypeError("Missing activity")
if os.path.isfile(str(self.filename)):
- ObjectStore().activity.read_file(self.filename)
+ kwargs["activity"].read_file(self.filename)
def undo(self):
"""
diff --git a/addons/typetextaction.py b/addons/typetextaction.py
index 8a09ff9..e4a5ecc 100644
--- a/addons/typetextaction.py
+++ b/addons/typetextaction.py
@@ -32,7 +32,9 @@ class TypeTextAction(Action):
"""
Type the text
"""
- widget = gtkutils.find_widget(ObjectStore().activity, self.widget)
+ if not "activity" in kwargs:
+ raise TypeError("Missing activity")
+ widget = gtkutils.find_widget(kwargs["activity"], self.widget)
if hasattr(widget, "insert_text"):
widget.insert_text(self.text, -1)
diff --git a/addons/widgetidentifyaction.py b/addons/widgetidentifyaction.py
index b59c94a..55f9209 100644
--- a/addons/widgetidentifyaction.py
+++ b/addons/widgetidentifyaction.py
@@ -25,12 +25,13 @@ class WidgetIdentifyAction(Action):
self._dialog = None
def do(self, **kwargs):
- os = ObjectStore()
- if os.activity:
- self.activity = os.activity
+ if not "activity" in kwargs:
+ raise TypeError("Missing activity")
- self._dialog = WidgetIdentifier(self.activity)
- self._dialog.show()
+ self.activity = kwargs["activity"]
+
+ self._dialog = WidgetIdentifier(self.activity)
+ self._dialog.show()
def undo(self):