[PATCH] evolution: Implement SendFileByMail action.



---
 kupfer/plugin/evolution.py |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/kupfer/plugin/evolution.py b/kupfer/plugin/evolution.py
index 7c2d34d..5f84597 100644
--- a/kupfer/plugin/evolution.py
+++ b/kupfer/plugin/evolution.py
@@ -3,20 +3,21 @@ from __future__ import absolute_import
 
 __kupfer_name__ = _("Evolution")
 __kupfer_sources__ = ("ContactsSource", )
-__kupfer_actions__ = ("NewMailAction", )
+__kupfer_actions__ = ("NewMailAction", "SendFileByMail")
 __description__ = _("Evolution contacts")
-__version__ = "2010-02-08"
+__version__ = "2010-02-14"
 __author__ = "Francesco Marella, Karol BÄ?dkowski"
 
 import evolution
 
 from kupfer.objects import Action
-from kupfer.objects import TextLeaf, UrlLeaf, RunnableLeaf
+from kupfer.objects import TextLeaf, UrlLeaf, RunnableLeaf, FileLeaf
 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):
@@ -57,6 +58,41 @@ class NewMailAction(Action):
 		return bool(email_from_leaf(item))
 
 
+class SendFileByMail (Action):
+	'''Create new e-mail and attach selected file'''
+	def __init__(self):
+		Action.__init__(self, _('Send in Email To...'))
+
+	def activate(self, obj, iobj):
+		self.activate_multiple((obj, ), (iobj, ))
+
+	def activate_multiple(self, objects, iobjects):
+		recipients = ",".join(email_from_leaf(I) for I in iobjects)
+		attachlist = ["attach=%s" % L.object for L in objects]
+		utils.spawn_async(["evolution",
+			"mailto:%s?%s"; % (recipients, "&".join(attachlist))])
+
+	def item_types(self):
+		yield FileLeaf
+	def valid_for_item(self, item):
+		return not item.is_dir()
+
+	def requires_object(self):
+		return True
+	def object_types(self):
+		yield ContactLeaf
+		# we can enter email
+		yield TextLeaf
+		yield UrlLeaf
+	def valid_object(self, iobj, for_item=None):
+		return bool(email_from_leaf(iobj))
+
+	def get_description(self):
+		return _("Compose new message in Evolution and attach file")
+	def get_icon_name(self):
+		return "document-send"
+
+
 class ContactsSource(AppLeafContentMixin, ToplevelGroupingSource):
 	appleaf_content_id = 'evolution'
 
-- 
1.6.6.1


--=-8z8m9Ey5447XLow4Sdaj--



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