[Sugar-devel] [PATCH] Take list of supported image formats mime types from GdkPixbuf - SL #3845

godiard at sugarlabs.org godiard at sugarlabs.org
Mon Sep 3 07:52:06 EDT 2012


From: Gonzalo Odiard <godiard at gmail.com>

Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
Acked-by: Simon Schampijer <simon at laptop.org>
---
 src/sugar3/mime.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/sugar3/mime.py b/src/sugar3/mime.py
index 07d085e..70b4d2b 100644
--- a/src/sugar3/mime.py
+++ b/src/sugar3/mime.py
@@ -25,6 +25,8 @@ import os
 import logging
 import gettext
 
+from gi.repository import GdkPixbuf
+
 from sugar3 import _sugarbaseext
 
 _ = lambda msg: gettext.dgettext('sugar-base', msg)
@@ -35,6 +37,14 @@ GENERIC_TYPE_AUDIO = 'Audio'
 GENERIC_TYPE_VIDEO = 'Video'
 GENERIC_TYPE_LINK = 'Link'
 
+
+def _get_supported_image_mime_types():
+    mime_types = []
+    for image_format in GdkPixbuf.Pixbuf.get_formats():
+        mime_types.extend(image_format.get_mime_types())
+    return mime_types
+
+
 _extensions = {}
 _globs_timestamps = []
 _generic_types = [
@@ -51,7 +61,7 @@ _generic_types = [
     'id': GENERIC_TYPE_IMAGE,
     'name': _('Image'),
     'icon': 'image-x-generic',
-    'types': ['image/png', 'image/gif', 'image/jpeg'],
+    'types': _get_supported_image_mime_types(),
 },
 {
     'id': GENERIC_TYPE_AUDIO,
-- 
1.7.11.4



More information about the Sugar-devel mailing list