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/timerevent.py') 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