Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-05-27 18:43:31 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-05-27 18:43:31 (GMT)
commit11437e34849b77a84fa94ff9ea65d0ca8f6f35e3 (patch)
treef77b467814a70e7b4b1e13c9e006bbd7a51c076b
parent42fef182f4a2853cd7da0c550f77a81c5f749d90 (diff)
Add mime matching to the registry.
-rwxr-xr-xbin/sugar-install-bundle4
-rw-r--r--shell/shellservice.py12
-rw-r--r--sugar/activity/registry.py12
3 files changed, 22 insertions, 6 deletions
diff --git a/bin/sugar-install-bundle b/bin/sugar-install-bundle
index 359c1c0..01a45ae 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 4e8f469..e6d11bf 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 1efda45..9eed4aa 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)