From 6ed9d0a161b02da09e59c382aa891ac193717acc Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 23 Jan 2006 22:36:34 +0000 Subject: [PATCH] * src/DisplayState.py: Warning log handler, add timeout handler svn: r5824 --- ChangeLog | 2 +- src/DisplayState.py | 14 ++++++++++++++ src/GrampsDb/_ReadGedcom.py | 13 +++++-------- src/ViewManager.py | 1 - 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab6d5fd12..060db3b4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 2006-01-23 Don Allingham - * 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 diff --git a/src/DisplayState.py b/src/DisplayState.py index 32081e174..18bb05aae 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -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) diff --git a/src/GrampsDb/_ReadGedcom.py b/src/GrampsDb/_ReadGedcom.py index 7e451ef80..8dec2f20c 100644 --- a/src/GrampsDb/_ReadGedcom.py +++ b/src/GrampsDb/_ReadGedcom.py @@ -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: diff --git a/src/ViewManager.py b/src/ViewManager.py index 06a8f5a42..b1ef19c94 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -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)