summaryrefslogtreecommitdiff
path: root/alot/widgets
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2013-03-01 10:16:11 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2013-03-03 13:49:45 +0000
commitb712c2792629bb0666b1a80515cf6024130be481 (patch)
tree5b0bb9296ff55751a237d8da29bb86b13140ad60 /alot/widgets
parent2554e663a1e13c0d6a0c8aaec6b398b20c8a5f1d (diff)
dynamically reassemble attachements part in MessageTree
Diffstat (limited to 'alot/widgets')
-rw-r--r--alot/widgets/thread.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py
index 78764162..539641c1 100644
--- a/alot/widgets/thread.py
+++ b/alot/widgets/thread.py
@@ -354,17 +354,20 @@ class MessageTree(CollapsibleTree):
self._all_headers_tree = None
self._default_headers_tree = None
self.display_attachments = True
+ self._attachments = None
CollapsibleTree.__init__(self, SimpleTree(self._assemble_structure()))
def _assemble_structure(self):
mainstruct = [
(self._get_headers(), None),
- (self._get_body(), None),
]
- if self.display_attachments:
- for a in self._message.get_attachments():
- mainstruct.insert(1, (AttachmentWidget(a), None))
+
+ attachmenttree = self._get_attachments()
+ if attachmenttree is not None:
+ mainstruct.append((attachmenttree, None))
+
+ mainstruct.append((self._get_body(), None))
structure = [
(self._summaryw, mainstruct)
]
@@ -385,10 +388,20 @@ class MessageTree(CollapsibleTree):
elif self.display_headers == 'default':
if self._default_headers_tree is None:
headers = settings.get('displayed_headers')
- self._default_headers_tree = self.construct_header_pile(headers)
+ self._default_headers_tree = self.construct_header_pile(
+ headers)
ret = self._default_headers_tree
return ret
+ def _get_attachments(self):
+ if self._attachments is None:
+ alist = []
+ for a in self._message.get_attachments():
+ alist.append((AttachmentWidget(a), None))
+ if alist:
+ self._attachments = SimpleTree(alist)
+ return self._attachments
+
def construct_header_pile(self, headers=None, normalize=True):
mail = self._message.get_email()
if headers is None: