Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordave <drykod@gmail.com>2009-11-05 16:58:06 (GMT)
committer dave <drykod@gmail.com>2009-11-05 16:58:06 (GMT)
commitbbddd9d5595a6be2adfa6d1a5a174022a094da19 (patch)
treeb544582a57a1446493366cabc153dce4a8b48466
parentd3652ff76a15977328d60860ed05b5cc52fdec4c (diff)
updated events/actions
-rw-r--r--addons/bubblemessage.py2
-rw-r--r--addons/bubblemessagewimg.py2
-rw-r--r--addons/changecolor.py (renamed from addons/changecolorevent.py)49
-rw-r--r--addons/clickaction.py2
-rw-r--r--addons/dialogmessage.py2
-rw-r--r--addons/disablewidget.py2
-rw-r--r--addons/gtkwidgeteventfilter.py6
-rw-r--r--addons/oncewrapper.py2
-rw-r--r--addons/playsound.py2
-rw-r--r--addons/readfile.py2
-rw-r--r--addons/smiley.py2
-rw-r--r--addons/timerevent.py3
-rw-r--r--addons/triggereventfilter.py6
-rw-r--r--addons/widgetidentifyaction.py2
-rw-r--r--tutorius/TProbe.py6
15 files changed, 35 insertions, 55 deletions
diff --git a/addons/bubblemessage.py b/addons/bubblemessage.py
index 2bd2d31..f2264cd 100644
--- a/addons/bubblemessage.py
+++ b/addons/bubblemessage.py
@@ -48,7 +48,7 @@ class BubbleMessage(Action):
self._bubble = None
self._speaker = None
- def do(self):
+ def do(self, **kwargs):
"""
Show the dialog
"""
diff --git a/addons/bubblemessagewimg.py b/addons/bubblemessagewimg.py
index b214460..c4f42f9 100644
--- a/addons/bubblemessagewimg.py
+++ b/addons/bubblemessagewimg.py
@@ -54,7 +54,7 @@ class BubbleMessageWImg(Action):
self._bubble = None
self._speaker = None
- def do(self):
+ def do(self, **kwargs):
"""
Show the dialog
"""
diff --git a/addons/changecolorevent.py b/addons/changecolor.py
index 70b28f9..cf3431c 100644
--- a/addons/changecolorevent.py
+++ b/addons/changecolor.py
@@ -14,15 +14,13 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import logging
-
import time
import gobject
import gtk, gtk.gdk
-from sugar.tutorius.filters import EventFilter
+from sugar.tutorius.actions import Action, DragWrapper
from sugar.tutorius.properties import TStringProperty, TUAMProperty, TColorProperty, TIntProperty
from sugar.tutorius.gtkutils import find_widget
@@ -32,17 +30,17 @@ from sugar import profile
xo_line_color = profile.get_color().get_stroke_color()
xo_fill_color = profile.get_color().get_fill_color()
-class ChangeColorEvent(EventFilter):
+class ChangeColor(Action):
"""
ChangeColorEvent
"""
widaddr = TUAMProperty("0")
-
+
def __init__(self, widaddr=None):
"""Constructor - Change a widget color
@param widaddr: the widget for which you want to change the color (UAM)
"""
- super(ChangeColorEvent,self).__init__()
+ Action.__init__(self)
if widaddr: self.widaddr = widaddr
@@ -50,35 +48,26 @@ class ChangeColorEvent(EventFilter):
self._new_color = None
self.tmp_color = None
- self._old_label = None
-
self.wid = None
self._handler_id = None
-
- def install_handlers(self, callback, **kwargs):
- """install_handlers
+
+ def do(self, **kwargs):
+ """
+ do.
Change the color of the widaddred widget with the chosen color
"""
- super(ChangeColorEvent,self).install_handlers(callback, **kwargs)
-
- logging.debug("INSIDE INSTALL HANDLERS CHANGE COLOR")
if not "activity" in kwargs:
logging.debug("ACTIVITY NOT IN KWARGS **********")
# get widget instance
self.wid = find_widget(kwargs["activity"], self.widaddr)
- self.wid.connect("clicked", self.wid_clicked)
-
- logging.debug("GOT WIDGET IN CHANGE COLOR")
# we have to get the initial color in the sugar rc theme
current_style = self.wid.rc_get_style()
self._old_color = current_style.bg[gtk.STATE_NORMAL]
- self._old_label = self.wid.get_label()
-
# define new color
self._new_color = gtk.gdk.color_parse(xo_fill_color)
@@ -86,12 +75,11 @@ class ChangeColorEvent(EventFilter):
self.timeout = 500
self.tmp_color = self._old_color
self._handler_id = gobject.timeout_add(self.timeout, self._timeout_cb)
-
- def remove_handlers(self):
- """remove handler
+
+ def undo(self):
+ """
Go back to the original color
"""
- super(ChangeColorEvent,self).remove_handlers()
if self._handler_id:
try:
@@ -107,8 +95,6 @@ class ChangeColorEvent(EventFilter):
self.wid.modify_bg(gtk.STATE_ACTIVE, self._old_color)
self.wid.modify_bg(gtk.STATE_INSENSITIVE, self._old_color)
- self.wid.set_label(self._old_label)
-
def _timeout_cb(self):
"""
_timeout_cb triggers the eventfilter callback.
@@ -119,10 +105,8 @@ class ChangeColorEvent(EventFilter):
if self.tmp_color == self._old_color:
self.tmp_color = self._new_color
- self.wid.set_label("CLICK")
else:
self.tmp_color = self._old_color
- self.wid.set_label(self._old_label)
# modify bg color
self.wid.modify_bg(gtk.STATE_NORMAL, self.tmp_color)
@@ -132,14 +116,11 @@ class ChangeColorEvent(EventFilter):
self._handler_id = gobject.timeout_add(self.timeout, self._timeout_cb)
- def wid_clicked(self, widget):
- self.do_callback()
-
-__event__ = {
- "name" : "ChangeColorEvent",
- "display_name" : "Change color",
+__action__ = {
+ "name" : "ChangeColor",
+ "display_name" : "Change widget color",
"icon" : "message-bubble",
- "class" : ChangeColorEvent,
+ "class" : ChangeColor,
"mandatory_props" : ["widaddr"]
}
diff --git a/addons/clickaction.py b/addons/clickaction.py
index 828dd75..d0d2103 100644
--- a/addons/clickaction.py
+++ b/addons/clickaction.py
@@ -29,7 +29,7 @@ class ClickAction(Action):
Action.__init__(self)
self.widget = widget
- def do(self):
+ def do(self, **kwargs):
"""
click the widget
"""
diff --git a/addons/dialogmessage.py b/addons/dialogmessage.py
index f15f256..da2777f 100644
--- a/addons/dialogmessage.py
+++ b/addons/dialogmessage.py
@@ -36,7 +36,7 @@ class DialogMessage(Action):
self.message = message
if position: self.position = position
- def do(self):
+ def do(self, **kwargs):
"""
Show the dialog
"""
diff --git a/addons/disablewidget.py b/addons/disablewidget.py
index ce3f235..4c104f7 100644
--- a/addons/disablewidget.py
+++ b/addons/disablewidget.py
@@ -30,7 +30,7 @@ class DisableWidgetAction(Action):
self.target = target
self._widget = None
- def do(self):
+ def do(self, **kwargs):
"""Action do"""
os = ObjectStore()
if os.activity:
diff --git a/addons/gtkwidgeteventfilter.py b/addons/gtkwidgeteventfilter.py
index 5497af4..8d8ff38 100644
--- a/addons/gtkwidgeteventfilter.py
+++ b/addons/gtkwidgeteventfilter.py
@@ -14,7 +14,7 @@
# 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.filters import EventFilter
-from sugar.tutorius.properties import TUAMProperty, TStringProperty
+from sugar.tutorius.properties import TUAMProperty, TEventType
from sugar.tutorius.gtkutils import find_widget
class GtkWidgetEventFilter(EventFilter):
@@ -22,7 +22,7 @@ class GtkWidgetEventFilter(EventFilter):
Basic Event filter for Gtk widget events
"""
object_id = TUAMProperty()
- event_name = TStringProperty("clicked")
+ event_name = TEventType('clicked')
def __init__(self, object_id=None, event_name=None):
"""Constructor
@@ -64,6 +64,6 @@ __event__ = {
"display_name" : "GTK Event catcher",
"icon" : "player_play",
"class" : GtkWidgetEventFilter,
- "mandatory_props" : ["object_id"]
+ "mandatory_props" : ["object_id", "event_name"]
}
diff --git a/addons/oncewrapper.py b/addons/oncewrapper.py
index 97f4752..1c697b0 100644
--- a/addons/oncewrapper.py
+++ b/addons/oncewrapper.py
@@ -32,7 +32,7 @@ class OnceWrapper(Action):
self._need_undo = False
self.action = action
- def do(self):
+ def do(self, **kwargs):
"""
Do the action only on the first time
"""
diff --git a/addons/playsound.py b/addons/playsound.py
index b657c8a..e95bf76 100644
--- a/addons/playsound.py
+++ b/addons/playsound.py
@@ -24,7 +24,7 @@ class PlaySound(Action):
Action.__init__(self)
self._target = target
- def do(self):
+ def do(self, **kwargs):
"""Action do
Play a sound in the mixer
"""
diff --git a/addons/readfile.py b/addons/readfile.py
index 0d276b9..3cd41b6 100644
--- a/addons/readfile.py
+++ b/addons/readfile.py
@@ -34,7 +34,7 @@ class ReadFile(Action):
if filename:
self.filename=filename
- def do(self):
+ def do(self, **kwargs):
"""
Perform the action, call read_file on the activity
"""
diff --git a/addons/smiley.py b/addons/smiley.py
index 8e7c0c4..418d7d1 100644
--- a/addons/smiley.py
+++ b/addons/smiley.py
@@ -28,7 +28,7 @@ class Smiley(Action):
self.overlay = None
self._smiley = None
- def do(self):
+ def do(self, **kwargs):
"""
Do
"""
diff --git a/addons/timerevent.py b/addons/timerevent.py
index c7374d0..7ab330f 100644
--- a/addons/timerevent.py
+++ b/addons/timerevent.py
@@ -67,7 +67,8 @@ class TimerEvent(EventFilter):
__event__ = {
"name" : "TimerEvent",
"display_name" : "Timed transition",
- "icon" : "clock",
+ "icon" : "message-bubble",
"class" : TimerEvent,
"mandatory_props" : ["timeout"]
}
+
diff --git a/addons/triggereventfilter.py b/addons/triggereventfilter.py
index 06c0995..6a0c2c9 100644
--- a/addons/triggereventfilter.py
+++ b/addons/triggereventfilter.py
@@ -23,8 +23,8 @@ class TriggerEventFilter(EventFilter):
Used to fake events and see the effect on the FSM.
"""
- def __init__(self, next_state):
- EventFilter.__init__(self, next_state)
+ def __init__(self):
+ EventFilter.__init__(self)
self.toggle_on_callback = False
def install_handlers(self, callback, **kwargs):
@@ -41,6 +41,6 @@ __event__ = {
'display_name' : 'Triggerable event filter (test only)',
'icon' : '',
'class' : TriggerEventFilter,
- 'mandatory_props' : ['next_state'],
+ 'mandatory_props' : [],
'test' : True
}
diff --git a/addons/widgetidentifyaction.py b/addons/widgetidentifyaction.py
index 3c66211..fd12f14 100644
--- a/addons/widgetidentifyaction.py
+++ b/addons/widgetidentifyaction.py
@@ -24,7 +24,7 @@ class WidgetIdentifyAction(Action):
self.activity = None
self._dialog = None
- def do(self):
+ def do(self, **kwargs):
os = ObjectStore()
if os.activity:
self.activity = os.activity
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index 6d7b6e2..d2a0798 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -110,8 +110,8 @@ class TProbe(dbus.service.Object):
if action._props:
action._props.update(loaded_action._props)
- action.do()
-
+ action.do(activity=self._activity)
+
return address
@dbus.service.method("org.tutorius.ProbeInterface",
@@ -388,8 +388,6 @@ class ProbeProxy:
@return None
"""
LOGGER.debug("ProbeProxy :: Unregister adress %s issued", str(address))
- if not block:
- raise RuntimeError("This function does not allow non-blocking mode yet")
if address in self._subscribedEvents.keys():
remote_call(self._probe.unsubscribe, (address,),
return_cb=save_args(self.__clear_event, address),