[kupfer] defaultmail: Send file to contact action



commit 9a59975065c1cd6bc7416723b677bbfa4cc45d8c
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Jan 11 19:06:07 2010 +0100

    defaultmail: Send file to contact action

 kupfer/plugin/defaultmail.py |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/defaultmail.py b/kupfer/plugin/defaultmail.py
index 117337b..64b286e 100644
--- a/kupfer/plugin/defaultmail.py
+++ b/kupfer/plugin/defaultmail.py
@@ -1,10 +1,13 @@
 from kupfer.objects import Action
-from kupfer.objects import TextLeaf, UrlLeaf
+from kupfer.objects import TextLeaf, UrlLeaf, FileLeaf
 from kupfer.obj.contacts import ContactLeaf, email_from_leaf
 from kupfer import utils
 
 __kupfer_name__ = _("Default Email Client")
-__kupfer_actions__ = ("NewMailAction", )
+__kupfer_actions__ = (
+	"NewMailAction",
+	"SendFileByMail",
+)
 __description__ = _("Compose email using the system's default mailto: handler")
 __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
 
@@ -27,3 +30,31 @@ class NewMailAction(Action):
 		return __description__
 	def get_icon_name(self):
 		return "mail-message-new"
+
+class SendFileByMail (Action):
+	def __init__(self):
+		Action.__init__(self, _('Send by Email To..'))
+
+	def activate(self, obj, iobj):
+		filepath = obj.object
+		email = email_from_leaf(iobj)
+		# FIXME: revisit for unicode email addresses
+		url = "mailto:%s?attach=%s"; % (email, filepath)
+		utils.show_url(url)
+
+	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
+		yield TextLeaf
+		yield UrlLeaf
+	def valid_object(self, iobj, for_item=None):
+		return bool(email_from_leaf(iobj))
+
+	def get_icon_name(self):
+		return "document-send"



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