Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/activity/activityfactory.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-07-20 11:15:11 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-07-20 11:15:11 (GMT)
commit19c8532d09fe19d27ef4b6822e0e0ed9e478bf28 (patch)
treeda60a4b1318cdd4de490b79a3f69adedd9f71406 /sugar/activity/activityfactory.py
parentba3b8043f3eea0eef9a7d57a9705092681caf405 (diff)
Ensure activity uniquness in the shell
Diffstat (limited to 'sugar/activity/activityfactory.py')
-rw-r--r--sugar/activity/activityfactory.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py
index d1480b2..fe2a8bd 100644
--- a/sugar/activity/activityfactory.py
+++ b/sugar/activity/activityfactory.py
@@ -90,24 +90,32 @@ class ActivityCreationHandler(gobject.GObject):
self._activity_handle = activity_handle
bus = dbus.SessionBus()
+
+ bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
+ self._shell = dbus.Interface(bus_object, _SHELL_IFACE)
+
object_path = '/' + service_name.replace('.', '/')
proxy_obj = bus.get_object(service_name, object_path,
follow_name_owner_changes=True)
- factory = dbus.Interface(proxy_obj, _ACTIVITY_FACTORY_INTERFACE)
+ self._factory = dbus.Interface(proxy_obj, _ACTIVITY_FACTORY_INTERFACE)
- factory.create(self._activity_handle.get_dict(),
- reply_handler=self._no_reply_handler,
- error_handler=self._create_error_handler)
-
- bus = dbus.SessionBus()
- bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
- self._shell = dbus.Interface(bus_object, _SHELL_IFACE)
+ if self.get_activity_id() != None:
+ self._shell.ActivateActivity(self.get_activity_id(),
+ reply_handler=self._activate_reply_handler,
+ error_handler=self._activate_error_handler)
+ else:
+ self._launch_activity()
+ def _launch_activity(self):
self._shell.NotifyLaunch(
- service_name, self.get_activity_id(),
+ self._service_name, self.get_activity_id(),
reply_handler=self._no_reply_handler,
error_handler=self._notify_launch_error_handler)
+ self._factory.create(self._activity_handle.get_dict(),
+ reply_handler=self._no_reply_handler,
+ error_handler=self._create_error_handler)
+
def get_activity_id(self):
"""Retrieve the unique identity for this activity"""
return self._activity_handle.activity_id
@@ -121,6 +129,13 @@ class ActivityCreationHandler(gobject.GObject):
def _notify_launch_error_handler(self, err):
logging.debug('Notify launch failed %s' % err)
+ def _activate_reply_handler(self, activated):
+ if not activated:
+ self._launch_activity()
+
+ def _activate_error_handler(self, err):
+ logging.debug("Activity activation request failed %s" % err)
+
def _create_reply_handler(self, xid):
logging.debug("Activity created %s (%s)." %
(self._activity_handle.activity_id, self._service_name))