From 78de92cde03264725093868231bdb539feb4f56b Mon Sep 17 00:00:00 2001 From: charles Date: Wed, 15 Apr 2009 15:22:45 +0000 Subject: Added ClickAction and TypeTextAction + support for initial state --- (limited to 'src/sugar/tutorius/core.py') diff --git a/src/sugar/tutorius/core.py b/src/sugar/tutorius/core.py index 901820f..f290f1e 100644 --- a/src/sugar/tutorius/core.py +++ b/src/sugar/tutorius/core.py @@ -24,6 +24,7 @@ This module contains the core classes for tutorius import gtk import logging import copy +import os from sugar.tutorius.dialog import TutoriusDialog from sugar.tutorius.gtkutils import find_widget @@ -36,12 +37,13 @@ class Tutorial (object): Tutorial Class, used to run through the FSM. """ - def __init__(self, name, fsm): + def __init__(self, name, fsm,filename= None): """ Creates an unattached tutorial. """ object.__init__(self) self.name = name + self.activity_init_state_filename = filename self.state_machine = fsm self.state_machine.set_tutorial(self) @@ -64,6 +66,7 @@ class Tutorial (object): self.activity = activity ObjectStore().activity = activity ObjectStore().tutorial = self + self._prepare_activity() self.state_machine.set_state("INIT") def detach(self): @@ -97,6 +100,21 @@ class Tutorial (object): #Swith to the next state pointed by the eventfilter self.set_state(eventfilter.get_next_state()) + + def _prepare_activity(self): + """ + Prepare the activity for the tutorial by loading the saved state and + emitting gtk signals + """ + #Load the saved activity if any + if self.activity_init_state_filename is not None: + #For now the file will be saved in the data folder + #of the activity root directory + filename = os.getenv("SUGAR_ACTIVITY_ROOT") + "/data/" +\ + self.activity_init_state_filename + if os.path.exists(filename): + self.activity.read_file(filename) + class State(object): """ -- cgit v0.9.1