Move find_mime_type_pixbuf from the Mime module to ThumbNails. It is more closely related to thumbnails than mime.

svn: r14109
This commit is contained in:
Brian Matherly 2010-01-24 04:52:22 +00:00
parent 4a529d0c28
commit 2e9a4c27d0
6 changed files with 28 additions and 31 deletions

View File

@ -21,7 +21,6 @@
# $Id:_GnomeMime.py 9912 2008-01-22 09:17:46Z acraphae $ # $Id:_GnomeMime.py 9912 2008-01-22 09:17:46Z acraphae $
import gtk import gtk
import const
try: try:
from gnomevfs import mime_get_short_list_applications, \ from gnomevfs import mime_get_short_list_applications, \
@ -83,21 +82,3 @@ def mime_type_is_defined(type):
except: except:
return False return False
_icon_theme = gtk.icon_theme_get_default()
def find_mime_type_pixbuf(mime_type):
try:
icontmp = mime_type.replace('/','-')
newicon = "gnome-mime-%s" % icontmp
try:
return _icon_theme.load_icon(newicon,48,0)
except:
icontmp = mime_type.split('/')[0]
try:
newicon = "gnome-mime-%s" % icontmp
return _icon_theme.load_icon(newicon,48,0)
except:
return gtk.gdk.pixbuf_new_from_file(const.ICON)
except:
return gtk.gdk.pixbuf_new_from_file(const.ICON)

View File

@ -19,7 +19,6 @@
# #
import mimetypes import mimetypes
import const
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
_type_map = { _type_map = {
@ -64,7 +63,3 @@ def mime_type_is_defined(mime_type):
Return True if a description for a mime type exists. Return True if a description for a mime type exists.
""" """
return mime_type in _type_map return mime_type in _type_map
def find_mime_type_pixbuf(mime_type):
import gtk
return gtk.gdk.pixbuf_new_from_file(const.ICON)

View File

@ -122,9 +122,6 @@ def mime_type_is_defined(mime_type):
else: else:
return _PythonMime.mime_type_is_defined(mime_type) return _PythonMime.mime_type_is_defined(mime_type)
def find_mime_type_pixbuf(mime_type):
return _PythonMime.find_mime_type_pixbuf(mime_type)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# private functions # private functions

View File

@ -186,6 +186,29 @@ def __create_thumbnail_image(src_file, mtype=None, rectangle=None):
except: except:
return return
#-------------------------------------------------------------------------
#
# find_mime_type_pixbuf
#
#-------------------------------------------------------------------------
_icon_theme = gtk.icon_theme_get_default()
def find_mime_type_pixbuf(mime_type):
try:
icontmp = mime_type.replace('/','-')
newicon = "gnome-mime-%s" % icontmp
try:
return _icon_theme.load_icon(newicon,48,0)
except:
icontmp = mime_type.split('/')[0]
try:
newicon = "gnome-mime-%s" % icontmp
return _icon_theme.load_icon(newicon,48,0)
except:
return gtk.gdk.pixbuf_new_from_file(const.ICON)
except:
return gtk.gdk.pixbuf_new_from_file(const.ICON)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# run_thumbnailer # run_thumbnailer
@ -263,7 +286,7 @@ def get_thumbnail_image(src_file, mtype=None, rectangle=None):
return gtk.gdk.pixbuf_new_from_file(filename) return gtk.gdk.pixbuf_new_from_file(filename)
except (gobject.GError, OSError): except (gobject.GError, OSError):
if mtype: if mtype:
return Mime.find_mime_type_pixbuf(mtype) return find_mime_type_pixbuf(mtype)
else: else:
default = os.path.join(const.IMAGE_DIR, "document.png") default = os.path.join(const.IMAGE_DIR, "document.png")
return gtk.gdk.pixbuf_new_from_file(default) return gtk.gdk.pixbuf_new_from_file(default)

View File

@ -54,6 +54,7 @@ import const
import config import config
import Utils import Utils
import Mime import Mime
import ThumbNails
import GrampsDisplay import GrampsDisplay
import ManagedWindow import ManagedWindow
from QuestionDialog import ErrorDialog, WarningDialog from QuestionDialog import ErrorDialog, WarningDialog
@ -200,7 +201,7 @@ class AddMediaObject(ManagedWindow.ManagedWindow):
if mtype and mtype.startswith("image"): if mtype and mtype.startswith("image"):
image = scale_image(filename, const.THUMBSCALE) image = scale_image(filename, const.THUMBSCALE)
else: else:
image = Mime.find_mime_type_pixbuf(mtype) image = ThumbNails.find_mime_type_pixbuf(mtype)
self.image.set_from_pixbuf(image) self.image.set_from_pixbuf(image)
def _cleanup_on_exit(self): def _cleanup_on_exit(self):

View File

@ -165,7 +165,7 @@ class EditMedia(EditPrimary):
mtype) mtype)
self.pixmap.set_from_pixbuf(pb) self.pixmap.set_from_pixbuf(pb)
else: else:
pb = Mime.find_mime_type_pixbuf('text/plain') pb = ThumbNails.find_mime_type_pixbuf('text/plain')
self.pixmap.set_from_pixbuf(pb) self.pixmap.set_from_pixbuf(pb)
def setup_filepath(self): def setup_filepath(self):