Add default mime type handlers
This commit is contained in:
parent
d74f966f6d
commit
8b784a6223
1
NEWS
1
NEWS
@ -1,3 +1,4 @@
|
||||
* #3339 Add default mime types handler to the shell. (marco)
|
||||
* #3143 Finish up the invite-only mode implementation. (marco)
|
||||
|
||||
Snapshot 79237f3114
|
||||
|
@ -8,6 +8,7 @@ sugar-xo.gtkrc: gtkrc.em
|
||||
|
||||
sugardir = $(pkgdatadir)/data
|
||||
sugar_DATA = \
|
||||
mime.defaults \
|
||||
$(GTKRC_FILES)
|
||||
|
||||
GTKRC_FILES = \
|
||||
|
20
data/mime.defaults
Normal file
20
data/mime.defaults
Normal file
@ -0,0 +1,20 @@
|
||||
# MIME Activity service name
|
||||
|
||||
application/pdf org.laptop.sugar.ReadActivity
|
||||
|
||||
text/rtf org.laptop.AbiWordActivity
|
||||
text/plain org.laptop.AbiWordActivity
|
||||
application/x-abiword org.laptop.AbiWordActivity
|
||||
text/x-xml-abiword org.laptop.AbiWordActivity
|
||||
application/msword org.laptop.AbiWordActivity
|
||||
application/rtf org.laptop.AbiWordActivity
|
||||
|
||||
image/png org.laptop.WebActivity
|
||||
image/gif org.laptop.WebActivity
|
||||
image/jpeg org.laptop.WebActivity
|
||||
text/html org.laptop.WebActivity
|
||||
application/xhtml+xml org.laptop.WebActivity
|
||||
application/xml org.laptop.WebActivity
|
||||
application/rss+xml org.laptop.WebActivity
|
||||
|
||||
application/ogg org.osl.MediaPlayerActivity
|
@ -29,6 +29,20 @@ def _get_data_dirs():
|
||||
else:
|
||||
return [ '/usr/local/share/', '/usr/share/' ]
|
||||
|
||||
def _load_mime_defaults():
|
||||
defaults = {}
|
||||
|
||||
f = open(env.get_data_path('mime.defaults'), 'r')
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
mime = line[:line.find(' ')]
|
||||
handler = line[line.rfind(' ') + 1:]
|
||||
defaults[mime] = handler
|
||||
f.close()
|
||||
|
||||
return defaults
|
||||
|
||||
class _ServiceManager(object):
|
||||
"""Internal class responsible for creating dbus service files
|
||||
|
||||
@ -72,6 +86,7 @@ class BundleRegistry(gobject.GObject):
|
||||
self._bundles = []
|
||||
self._search_path = []
|
||||
self._service_manager = _ServiceManager()
|
||||
self._mime_defaults = _load_mime_defaults()
|
||||
|
||||
def get_bundle(self, service_name):
|
||||
"""Returns an bundle given his service name"""
|
||||
@ -120,7 +135,10 @@ class BundleRegistry(gobject.GObject):
|
||||
result = []
|
||||
for bundle in self._bundles:
|
||||
if bundle.get_mime_types() and mime_type in bundle.get_mime_types():
|
||||
result.append(bundle)
|
||||
if self._mime_defaults[mime_type] == bundle.get_service_name():
|
||||
result.insert(0, bundle)
|
||||
else:
|
||||
result.append(bundle)
|
||||
return result
|
||||
|
||||
def get_registry():
|
||||
|
@ -112,6 +112,7 @@ class DSObject(object):
|
||||
activities.append(activity_info)
|
||||
|
||||
mime_type = self.metadata['mime_type']
|
||||
print mime_type
|
||||
if mime_type:
|
||||
activities_info = activity.get_registry().get_activities_for_type(mime_type)
|
||||
for activity_info in activities_info:
|
||||
|
Loading…
Reference in New Issue
Block a user