From fa9b23107a78b7bb6a4f9a597a24d5316f526997 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 9 Feb 2009 12:23:40 +0000 Subject: [PATCH] Support for displaying picture on contacts. --- ChangeLog | 1 + Wammu/Image.py | 17 +++++++++++++++++ Wammu/Utils.py | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4e681fb5..b2bd7563 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ two versions can be retrieved from Subversion. * Do not fail if group ID can not be converted to name. * Updated to work with current python-gammu. * Translation updates. +* Support for displaying picture on contacts. 0.29 ==== (2008-10-04) diff --git a/Wammu/Image.py b/Wammu/Image.py index 9d4ba6e4..796cceb7 100644 --- a/Wammu/Image.py +++ b/Wammu/Image.py @@ -25,6 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., import wx import wx.lib.throbber +import base64 defaultbmp = [ '20 20 2 1', @@ -51,6 +52,21 @@ defaultbmp = [ ' .. .. ', ' '] +class MemoryInputStream(wx.InputStream): + def __init__(self, data): + import cStringIO + wx.InputStream.__init__(self,cStringIO.StringIO(data)) + +class EncodedBitmap(wx.StaticBitmap): + def __init__(self, parent, tooltip = 'Image', image = defaultbmp, size = None, scale = 1): + image = wx.ImageFromStream(MemoryInputStream(base64.b64decode(image))) + if scale > 1: + bitmap = wx.BitmapFromImage(image.Scale(bitmap.GetWidth() * scale, bitmap.GetHeight() * scale)) + else: + bitmap = wx.BitmapFromImage(image) + wx.StaticBitmap.__init__(self, parent, -1, bitmap, (0,0)) + self.SetToolTipString(tooltip) + class Bitmap(wx.StaticBitmap): def __init__(self, parent, tooltip = 'Image', image = defaultbmp, size = None, scale = 1): bitmap = wx.BitmapFromXPMData(image) @@ -71,3 +87,4 @@ class Throbber(wx.lib.throbber.Throbber): bitmaps.append(bitmap) wx.lib.throbber.Throbber.__init__(self, parent, -1, bitmaps, frameDelay = delay) self.SetToolTipString(tooltip) + diff --git a/Wammu/Utils.py b/Wammu/Utils.py index e91fc637..96b4349f 100644 --- a/Wammu/Utils.py +++ b/Wammu/Utils.py @@ -30,6 +30,7 @@ import re import wx import string import os +import base64 try: import grp HAVE_GRP = True @@ -62,6 +63,8 @@ def GetItemType(txt): return 'category' elif txt == 'PictureID' or txt == 'RingtoneID' or txt == 'RingtoneFileSystemID': return 'id' + elif txt == 'Photo': + return 'photo' else: return 'number' @@ -191,6 +194,12 @@ def GetTypeString(type, value, values, linkphone = True): if v[-1] == 'L': v = v[:-1] return v + elif t == 'photo': + return '' + \ + '' + \ + '' else: return StrConv(value) -- 2.11.4.GIT