[kupfer: 12/12] Add plugin for evolution contact list and email actions



commit dc32bd62d9dccb71fc8f63050a3d6911c899c5b2
Author: Francesco Marella <francesco marella gmail com>
Date:   Tue Feb 9 20:35:45 2010 +0100

    Add plugin for evolution contact list and email actions

 kupfer/plugin/evolution.py |   88 ++++++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in             |    1 +
 2 files changed, 89 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/evolution.py b/kupfer/plugin/evolution.py
new file mode 100644
index 0000000..7c2d34d
--- /dev/null
+++ b/kupfer/plugin/evolution.py
@@ -0,0 +1,88 @@
+# -*- coding: UTF-8 -*-
+from __future__ import absolute_import
+
+__kupfer_name__ = _("Evolution")
+__kupfer_sources__ = ("ContactsSource", )
+__kupfer_actions__ = ("NewMailAction", )
+__description__ = _("Evolution contacts")
+__version__ = "2010-02-08"
+__author__ = "Francesco Marella, Karol BÄ?dkowski"
+
+import evolution
+
+from kupfer.objects import Action
+from kupfer.objects import TextLeaf, UrlLeaf, RunnableLeaf
+from kupfer import utils
+from kupfer.obj.apps import AppLeafContentMixin
+from kupfer.obj.grouping import ToplevelGroupingSource
+from kupfer.obj.contacts import ContactLeaf, EmailContact, email_from_leaf
+
+class ComposeMail(RunnableLeaf):
+	''' Create new mail without recipient '''
+	def __init__(self):
+		RunnableLeaf.__init__(self, name=_("Compose New Email"))
+
+	def run(self):
+		utils.launch_commandline('evolution mailto:')
+
+	def get_description(self):
+		return _("Compose a new message in Evolution")
+
+	def get_icon_name(self):
+		return "mail-message-new"
+
+
+class NewMailAction(Action):
+	''' Create new mail to selected leaf'''
+	def __init__(self):
+		Action.__init__(self, _('Compose Email'))
+
+	def activate(self, leaf):
+		self.activate_multiple((leaf, ))
+
+	def activate_multiple(self, objects):
+		recipients = ",".join(email_from_leaf(L) for L in objects)
+		utils.spawn_async(["evolution", "mailto:%s"; % recipients])
+
+	def get_icon_name(self):
+		return "mail-message-new"
+
+	def item_types(self):
+		yield ContactLeaf
+		# we can enter email
+		yield TextLeaf
+		yield UrlLeaf
+
+	def valid_for_item(self, item):
+		return bool(email_from_leaf(item))
+
+
+class ContactsSource(AppLeafContentMixin, ToplevelGroupingSource):
+	appleaf_content_id = 'evolution'
+
+	def __init__(self, name=_("Evolution Address Book")):
+		super(ContactsSource, self).__init__(name, "Contacts")
+
+	def get_items(self):
+		ebook_ = evolution.ebook.open_addressbook("default")
+		for contact in ebook_.get_all_contacts():
+			name = contact.get_property("full-name")
+			email = contact.get_property("email-1")
+			if email:
+				yield EmailContact(email, name)
+
+		yield ComposeMail()
+
+	def should_sort_lexically(self):
+		return True
+
+	def get_description(self):
+		return _("Evolution contacts")
+
+	def get_icon_name(self):
+		return "evolution"
+
+	def provides(self):
+		yield RunnableLeaf
+		yield ContactLeaf
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e630a8a..01e2dad 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -58,6 +58,7 @@ kupfer/plugin/chromium.py
 kupfer/plugin/clawsmail.py
 kupfer/plugin/defaultmail.py
 kupfer/plugin/devhelp.py
+kupfer/plugin/evolution.py
 kupfer/plugin/gajim.py
 kupfer/plugin/gnome_terminal.py
 kupfer/plugin/google_search.py



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