home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / deskbar-applet / handlers / evolution.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-04-29  |  4.0 KB  |  81 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from gettext import gettext as _
  5. import cgi
  6. import gnomevfs
  7. import deskbar
  8. import deskbar.Indexer as deskbar
  9. import deskbar.Handler as deskbar
  10. import deskbar.evolution as deskbar
  11. import deskbar.Utils as deskbar
  12. import deskbar.Match as deskbar
  13. from deskbar.defs import VERSION
  14.  
  15. def _check_requirements():
  16.     if deskbar.evolution.num_address_books_with_completion() > 0:
  17.         return (deskbar.Handler.HANDLER_IS_HAPPY, None, None)
  18.     else:
  19.         return (deskbar.Handler.HANDLER_HAS_REQUIREMENTS, _('You need to enable autocomplete in your mail preferences'), (lambda dialog: deskbar.Utils.more_information_dialog(dialog, _('Autocompletion Needs to be Enabled'), _("We cannot provide e-mail addresses from your address book unless autocompletion is enabled.  To do this, from your mail program's menu, choose Edit - Preferences, and then Autocompletion."))))
  20.  
  21. HANDLERS = {
  22.     'EvolutionHandler': {
  23.         'name': _('Mail (Address Book)'),
  24.         'description': _('Send mail to your contacts by typing their name or e-mail address'),
  25.         'requirements': _check_requirements,
  26.         'version': VERSION } }
  27.  
  28. class EvolutionMatch(deskbar.Match.Match):
  29.     
  30.     def __init__(self, backend, name = None, email = None, pixbuf = None, **args):
  31.         deskbar.Match.Match.__init__(self, backend, name = name, email = email, **args)
  32.         self._icon = pixbuf
  33.         self.email = email
  34.  
  35.     
  36.     def action(self, text = None):
  37.         deskbar.Utils.url_show('mailto:' + self.email)
  38.  
  39.     
  40.     def get_category(self):
  41.         return 'people'
  42.  
  43.     
  44.     def get_name(self, text = None):
  45.         return {
  46.             'name': cgi.escape(self.name),
  47.             'email': self.email }
  48.  
  49.     
  50.     def get_verb(self):
  51.         return _('Send Email to <b>%(name)s</b> (%(email)s)')
  52.  
  53.     
  54.     def get_hash(self, text = None):
  55.         return self.email
  56.  
  57.  
  58.  
  59. class EvolutionHandler(deskbar.Handler.Handler):
  60.     
  61.     def __init__(self):
  62.         deskbar.Handler.Handler.__init__(self, 'stock_addressbook')
  63.  
  64.     
  65.     def initialize(self):
  66.         deskbar.evolution.set_pixbuf_size(deskbar.ICON_HEIGHT)
  67.  
  68.     
  69.     def query(self, query):
  70.         hits = deskbar.evolution.search_sync(query, deskbar.DEFAULT_RESULTS_PER_HANDLER)
  71.         matches = []
  72.         for name, email, pixbuf in hits:
  73.             if name == None or email == None:
  74.                 continue
  75.             
  76.             matches.append(EvolutionMatch(self, name, email, pixbuf))
  77.         
  78.         return matches
  79.  
  80.  
  81.