From 912528253fcf1fc43c1a2d02ffe6e540fe60d8e7 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Mon, 19 Oct 2009 20:15:41 +0000 Subject: Merge the TProbe Integration and fix merging induced bugs --- (limited to 'addons') diff --git a/addons/bubblemessage.py b/addons/bubblemessage.py index c499bdb..2bd2d31 100644 --- a/addons/bubblemessage.py +++ b/addons/bubblemessage.py @@ -13,14 +13,17 @@ # 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 * +from sugar.tutorius.actions import Action, DragWrapper +from sugar.tutorius.properties import TStringProperty, TArrayProperty +from sugar.tutorius import overlayer +from sugar.tutorius.services import ObjectStore class BubbleMessage(Action): message = TStringProperty("Message") # Create the position as an array of fixed-size 2 - position = TArrayProperty([0,0], 2, 2) + position = TArrayProperty((0,0), 2, 2) # Do the same for the tail position - tail_pos = TArrayProperty([0,0], 2, 2) + tail_pos = TArrayProperty((0,0), 2, 2) def __init__(self, message=None, position=None, speaker=None, tail_pos=None): """ @@ -94,7 +97,7 @@ class BubbleMessage(Action): def exit_editmode(self, *args): x,y = self._drag.position - self.position = [int(x), int(y)] + self.position = (int(x), int(y)) if self._drag: self._drag.draggable = False self._drag = None diff --git a/addons/dialogmessage.py b/addons/dialogmessage.py index 298466a..f15f256 100644 --- a/addons/dialogmessage.py +++ b/addons/dialogmessage.py @@ -20,7 +20,7 @@ from sugar.tutorius.actions import * class DialogMessage(Action): message = TStringProperty("Message") - position = TArrayProperty([0, 0], 2, 2) + position = TArrayProperty((0, 0), 2, 2) def __init__(self, message=None, position=None): """ diff --git a/addons/gtkwidgeteventfilter.py b/addons/gtkwidgeteventfilter.py index cbfb00c..5497af4 100644 --- a/addons/gtkwidgeteventfilter.py +++ b/addons/gtkwidgeteventfilter.py @@ -13,8 +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.filters import * -from sugar.tutorius.properties import * +from sugar.tutorius.filters import EventFilter +from sugar.tutorius.properties import TUAMProperty, TStringProperty +from sugar.tutorius.gtkutils import find_widget class GtkWidgetEventFilter(EventFilter): """ @@ -23,13 +24,12 @@ class GtkWidgetEventFilter(EventFilter): object_id = TUAMProperty() event_name = TStringProperty("clicked") - def __init__(self, next_state=None, object_id=None, event_name=None): + def __init__(self, object_id=None, event_name=None): """Constructor - @param next_state default EventFilter param, passed on to EventFilter @param object_id object fqdn-style identifier @param event_name event to attach to """ - super(GtkWidgetEventFilter,self).__init__(next_state) + super(GtkWidgetEventFilter,self).__init__() self._callback = None self.object_id = object_id self.event_name = event_name diff --git a/addons/readfile.py b/addons/readfile.py new file mode 100644 index 0000000..0d276b9 --- /dev/null +++ b/addons/readfile.py @@ -0,0 +1,56 @@ +# Copyright (C) 2009, Tutorius.org +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 + +import os + +from sugar.tutorius.actions import Action +from sugar.tutorius.properties import TFileProperty +from sugar.tutorius.services import ObjectStore + +class ReadFile(Action): + filename = TFileProperty(None) + + def __init__(self, filename=None): + """ + Calls activity.read_file to restore a specified state to an activity + like when restored from the journal. + @param filename Path to the file to read + """ + Action.__init__(self) + + if filename: + self.filename=filename + + def do(self): + """ + Perform the action, call read_file on the activity + """ + if os.path.isfile(str(self.filename)): + ObjectStore().activity.read_file(self.filename) + + def undo(self): + """ + Not undoable + """ + pass + +__action__ = { + "name" : "ReadFile", + "display_name" : "Read File", + "icon" : "message-bubble", #FIXME + "class" : ReadFile, + "mandatory_props" : ["filename"] +} diff --git a/addons/timerevent.py b/addons/timerevent.py index 5bad416..c7374d0 100644 --- a/addons/timerevent.py +++ b/addons/timerevent.py @@ -14,35 +14,34 @@ # 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 * -from sugar.tutorius.properties import * import gobject -import logging -logger = logging.getLogger('filters') +from sugar.tutorius.filters import EventFilter +from sugar.tutorius.properties import TIntProperty class TimerEvent(EventFilter): - timeout_s = TIntProperty("1000") """ TimerEvent is a special EventFilter that uses gobject timeouts to trigger a state change after a specified amount of time. It must be used inside a gobject main loop to work. """ - def __init__(self,next_state,timeout_s): + timeout = TIntProperty(15, 0) + + def __init__(self, timeout=None): """Constructor. - @param next_state default EventFilter param, passed on to EventFilter - @param timeout_s timeout in seconds + @param timeout timeout in seconds """ - super(TimerEvent,self).__init__(next_state) - self.timeout_s = timeout_s + super(TimerEvent,self).__init__() + if timeout: + self.timeout = timeout self._handler_id = None def install_handlers(self, callback, **kwargs): """install_handlers creates the timer and starts it""" super(TimerEvent,self).install_handlers(callback, **kwargs) #Create the timer - self._handler_id = gobject.timeout_add_seconds(self.timeout_s, self._timeout_cb) + self._handler_id = gobject.timeout_add_seconds(self.timeout, self._timeout_cb) def remove_handlers(self): """remove handler removes the timer""" @@ -70,5 +69,5 @@ __event__ = { "display_name" : "Timed transition", "icon" : "clock", "class" : TimerEvent, - "mandatory_props" : ["next_state", "timeout_s"] + "mandatory_props" : ["timeout"] } -- cgit v0.9.1