Add v0.0.4 of Hermes from source tarball 0.0.4
authorAndrew Flegg <andrew@bleb.org>
Tue, 13 Oct 2009 19:34:36 +0000 (20:34 +0100)
committerAndrew Flegg <andrew@bleb.org>
Tue, 13 Oct 2009 19:34:36 +0000 (20:34 +0100)
package/debian/changelog
package/src/contactview.py
package/src/gui.py

index 7f7f264..d37d2e7 100644 (file)
@@ -1,3 +1,10 @@
+hermes (0.0.4) unstable; urgency=low
+
+  * Use own photo loading to avoid issue with EContact.get_photo()
+    which resulted in missing icons.
+
+ -- Andrew Flegg <andrew@bleb.org>  Sun,  4 Oct 2009 00:06:23 +0100
+
 hermes (0.0.3) unstable; urgency=low
 
   * Improve GUI responsiveness.
index 5ea8093..6488cc5 100644 (file)
@@ -1,5 +1,6 @@
 import gtk
 import hildon
+from ctypes import *
 
 class ContactView(hildon.PannableArea):
   """Widget which shows a list of contacts in a pannable area.
@@ -16,7 +17,26 @@ class ContactView(hildon.PannableArea):
     self.contacts = contacts
     self.treestore = gtk.ListStore(str, gtk.gdk.Pixbuf)
     for contact in self.contacts:
-      self.treestore.append(row = [contact.get_name(), contact.get_photo(48)])
+      if not contact.get_name():
+        continue
+        
+      photo = contact.get_property('photo')
+      pi = cast(c_void_p(hash(photo)), POINTER(EContactPhoto))
+      pixbuf = None
+      if pi.contents.data.uri.startswith("image/"):
+        data = string_at(pi.contents.data.inlined.data, pi.contents.data.inlined.length)
+        pixbuf_loader = gtk.gdk.PixbufLoader()
+        pixbuf_loader.write(data)
+        pixbuf_loader.close()
+        pixbuf = pixbuf_loader.get_pixbuf()
+      elif pi.contents.data.uri.startswith("file://"):
+        filename = pi.contents.data.uri[7:]
+        pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
+            
+      if pixbuf:
+        size = min(pixbuf.get_width(), pixbuf.get_height())
+        pixbuf = pixbuf.subpixbuf(0, 0, size, size).scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR)
+      self.treestore.append(row = [contact.get_name(), pixbuf])
 
     self.treeview = gtk.TreeView(self.treestore)
     tvcolumn = gtk.TreeViewColumn('Name', gtk.CellRendererText(), text = 0)
@@ -30,3 +50,18 @@ class ContactView(hildon.PannableArea):
     self.add(self.treeview)
     self.set_size_request(600, 380)
 
+
+class EContactPhoto_inlined(Structure):
+  _fields_ = [('mime_type', c_char_p),
+              ('length', c_uint),
+              ('data', c_void_p)]
+
+class EContactPhoto_data(Union):
+  _fields_ = [('inlined', EContactPhoto_inlined),
+              ('uri', c_char_p)]
+
+class EContactPhoto(Structure):
+  _fields_ = [('type', c_int),
+              ('data', EContactPhoto_data)]
+
+
index 56ca58d..e3366fc 100755 (executable)
@@ -216,7 +216,7 @@ class HermesGUI:
     self.app = hildon.Program()
     self.window = hildon.Window()
     gtk.set_application_name('Hermes')
-    self.osso_context = osso.Context('org.maemo.hermes', '0.0.3', False)
+    self.osso_context = osso.Context('org.maemo.hermes', '0.0.4', False)
     self.app.add_window(self.window)
 
     self.window.connect("delete-event", gtk.main_quit)