diff --git a/NEWS b/NEWS index ca3860c7..4a819430 100644 --- a/NEWS +++ b/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 diff --git a/data/Makefile.am b/data/Makefile.am index 2ab45601..1fc8051f 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -8,6 +8,7 @@ sugar-xo.gtkrc: gtkrc.em sugardir = $(pkgdatadir)/data sugar_DATA = \ + mime.defaults \ $(GTKRC_FILES) GTKRC_FILES = \ diff --git a/data/mime.defaults b/data/mime.defaults new file mode 100644 index 00000000..e2ef352a --- /dev/null +++ b/data/mime.defaults @@ -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 diff --git a/services/shell/bundleregistry.py b/services/shell/bundleregistry.py index fbcef878..8de49ff1 100644 --- a/services/shell/bundleregistry.py +++ b/services/shell/bundleregistry.py @@ -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(): diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index eb88458a..8fb30da1 100644 --- a/sugar/datastore/datastore.py +++ b/sugar/datastore/datastore.py @@ -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: