Fix sleeping in the Blinkenlights UI

We were still referring to s.gettf() in sleeping(self, ...) causing each
attempt to sleep to crash. Fix this, and the CursesAccountFrame.sleeping()
method. I am sure, there is still wrong and broken but we are getting there.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-11-02 12:48:22 +01:00
parent 8dbf62cfdb
commit 212e50eb4b

View File

@ -151,26 +151,15 @@ class CursesAccountFrame:
self.children.append(tf) self.children.append(tf)
return tf return tf
def startsleep(s, sleepsecs): def startsleep(self, sleepsecs):
s.sleeping_abort = 0 self.sleeping_abort = 0
def sleeping(s, sleepsecs, remainingsecs): def sleeping(self, sleepsecs, remainingsecs):
if remainingsecs: # show how long we are going to sleep and sleep
s.c.lock() self.drawleadstr(remainingsecs)
try: self.ui.exec_locked(self.window.refresh)
s.drawleadstr(remainingsecs) time.sleep(sleepsecs)
s.window.refresh() return 0
finally:
s.c.unlock()
time.sleep(sleepsecs)
else:
s.c.lock()
try:
s.drawleadstr()
s.window.refresh()
finally:
s.c.unlock()
return s.sleeping_abort
def syncnow(s): def syncnow(s):
s.sleeping_abort = 1 s.sleeping_abort = 1
@ -513,10 +502,9 @@ class Blinkenlights(UIBase, CursesUtil):
return super(Blinkenlights, self).sleep(sleepsecs, account) return super(Blinkenlights, self).sleep(sleepsecs, account)
def sleeping(self, sleepsecs, remainingsecs): def sleeping(self, sleepsecs, remainingsecs):
if remainingsecs and s.gettf().getcolor() == 'black': if not sleepsecs:
self.gettf().setcolor('red') # reset color to default if we are done sleeping.
else: self.gettf().setcolor('white')
self.gettf().setcolor('black')
return self.getaccountframe().sleeping(sleepsecs, remainingsecs) return self.getaccountframe().sleeping(sleepsecs, remainingsecs)
def resizeterm(self): def resizeterm(self):