Exemple #1
0
 def on_contactsTreeView_selection_changed(self,selection):
     ''' IMPORTANT: This signal is associated with a gtk.TreeSelection not in Glade-3! '''
     model, paths = selection.get_selected_rows()
     if paths and paths[0]:
         contId=paths[0][0]
         log.debug("on_contactsTreeView_selection_changed : %s" % contId)
         self.selectAndDisplayContact(contId)
Exemple #2
0
 def on_cancel_pressed(self,button):
     if self.discoverer:
         log.debug("on_cancel_pressed: cancelling existing discovery")
         # Need to cancel our discovery...
         self.discoverer.cancel_discovery()
     else:
         log.debug("on_cancel_pressed: destroying dialog")
         self.devicesDialog.destroy()        
Exemple #3
0
 def on_discoveredDevice(self,address,name,device_class):
     log.debug("on_discoveredDevice: %s %s %s" % (address,name,device_class))
     # TODO: This device needs to be added to the database and updated in UI...
     with open(DEVICESTORE,'a') as f:
         def deviceClassToStr(devclass):
             return "unknown"
         f.write("%s;%s;%s\n" % (address,name,deviceClassToStr(device_class)))
         self.devicesModel.append((address,name,deviceClassToStr(device_class)))
Exemple #4
0
 def on_button_delete_clicked(self,widget,data=None):
     ''' Use a modal verification dialog '''
     contId,contFullName=self.currentContact
     messageDlg=ConfirmationDialog(self,"Are you sure you want to delete '%s'?" % contFullName)
     resp=messageDlg.run()
     if resp==gtk.RESPONSE_ACCEPT:
         log.debug("Delete '%s' now!" % contFullName)
     messageDlg.destroy()  # destroy dialog either way
Exemple #5
0
 def on_button_export_clicked(self,widget,data=None):
     ''' User clicked to export a contact.  This should launch a new file dialog '''
     if not self.currentContact:
         log.warning("No current contact set - returning")
         return
     contId,contFullName=self.currentContact
     cont=self.getContactById(contId)
     vcard=cont.get_vcard_string()
     log.debug("Current contact='%s'" % contFullName)
     export_dialog=ExportDialog(self,contFullName,vcard)
     export_dialog.show()
Exemple #6
0
 def populateWithEvolutionContacts(self):
     ''' Appends all Evolution contacts to the contactList using the Evolution (id,name) as the contact (id,name) '''
     # Zeth on pyevolution:  http://commandline.org.uk/python/2007/dec/1/three-useful-python-bindings/
     log.debug("ContactsApp::populateWithEvolutionContacts")
     self.addresses=evolution.ebook.open_addressbook('default')
     # This will show you all the available properties
     allContacts=self.addresses.get_all_contacts()
     contacts=[(cont.get_property('full-name').lower(),cont) for cont in allContacts]    # Note the lowering...
     contacts.sort() # alphabetic sort in-place on contact names
     for (name,cont) in contacts:
         contId=cont.get_property('id')
         name=cont.get_property('full-name')
         self.contactModel.append((contId,name))            
