diff options
author | charles <iso.swiffer@gmail.com> | 2009-04-15 15:22:45 (GMT) |
---|---|---|
committer | Vincent Vinet <vince.vinet@gmail.com> | 2009-04-16 15:29:14 (GMT) |
commit | 78de92cde03264725093868231bdb539feb4f56b (patch) | |
tree | 6da8245abeabb699e7cc06ee965ee8ea6ef3468b /src/sugar/tutorius/core.py | |
parent | 8ab1e32a479c018766f330ecf71670ef71492300 (diff) |
Added ClickAction and TypeTextAction + support for initial state
Diffstat (limited to 'src/sugar/tutorius/core.py')
-rw-r--r-- | src/sugar/tutorius/core.py | 20 |
1 files changed, 19 insertions, 1 deletions
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): """ |