From 172707d69b8a431c67c5de4160d8bfcf81ebffc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Tue, 6 Nov 2012 01:25:09 -0300
Subject: [PATCH toolkit-gtk3 4/4] Icon: force bytestring encoding for color
entities and width, height == 0, 0 - SL
#4157
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
When the color entities are given by the remote buddy, they come as
unicode, but the Rsvg.Handle.new_from_data method needs a bytestring.
So we cast to str in this case.
Also activity icons that come from the remote buddy to notify
invitations have width, height == 0, 0 . Handle this case too.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
src/sugar3/graphics/icon.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 507db41..03f6785 100644
a
|
b
|
class _SVGLoader(object): |
57 | 57 | |
58 | 58 | for entity, value in entities.items(): |
59 | 59 | if isinstance(value, basestring): |
| 60 | if isinstance(value, unicode): |
| 61 | entity, value = str(entity), str(value) |
60 | 62 | xml = '<!ENTITY %s "%s">' % (entity, value) |
61 | 63 | icon = re.sub('<!ENTITY %s .*>' % entity, xml, icon) |
62 | 64 | else: |
… |
… |
class _IconBuffer(object): |
185 | 187 | context.paint() |
186 | 188 | |
187 | 189 | def _get_size(self, icon_width, icon_height, padding): |
188 | | if self.width is not None and self.height is not None: |
| 190 | if ((self.width is not None and self.width != 0) and |
| 191 | (self.height is not None and self.height != 0)): |
189 | 192 | width = self.width + padding |
190 | 193 | height = self.height + padding |
191 | 194 | else: |