sugar-toolkit-gtk3/tests/graphics/cellrenderericon.py
Manuel Quiñones a14574c666 Finish the port of the CellRendererIcon
In pygtk custom cellrenderers were done inheriting
gtk.GenericCellRenderer, and overriding the on_* methods.  Now we
inherit Gtk.CellRenderer and the methods to override changed to do_* .

The destroy signal was moved to Gtk.Widget [1] so the Gtk.CellRenderer
doesn't have it anymore.  Now we do the cleanup in the python
destructor method.  A testcase tests/graphics/customdestroy.py shows
how is done.

tests/graphics/cellrenderericon.py tests the usage.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>

[1] http://developer.gnome.org/gtk3/stable/ch24s02.html#id1459754
2012-09-03 22:55:35 +02:00

38 lines
849 B
Python

from gi.repository import Gtk
from sugar3.graphics import style
from sugar3.graphics.icon import CellRendererIcon
import common
test = common.Test()
test.show()
model = Gtk.ListStore(str)
for icon in ['one', 'two', 'three']:
model.append([icon])
treeview = Gtk.TreeView()
treeview.set_model(model)
test.pack_start(treeview, True, True, 0)
treeview.show()
col = Gtk.TreeViewColumn()
treeview.append_column(col)
cell_icon = CellRendererIcon(treeview)
cell_icon.props.width = style.GRID_CELL_SIZE
cell_icon.props.height = style.GRID_CELL_SIZE
cell_icon.props.size = style.SMALL_ICON_SIZE
cell_icon.props.icon_name = 'emblem-favorite'
col.pack_start(cell_icon, expand=False)
cell_text = Gtk.CellRendererText()
col.pack_start(cell_text, expand=True)
col.add_attribute(cell_text, 'text', 0)
if __name__ == '__main__':
common.main(test)