From 3e1d901f74091775dc3dd4711767e3f55ceca92e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 18 May 2021 16:46:49 +0200 Subject: widgets/thread: remove an unnecessary container widget --- alot/widgets/thread.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index c89f175d..a7eb3432 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -628,7 +628,7 @@ class MessageWidget(urwid.WidgetWrap): _headers_wgt = None _source_wgt = None _body_wgt = None - _attach_wgt = None + _attach_wgts = None def __init__(self, message): """ @@ -645,7 +645,7 @@ class MessageWidget(urwid.WidgetWrap): self._headers_wgt = self._get_headers() self._source_wgt = _RawMessageWidget(message.as_bytes()) - self._attach_wgt = self._get_attachments() + self._attach_wgts = self._get_attachments() self._body_wgt = _render_mime_tree(message.body, alternative_pref, force_inline_types) if self._body_wgt is None: @@ -671,9 +671,7 @@ class MessageWidget(urwid.WidgetWrap): alist = [] for a in self._message.iter_attachments(): alist.append(AttachmentWidget(a)) - if alist: - return urwid.Pile(alist) - return None + return alist @property def display_all_headers(self): @@ -731,9 +729,7 @@ class MessageWidget(urwid.WidgetWrap): widgets.append(self._source_wgt) else: widgets.append(self._headers_wgt) - - if self._attach_wgt is not None: - widgets.append(self._attach_wgt) + widgets.extend(self._attach_wgts) widgets.append(self._body_wgt) @@ -756,8 +752,8 @@ class MessageWidget(urwid.WidgetWrap): If an AttachmentWidget is currently focused, return it. Otherwise return None. """ - if self._w.focus is self._attach_wgt: - return self._attach_wgt.focus.attachment + if self._w.focus in self._attach_wgts: + return self._w.focus.attachment return None class _ThreadNodeDecoration(urwid.Widget): -- cgit v1.2.3