Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-06-29 17:05:10 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-06-29 17:05:10 (GMT)
commitd7a8c5430e1565fb7f8ebfd5c828b83eff24c0b5 (patch)
tree26ef68b79b6edcb4cb38fb26f2ed2d27170ba6a9 /sugar
parent64812c7d67c3f926cb7348bd8fffcf6f4d1f219f (diff)
Make notification work from outside the shell process
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/activityfactory.py55
1 files changed, 30 insertions, 25 deletions
diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py
index 4bfccf0..f3e8bbe 100644
--- a/sugar/activity/activityfactory.py
+++ b/sugar/activity/activityfactory.py
@@ -26,6 +26,10 @@ from sugar.presence import presenceservice
from sugar.activity.activityhandle import ActivityHandle
from sugar import util
+_SHELL_SERVICE = "org.laptop.Shell"
+_SHELL_PATH = "/org/laptop/Shell"
+_SHELL_IFACE = "org.laptop.Shell"
+
_ACTIVITY_FACTORY_INTERFACE = "org.laptop.ActivityFactory"
def create_activity_id():
@@ -59,13 +63,6 @@ class ActivityCreationHandler(gobject.GObject):
activity startup using callbacks to the service's
create call.
"""
- __gsignals__ = {
- 'success': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ([])),
- 'error': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT]))
- }
def __init__(self, service_name, activity_handle):
"""Initialise the handler
@@ -99,34 +96,42 @@ class ActivityCreationHandler(gobject.GObject):
factory = dbus.Interface(proxy_obj, _ACTIVITY_FACTORY_INTERFACE)
factory.create(self._activity_handle.get_dict(),
- reply_handler=self._reply_handler,
- error_handler=self._error_handler)
+ 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)
+
+ self._shell.NotifyLaunch(
+ service_name, self.get_activity_id(),
+ reply_handler=self._no_reply_handler,
+ error_handler=self._notify_launch_error_handler)
def get_activity_id(self):
"""Retrieve the unique identity for this activity"""
return self._activity_handle.activity_id
- def _reply_handler(self, xid):
- """Reply from service regarding what window was created
-
- xid -- X windows ID for the window that was just created
-
- emits the "success" message (on ourselves)
- """
+ def _no_reply_handler(self, *args):
+ pass
+
+ def _notify_launch_failure_error_handler(self, err):
+ logging.debug('Notify launch failure failed %s' % err)
+
+ def _notify_launch_error_handler(self, err):
+ logging.debug('Notify launch failed %s' % err)
+
+ def _create_reply_handler(self, xid):
logging.debug("Activity created %s (%s)." %
(self._activity_handle.activity_id, self._service_name))
- self.emit('success')
- def _error_handler(self, err):
- """Reply from service with an error message (exception)
-
- err -- exception object describing the error
-
- emits the "error" message (on ourselves)
- """
+ def _create_error_handler(self, err):
logging.debug("Couldn't create activity %s (%s): %s" %
(self._activity_handle.activity_id, self._service_name, err))
- self.emit('error', err)
+ self._shell.NotifyLaunchFailure(
+ service_name, self.get_activity_id(),
+ reply_handler=self._no_reply_handler,
+ error_handler=self._notify_launch_failure_error_handler)
def create(service_name, activity_handle=None):
"""Create a new activity from its name."""