Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/TProbe.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-12-09 02:58:20 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-12-09 03:07:06 (GMT)
commit394001c2e7c8585b7152e8f5888e340a0c7a1bbc (patch)
tree6254b8f0a17768c9e47aeafa5ff2c1992ff6d33c /tutorius/TProbe.py
parentcf6785d168eaf3ed5505705478a6aea05ad3da98 (diff)
Integration with Sugar : Exposing set_current_act on Service
Correcting two interface mismatches (install error on translator, subscribe error on creator) Changing MessageButtonNext to ButtonNext
Diffstat (limited to 'tutorius/TProbe.py')
-rw-r--r--tutorius/TProbe.py50
1 files changed, 29 insertions, 21 deletions
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index 7f717f1..ea677ca 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -673,15 +673,24 @@ class ProbeProxy:
else:
LOGGER.debug("ProbeProxy :: unsubsribe address %s inconsistency : not registered", address)
- def create_event(self, addon_name):
+ def create_event(self, addon_name, event_created_cb):
"""
Create an event on the app side and request the user to fill the
properties before returning it.
@param addon_name: the add-on name of the event
+ @param event_created_cb The notification to trigger once the event has
+ been instantiated
@returns: an eventfilter instance
"""
- return pickle.loads(str(self._probe.create_event(addon_name)))
+ self._probe.create_event(addon_name,
+ reply_handler=save_args(self._event_created_cb, event_created_cb),
+ error_handler=ignore)
+
+ def _event_created_cb(self, event_created_cb, event):
+ LOGGER.debug("ProbeProxy :: _event_created_cb, calling upper layer")
+ event = pickle.loads(str(event))
+ event_created_cb(event)
def subscribe(self, event, notification_cb, event_subscribed_cb, error_cb):
@@ -754,26 +763,20 @@ class ProbeManager(object):
ProbeManager._LOGGER.debug("__init__()")
def setCurrentActivity(self, activity_id):
- if not activity_id in self._probes:
- raise RuntimeError("Activity not attached, id : %s"%activity_id)
+ # HACK : Disabling check for now, since it prevents usage of probes
+ # in activities that have yet to register their probes... We might
+ # set the current activity before having to execute anything inside it
+ # e.g. A new source is crawling in and we need to start the activity
+ #
+ # This should be removed once the Home Window probes are installed.
+
+ #if not activity_id in self._probes:
+ # raise RuntimeError("Activity not attached, id : %s"%activity_id)
+ LOGGER.debug("ProbeManager :: New activity set as current = %s", str(activity_id))
self._current_activity = activity_id
def getCurrentActivity(self):
- if self._current_activity == "org.laptop.JournalActivity":
- return self._current_activity
- # TODO : Insert the correct call to remember the current activity,
- # taking the views and frame into account
- current_act = get_model().get_active_activity()
- bundle_path = current_act.get_bundle_path()
- if bundle_path:
- current_act_bundle = ActivityBundle(bundle_path)
- current_act_id = current_act_bundle.get_bundle_id()
- self._current_activity = current_act_id
- return self._current_activity
- else:
- # Temp hack for Journal
- self._current_activity = 'org.laptop.JournalActivity'#current_act.get_bundle_id()
- return self._current_activity
+ return self._current_activity
currentActivity = property(fget=getCurrentActivity, fset=setCurrentActivity)
@@ -848,16 +851,17 @@ class ProbeManager(object):
else:
raise RuntimeWarning("No activity attached")
- def create_event(self, addon_name):
+ def create_event(self, addon_name, event_created_cb):
"""
Create an event on the app side and request the user to fill the
properties before returning it.
@param addon_name: the add-on name of the event
+ @param event_created_cb The notification to send once the event was created
@returns: an eventfilter instance
"""
if self.currentActivity:
- return self._first_proxy(self.currentActivity).create_event(addon_name)
+ return self._first_proxy(self.currentActivity).create_event(addon_name, event_created_cb)
else:
raise RuntimeWarning("No activity attached")
@@ -918,6 +922,10 @@ class ProbeManager(object):
self._probes[process_name] = [(unique_id,self._ProxyClass(process_name, unique_id))]
else:
self._probes[process_name].append((unique_id,self._ProxyClass(process_name, unique_id)))
+ # Register the probe that was just installed as the current activity
+ # (this will be true by default since we probably were waiting for it
+ # to open up)
+ self.currentActivity = process_name
def unregister_probe(self, unique_id):