diff options
author | pazz <patricktotzke@gmail.com> | 2011-08-01 20:32:28 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-08-01 20:32:28 +0100 |
commit | 413200b68ea06d2eb8853b32bec9908f215c36df (patch) | |
tree | c940d5a41bd54376e413ee538b10c90ef7034bc6 | |
parent | b3751beaa62541a24a336e020c182bdce0ab12c8 (diff) |
show_notificationbar and timeout=-1
removed show_notificationbar setting singe we force it to be
Off. Seconly, this implements ui.notify with timeout=-1
which means the user has to acknowledge the msg by hitting a key.
-rw-r--r-- | alot/command.py | 10 | ||||
-rw-r--r-- | alot/settings.py | 1 | ||||
-rw-r--r-- | alot/ui.py | 42 |
3 files changed, 32 insertions, 21 deletions
diff --git a/alot/command.py b/alot/command.py index 87fcf6ce..e297f328 100644 --- a/alot/command.py +++ b/alot/command.py @@ -791,7 +791,7 @@ aliases = {'clo': 'close', 'quit': 'exit', } -globalcomands = [ +globalcommands = [ 'bnext', 'bprevious', 'bufferlist', @@ -810,10 +810,10 @@ globalcomands = [ ALLOWED_COMMANDS = { 'search': ['refine', 'refineprompt', 'toggletag', 'openthread', 'retag', - 'retagprompt'] + globalcomands, - 'envelope': ['send', 'reedit', 'to', 'subject'] + globalcomands, - 'bufferlist': ['openfocussed', 'closefocussed'] + globalcomands, - 'taglist': ['select'] + globalcomands, + 'retagprompt'] + globalcommands, + 'envelope': ['send', 'reedit', 'to', 'subject'] + globalcommands, + 'bufferlist': ['openfocussed', 'closefocussed'] + globalcommands, + 'taglist': ['select'] + globalcommands, 'thread': globalcommands + ['toggletag', 'reply', 'groupreply', 'bounce', 'forward'], } diff --git a/alot/settings.py b/alot/settings.py index 65e4a3a1..0d9017fa 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -34,7 +34,6 @@ DEFAULTS = { 'authors_maxlength': '30', 'ask_subject': 'True', 'notify_timeout': '2', - 'show_notificationbar': 'False', 'show_statusbar': 'True', 'flush_retry_timeout': '5', 'hooksfile': '~/.alot.py', @@ -49,9 +49,7 @@ class UI: self.mainloop.screen.set_terminal_properties(colors=colourmode) self.show_statusbar = config.getboolean('general', 'show_statusbar') - self.show_notificationbar = config.getboolean('general', - 'show_notificationbar') - self.notificationbar = None # urwid.Text(' ') + self.notificationbar = None self.mode = '' self.logger.debug('setup bindings') @@ -164,27 +162,41 @@ class UI: return filter(lambda x: isinstance(x, t), self.buffers) def notify(self, message, priority='normal', timeout=0): - myline = urwid.AttrMap(urwid.Columns([urwid.Text(message)]),'notify_' + priority) + + 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: + msgs.append(build_line('(hit any key to proceed)', 'normal')) + footer = self.mainframe.get_footer() if not self.notificationbar: - self.notificationbar = urwid.Pile([myline]) + self.notificationbar = urwid.Pile(msgs) else: - newpile = self.notificationbar.widget_list + [myline] + newpile = self.notificationbar.widget_list + msgs self.notificationbar = urwid.Pile(newpile) + self.update() def clear_notify(*args): footer = self.mainframe.get_footer() - if len(self.notificationbar.widget_list) == 1: - self.notificationbar = None - else: - newpile = self.notificationbar.widget_list - newpile.remove(myline) + 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() - if not timeout: - timeout = config.getint('general', 'notify_timeout') - self.mainloop.set_alarm_in(timeout, clear_notify) - self.update() + + if timeout == -1: + self.mainloop.draw_screen() + keys = self.mainloop.screen.get_input() + clear_notify() + else: + if timeout == 0: + timeout = config.getint('general', 'notify_timeout') + self.mainloop.set_alarm_in(timeout, clear_notify) def update(self): """ |