diff options
-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 |