Ticket #4343: 0001-CellRendererInvoker-remove-duplicate-code-in-CellRen.patch

File 0001-CellRendererInvoker-remove-duplicate-code-in-CellRen.patch, 3.1 KB (added by manuq, 8 years ago)
  • src/sugar3/graphics/icon.py

    From 0df3b7c49b59b5cbb0cc3f63702e160cb93e6c2f Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Wed, 20 Mar 2013 16:55:18 -0300
    Subject: [PATCH 1/5] CellRendererInvoker: remove duplicate code in
     CellRendererIcon - 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>
    
    Make public the method to check if the pointer is inside the
    CellRendererIcon and reuse it in CellRendererInvoker.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/sugar3/graphics/icon.py          |  6 +++---
     src/sugar3/graphics/palettewindow.py | 16 ++--------------
     2 files changed, 5 insertions(+), 17 deletions(-)
    
    diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
    index a554324..6ee9838 100644
    a b class CellRendererIcon(Gtk.CellRenderer): 
    775775        self._palette_invoker.detach()
    776776
    777777    def __button_press_event_cb(self, widget, event):
    778         if self._point_in_cell_renderer(widget, event.x, event.y):
     778        if self.point_in_cell_renderer(widget, event.x, event.y):
    779779            self._active_state = True
    780780
    781781    def __button_release_event_cb(self, widget, event):
    class CellRendererIcon(Gtk.CellRenderer): 
    877877                         flags):
    878878        pass
    879879
    880     def _point_in_cell_renderer(self, tree_view, x=None, y=None):
     880    def point_in_cell_renderer(self, tree_view, x=None, y=None):
    881881        """Check if the point with coordinates x, y is inside this icon.
    882882
    883883        If the x, y coordinates are not given, they are taken from the
    class CellRendererIcon(Gtk.CellRenderer): 
    907907        context.save()
    908908        context.add_class("sugar-icon-cell")
    909909
    910         pointer_inside = self._point_in_cell_renderer(widget)
     910        pointer_inside = self.point_in_cell_renderer(widget)
    911911
    912912        # The context will have prelight state if the mouse pointer is
    913913        # in the entire row, but we want that state if the pointer is
  • src/sugar3/graphics/palettewindow.py

    diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
    index 995e258..28789f3 100644
    a b class CellRendererInvoker(Invoker): 
    14661466            self.notify_right_click()
    14671467
    14681468    def point_in_cell_renderer(self, event_x, event_y):
    1469         pos = self._tree_view.get_path_at_pos(int(event_x), int(event_y))
    1470         if pos is None:
    1471             return False
    1472 
    1473         path_, column, x, y_ = pos
    1474 
    1475         for cell_renderer in column.get_cells():
    1476             if cell_renderer == self._cell_renderer:
    1477                 cell_x, cell_width = column.cell_get_position(cell_renderer)
    1478                 if x > cell_x and x < (cell_x + cell_width):
    1479                     return True
    1480                 return False
    1481 
    1482         return False
     1469        return self._cell_renderer.point_in_cell_renderer(
     1470            self._tree_view, event_x, event_y)
    14831471
    14841472    def get_toplevel(self):
    14851473        return self._tree_view.get_toplevel()