From c4ccf4ac9f14cc4d7bf8f0fe063b1767380cdb4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Wed, 20 Mar 2013 22:04:14 -0300
Subject: [PATCH 2/5] CellRendererIcon: improve point_in_cell_renderer - SL
#4343
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
Call Gtk.TreeViewColumn.cell_get_position() early and return if the
cell was not found in the column. This is when it returns None [1] .
[1] https://developer.gnome.org/gtk3/stable/GtkTreeViewColumn.html#gtk-tree-view-column-cell-get-position
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
src/sugar3/graphics/icon.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 6ee9838..7c428b7 100644
a
|
b
|
class CellRendererIcon(Gtk.CellRenderer): |
892 | 892 | return False |
893 | 893 | |
894 | 894 | path_, column, x, y_ = pos |
| 895 | result = column.cell_get_position(self) |
895 | 896 | |
| 897 | # If this cell was not found in the column: |
| 898 | if result is None: |
| 899 | return False |
| 900 | |
| 901 | cell_x, cell_width = result |
896 | 902 | for cell_renderer in column.get_cells(): |
897 | 903 | if cell_renderer == self: |
898 | | cell_x, cell_width = column.cell_get_position(cell_renderer) |
899 | 904 | if x > cell_x and x < (cell_x + cell_width): |
900 | 905 | return True |
901 | 906 | return False |