Issue 3960, warn button disappears too soon on long GEDCOM import with errors.

svn: r15858
This commit is contained in:
Peter Landgren 2010-09-06 15:18:28 +00:00
parent aff081d139
commit 531f089f10

View File

@ -307,19 +307,30 @@ class WarnHandler(RotateHandler):
self.button = button self.button = button
button.on_clicked(self.display) button.on_clicked(self.display)
self.timer = None self.timer = None
self.last_line = '-1'
def emit(self, record): def emit(self, record):
if self.timer: if self.timer is None:
gobject.source_remove(self.timer) #check every 3 minutes if warn button can disappear
gobject.timeout_add(180*1000, self._clear) self.timer = gobject.timeout_add(3*60*1000, self._check_clear)
RotateHandler.emit(self, record) RotateHandler.emit(self, record)
self.button.show() self.button.show()
def _check_clear(self):
new_last_line = self.get_buffer()[-1]
if self.last_line == new_last_line:
#buffer has not changed for 3 minutes, let's clear it:
self._clear()
return False
else:
self.last_line = new_last_line
return True
def _clear(self): def _clear(self):
self.button.hide() self.button.hide()
self.set_capacity(self._capacity) self.set_capacity(self._capacity)
self.last_line = '-1'
self.timer = None self.timer = None
return False
def display(self, obj): def display(self, obj):
obj.hide() obj.hide()
@ -329,7 +340,6 @@ class WarnHandler(RotateHandler):
buf = msg.get_buffer() buf = msg.get_buffer()
for i in self.get_formatted_log(): for i in self.get_formatted_log():
buf.insert_at_cursor(i + '\n') buf.insert_at_cursor(i + '\n')
self.set_capacity(self._capacity)
top.run() top.run()
top.destroy() top.destroy()