summaryrefslogtreecommitdiff
path: root/alot/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'alot/widgets')
-rw-r--r--alot/widgets/thread.py66
1 files changed, 17 insertions, 49 deletions
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()
@@ -290,19 +283,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
@display_source.setter
@@ -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():