nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit a15ad1ca7a80c6669d192391b1aabb5efbc25c84
parent c730311cbb9a21a1835358b38f3037b68be87d10
Author: Eric Davis <edavis@insanum.com>
Date:   Mon,  7 Jul 2014 22:54:58 -0700

simplified log message urwid alarm processing

Diffstat:
Msncli.py | 32+++++++-------------------------
1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/sncli.py b/sncli.py @@ -120,17 +120,9 @@ def gui_body_focus(self): def log_timeout(self, loop, arg): self.log_lock.acquire() - self.log_alarm = None - self.gui_footer_clear() - - self.log_lock.release() - - def log_cancel(self): - self.log_lock.acquire() - - if self.log_alarm: - self.sncli_loop.remove_alarm(self.log_alarm) - self.log_alarm = None + self.log_alarms -= 1 + if self.log_alarms == 0: + self.gui_footer_clear() self.log_lock.release() @@ -145,23 +137,16 @@ def log(self, msg): # if there is already a message showing then concatenate them existing_msg = '' - if self.log_alarm and \ + if self.log_alarms and \ 'footer' in self.master_frame.contents.keys(): existing_msg = \ self.master_frame.contents['footer'][0].base_widget.text + u'\n' - # cancel any existing state message alarm - if self.log_alarm: - self.sncli_loop.remove_alarm(self.log_alarm) - self.log_alarm = None - self.gui_footer_set(urwid.AttrMap(urwid.Text(existing_msg + msg), 'log')) - self.log_alarm = \ - self.sncli_loop.set_alarm_at(time.time() + 5, - self.log_timeout, - None) + self.sncli_loop.set_alarm_in(5, self.log_timeout, None) + self.log_alarms += 1 self.log_lock.release() @@ -471,7 +456,6 @@ def gui_frame_keypress(self, size, key): else: # self.gui_body_get().__class__ == view_note.ViewNote: note = lb.note - self.log_cancel() self.gui_footer_set( urwid.AttrMap( user_input.UserInput(self.config, @@ -512,7 +496,6 @@ def gui_frame_keypress(self, size, key): if self.gui_body_get().__class__ != view_titles.ViewTitles: return key - self.log_cancel() self.gui_footer_set(urwid.AttrMap( user_input.UserInput(self.config, key, '', @@ -598,7 +581,6 @@ def gui_frame_keypress(self, size, key): else: # self.gui_body_get().__class__ == view_note.ViewNote: note = lb.note - self.log_cancel() self.gui_footer_set( urwid.AttrMap( user_input.UserInput(self.config, @@ -654,7 +636,7 @@ def gui(self, do_sync): self.last_view = [] self.status_bar = self.config.get_config('status_bar') - self.log_alarm = None + self.log_alarms = 0 self.log_lock = threading.Lock() self.thread_save = threading.Thread(target=self.ndb.save_worker)