Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/core.py
diff options
context:
space:
mode:
authorVincent Vinet <vince.vinet@gmail.com>2009-02-27 16:38:02 (GMT)
committer Vincent Vinet <vince.vinet@gmail.com>2009-02-27 16:38:02 (GMT)
commit938cdfc307b359d3c4cc528acd5d412aae8b2a80 (patch)
treecbd16289f134305e4a443e14589dbdcc609636c2 /src/sugar/tutorius/core.py
parent7b67b9593fcf0b24291e3c5a926e4ee697692fa1 (diff)
Use actions instead of messages in the tutorials
Diffstat (limited to 'src/sugar/tutorius/core.py')
-rw-r--r--src/sugar/tutorius/core.py23
1 files changed, 15 insertions, 8 deletions
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):
"""