diff --git a/bin/sugar-install-bundle b/bin/sugar-install-bundle index 359c1c06..01a45ae4 100755 --- a/bin/sugar-install-bundle +++ b/bin/sugar-install-bundle @@ -1,4 +1,4 @@ -#!/usr/bin/env python +a#!/usr/bin/env python import sys import os import zipfile @@ -44,7 +44,7 @@ if os.spawnlp(os.P_WAIT, 'unzip', 'unzip', sys.argv[1], '-d', bundle_dir): raise RuntimeError, 'An error occurred while extracting the .xo contents.' # notify shell of new bundle -if not dbus_service.add_bundle(bundle_path): +if not dbus_service.AddBundle(bundle_path): # error, let's delete the just expanded bundle. for root, dirs, files in os.walk(bundle_path, topdown=False): for name in files: diff --git a/shell/shellservice.py b/shell/shellservice.py index 4e8f469f..e6d11bf6 100644 --- a/shell/shellservice.py +++ b/shell/shellservice.py @@ -90,6 +90,18 @@ class ShellService(dbus.service.Object): return result + @dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE, + in_signature="s", out_signature="aa{sv}") + def GetActivitiesForType(self, mime_type): + result = [] + + for bundle in bundleregistry.get_registry(): + service_name = bundle.get_service_name().lower() + if mime_type in bundle.get_mime_types(): + result.append(self._get_activity_info(bundle).to_dict()) + + return result + @dbus.service.signal(_DBUS_OWNER_IFACE, signature="s") def ColorChanged(self, color): pass diff --git a/sugar/activity/registry.py b/sugar/activity/registry.py index 1efda458..9eed4aa4 100644 --- a/sugar/activity/registry.py +++ b/sugar/activity/registry.py @@ -45,14 +45,18 @@ class ActivityRegistry(object): bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH) self._registry = dbus.Interface(bus_object, _REGISTRY_IFACE) - def get_activities_for_name(self, name): + def _convert_info_list(self, info_list): result = [] - activities = self._registry.GetActivitiesForName(name) - for info_dict in activities: + for info_dict in info_list: result.append(_activity_info_from_dict(info_dict)) return result + def get_activities_for_name(self, name): + info_list = self._registry.GetActivitiesForName(name) + return self._convert_info_list(info_list) + def get_activities_for_type(self, mime_type): - pass + info_list = self._registry.GetActivitiesForType(mime_type) + return self._convert_info_list(info_list)