gimmie r664 - in trunk: . gimmie



Author: orph
Date: Thu Feb  7 11:09:11 2008
New Revision: 664
URL: http://svn.gnome.org/viewvc/gimmie?rev=664&view=rev

Log:
2008-02-07  Alex Graveley  <alex beatniksoftware com>

	* gimmie/gimmie_evolution.py (EvolutionSource): Handle weird/wacky
	evolution binds better.



Modified:
   trunk/ChangeLog
   trunk/gimmie/gimmie_evolution.py

Modified: trunk/gimmie/gimmie_evolution.py
==============================================================================
--- trunk/gimmie/gimmie_evolution.py	(original)
+++ trunk/gimmie/gimmie_evolution.py	Thu Feb  7 11:09:11 2008
@@ -1,18 +1,17 @@
 
+import os
+import gobject
+
+import gtk
+from gimmie_base import Item, ItemSource
+
 try:
-    import os
-    import gobject
     import evolution
-    import pygtk
-    import gtk
-    from gimmie_base import Item, ItemSource
-   
 except ImportError, err:
-    w= gtk.Window()
-    label= gtk.Label(err)
-    w.add(label)
-    w.show_all()
-            
+    print " !!! Unable to import evolution bindings:", err
+    evolution = None
+
+
 class EvolutionContactWindow(gtk.Window):
     def __init__(self,contact):
         
@@ -66,6 +65,7 @@
         entry = self.combobox.get_active_text()
         os.system('evolution mailto:'+entry)
 
+
 class EvolutionContact(Item):
     def __init__(self,c):
         self.contact=c
@@ -82,17 +82,9 @@
         ecw=EvolutionContactWindow(self.contact)
         ecw.show()
 
-class EvolutionSource(ItemSource):
 
+class EvolutionSource(ItemSource):
     def __init__(self):
-        self.contacts=[]
-        addressbooks = evolution.list_addressbooks()
-        for temp in addressbooks:
-            addressBook = evolution.open_addressbook(temp[1])
-            for c in addressBook.get_all_contacts():
-                contact = EvolutionContact(c)
-                self.contacts.append(contact)
-                #print(c.get_name())
         ItemSource.__init__(self,
                             name="Evolution",
                             icon="stock_mail",
@@ -100,8 +92,17 @@
                             filter_by_date=False)
         self.categories = ["Evolution"]
         self.topics = ["People"]
-    def get_items(self):
-        return self.get_items_uncached()
-        
+
+    def _get_all_contacts(self):
+        contacts = []
+        if evolution:
+            for book_id in evolution.list_addressbooks():
+                book = evolution.open_addressbook(book_id[1])
+                if book:
+                    for c in book.get_all_contacts():
+                        contact = EvolutionContact(c)
+                        contacts.append(contact)
+        return contacts
+
     def get_items_uncached(self):
-        return self.contacts
+        return self._get_all_contacts()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]