Пример #1
0
def get_icon_with_type(filepath, size):
    icon = ui.icon_lookup(icontheme, None, filepath)

    try:
        pixbuf = icontheme.load_icon(icon[0], size, 0)
    except:
        return get_icon_with_name('gtk-execute', size)

    if pixbuf.get_height() != size:
        return pixbuf.scale_simple(24, 24, gtk.gdk.INTERP_BILINEAR)
    
    return pixbuf
Пример #2
0
def get_icon_for_uri(uri, icon_size=48):
	""" 
	Returns a pixbuf representing the file at
	the URI generally (mime-type based)
	
	@param icon_size: a pixel size of the icon 
	@type icon_size: an integer object.  
	 
	""" 
	from gtk import icon_theme_get_default, ICON_LOOKUP_USE_BUILTIN
	from gnomevfs import get_mime_type
	from gnome.ui import ThumbnailFactory, icon_lookup 

	mtype = get_mime_type(uri)
	icon_theme = icon_theme_get_default()
	thumb_factory = ThumbnailFactory(16)
	icon_name, num = icon_lookup(icon_theme, thumb_factory,  file_uri=uri, custom_icon="")
	icon = icon_theme.load_icon(icon_name, icon_size, ICON_LOOKUP_USE_BUILTIN)
	return icon