From d035e850d3dde1fbc8d556861f7ef72d581c5506 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 1 Mar 2020 21:49:28 +0100 Subject: buffers/thread: make the widget split-window The top part displayes the thread structure, the bottom half the message body. This makes more sense then displaying the message inside the tree structure and makes it easier to implement features such as folding a part of the message body. Drop commands related to folding, since that functionality does not exist anymore. --- alot/widgets/thread.py | 66 +++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) (limited to 'alot/widgets') diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 7c423383..0096188d 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -142,11 +142,9 @@ class MessageWidget(urwid.WidgetWrap): """ _display_all_headers = None - _display_content = None _display_source = None _headers_wgt = None - _summary_wgt = None _source_wgt = None _body_wgt = None _attach_wgt = None @@ -154,45 +152,40 @@ class MessageWidget(urwid.WidgetWrap): _QUOTE_CHARS = '>|:}#' _QUOTE_REGEX = '(([ \t]*[{quote_chars}])+)'.format(quote_chars = _QUOTE_CHARS) - def __init__(self, message, odd): + def __init__(self, message): """ :param message: Message to display :type message: alot.db.Message - :param odd: theme summary widget as if this is an odd line in the thread order - :type odd: bool """ self._message = message self._headers_wgt = self._get_headers() - self._summary_wgt = MessageSummaryWidget(message, odd) self._source_wgt = self._get_source() self._body_wgt = self._get_body() self._attach_wgt = self._get_attachments() - super().__init__(urwid.Pile([])) + super().__init__(urwid.ListBox(urwid.SimpleListWalker([]))) self.display_all_headers = False self.display_source = False - self.display_content = False def get_message(self): return self._message - def _reassemble(self, display_content, display_source): - widgets = [self._summary_wgt] + def _reassemble(self, display_source): + widgets = [] - if display_content: - if display_source: - widgets.append(self._source_wgt) - else: - widgets.append(self._headers_wgt) + if display_source: + widgets.append(self._source_wgt) + else: + widgets.append(self._headers_wgt) - if self._attach_wgt is not None: - widgets.append(self._attach_wgt) + if self._attach_wgt is not None: + widgets.append(self._attach_wgt) - widgets.append(self._body_wgt) + widgets.append(self._body_wgt) - self._w.contents = [(w, ('pack', None)) for w in widgets] + self._w.body[:] = widgets def _get_source(self): sourcetxt = self._message.get_email().as_string() @@ -289,19 +282,6 @@ class MessageWidget(urwid.WidgetWrap): self._display_all_headers = val - @property - def display_content(self): - return self._display_content - @display_content.setter - def display_content(self, val): - val = bool(val) - - if val == self._display_content: - return - - self._reassemble(val, self.display_source) - self._display_content = val - @property def display_source(self): return self._display_source @@ -312,21 +292,9 @@ class MessageWidget(urwid.WidgetWrap): if val == self._display_source: return - self._reassemble(self.display_content, val) + self._reassemble(val) self._display_source = val - def expand(self): - self.display_content = True - def collapse(self): - self.display_content = False - - def collapse_if_matches(self, querystring): - """ - collapse (and show summary only) if the :class:`alot.db.Message` - matches given `querystring` - """ - self.display_content = not self._message.matches(querystring) - def get_selected_attachment(self): """ If an AttachmentWidget is currently focused, return it. Otherwise return @@ -346,14 +314,14 @@ class ThreadNode(urwid.WidgetWrap): _decor_text = None _have_next_sibling = None - def __init__(self, msg_wgt, thread, pos, indent): - msg = msg_wgt.get_message() + def __init__(self, msg, thread, pos, indent): + msg_summary = MessageSummaryWidget(msg, pos & 1) if msg.depth == 0: - wgt = msg_wgt + wgt = msg_summary else: self._decor_text = urwid.Text('') - wgt = urwid.Columns([('pack', self._decor_text), msg_wgt]) + wgt = urwid.Columns([('pack', self._decor_text), msg_summary]) ancestor_chain = [msg] for p in msg.parents(): -- cgit v1.2.3