def populate(self):
"""populate
Populates the file list with data from the global var 'files'.
It reads in their image data and gives them an icon from that.
"""
main_window = self.get_toplevel()
for name in files:
image = files[name]['image']
pix_width = len(image[0])
pix_height = len(image)
if pix_width < 6:
pix_width = 6
if pix_height < 6:
pix_height = 6
pix_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, pix_width,
pix_height)
pix_context = cairo.Context(pix_surface)
pix_context.set_source_rgba(*main_window.paint_background.get_rgba())
for yi, yv in enumerate(image):
for xi, xv in enumerate(yv):
rgb, var = xv
if rgb is not None:
pix_context.set_source_rgba(*rgb)
pix_context.rectangle(xi, yi, 1, 1)
pix_context.fill()
pixbuf = Gdk.pixbuf_get_from_surface(pix_surface, 0, 0, pix_width,
pix_height)
icon = Gtk.IconTheme.get_default().load_icon('image-x-generic', 40, 0)
self.list.append([pixbuf, name])
return None
评论列表
文章目录