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 $
import gtk
import const
try:
from gnomevfs import mime_get_short_list_applications, \
@ -82,22 +81,4 @@ def mime_type_is_defined(type):
return True
except:
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 const
from gen.ggettext import gettext as _
_type_map = {
@ -64,7 +63,3 @@ def mime_type_is_defined(mime_type):
Return True if a description for a mime type exists.
"""
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

@ -121,9 +121,6 @@ def mime_type_is_defined(mime_type):
return True
else:
return _PythonMime.mime_type_is_defined(mime_type)
def find_mime_type_pixbuf(mime_type):
return _PythonMime.find_mime_type_pixbuf(mime_type)
#-------------------------------------------------------------------------
#

View File

@ -186,6 +186,29 @@ def __create_thumbnail_image(src_file, mtype=None, rectangle=None):
except:
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
@ -263,7 +286,7 @@ def get_thumbnail_image(src_file, mtype=None, rectangle=None):
return gtk.gdk.pixbuf_new_from_file(filename)
except (gobject.GError, OSError):
if mtype:
return Mime.find_mime_type_pixbuf(mtype)
return find_mime_type_pixbuf(mtype)
else:
default = os.path.join(const.IMAGE_DIR, "document.png")
return gtk.gdk.pixbuf_new_from_file(default)

View File

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

View File

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