[kupfer] clawsmail: Send file by email as three-part action



commit 2bae0bd104ac1fa0546d855f714076446d453942
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Jan 11 18:00:35 2010 +0100

    clawsmail: Send file by email as three-part action
    
    Make Send by Email To.. a three-part action as like:
    (File) -> Send To -> (Contact)
    
    Any (email) contact in Kupfer is used. The user may also type in
    addresses by hand.

 kupfer/plugin/clawsmail.py |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/kupfer/plugin/clawsmail.py b/kupfer/plugin/clawsmail.py
index b4bcf99..44c731c 100644
--- a/kupfer/plugin/clawsmail.py
+++ b/kupfer/plugin/clawsmail.py
@@ -69,26 +69,37 @@ class NewMailAction(Action):
 	def valid_for_item(self, item):
 		return bool(email_from_leaf(item))
 
-class SendFileByMail(Action):
-	''' Createn new mail and attach selected file'''
-	def __init__(self):
-		Action.__init__(self, _('Send by Email'))
 
-	def activate(self, leaf):
-		filepath = leaf.object
-		utils.launch_commandline("claws-mail --attach '%s'" % filepath)
+class SendFileByMail (Action):
+	'''Create new e-mail and attach selected file'''
+	def __init__(self):
+		Action.__init__(self, _('Send by Email To..'))
 
-	def get_icon_name(self):
-		return "document-send"
+	def activate(self, obj, iobj):
+		filepath = obj.object
+		email = email_from_leaf(iobj)
+		utils.launch_commandline("claws-mail --compose '%s' --attach '%s'" %
+				(email, filepath))
 
 	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 email in ClawsMail and attach file")
-
-	def valid_for_item(self, item):
-		return os.path.isfile(item.object)
+	def get_icon_name(self):
+		return "document-send"
 
 
 class ClawsContactsSource(AppLeafContentMixin, ToplevelGroupingSource,



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