diff --git a/python/deskbar-handler/tracker-handler.py b/python/deskbar-handler/tracker-handler.py
index 89f99b0..05f9697 100644
--- a/python/deskbar-handler/tracker-handler.py
+++ b/python/deskbar-handler/tracker-handler.py
@@ -44,7 +44,12 @@ TYPES = {
'Emails': {
'description': (_('Email from %s') % '%(publisher)s' ) + '\n%(title)s',
'category': 'emails',
- 'action': 'evolution %(uri)s',
+ 'action': { # more actions for different MUAs
+ 'key': 'mua', # see TrackerLiveSearchMatch.action for a demo
+ 'Evolution': 'evolution %(uri)s',
+ 'Thunderbird': 'thunderbird -viewbeagle %(uri)s',
+ 'KMail': 'kmail --view %(uri)s',
+ },
'icon': 'stock_mail',
},
@@ -169,7 +174,15 @@ class TrackerLiveSearchMatch (deskbar.Match.Match):
def action(self, text=None):
if TYPES[self.result['type']].has_key('action'):
- cmd = TYPES[self.result['type']]['action']
+ if isinstance (TYPES[self.result['type']]['action'], dict):
+ try:
+ key = TYPES[self.result['type']]['action']['key']
+ cmd = TYPES[self.result['type']]['action'][self.result[key]]
+ except KeyError:
+ print >> sys.stderr, "Unknown action for URI %s" % self.result['uri']
+ return
+ else:
+ cmd = TYPES[self.result['type']]['action']
cmd = map(lambda arg : arg % self.result, cmd.split()) # we need this to handle spaces correctly
print 'Opening Tracker hit with command:', cmd
@@ -228,6 +241,7 @@ class TrackerLiveSearchHandler(deskbar.Handler.SignallingHandler):
def handle_email_hits (self, info, output):
output['title'] = cgi.escape(info[3])
output['publisher'] = cgi.escape(info[4])
+ output['mua'] = info[2]
def handle_conversation_hits (self, info, output):
m = self.conv_re.match (output['escaped_uri'])
diff --git a/python/deskbar-handler/tracker-module.py b/python/deskbar-handler/tracker-module.py
index 90a9ccb..b7d64c5 100644
--- a/python/deskbar-handler/tracker-module.py
+++ b/python/deskbar-handler/tracker-module.py
@@ -103,7 +103,12 @@ TYPES = {
'Emails': {
'description': (_('Email from %s') % '%(publisher)s' ) + '\n%(title)s',
'category': 'emails',
- 'action' : 'evolution %(uri)s',
+ 'action': { # more actions for different MUAs
+ 'key': 'mua', # see TrackerLiveSearchAction.action for a demo
+ 'Evolution': 'evolution %(uri)s',
+ 'Thunderbird': 'thunderbird -viewbeagle %(uri)s',
+ 'KMail': 'kmail --view %(uri)s',
+ },
},
'Music': {
@@ -210,7 +215,7 @@ class TrackerLiveSearchAction (deskbar.interfaces.Action):
self.name = result['name']
self.desktop = desktop
self.result = result
- self.init_names (result['unquoted_uri'])
+ self.init_names (result['uri'])
def get_name(self, text=None):
return self.result
@@ -229,7 +234,15 @@ class TrackerLiveSearchAction (deskbar.interfaces.Action):
def activate (self, text=None):
if TYPES[self.result['type']].has_key('action'):
- cmd = TYPES[self.result['type']]['action']
+ if isinstance (TYPES[self.result['type']]['action'], dict):
+ try:
+ key = TYPES[self.result['type']]['action']['key']
+ cmd = TYPES[self.result['type']]['action'][self.result[key]]
+ except KeyError:
+ print >> sys.stderr, "Unknown action for URI %s" % self.result['uri']
+ return
+ else:
+ cmd = TYPES[self.result['type']]['action']
cmd = map(lambda arg : arg % self.result, cmd.split()) # we need this to handle spaces correctly
print 'Opening Tracker hit with command:', cmd
@@ -314,6 +327,7 @@ class TrackerLiveSearchHandler(deskbar.interfaces.Module):
def handle_email_hits (self, info, output):
output['title'] = info[3]
output['publisher'] = info[4]
+ output['mua'] = info[2]
def handle_conversation_hits (self, info, output):
output ['uri'] = info [0]
@@ -365,8 +379,8 @@ class TrackerLiveSearchHandler(deskbar.interfaces.Module):
info = [str (i) for i in info]
- output['unquoted_uri'] = output['uri'] = info[0]
- output['name'] = os.path.basename(output['unquoted_uri'])
+ output['uri'] = info[0]
+ output['name'] = os.path.basename(output['uri'])
output['type'] = info[1]
if not TYPES.has_key(output['type']):