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