Fix-up manual matching to work off new friend class.
[hermes] / package / src / org / maemo / hermes / gui / mapcontact.py
index ca668cd..ca9f517 100644 (file)
@@ -21,28 +21,29 @@ class MapContact(hildon.PannableArea):
         self.treestore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, gobject.TYPE_PYOBJECT)
         
         accounts = {}
-        _facebook = gtk.gdk.pixbuf_new_from_file('/opt/hermes/share/account-facebook.png')
-        _twitter  = gtk.gdk.pixbuf_new_from_file('/opt/hermes/share/account-twitter.png')
-        _tick     = gtk.icon_theme_get_default().load_icon('widgets_tickmark_list', 48, 0)
+        _tick    = gtk.icon_theme_get_default().load_icon('widgets_tickmark_list', 48, 0)
         
         self.contact_mapped = False
         mapped_iter = None
         for key in sorted(self.friends.keys(), cmp = lambda a, b: cmp(a.lower(), b.lower())):
             friend = self.friends[key]
-            if friend['account'] not in accounts:
-                accounts[friend['account']] = gtk.gdk.pixbuf_new_from_file("/opt/hermes/share/account-%s.png" % (friend['account']))
+            if friend.get_source() not in accounts:
+                try:
+                    accounts[friend.get_source()] = gtk.gdk.pixbuf_new_from_file("/opt/hermes/share/account-%s.png" % (friend.get_source()))
+                except glib.GError, e:
+                    accounts[friend.get_source()] = None
+                    print "Couldn't find icon:", e.message
               
-            photo = friend['pic']
             pixbuf = None
-            if 'contact' in friend:
-                if friend['contact'] == contact:
+            if friend.get_contact() is not None:
+                if friend.get_contact() == contact:
                     pixbuf = _tick
                     self.contact_mapped = True
-                    mapped_iter = self.treestore.append([accounts[friend['account']], friend['name'], pixbuf, friend])
+                    mapped_iter = self.treestore.append([accounts[friend.get_source()], friend.get_name(), pixbuf, friend])
                 else:
                     continue
             else:
-                self.treestore.append([accounts[friend['account']], friend['name'], pixbuf, friend])
+                self.treestore.append([accounts[friend.get_source()], friend.get_name(), pixbuf, friend])
         
         self.treeview = gtk.TreeView(self.treestore)
         hildon.hildon_gtk_tree_view_set_ui_mode(self.treeview, gtk.HILDON_UI_MODE_EDIT)
@@ -58,9 +59,12 @@ class MapContact(hildon.PannableArea):
             path = self.treestore.get_path(mapped_iter)
             self.treeview.get_selection().select_path(path)
             self.treeview.scroll_to_cell(path)
+        else:
+            self.treeview.get_selection().unselect_all()
           
         self.add(self.treeview)
-        self.set_size_request(600, 320)
+        self.set_size_request_policy(hildon.SIZE_REQUEST_CHILDREN)
+
       
     # -----------------------------------------------------------------------
     def get_selected_friend(self):