diff options
author | pazz <patricktotzke@gmail.com> | 2011-08-14 14:22:11 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-08-14 14:22:11 +0100 |
commit | 20acc8a7b5c700a9c287ae59ecf4f4f318497aa6 (patch) | |
tree | 3ef3c95227fc35d780d9b7e83d9996173596bb51 /alot | |
parent | bd1d61c3341b4b8b5d66772c8c5fe5b5173b1a93 (diff) |
fill line w/o handling non-text parts
This makes searches a bit slower as all messages in
all displayed treads are opened.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/message.py | 14 | ||||
-rw-r--r-- | alot/widgets.py | 15 |
2 files changed, 26 insertions, 3 deletions
diff --git a/alot/message.py b/alot/message.py index 57b66765..d464fdfd 100644 --- a/alot/message.py +++ b/alot/message.py @@ -157,6 +157,20 @@ class Message: searchfor = querystring + ' AND id:' + self._id return self._dbman.count_messages(searchfor) > 0 + def get_text_content(self): + res = '' + for part in self.get_email().walk(): + ctype = part.get_content_type() + enc = part.get_content_charset() + if part.get_content_maintype() == 'text': + raw_payload = part.get_payload(decode=True) + if enc: + raw_payload = raw_payload.decode(enc, errors='replace') + else: + raw_payload = unicode(raw_payload, errors='replace') + res += raw_payload + return res + def extract_body(mail): bodytxt = '' diff --git a/alot/widgets.py b/alot/widgets.py index 8a6d22f4..ddf7c331 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -56,16 +56,25 @@ class ThreadlineWidget(urwid.AttrMap): authors = self.thread.get_authors() or '(None)' maxlength = config.getint('general', 'authors_maxlength') - authorsstring = shorten(authors, maxlength) + authorsstring = shorten(authors, maxlength).strip() self.authors_w = urwid.AttrMap(urwid.Text(authorsstring), 'threadline_authors') cols.append(('fixed', len(authorsstring), self.authors_w)) - subjectstring = self.thread.get_subject() + subjectstring = self.thread.get_subject().strip() self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'), 'threadline_subject') if subjectstring: - cols.append(self.subject_w) + cols.append(('fixed', len(subjectstring), self.subject_w)) + + # fill line with message content + msgs = self.thread.get_messages().keys() + msgs.sort() + lastcontent = ' '.join([m.get_text_content() for m in msgs]) + contentstring = lastcontent.replace('\n', ' ').strip() + self.content_w = urwid.AttrMap(urwid.Text(contentstring, wrap='clip'), + 'threadline_content') + cols.append(self.content_w) self.columns = urwid.Columns(cols, dividechars=1) self.original_widget = self.columns |