diff options
author | Simon Schampijer <simon@laptop.org> | 2012-10-30 08:30:31 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2012-10-31 07:49:22 (GMT) |
commit | 8af0d49591383ec3e88458c0e8feb2d0d7ff695f (patch) | |
tree | 29111dbf690094f832add39a4189a6db4de46a2f | |
parent | 2a76b10ce0eb2cfdaad5288e1e0f2999acedd735 (diff) |
GtkMenu: use point_in_cell_renderer for CellRendereInvoker to check if a point is in, 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.
We already have a point_in_cell_renderer method in the
CellRendererInvoker so we can use this to check if the mouse pointer
is over the cell or not. The method point_in_cell_renderer is made
public to make it clearer that it can be used from the outside.
Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel QuiƱones <manuq@laptop.org>
-rw-r--r-- | src/sugar3/graphics/palettewindow.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py index 0407bfc..6e33efe 100644 --- a/src/sugar3/graphics/palettewindow.py +++ b/src/sugar3/graphics/palettewindow.py @@ -205,11 +205,16 @@ class _PaletteMenuWidget(Gtk.Menu): return False def _motion_notify_cb(self, widget, event): - rect = self._invoker.get_rect() x = event.x_root y = event.y_root - in_invoker = x >= rect.x and x < (rect.x + rect.width) \ - and y >= rect.y and y < (rect.y + rect.height) + + if type(self._invoker) is CellRendererInvoker: + in_invoker = self._invoker.point_in_cell_renderer(x, y) + else: + rect = self._invoker.get_rect() + in_invoker = x >= rect.x and x < (rect.x + rect.width) \ + and y >= rect.y and y < (rect.y + rect.height) + if in_invoker != self._mouse_in_invoker: self._mouse_in_invoker = in_invoker self._reevaluate_state() @@ -1256,7 +1261,7 @@ class CellRendererInvoker(Invoker): def __motion_notify_event_cb(self, widget, event): if event.window != widget.get_bin_window(): return - if self._point_in_cell_renderer(event.x, event.y): + if self.point_in_cell_renderer(event.x, event.y): tree_view = self._tree_view path, column_, x_, y_ = tree_view.get_path_at_pos(int(event.x), @@ -1295,7 +1300,7 @@ class CellRendererInvoker(Invoker): return False def __button_release_event_cb(self, widget, event): - if event.button == 1 and self._point_in_cell_renderer(event.x, + if event.button == 1 and self.point_in_cell_renderer(event.x, event.y): tree_view = self._tree_view path, column_, x_, y_ = tree_view.get_path_at_pos(int(event.x), @@ -1303,14 +1308,14 @@ class CellRendererInvoker(Invoker): self._cell_renderer.emit('clicked', path) # So the treeview receives it and knows a drag isn't going on return False - if event.button == 3 and self._point_in_cell_renderer(event.x, + if event.button == 3 and self.point_in_cell_renderer(event.x, event.y): self.notify_right_click() return True else: return False - def _point_in_cell_renderer(self, event_x, event_y): + def point_in_cell_renderer(self, event_x, event_y): pos = self._tree_view.get_path_at_pos(int(event_x), int(event_y)) if pos is None: return False |