* src/DisplayState.py: Warning log handler, add timeout handler

svn: r5824
This commit is contained in:
Don Allingham 2006-01-23 22:36:34 +00:00
parent 4b01a84b63
commit d2092f04d7
4 changed files with 20 additions and 10 deletions

View File

@ -1,5 +1,5 @@
2006-01-23 Don Allingham <don@gramps-project.org>
* src/DisplayState.py: Warning log handler
* src/DisplayState.py: Warning log handler, add timeout handler
* src/EditFamily.py: remove icon in father/mother column
* src/EditPerson.py: remove commented out code
* src/GrampsWidgets.py: add WarnButton

View File

@ -533,11 +533,21 @@ class WarnHandler(RotateHandler):
self.setLevel(logging.WARN)
self.button = button
button.on_clicked(self.display)
self.timer = None
def emit(self,record):
if self.timer:
gobject.source_remove(self.timer)
gobject.timeout_add(180*1000,self._clear)
RotateHandler.emit(self,record)
self.button.show()
def _clear(self):
self.button.hide()
self.set_capacity(self._capacity)
self.timer = None
return False
def display(self,obj):
obj.hide()
g = gtk.glade.XML(const.gladeFile,'scrollmsg')
@ -546,7 +556,9 @@ class WarnHandler(RotateHandler):
buf = msg.get_buffer()
for i in self.get_formatted_log():
buf.insert_at_cursor(i + '\n')
self.set_capacity(self._capacity)
top.run()
top.destroy()
class DisplayState(GrampsDb.GrampsDBCallback):
@ -565,7 +577,9 @@ class DisplayState(GrampsDb.GrampsDBCallback):
self.widget = None
self.warnbtn = warnbtn
formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')
self.rh = WarnHandler(capacity=400,button=warnbtn)
self.rh.setFormatter(formatter)
self.log = logging.getLogger()
self.log.setLevel(logging.WARN)
self.log.addHandler(self.rh)

View File

@ -85,7 +85,7 @@ def latin_to_utf8(s):
return unicode(s,'iso-8859-1')
log = logging.getLogger('.ReadGedcom')
log = logging.getLogger('.GEDCOM_import')
#-------------------------------------------------------------------------
#
@ -572,7 +572,7 @@ class GedcomParser:
self.index += 1
self.text = "";
self.backoff = 0
msg = _("Warning: Premature end of file at line %d.\n") % self.index
msg = _("Premature end of file at line %d.\n") % self.index
self.errmsg(msg)
self.error_count = self.error_count + 1
self.groups = (-1, TOKEN_UNKNOWN, "","")
@ -584,10 +584,7 @@ class GedcomParser:
return self.groups
def barf(self,level):
msg = _("Warning: line %d was not understood, so it was ignored.") % self.index
self.errmsg(msg)
msg = "\n\t%s\n" % self.text
msg = _("Line %d was not understood, so it was ignored.") % self.index
self.errmsg(msg)
self.error_count = self.error_count + 1
self.ignore_sub_junk(level)
@ -1128,7 +1125,7 @@ class GedcomParser:
else:
(ok,path) = self.find_file(filename,self.dir_path)
if not ok:
self.warn(_("Warning: could not import %s") % filename)
self.warn(_("Could not import %s") % filename)
path = filename.replace('\\','/')
photo_handle = self.media_map.get(path)
if photo_handle == None:
@ -1169,7 +1166,7 @@ class GedcomParser:
if form:
(ok,path) = self.find_file(filename,self.dir_path)
if not ok:
self.warn(_("Warning: could not import %s") % filename)
self.warn(_("Could not import %s") % filename)
path = filename.replace('\\','/')
photo_handle = self.media_map.get(path)
if photo_handle == None:

View File

@ -182,7 +182,6 @@ class ViewManager:
vbox = gtk.VBox()
self.window.add(vbox)
hbox = gtk.HBox()
hbox.set_border_width(4)
self.ebox = gtk.EventBox()
self.bbox = gtk.VBox()
self.ebox.add(self.bbox)