Ticket #3845: 0001-Take-list-of-supported-image-formats-mime-types-from.patch

File 0001-Take-list-of-supported-image-formats-mime-types-from.patch, 1.3 KB (added by godiard, 12 years ago)
  • src/sugar3/mime.py

    From f81841c35b37550bad81c3df8bafd69854f424b7 Mon Sep 17 00:00:00 2001
    From: Gonzalo Odiard <godiard@gmail.com>
    Date: Fri, 31 Aug 2012 17:56:43 -0300
    Subject: [sugar-toolkit-gtk3] Take list of supported image formats mime types
     from GdkPixbuf - SL #3845
    
    Signed-off-by: Gonzalo Odiard <gonzalo@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..d0b12dc 100644
    a b import os 
    2525import logging
    2626import gettext
    2727
     28from gi.repository import GdkPixbuf
     29
    2830from sugar3 import _sugarbaseext
    2931
    3032_ = lambda msg: gettext.dgettext('sugar-base', msg)
    GENERIC_TYPE_AUDIO = 'Audio' 
    3537GENERIC_TYPE_VIDEO = 'Video'
    3638GENERIC_TYPE_LINK = 'Link'
    3739
     40
     41def get_supported_image_mime_types():
     42    mime_types = []
     43    for image_format in  GdkPixbuf.Pixbuf.get_formats():
     44        mime_types.extend(image_format.get_mime_types())
     45    return mime_types
     46
     47
    3848_extensions = {}
    3949_globs_timestamps = []
    4050_generic_types = [
    _generic_types = [ 
    5161    'id': GENERIC_TYPE_IMAGE,
    5262    'name': _('Image'),
    5363    'icon': 'image-x-generic',
    54     'types': ['image/png', 'image/gif', 'image/jpeg'],
     64    'types': get_supported_image_mime_types(),
    5565},
    5666{
    5767    'id': GENERIC_TYPE_AUDIO,