2 # Copyright (C) 2009, Thomas Leonard
3 # See the README file for details, or visit http://0install.net.
5 from zeroinstall
import _
7 from logging
import warn
9 def load_icon(icon_path
):
10 """Load icon from path. Icon MUST be in PNG format.
11 @param icon_path: pathname of icon, or None to load nothing
12 @return: a GdkPixbuf, or None on failure"""
16 # Icon format must be PNG (to avoid attacks)
17 loader
= gtk
.gdk
.PixbufLoader('png')
19 loader
.write(file(icon_path
).read())
22 return loader
.get_pixbuf()
24 warn(_("Failed to load cached PNG icon: %s") % ex
)