sugar-toolkit-gtk3/tests/graphics/customdestroy.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

45 lines
918 B
Python

from gi.repository import Gtk
"""
Since GTK+3 Gtk.CellRenderer doesn't have a destroy signal anymore.
We can do the cleanup in the python destructor method instead.
"""
class MyCellRenderer(Gtk.CellRenderer):
def __init__(self):
Gtk.CellRenderer.__init__(self)
def __del__(self):
print "cellrenderer destroy"
def do_render(self, cairo_t, widget, background_area, cell_area, flags):
pass
def window_destroy_cb(*kwargs):
print "window destroy"
Gtk.main_quit()
window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
window.connect("destroy", window_destroy_cb)
window.show()
def treeview_destroy_cb(*kwargs):
print "treeview destroy"
treeview = Gtk.TreeView()
treeview.connect("destroy", treeview_destroy_cb)
window.add(treeview)
treeview.show()
col = Gtk.TreeViewColumn()
treeview.append_column(col)
cel = MyCellRenderer()
col.pack_start(cel, expand=True)
Gtk.main()