From 1ea8303633f6b58bf40509aece5c28c6ab66bb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 18 Sep 2008 17:06:10 +0200 Subject: [PATCH] Fix render for gtk.gdk.Pixmap It seems that there is a bug in pygtk that doesn't what to render on Pixmap --- tryton/common/cellrenderertext.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tryton/common/cellrenderertext.py b/tryton/common/cellrenderertext.py index 9582d59614..ea888682d6 100644 --- a/tryton/common/cellrenderertext.py +++ b/tryton/common/cellrenderertext.py @@ -1,6 +1,7 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. import gtk import gobject +import pango class CellRendererText(gtk.GenericCellRenderer): @@ -38,6 +39,16 @@ class CellRendererText(gtk.GenericCellRenderer): def on_render(self, window, widget, background_area, cell_area, expose_area, flags): + # Handle Pixmap window as pygtk failed + if type(window) == gtk.gdk.Pixmap: + layout = widget.create_pango_layout(self.text) + layout.set_font_description(widget.style.font_desc) + w, h = layout.get_size() + xalign = self._renderer.get_property('xalign') + x = int(cell_area.x + (cell_area.width - w / pango.SCALE) * xalign) + y = int(cell_area.y + (cell_area.height - h / pango.SCALE) / 2) + window.draw_layout(widget.style.text_gc[0], x, y, layout) + return return self._renderer.render(window, widget, background_area, cell_area, expose_area, flags)