diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-02 22:54:27 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-03 13:49:45 +0000 |
commit | 21f2f15eb4f5c889fb702c4a5994d2595496b102 (patch) | |
tree | f26ff4834cfe4b8f63e5aa0b7a3ff746ada09854 /alot/widgets/thread.py | |
parent | 995e00b346c0a2e844b89380ff7dc485c444efd3 (diff) |
only insert bodytree if bodytxt is nonempty
Diffstat (limited to 'alot/widgets/thread.py')
-rw-r--r-- | alot/widgets/thread.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 76fbf7e3..679245c4 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -314,6 +314,7 @@ class MessageBodyWidget(urwid.AttrMap): att = settings.get_theming_attribute('thread', 'body') urwid.AttrMap.__init__(self, urwid.Text(bodytxt), att) + class FocusableText(urwid.WidgetWrap): """Selectable Text used for nodes in our example""" def __init__(self, txt, att, att_focus): @@ -327,6 +328,7 @@ class FocusableText(urwid.WidgetWrap): def keypress(self, size, key): return key + class TextlinesList(SimpleTree): def __init__(self, content, attr=None, attr_focus=None): """ @@ -335,7 +337,7 @@ class TextlinesList(SimpleTree): """ structure = [] for line in content.splitlines(): - structure.append((FocusableText(line, attr, attr_focus) , None)) + structure.append((FocusableText(line, attr, attr_focus), None)) SimpleTree.__init__(self, structure) @@ -408,7 +410,9 @@ class MessageTree(CollapsibleTree): if attachmenttree is not None: mainstruct.append((attachmenttree, None)) - mainstruct.append((self._get_body(), None)) + bodytree = self._get_body() + if bodytree is not None: + mainstruct.append((self._get_body(), None)) structure = [ (self._summaryw, mainstruct) @@ -430,9 +434,11 @@ class MessageTree(CollapsibleTree): def _get_body(self): if self._bodytree is None: bodytxt = extract_body(self._message.get_email()) - att = settings.get_theming_attribute('thread', 'body') - att_focus = settings.get_theming_attribute('thread', 'body_focus') - self._bodytree = TextlinesList(bodytxt, att, att_focus) + if bodytxt: + att = settings.get_theming_attribute('thread', 'body') + att_focus = settings.get_theming_attribute( + 'thread', 'body_focus') + self._bodytree = TextlinesList(bodytxt, att, att_focus) return self._bodytree def _get_headers(self): |