import cairo

from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk


class Cell(Gtk.CellRenderer):
    rgba = GObject.Property(type=object)

    def do_render(self, cr, widget, background_area, cell_area, flags):
        cr.set_source_rgba(*tuple(self.rgba))
        cr.rectangle(background_area.x, background_area.y,
                     background_area.width, background_area.height)
        cr.fill()

    def do_get_size(self, widget, cell_area=None):
        return (0, 0, 42, 10)


model = Gtk.ListStore(object)
model.append([Gdk.RGBA(red=0.2, green=0.5, blue=0.2)])
model.append([Gdk.RGBA(red=0.2, green=0.2, blue=0.5)])

tree = Gtk.TreeView(model=model)

cell = Cell()
column = Gtk.TreeViewColumn('test', cell, rgba=0)
tree.append_column(column)

window = Gtk.Window()
window.add(tree)

window.show_all()
window.connect('destroy', Gtk.main_quit)
Gtk.main()
