Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
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 /shell
parentba3b8043f3eea0eef9a7d57a9705092681caf405 (diff)
Ensure activity uniquness in the shell
Diffstat (limited to 'shell')
-rw-r--r--shell/model/homeactivity.py36
-rw-r--r--shell/shellservice.py9
2 files changed, 35 insertions, 10 deletions
diff --git a/shell/model/homeactivity.py b/shell/model/homeactivity.py
index 4487c09..8b6a8dc 100644
--- a/shell/model/homeactivity.py
+++ b/shell/model/homeactivity.py
@@ -64,6 +64,14 @@ class HomeActivity(gobject.GObject):
self._launch_time = time.time()
self._launching = False
+ self._retrieve_service()
+
+ if not self._service:
+ bus = dbus.SessionBus()
+ bus.add_signal_receiver(self._name_owner_changed_cb,
+ signal_name="NameOwnerChanged",
+ dbus_interface="org.freedesktop.DBus")
+
def set_window(self, window):
"""An activity is 'launched' once we get its window."""
if self._window or self._xid:
@@ -75,22 +83,14 @@ class HomeActivity(gobject.GObject):
self._xid = window.get_xid()
def get_service(self):
- """Retrieve the application's sugar introspection service
+ """Get the activity service
Note that non-native Sugar applications will not have
such a service, so the return value will be None in
those cases.
"""
- bus = dbus.SessionBus()
- try:
- service = dbus.Interface(
- bus.get_object(_SERVICE_NAME + self._activity_id,
- _SERVICE_PATH + "/" + self._activity_id),
- _SERVICE_INTERFACE)
- except dbus.DBusException:
- service = None
- return service
+ return self._service
def get_title(self):
"""Retrieve the application's root window's suggested title"""
@@ -182,3 +182,19 @@ class HomeActivity(gobject.GObject):
def do_get_property(self, pspec):
if pspec.name == 'launching':
return self._launching
+
+ def _get_service_name(self):
+ return _SERVICE_NAME + self._activity_id
+
+ def _retrieve_service(self):
+ try:
+ bus = dbus.SessionBus()
+ proxy = bus.get_object(self._get_service_name(),
+ _SERVICE_PATH + "/" + self._activity_id)
+ self._service = dbus.Interface(proxy, _SERVICE_INTERFACE)
+ except dbus.DBusException:
+ self._service = None
+
+ def _name_owner_changed_cb(self, name, old, new):
+ if name == self._get_service_name():
+ self._retrieve_service()
diff --git a/shell/shellservice.py b/shell/shellservice.py
index c612d6e..5728e44 100644
--- a/shell/shellservice.py
+++ b/shell/shellservice.py
@@ -63,6 +63,15 @@ class ShellService(dbus.service.Object):
bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus)
dbus.service.Object.__init__(self, bus_name, _DBUS_PATH)
+ @dbus.service.method(_DBUS_SHELL_IFACE,
+ in_signature="s", out_signature="b")
+ def ActivateActivity(self, activity_id):
+ host = self._shell.get_activity(activity_id)
+ if host:
+ host.present()
+ return True
+
+ return False
@dbus.service.method(_DBUS_SHELL_IFACE,
in_signature="ss", out_signature="")