Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius')
-rw-r--r--tutorius/TProbe.py68
-rw-r--r--tutorius/creator.py3
-rw-r--r--tutorius/engine.py3
3 files changed, 73 insertions, 1 deletions
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index ea677ca..d2af13f 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -27,6 +27,8 @@ import cPickle as pickle
from functools import partial
from jarabe.model.shell import get_model
+from jarabe.model import bundleregistry
+from sugar.activity import activityfactory
from sugar.bundle.activitybundle import ActivityBundle
from . import addon
@@ -760,6 +762,11 @@ class ProbeManager(object):
self._probes = {}
self._current_activity = None
+ self.is_activity_launching = False
+
+ self.list_pending_actions = None
+ self.list_pending_transitions = None
+
ProbeManager._LOGGER.debug("__init__()")
def setCurrentActivity(self, activity_id):
@@ -786,6 +793,42 @@ class ProbeManager(object):
else:
return None
+ def prelaunch_activity(self, activity, action_event, is_event=False):
+ if activity == "org.sugar.desktop.mesh":
+ get_model()._set_zoom_level(get_model().ZOOM_MESH)
+ return False
+ elif activity == "org.sugar.desktop.group":
+ get_model()._set_zoom_level(get_model().ZOOM_GROUP)
+ return False
+ elif activity == "org.sugar.desktop.home":
+ get_model()._set_zoom_level(get_model().ZOOM_HOME)
+ return False
+
+ if activity == get_model().get_active_activity().get_type():
+ return False
+
+ model = get_model()
+ for active_activity in model:
+ if active_activity is not None and active_activity.get_type() == activity:
+ active_activity.get_window().activate(gtk.get_current_event_time())
+ return False
+
+ bundle = bundleregistry.get_registry().get_bundle(activity)
+ if not bundle:
+ print 'WARNING : Cannot find bundle'
+ else:
+ path = bundle.get_path()
+ activity_bundle = ActivityBundle(path)
+ if self.is_activity_launching == False:
+ activityfactory.create(activity_bundle)
+ self.is_activity_launching = True
+ if is_event:
+ self.list_pending_transitions = action_event
+ else:
+ self.list_pending_actions = action_event
+ return True
+ return False
+
def install(self, action, action_installed_cb, error_cb, is_editing=False, editing_cb=None):
"""
Install an action on the current activity
@@ -803,6 +846,13 @@ class ProbeManager(object):
activity = self.currentActivity
if activity:
+ wait_install = self.prelaunch_activity(activity, action)
+
+ if wait_install:
+ self.list_action_installed_cb = action_installed_cb
+ self.list_error_cb = error_cb
+ return
+
return self._first_proxy(activity).install(
action=action,
is_editing=is_editing,
@@ -879,6 +929,14 @@ class ProbeManager(object):
activity = self.get_source_activity(event)
if activity:
+ wait_install = self.prelaunch_activity(activity, event, True)
+
+ if wait_install:
+ self.list_notification_cb = notification_cb
+ self.list_event_subscribed_cb = event_subscribed_cb
+ self.list_error_cb = error_cb
+ return
+
return self._first_proxy(activity).subscribe(event, notification_cb,\
event_subscribed_cb, error_cb)
else:
@@ -927,6 +985,16 @@ class ProbeManager(object):
# to open up)
self.currentActivity = process_name
+ if self.list_pending_actions:
+ self.install(self.list_pending_actions, self.list_action_installed_cb, self.list_error_cb)
+ self.list_pending_actions = None
+
+ if self.list_pending_transitions:
+ self.subscribe(self.list_pending_transitions, self.list_notification_cb, self.list_event_subscribed_cb, self.list_error_cb)
+ self.list_pending_transitions = None
+
+ self.is_activity_launching = False
+
def unregister_probe(self, unique_id):
""" Remove a probe from the known probes.
diff --git a/tutorius/creator.py b/tutorius/creator.py
index 7d9153b..12f48aa 100644
--- a/tutorius/creator.py
+++ b/tutorius/creator.py
@@ -115,7 +115,8 @@ class Creator(Object):
new_state=self._state)
final_event = addon.create(
name='MessageButtonNext',
- message=T('This is the end of this tutorial.')
+ message=T('This is the end of this tutorial.',
+ source=self._probe_mgr.currentActivity)
)
self._tutorial.add_transition(
state_name=self._state,
diff --git a/tutorius/engine.py b/tutorius/engine.py
index de58f88..a63ad00 100644
--- a/tutorius/engine.py
+++ b/tutorius/engine.py
@@ -309,6 +309,9 @@ class Engine:
""" Launch a tutorial
@param tutorialID unique tutorial identifier used to retrieve it from the disk
"""
+ if self._probeManager.is_activity_launching:
+ return
+
if self._tutorial:
self.stop()