Exemple #7
0
 def __init__(self):
     log.debug("ContactsApp::__init__")
     self.currentContact = None
     self.about_dialog = None
     self.hostHasGtkBuilder = False
     version=gtk.gtk_version
     if int(version[0]) >= 2 and int(version[1]) >= 12:   
         self.hostHasGtkBuilder = True
     log.debug("Does host support GtkBuilder?: %s" % self.hostHasGtkBuilder)
     self.gladefile=GLADEFILE
     self.wTree=gtk.glade.XML(self.gladefile,"mainWindow")
     self.window = self.wTree.get_widget("mainWindow")
     self.window.maximize()
     self.notebook=self.wTree.get_widget("mainNotebook")
     self.statusbar = self.wTree.get_widget("statusbar")
     self.contactModelView=self.wTree.get_widget("contactsTreeView")
     # Color changing of background needs to be done on the uppermost widget - in our case the viewport
     self.contactDetailViewport=self.wTree.get_widget("summaryViewport")
     color = gtk.gdk.color_parse("white")
     self.contactDetailViewport.modify_bg(gtk.STATE_NORMAL,color)
     self.contactDetailVbox=self.wTree.get_widget("summaryVbox")
     self.contactDetailName=self.wTree.get_widget("summaryName")
     self.contactDetailPhoto=self.wTree.get_widget("summaryPhoto")
     self.contactDetailTable=self.wTree.get_widget("summaryTable")
     # Create the listStore model to use with the contactListView
     self.contactModel=gtk.ListStore(str,str)  # (ContactId,FullName)
     self.populateWithAddressBookContacts()
     # Create a filter, from the model and set the TreeView to use it
     self.contactFilter=self.contactModel.filter_new()
     self.contactFilter.set_visible_column(1)
     #view=gtk.TreeView(filter)
     self.contactModelView.set_model(self.contactModel)
     self.contactModelView.set_enable_search(True)
     self.contactModelView.set_search_column(1)
     #self.contactModelView.set_filter(self.contactFilter)
     treeselection=self.contactModelView.get_selection()
     treeselection.connect('changed',self.on_contactsTreeView_selection_changed)
     col=contactDetails.createTreeViewColumn("Name",1)
     self.contactModelView.append_column(col)
     self.toolbar = self.wTree.get_widget("toolbar")
     # autoconnect => signal handlers are named class methods.  eg. "on_mainWindow_destroy"
     self.wTree.signal_autoconnect(self)
     self.window.set_icon_name(gtk.STOCK_ORIENTATION_PORTRAIT)   # set the window icon to the GTK "portrait" icon
     self.statusbar_cid = self.statusbar.get_context_id(APPNAME)   # setup and initialize our statusbar
     # We're going to fire up the last contact Id on startup
     self.contactModelView.set_cursor(121,col)
     # Now show everything!
     self.window.show()
Exemple #8
0
 def displayEvolutionContact(self,contId,contFullName):
     ''' Displays corresponding Evolution contact field details in the table in 'summaryViewport' '''
     log.debug("displayEvolutionContact(%s,'%s')" % (contId,contFullName))
     if self.currentContact and contId==self.currentContact[0]:
         log.debug("Attempting to show the same contact - moving on")
         return
     self.currentContact=(contId,contFullName)
     cont=self.getContactById(contId)
     # Now follows the display utility logic
     view,table=contactDetails.initContactDetailView(self)
     contactDetails.setupContactNameLabel(self,contFullName)
     image=cont.get_photo(80)    # gtk.gdk.Pixbuf - you can pull out this photo into a GTKImage        
     contactDetails.setupContactThumbnail(self,image)
     # Populate our table with attr-vals from contact.  
     contactDetails.populateEvolutionContactDetailFields(table,cont) 
     view.show_all()     # To now show the table
Exemple #9
0
 def displayVCardContact(self,contId,contFullName):
     ''' Displays corresponding vCard contact field details in the table in 'summaryViewport' '''
     log.debug("displayVcardContact(%s,'%s')" % (contId,contFullName))
     if self.currentContact and contId==self.currentContact[0]:
         log.debug("Attempting to show the same contact - moving on")
         return
     self.currentContact=(contId,contFullName)
     cont=self.getContactById(contId)
     vcf=cont.get_vcard_string()
     vcont=vobject.readOne(vcf)   # Use Chandler vobject library to process Evolution vCard 3.0 format
     view,table=contactDetails.initContactDetailView(self)
     contactDetails.setupContactNameLabel(self,contFullName)
     try:
         if USE_VCARD_THUMBNAIL:
             image=contactDetails.vcardThumbnailToGtkImage(vcont.photo.value)
         else:
             image=cont.get_photo(80)    # gtk.gdk.Pixbuf - you can pull out this photo into a GTKImage        
     except:
         image=None
     contactDetails.setupContactThumbnail(self,image) 
     contactDetails.populateVobjectContactDetailFields(table,vcont)
     view.show_all()     # To now show the table
Exemple #10
0
 def on_device_selection_changed(self,selection):
     ''' IMPORTANT: This signal is associated with a gtk.TreeSelection not in Glade-3! '''
     model, paths = selection.get_selected_rows()
     if paths and paths[0]:
         id=paths[0][0]
         log.debug("on_device_selection_changed: %s" % id)
