Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/engine.py
blob: 57c08e4e596c8c8c5212af470333d8dd36d3601a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import dbus.mainloop.glib
from sugar.tutorius.TProbe import ProbeProxy
import sugar.tutorius.addon as addon

class Engine:
    """
    Driver for the execution of tutorials
    """

    def __init__(self):
        # FIXME Probe management should be in the probe manager
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self._probe = ProbeProxy("org.laptop.Calculate") 
        self._bm = None

    
    def launch(self, tutorialID):
	""" Launch a tutorial 
            @param tutorialID unique tutorial identifier used to retrieve it from the disk
        """
        if self._bm == None:
            self._bm = addon.create("BubbleMessage")
        self._bm.position = (300,300)
        self._bm.message = "Tutorial Started"

        self._probe.install(self._bm)
        

    def stop(self):
        """ Stop the current tutorial
        """
        self._probe.uninstall(self._bm)

    def pause(self):
        """ Interrupt the current tutorial and save its state in the journal
        """
        self._bm.message = "Tutorial State would be saved"
        self._probe.update(self._bm)