From 6850657229febe167408243a9d362020b80b6fa4 Mon Sep 17 00:00:00 2001
From: Simon Schampijer <simon@laptop.org>
Date: Tue, 30 Oct 2012 08:28:29 +0100
Subject: [PATCH toolkit-gtk3] CellRendererInvoker: use the cell renderer
allocation not the TreeView one, part of SL
#3921
We use get_rect to check if the mouse is still over the invoker
in order to know when to popdown the Palette. The CellRendererInvoker
did return the allocation of the TreeView so far.
The CellRenderer is not a Gtk.Widget anymore, so getting the allocation
is a bit more complicated, we do similar as in the point_in_cell_renderer
method. We fallback onto the treeview allocation in the case of errors.
Signed-off-by: Simon Schampijer <simon@laptop.org>
---
src/sugar3/graphics/palettewindow.py | 38 +++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
index 0407bfc..134256c 100644
a
|
b
|
class CellRendererInvoker(Invoker): |
1234 | 1234 | self._tree_view.disconnect(self._release_hid) |
1235 | 1235 | |
1236 | 1236 | def get_rect(self): |
1237 | | allocation = self._tree_view.get_allocation() |
1238 | | window = self._tree_view.get_window() |
1239 | | if window is not None: |
1240 | | res, x, y = window.get_origin() |
1241 | | else: |
1242 | | logging.warning( |
1243 | | "Trying to position palette with invoker that's not realized.") |
1244 | | x = 0 |
1245 | | y = 0 |
1246 | | |
1247 | 1237 | rect = Gdk.Rectangle() |
1248 | | rect.x = x + allocation.x |
1249 | | rect.y = y + allocation.y |
1250 | 1238 | |
1251 | | rect.width = allocation.width |
1252 | | rect.height = allocation.height |
| 1239 | column = None |
| 1240 | for column in self._tree_view.get_columns(): |
| 1241 | if self._cell_renderer in column.get_cells(): |
| 1242 | break |
| 1243 | |
| 1244 | if column is None or self.path is None: |
| 1245 | allocation = self._tree_view.get_allocation() |
| 1246 | window = self._tree_view.get_window() |
| 1247 | if window is not None: |
| 1248 | res, x, y = window.get_origin() |
| 1249 | else: |
| 1250 | x = 0 |
| 1251 | y = 0 |
| 1252 | rect.x = x |
| 1253 | rect.y = y |
| 1254 | rect.width = allocation.width |
| 1255 | rect.height = allocation.height |
| 1256 | else: |
| 1257 | area = self._tree_view.get_background_area(self.path, column) |
| 1258 | rect.x, rect.y = \ |
| 1259 | self._tree_view.convert_bin_window_to_widget_coords(area.x, |
| 1260 | area.y) |
| 1261 | rect.width = area.width |
| 1262 | rect.height = area.height |
1253 | 1263 | |
1254 | 1264 | return rect |
1255 | 1265 | |