[Sugar-devel] [PATCH sugar-toolkit-gtk3] Finish the port of the CellRendererIcon

Simon Schampijer simon at schampijer.de
Mon Sep 3 16:57:29 EDT 2012


On 08/24/2012 03:13 PM, Manuel Quiñones wrote:
> 2012/8/24 Simon Schampijer <simon at schampijer.de>:
>> On 08/23/2012 08:16 PM, Manuel Quiñones wrote:
>>>
>>> In pygtk custom cellrenderers were done inheriting
>>> gtk.GenericCellRenderer, and overriding the on_* methods.  Now we
>>> inherit Gtk.CellRenderer and the methods to override changed to do_* .
>>>
>>> The destroy signal was moved to Gtk.Widget [1] so the Gtk.CellRenderer
>>> doesn't have it anymore.  Now we do the cleanup in the python
>>> destructor method.  A testcase tests/graphics/customdestroy.py shows
>>> how is done.
>>>
>>> tests/graphics/cellrenderericon.py tests the usage.
>>>
>>> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
>>
>>
>> Great, thanks for adding as well a testcase:
>>
>> I get one traceback when hovering over a cell:
>>
>> Traceback (most recent call last):
>>    File
>> "/home/erikos/sugar-build/install/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py",
>> line 1199, in __motion_notify_event_cb
>>      if self._point_in_cell_renderer(event.x, event.y):
>>    File
>> "/home/erikos/sugar-build/install/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py",
>> line 1258, in _point_in_cell_renderer
>>      for cell_renderer in column.get_cell_renderers():
>> AttributeError: 'TreeViewColumn' object has no attribute
>> 'get_cell_renderers'
>>
>> Do you get that as well?
>
> Yes.  I was thinking in a separate patch for the palettewindow, but
> what do you think?  Is better to do it in this one?
>
> The issue is for the API change, column.get_cell_renderers now is
> column.get_cells .

Ok, let's do in a separate patch, something like this would do:

diff --git a/src/sugar3/graphics/palettewindow.py 
b/src/sugar3/graphics/palettewindow.py
index 2c8816c..1307a20 100644
--- a/src/sugar3/graphics/palettewindow.py
+++ b/src/sugar3/graphics/palettewindow.py
@@ -1221,7 +1221,7 @@ class CellRendererInvoker(Invoker):
      def _redraw_path(self, path):
          column = None
          for column in self._tree_view.get_columns():
-            if self._cell_renderer in column.get_cell_renderers():
+            if self._cell_renderer in column.get_cells():
                  break
          assert column is not None
          area = self._tree_view.get_background_area(path, column)
@@ -1255,7 +1255,7 @@ class CellRendererInvoker(Invoker):

          path_, column, x, y_ = pos

-        for cell_renderer in column.get_cell_renderers():
+        for cell_renderer in column.get_cells():
              if cell_renderer == self._cell_renderer:
                  cell_x, cell_width = 
column.cell_get_position(cell_renderer)
                  if x > cell_x and x < (cell_x + cell_width):

But should be verified.

I pushed your patch in the meantime.

Thanks,
    Simon



More information about the Sugar-devel mailing list