summaryrefslogtreecommitdiff
path: root/alot/ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/ui.py')
-rw-r--r--alot/ui.py41
1 files changed, 28 insertions, 13 deletions
diff --git a/alot/ui.py b/alot/ui.py
index 7c64ae3b..9e5e81b0 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
@@ -212,7 +213,7 @@ class UI(object):
string = 'tried to close unknown buffer: %s. \n\ni have:%s'
logging.error(string % (buf, self.buffers))
elif self.current_buffer == buf:
- logging.debug('UI: closing current buffer %s' % buf)
+ logging.info('closing current buffer %s' % buf)
index = buffers.index(buf)
buffers.remove(buf)
offset = settings.get('bufferclose_focus_offset')
@@ -221,7 +222,7 @@ class UI(object):
buf.cleanup()
else:
string = 'closing buffer %d:%s'
- logging.debug(string % (buffers.index(buf), buf))
+ logging.info(string % (buffers.index(buf), buf))
buffers.remove(buf)
buf.cleanup()
@@ -416,13 +417,27 @@ 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 = u''
+ if cb is not None:
+ 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')
- righttxt = 'total messages: %d' % self.dbman.count_messages('*')
pending_writes = len(self.dbman.writequeue)
if pending_writes > 0:
righttxt = ('|' * pending_writes) + ' ' + righttxt
@@ -446,7 +461,7 @@ class UI(object):
if cmd:
# call pre- hook
if cmd.prehook:
- logging.debug('calling pre-hook')
+ logging.info('calling pre-hook')
try:
cmd.prehook(ui=self, dbm=self.dbman)
except:
@@ -456,7 +471,7 @@ class UI(object):
# define (callback) function that invokes post-hook
def call_posthook(retval_from_apply):
if cmd.posthook:
- logging.debug('calling post-hook')
+ logging.info('calling post-hook')
try:
cmd.posthook(ui=self, dbm=self.dbman)
except:
@@ -465,12 +480,12 @@ class UI(object):
# define error handler for Failures/Exceptions
# raised in cmd.apply()
def errorHandler(failure):
- logging.debug(failure.getTraceback())
- msg = "Error: %s,\ncheck the log for details"
+ logging.error(failure.getTraceback())
+ msg = "Error: %s,\n(check the log for details)"
self.notify(msg % failure.getErrorMessage(), priority='error')
# call cmd.apply
- logging.debug('apply command: %s' % cmd)
+ logging.info('apply command: %s' % cmd)
d = defer.maybeDeferred(cmd.apply, self)
d.addErrback(errorHandler)
d.addCallback(call_posthook)