From 938cdfc307b359d3c4cc528acd5d412aae8b2a80 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Fri, 27 Feb 2009 16:38:02 +0000 Subject: Use actions instead of messages in the tutorials --- (limited to 'src/sugar/tutorius/core.py') diff --git a/src/sugar/tutorius/core.py b/src/sugar/tutorius/core.py index 8919057..62caee0 100644 --- a/src/sugar/tutorius/core.py +++ b/src/sugar/tutorius/core.py @@ -15,9 +15,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ -Module Tutorial +Core -This is the main module for Tutorius. +This module contains the core classes for tutorius """ @@ -57,6 +57,8 @@ class Event: return False + + class Tutorial (object): """ Tutorial Class, used to run through the FSM. @@ -139,18 +141,24 @@ class Tutorial (object): if not self.state_machine.has_key(name): return logger.debug("====NEW STATE: %s====" % name) + + #Remove handlers (TODO replace by EventFilter unregister) self.disconnect_handlers() + #Undo actions + for act in self.state_machine.get(self.state,{}).get("Actions",()): + act.undo() + + #Switch to new state self.state = name newstate = self.state_machine.get(name) + #Add handlers (TODO replace by EventFilter register) for event, unused in newstate["Events"]: self.register_signal(self.handle_event, \ event.object_name, event.event_name) - if newstate.has_key("Message"): - dlg = TutoriusDialog(newstate["Message"]) - dlg.set_button_clicked_cb(dlg.close_self) - dlg.run() - + #Do actions + for act in newstate.get("Actions",()): + act.do() def register_signals(self, target, handler, prefix=None, max_depth=None): """ @@ -322,7 +330,6 @@ class FiniteStateMachine(State): self.actions = setup_actions self.current_state = self.start_state - #TODO Setup current state now? def setup(self): """ -- cgit v0.9.1