From f49f87c637458ffb33a765cde8746fe08dd08509 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Tue, 19 Jun 2012 22:37:03 +0100 Subject: implement configurable statusbar feature by looking up the format defined in the config and building the status bar strings accordingly in UI.build_statusbar --- alot/ui.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'alot/ui.py') diff --git a/alot/ui.py b/alot/ui.py index 7c64ae3b..2af2ced6 100644 --- a/alot/ui.py +++ b/alot/ui.py @@ -416,13 +416,25 @@ class UI(object): def build_statusbar(self): """construct and return statusbar widget""" - if self.current_buffer is not None: - idx = self.buffers.index(self.current_buffer) - lefttxt = '%d: %s' % (idx, self.current_buffer) - else: - lefttxt = '[no buffers]' + info = {} + cb = self.current_buffer + btype = None + + if cb is not None: + info = cb.get_info() + btype = cb.modename + info['buffer_no'] = self.buffers.index(cb) + info['buffer_type'] = btype + info['total_messages'] = self.dbman.count_messages('*') + info['pending_writes'] = len(self.dbman.writequeue) + + lefttxt = righttxt = '' + if cb is not None: + lefttxt, righttxt = settings.get(btype + '_statusbar', ('','')) + lefttxt = lefttxt.format(**info) + righttxt = righttxt.format(**info) + footerleft = urwid.Text(lefttxt, align='left') - righttxt = 'total messages: %d' % self.dbman.count_messages('*') pending_writes = len(self.dbman.writequeue) if pending_writes > 0: righttxt = ('|' * pending_writes) + ' ' + righttxt -- cgit v1.2.3 From 4bc109095927a40defad6eff9c63a6eb80ce1820 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sat, 23 Jun 2012 17:19:18 +0100 Subject: fix implicit decoding issue with str.format cf issue #476 --- alot/ui.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'alot/ui.py') diff --git a/alot/ui.py b/alot/ui.py index 2af2ced6..7f89d62e 100644 --- a/alot/ui.py +++ b/alot/ui.py @@ -11,6 +11,7 @@ from buffers import BufferlistBuffer import commands from commands import commandfactory from alot.commands import CommandParseError +from alot.helper import string_decode import widgets @@ -428,10 +429,12 @@ class UI(object): info['total_messages'] = self.dbman.count_messages('*') info['pending_writes'] = len(self.dbman.writequeue) - lefttxt = righttxt = '' + lefttxt = righttxt = u'' if cb is not None: - lefttxt, righttxt = settings.get(btype + '_statusbar', ('','')) + lefttxt, righttxt = settings.get(btype + '_statusbar', (u'', u'')) + lefttxt = string_decode(lefttxt, 'UTF-8') lefttxt = lefttxt.format(**info) + righttxt = string_decode(righttxt, 'UTF-8') righttxt = righttxt.format(**info) footerleft = urwid.Text(lefttxt, align='left') -- cgit v1.2.3