Ticket #4190: 0001-CellRendererIcon-Skip-drawing-if-the-icon-is-empty-S.patch

File 0001-CellRendererIcon-Skip-drawing-if-the-icon-is-empty-S.patch, 1.5 KB (added by manuq, 11 years ago)

Proposed patch.

  • src/sugar3/graphics/icon.py

    From 8a5e47e42349a5277af6d34a9a2db9365a1b9cd0 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Fri, 23 Nov 2012 11:21:17 -0300
    Subject: [PATCH toolkit] CellRendererIcon: Skip drawing if the icon is empty
     - SL #4190
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    Adds a is_empty method to the _IconBuffer class.  If it doesn't have
    file_name or icon_name then it's get_surface method returns None.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/sugar3/graphics/icon.py | 6 ++++++
     1 file changed, 6 insertions(+)
    
    diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
    index 507db41..73fa028 100644
    a b class _IconBuffer(object): 
    246246
    247247        return pixbuf
    248248
     249    def is_empty(self):
     250        return not self.icon_name and not self.file_name
     251
    249252    def get_surface(self, sensitive=True, widget=None):
    250253        cache_key = self._get_cache_key(sensitive)
    251254        if cache_key in self._surface_cache:
    class CellRendererIcon(Gtk.CellRenderer): 
    902905        return False
    903906
    904907    def do_render(self, cr, widget, background_area, cell_area, flags):
     908        if self._buffer.is_empty():
     909            return
     910
    905911        context = widget.get_style_context()
    906912        context.save()
    907913        context.add_class("sugar-icon-cell")