summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatrick <p.totzke@ed.ac.uk>2011-08-04 15:41:42 +0100
committerpatrick <p.totzke@ed.ac.uk>2011-08-04 15:41:42 +0100
commit5f17b05d77b0532fdba3208cadac5928235039c8 (patch)
tree3a773283b17f00ec852fb6f0cece8bb979538ad6
parent3d22e66611642e237ebc807965d94118074d7449 (diff)
"sending.." notification that gets cleared
issue #58
-rw-r--r--alot/command.py2
-rw-r--r--alot/ui.py34
2 files changed, 21 insertions, 15 deletions
diff --git a/alot/command.py b/alot/command.py
index ea61ecde..975628ea 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -702,7 +702,9 @@ class EnvelopeSendCommand(Command):
sname, saddr = email.Utils.parseaddr(frm)
account = ui.accountman.get_account_by_address(saddr)
if account:
+ clearme = ui.notify('sending..', timeout=-1, block=False)
success, reason = account.sender.send_mail(mail)
+ ui.clear_notify([clearme])
if success:
cmd = BufferCloseCommand(buffer=envelope)
ui.apply_command(cmd)
diff --git a/alot/ui.py b/alot/ui.py
index 99c87c60..f72779e6 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -163,13 +163,23 @@ class UI:
def get_buffers_of_type(self, t):
return filter(lambda x: isinstance(x, t), self.buffers)
- def notify(self, message, priority='normal', timeout=0):
+ def clear_notify(self, messages):
+ footer = self.mainframe.get_footer()
+ newpile = self.notificationbar.widget_list
+ for l in messages:
+ newpile.remove(l)
+ if newpile:
+ self.notificationbar = urwid.Pile(newpile)
+ else:
+ self.notificationbar = None
+ self.update()
+ def notify(self, message, priority='normal', timeout=0, block=True):
def build_line(msg, prio):
cols =urwid.Columns([urwid.Text(msg)])
return urwid.AttrMap(cols, 'notify_' + prio)
msgs = [build_line(message, priority)]
- if timeout == -1:
+ if timeout == -1 and block:
msgs.append(build_line('(hit any key to proceed)', 'normal'))
footer = self.mainframe.get_footer()
@@ -180,25 +190,19 @@ class UI:
self.notificationbar = urwid.Pile(newpile)
self.update()
- def clear_notify(*args):
- footer = self.mainframe.get_footer()
- newpile = self.notificationbar.widget_list
- for l in msgs :
- newpile.remove(l)
- if newpile:
- self.notificationbar = urwid.Pile(newpile)
- else:
- self.notificationbar = None
- self.update()
+ def clear(*args):
+ self.clear_notify(msgs)
if timeout == -1:
self.mainloop.draw_screen()
- keys = self.mainloop.screen.get_input()
- clear_notify()
+ if block:
+ keys = self.mainloop.screen.get_input()
+ clear()
else:
if timeout == 0:
timeout = config.getint('general', 'notify_timeout')
- self.mainloop.set_alarm_in(timeout, clear_notify)
+ self.mainloop.set_alarm_in(timeout, clear)
+ return msgs[0]
def update(self):
"""