From b03af5b8640ae691e89d3ae42701c95100c8a336 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 19 Apr 2020 17:15:18 +0200 Subject: widgets/thread: configurable theming for crypto --- alot/widgets/thread.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'alot/widgets') diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 5852967d..09dd15fe 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -156,30 +156,25 @@ class _MessageBodyWidget(urwid.WidgetWrap): text_parts.append(desc + ' MIME part') if mime_tree.is_signed and mime_tree.sig_valid: - trust = 'trusted' if mime_tree.sig_trusted else 'untrusted' - t = 'valid signature from: %s (%s)' % (mime_tree.signer_id, trust) + if mime_tree.sig_trusted: + trust = 'trusted' + attr_name = 'crypt_trusted' + else: + trust = 'untrusted' + attr_name = 'crypt_untrusted' + + t = 'valid %s signature from "%s"' % (trust, mime_tree.signer_id) text_parts.append(t) + else: + attr_name = 'crypt_unsigned' if mime_tree.crypt_error: text_parts.append('crypto processing error: ' + mime_tree.crypt_error) - - header = urwid.Columns([]) - - div_down = urwid.Divider('↓') - div_up = urwid.Divider('↑') - hdr_sep = (div_down, ('weight', 1, False)) - - header.contents.append(hdr_sep) - - for t in text_parts: - header.contents.append((urwid.Text(t), ('pack', None, False))) - header.contents.append(hdr_sep) - - footer = div_up + attr_name = 'crypt_invalid' body = self._build_body(mime_tree.children[0]) - - return urwid.Pile([header, body, footer]) + attr = settings.get_theming_attribute('thread', attr_name) + return urwid.AttrMap(urwid.LineBox(body, title = ':'.join(text_parts)), attr) def _render_plain_text(self, text): attr_text = settings.get_theming_attribute('thread', 'body') -- cgit v1.2.3