Exemple #11
0
 def on_completedDiscovery(self,count):
     log.debug("on_completedDiscovery: %d" % count)
     self.discoverer=None
     self.devicesDialog.set_title("Bluetooth device neighbourhood")
Exemple #12
0
 def populateWithWABContacts(self):
     ''' Appends all WAB contacts to the contactList using the WAB (id,name) as the contact (id,name) '''
     log.debug("ContactsApp::populateWithWABContacts")
     self.addresses=EnsureDispatch("WABAccess.Session",bForDemand=0)
Exemple #13
0
 def on_startedDiscovery(self):
     log.debug("on_startedDiscovery")
Exemple #14
0
 def on_search_pressed(self,button):
     ''' Kick off a Bluetooth device discovery sequence to search for new Bluetooth devices '''
     log.debug("on_search_pressed: response=%s" % button)
     if not self.discoverer:
         # The following needs to run in its own thread!
         threading.Thread(target=self.kickDiscovery).start()
Exemple #15
0
 def on_connect_pressed(self,button):
     log.debug("on_connect_pressed: response=%s" % button)
Exemple #16
0
 def on_mainWindow_destroy(self, widget, data=None):
     ''' When our window is destroyed, we want to break out of the GTK main loop. 
     We do this by calling gtk_main_quit(). We could have also just specified 
     gtk_main_quit as the handler in Glade!'''
     log.debug("ContactsApp::on_mainWindow_destroy")
     gtk.main_quit()
Exemple #17
0
 def on_contactsTreeView_start_interactive_search(self,treeview,data=None):
     log.debug("on_contactsTreeView_start_interactive_search: %s" % data)
Exemple #18
0
 def on_close(self,dialog,response,parent):
     log.debug("on_close: %s %s %s" % (dialog,response,parent))
     parent.devicesDialog=None
     dialog.destroy()
Exemple #19
0
 def on_button_edit_clicked(self,widget,data=None):
     ''' User clicked to edit a contact.  This should launch an edit contact dialog '''
     log.debug("TBD")
Exemple #20
0
 def on_button_add_clicked(self,widget,data=None):
     ''' User clicked to add a contact.  This should launch a new contact dialog '''
     # TODO: We would want to launch a dialog OR edit page of notebook here...
     log.debug("TBD")
Exemple #21
0
 def editContact(self,contId,contFullName):
     log.debug("editContact(%s,'%s')" % (contId,contFullName))
Exemple #22
0
 def on_delete_event(self,dialog,event,parent):
     log.debug("on_delete_event: %s %s %s" % (dialog,event,parent))
     parent.devicesDialog=None
     return True
Exemple #23
0
    print "Failed to handle imports properly!"
    sys.exit(1)
        
from globals import *
from gtkUtils import contactDetails
from logUtils import log
#from contactUtils import symplaContact
from dialogs import AboutDialog,ExportDialog,BluetoothDevicesDialog,ConfirmationDialog
try:
    import vobject
except:
    print "Could not find vobject vCard support modulex"
    sys.exit()
    
osname,platf=determinePlatform()
log.debug("OS: '%s', PLATFORM: '%s'" % (osname,platf))
if osname=='nt':
    # Using WABAccess: http://sourceforge.net/projects/wabaccess/
    # WABAccess is a convenience COM/ATL component that gives late binding access 
    # (via IDispatch) to Windows Address Book and Outlook Express functionality.
    # NOTE: In order to use this support, it is necessary to run the win32com 
    # makepy.py utility over "WABAccess 1.0 Library" to generate the Python type library.
    # If we wanted to use Outlook directly instead, we would need to run makepy.py 
    # over "MicrosoftOutlook 11.0 Object Library" and then use the  same general 
    # support as below to talk to Outlook via COM.
    # The OutlookExplorer.py script shows the way.
    import win32com.client
    from win32com.client.gencache import EnsureDispatch
    from win32com.client import constants
    WINDOWS=True
elif osname=='posix':