diff options
author | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-06-12 19:57:49 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-06-12 19:57:49 (GMT) |
commit | 22689ed1dac2c99b10c7de5d8a51789f3abd4f35 (patch) | |
tree | 1752309ccee8210247a3ae4483684b9b306284fc /shell | |
parent | cc604e0815d77a5417fa5af50eeb5bdb4ffe32f6 (diff) |
Several fixes for the object type registry and the activity registry.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/shellservice.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/shell/shellservice.py b/shell/shellservice.py index e29d9b0..c9323a0 100644 --- a/shell/shellservice.py +++ b/shell/shellservice.py @@ -17,9 +17,6 @@ """D-bus service providing access to the shell's functionality""" import dbus -from sugar.activity import ActivityRegistry -from sugar.activity import ActivityInfo - from model import bundleregistry _DBUS_SERVICE = "org.laptop.Shell" @@ -77,8 +74,18 @@ class ShellService(dbus.service.Object): return registry.add_bundle(bundle_path) @dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE, + in_signature="s", out_signature="a{sv}") + def GetActivity(self, service_name): + registry = bundleregistry.get_registry() + bundle = registry.get_bundle(service_name) + if not bundle: + return {} + + return self._bundle_to_dict(bundle) + + @dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE, in_signature="s", out_signature="aa{sv}") - def GetActivitiesForName(self, name): + def FindActivity(self, name): result = [] key = name.lower() @@ -86,8 +93,7 @@ class ShellService(dbus.service.Object): name = bundle.get_name().lower() service_name = bundle.get_service_name().lower() if name.find(key) != -1 or service_name.find(key) != -1: - info = self._bundle_to_activity_info(bundle) - result.append(info.to_dict()) + result.append(self._bundle_to_dict(bundle)) return result @@ -97,9 +103,8 @@ class ShellService(dbus.service.Object): result = [] for bundle in bundleregistry.get_registry(): - if mime_type in bundle.get_mime_types(): - info = self._bundle_to_activity_info(bundle) - result.append(info.to_dict()) + if bundle.get_mime_types() and mime_type in bundle.get_mime_types(): + result.append(self._bundle_to_dict(bundle)) return result @@ -135,6 +140,8 @@ class ShellService(dbus.service.Object): if new_id: self.CurrentActivityChanged(new_id) - def _bundle_to_activity_info(self, bundle): - return ActivityInfo(bundle.get_name(), bundle.get_icon(), - bundle.get_service_name(), bundle.get_path()) + def _bundle_to_dict(self, bundle): + return {'name': bundle.get_name(), + 'icon': bundle.get_icon(), + 'service_name': bundle.get_service_name(), + 'path': bundle.get_path()} |