summaryrefslogtreecommitdiff
path: root/alot/widgets/thread.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2013-02-12 23:05:59 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-03-03 13:48:21 +0000
commitedeca57795985732894388af315b84d846030dde (patch)
tree46d61f698dc9711ad0f7b70fe2bf8ecf706384a3 /alot/widgets/thread.py
parent49b58c6b53a1cf8296855969a64363990e32e289 (diff)
use headers pile in message trees.
.. this should better be done using a ListWalker instead of a pile. (has to be interpreted by NestedTree)
Diffstat (limited to 'alot/widgets/thread.py')
-rw-r--r--alot/widgets/thread.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py
index 2538656d..22bdc19d 100644
--- a/alot/widgets/thread.py
+++ b/alot/widgets/thread.py
@@ -321,6 +321,7 @@ class MessageTree(CollapsibleTree):
structure = [
(MessageSummaryWidget(message, even=(not odd)),
[
+ (self.construct_header_pile(), None),
(MessageBodyWidget(message), None),
]
)
@@ -331,6 +332,40 @@ class MessageTree(CollapsibleTree):
self.set_position_collapsed(
self.root, self._message.matches(querystring))
+ def construct_header_pile(self, headers=None, normalize=True):
+ mail = self._message.get_email()
+ if headers is None:
+ headers = settings.get('displayed_headers')
+ else:
+ headers = [k for k in headers if
+ k.lower() == 'tags' or k in mail]
+
+ lines = []
+ for key in headers:
+ if key in mail:
+ if key.lower() in ['cc', 'bcc', 'to']:
+ values = mail.get_all(key)
+ values = [decode_header(v, normalize=normalize) for v in values]
+ lines.append((key, ', '.join(values)))
+ else:
+ for value in mail.get_all(key):
+ dvalue = decode_header(value, normalize=normalize)
+ lines.append((key, dvalue))
+ elif key.lower() == 'tags':
+ logging.debug('want tags header')
+ values = []
+ for t in self._message.get_tags():
+ tagrep = settings.get_tagstring_representation(t)
+ if t is not tagrep['translated']:
+ t = '%s (%s)' % (tagrep['translated'], t)
+ values.append(t)
+ lines.append((key, ', '.join(values)))
+
+ key_att = settings.get_theming_attribute('thread', 'header_key')
+ value_att = settings.get_theming_attribute('thread', 'header_value')
+ gaps_att = settings.get_theming_attribute('thread', 'header')
+ return HeadersList(lines, key_att, value_att, gaps_att)
+
class ThreadTree(Tree):
def __init__(self, thread):