Add mime matching to the registry.
This commit is contained in:
parent
42fef182f4
commit
11437e3484
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user