Ticket #4157: 0004-Icon-force-bytestring-encoding-for-color-entities-an.patch

File 0004-Icon-force-bytestring-encoding-for-color-entities-an.patch, 1.8 KB (added by manuq, 12 years ago)

Toolkit patch.

  • src/sugar3/graphics/icon.py

    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): 
    5757
    5858        for entity, value in entities.items():
    5959            if isinstance(value, basestring):
     60                if isinstance(value, unicode):
     61                    entity, value = str(entity), str(value)
    6062                xml = '<!ENTITY %s "%s">' % (entity, value)
    6163                icon = re.sub('<!ENTITY %s .*>' % entity, xml, icon)
    6264            else:
    class _IconBuffer(object): 
    185187            context.paint()
    186188
    187189    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)):
    189192            width = self.width + padding
    190193            height = self.height + padding
    191194        else: