[kupfer: 35/38] commatrick: Adjust Claws Mail actions for multiple dispatch



commit 3001f5548cff3b00fb82f51d7d15d2c604632289
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Jan 16 16:42:57 2010 +0100

    commatrick: Adjust Claws Mail actions for multiple dispatch
    
    Adjust Compose Email and Send by Email for multiple dispatch:
    When sending 2 files to 3 addresses, we should open 1 new email
    instead of 2*3 = 6 new email.

 kupfer/plugin/clawsmail.py |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/kupfer/plugin/clawsmail.py b/kupfer/plugin/clawsmail.py
index 343d80d..5b4be9c 100644
--- a/kupfer/plugin/clawsmail.py
+++ b/kupfer/plugin/clawsmail.py
@@ -54,8 +54,11 @@ class NewMailAction(Action):
 		Action.__init__(self, _('Compose Email'))
 
 	def activate(self, leaf):
-		email = email_from_leaf(leaf)
-		utils.launch_commandline("claws-mail --compose '%s'" % email)
+		self.activate_multiple((leaf, ))
+
+	def activate_multiple(self, objects):
+		recipients = ",".join(email_from_leaf(L) for L in objects)
+		utils.spawn_async(["claws-mail", "--compose", recipients])
 
 	def get_icon_name(self):
 		return "mail-message-new"
@@ -76,10 +79,12 @@ class SendFileByMail (Action):
 		Action.__init__(self, _('Send in Email To...'))
 
 	def activate(self, obj, iobj):
-		filepath = obj.object
-		email = email_from_leaf(iobj)
-		utils.launch_commandline("claws-mail --compose '%s' --attach '%s'" %
-				(email, filepath))
+		self.activate_multiple((obj, ), (iobj, ))
+
+	def activate_multiple(self, objects, iobjects):
+		recipients = ",".join(email_from_leaf(I) for I in iobjects)
+		attachlist = ["--attach"] + [L.object for L in objects]
+		utils.spawn_async(["claws-mail", "--compose", recipients] + attachlist)
 
 	def item_types(self):
 		yield FileLeaf



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