Added a safety in case there was image loading issues
authorepage <eopage@byu.net>
Fri, 1 Aug 2008 11:53:57 +0000 (11:53 +0000)
committerepage <eopage@byu.net>
Fri, 1 Aug 2008 11:53:57 +0000 (11:53 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@114 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

src/gc_dialer.py

index 8c42f69..ad9b313 100755 (executable)
@@ -221,14 +221,28 @@ class Dialpad(object):
                self._recentmodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
                self._recentviewselection = None
 
+               self._gcContactText = "GC"
+               try:
+                       self._gcContactIcon = gtk.gdk.pixbuf_new_from_file_at_size('gc_contact.png', 16, 16)
+               except gobject.GError:
+                       self._gcContactIcon = None
                self._contactstime = 0.0
-               self._contactsmodel = gtk.ListStore(
-                       gtk.gdk.Pixbuf,
-                       gobject.TYPE_STRING,
-                       gobject.TYPE_STRING,
-                       gobject.TYPE_STRING,
-                       gobject.TYPE_STRING
-               )
+               if self._gcContactIcon is not None:
+                       self._contactsmodel = gtk.ListStore(
+                               gtk.gdk.Pixbuf,
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING
+                       )
+               else:
+                       self._contactsmodel = gtk.ListStore(
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING,
+                               gobject.TYPE_STRING
+                       )
                self._contactsviewselection = None
 
                for path in Dialpad._glade_files:
@@ -361,9 +375,15 @@ class Dialpad(object):
                # Add the column to the treeview
                column = gtk.TreeViewColumn("Contact")
 
-               iconrenderer = gtk.CellRendererPixbuf()
-               column.pack_start(iconrenderer, expand=False)
-               column.add_attribute(iconrenderer, 'pixbuf', 0)
+               if self._gcContactIcon is not None:
+                       iconrenderer = gtk.CellRendererPixbuf()
+                       column.pack_start(iconrenderer, expand=False)
+                       column.add_attribute(iconrenderer, 'pixbuf', 0)
+               else:
+                       warnings.warn("Contact icon unavailable", UserWarning, 1)
+                       textrenderer = gtk.CellRendererText()
+                       column.pack_start(textrenderer, expand=False)
+                       column.add_attribute(textrenderer, 'text', 0)
 
                textrenderer = gtk.CellRendererText()
                column.pack_start(textrenderer, expand=True)
@@ -429,9 +449,12 @@ class Dialpad(object):
                contactsview.set_model(None)
 
                # get gc icon
-               gc_icon = gtk.gdk.pixbuf_new_from_file_at_size('gc_contact.png', 16, 16)
+               if self._gcContactIcon is not None:
+                       contactType = (self._gcContactIcon,)
+               else:
+                       contactType = (self._gcContactText,)
                for contactId, contactName in self._gcBackend.get_contacts():
-                       self._contactsmodel.append((gc_icon,) + (contactName, "", contactId) + ("",))
+                       self._contactsmodel.append(contactType + (contactName, "", contactId) + ("",))
                        yield
 
                # restart the treeview data rendering