diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-10-20 16:51:49 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-10-20 16:51:49 +0200 |
commit | 90e633b82eaf82cd21fb40dc6c0cf9edf35a5994 (patch) | |
tree | f004ff70970ddf3eb7c5c8d1e9da860938359d7d /alot/widgets | |
parent | aab91ae9f730a2d385ee6277fc5ebffa38f39ff4 (diff) |
widgets/thread: simplify MessageSummaryWidget
Diffstat (limited to 'alot/widgets')
-rw-r--r-- | alot/widgets/thread.py | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 35024d34..be19b6cf 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -17,15 +17,25 @@ class MessageSummaryWidget(urwid.WidgetWrap): one line summary of a :class:`~alot.db.message.Message`. """ - _text = None - def __init__(self, message, attr, attr_focus): """ :param message: a message :type message: alot.db.Message """ - self._text = self._build_text(message) - cols = [urwid.Text(self._text)] + + try: + subj = message.headers['Subject'] + except KeyError: + subj = '' + subj = re.sub(r'\n\s+', r' ', ','.join(subj)) + + author, address = message.get_author() + text = '%s: %s' % (author if author != '' else address, subj) + date = message.get_datestring() + if date is not None: + text += " (%s)" % date + + cols = [urwid.Text(text)] if settings.get('msg_summary_hides_threadwide_tags'): thread_tags = message.thread.get_tags(intersection=True) @@ -43,29 +53,6 @@ class MessageSummaryWidget(urwid.WidgetWrap): attr, attr_focus) super().__init__(line) - def _build_text(self, msg): - try: - subj = msg.headers['Subject'] - except KeyError: - subj = '' - subj = re.sub(r'\n\s+', r' ', ','.join(subj)) - - author, address = msg.get_author() - rep = '%s: %s' % (author if author != '' else address, subj) - date = msg.get_datestring() - if date is not None: - rep += " (%s)" % date - return rep - - def __str__(self): - return self._text - - def selectable(self): - return True - - def keypress(self, size, key): - return key - class _MIMEPartWidget(urwid.WidgetWrap): # when not None, a list of child _MIMEPartWidget subclasses |