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): |
246 | 246 | |
247 | 247 | return pixbuf |
248 | 248 | |
| 249 | def is_empty(self): |
| 250 | return not self.icon_name and not self.file_name |
| 251 | |
249 | 252 | def get_surface(self, sensitive=True, widget=None): |
250 | 253 | cache_key = self._get_cache_key(sensitive) |
251 | 254 | if cache_key in self._surface_cache: |
… |
… |
class CellRendererIcon(Gtk.CellRenderer): |
902 | 905 | return False |
903 | 906 | |
904 | 907 | def do_render(self, cr, widget, background_area, cell_area, flags): |
| 908 | if self._buffer.is_empty(): |
| 909 | return |
| 910 | |
905 | 911 | context = widget.get_style_context() |
906 | 912 | context.save() |
907 | 913 | context.add_class("sugar-icon-cell") |