def get_thumbnail_image(src_file, mtype=None, rectangle=None, size=SIZE_NORMAL):
"""
Return the thumbnail image (in GTK Pixbuf format) associated with the
source file passed to the function. If no thumbnail could be found,
the associated icon for the mime type is returned, or if that cannot be
found, a generic document icon is returned.
The image is not generated every time, but only if the thumbnail does not
exist, or if the source file is newer than the thumbnail.
:param src_file: Source media file
:type src_file: unicode
:param mime_type: mime type of the source file
:type mime_type: unicode
:param rectangle: subsection rectangle
:type rectangle: tuple
:returns: thumbnail representing the source file
:rtype: GdkPixbuf.Pixbuf
"""
try:
filename = get_thumbnail_path(src_file, mtype, rectangle, size)
return GdkPixbuf.Pixbuf.new_from_file(filename)
except (GObject.GError, OSError):
if mtype:
return find_mime_type_pixbuf(mtype)
else:
default = os.path.join(IMAGE_DIR, "document.png")
return GdkPixbuf.Pixbuf.new_from_file(default)
#-------------------------------------------------------------------------
#
# get_thumbnail_path
#
#-------------------------------------------------------------------------
评论列表
文章目录