diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 9d7d44fa9..1f651e856 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2005-10-23 Don Allingham + * src/ReadGedcom.py: handle progress bar + * src/gedcomimport.glade: add progress bar and expanders + 2005-10-24 Julio Sanchez * src/AddSpouse.py: signal fix * src/EventEdit.py: signal fix diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index 44d50ad85..8919a4236 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -198,7 +198,8 @@ def import2(database, filename, cb, codeset, use_trans): try: np = NoteParser(filename, False) - g = GedcomParser(database,filename,statusTop, codeset, np.get_map()) + g = GedcomParser(database,filename,statusTop, codeset, np.get_map(), + np.get_lines()) except IOError,msg: Utils.destroy_passed_object(statusWindow) ErrorDialog(_("%s could not be opened\n") % filename,str(msg)) @@ -234,7 +235,7 @@ def import2(database, filename, cb, codeset, use_trans): Utils.destroy_passed_object(statusWindow) DisplayTrace.DisplayTrace() return - + statusTop.get_widget("close").set_sensitive(True) statusWindow.set_modal(False) if close: @@ -278,12 +279,14 @@ concRE = re.compile(r"\s*\d+\s+CONC\s(.*)$") class NoteParser: def __init__(self, filename,broken): self.name_map = {} - + + self.count = 0 f = open(filename,"rU") innote = False for line in f.xreadlines(): + self.count += 1 if innote: match = contRE.match(line) if match: @@ -310,6 +313,9 @@ class NoteParser: def get_map(self): return self.name_map + def get_lines(self): + return self.count + #------------------------------------------------------------------------- # # @@ -320,7 +326,8 @@ class GedcomParser: SyntaxError = "Syntax Error" BadFile = "Not a GEDCOM file" - def __init__(self, dbase, filename, window, codeset, note_map): + def __init__(self, dbase, filename, window, codeset, note_map, lines): + self.maxlines = float(lines) self.dp = GedcomDateParser() self.db = dbase self.person = None @@ -396,9 +403,12 @@ class GedcomParser: self.close_done = window.get_widget('close_done') self.error_text_obj = window.get_widget("error_text") self.info_text_obj = window.get_widget("info_text") + self.progressbar = window.get_widget('progressbar') self.error_count = 0 - + self.current = 0.0 + self.oldval = 0.0 + amap = const.personalConstantAttributes self.attrs = amap.values() self.gedattr = {} @@ -489,6 +499,15 @@ class GedcomParser: def get_next(self): if self.backoff == 0: next_line = self.f.readline() + self.current += 1.0 + + newval = self.current/self.maxlines + if newval != self.oldval: + self.progressbar.set_fraction(min(newval,1.0)) + self.progressbar.set_text("%d%%" % int(newval*100)) + self.oldval = newval + while gtk.events_pending(): + gtk.main_iteration() # EOF ? if next_line == "": @@ -586,6 +605,8 @@ class GedcomParser: t = time.time() - t msg = _('Import Complete: %d seconds') % t + self.progressbar.set_fraction(1.0) + self.progressbar.set_text(_("Complete")) if use_trans: self.db.transaction_commit(self.trans,_("GEDCOM import")) self.db.enable_signals() diff --git a/gramps2/src/gedcomimport.glade b/gramps2/src/gedcomimport.glade index 09ec4fafa..993e295a9 100644 --- a/gramps2/src/gedcomimport.glade +++ b/gramps2/src/gedcomimport.glade @@ -55,403 +55,12 @@ 12 True - 8 + 3 5 False 6 12 - - - True - File: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - Created by: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - <b>Status</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 5 - 0 - 1 - fill - - - - - - - True - People: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - True - False - True - 0 - - True - * - False - - - 2 - 3 - 3 - 4 - - - - - - - True - True - False - True - 0 - - True - * - False - - - 2 - 3 - 1 - 2 - - - - - - - True - Encoding: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 3 - 4 - 1 - 2 - fill - - - - - - - True - True - False - True - 10 - - True - * - False - - - 4 - 5 - 1 - 2 - - - - - - - True - True - False - True - 0 - - True - * - False - - - 2 - 3 - 2 - 3 - - - - - - - True - True - False - True - 10 - - True - * - False - - - 4 - 5 - 2 - 3 - - - - - - - True - Version: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 3 - 4 - 2 - 3 - fill - - - - - - - True - True - False - True - 0 - - True - * - False - - - 4 - 5 - 3 - 4 - - - - - - - True - Families: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 3 - 4 - 3 - 4 - fill - - - - - - - True - True - False - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - - - - True - <b>Information</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - 5 - 5 - 6 - fill - - - True @@ -516,11 +125,399 @@ 0 5 - 7 - 8 + 2 + 3 fill + + + + True + True + False + 0 + + + + True + 8 + 5 + False + 6 + 6 + + + + True + File: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Created by: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + People: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + True + False + True + 0 + + True + * + False + + + 2 + 3 + 0 + 1 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 2 + 3 + 1 + 2 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 2 + 3 + 2 + 3 + + + + + + + True + Encoding: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 3 + 4 + 0 + 1 + fill + + + + + + + True + Version: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 3 + 4 + 1 + 2 + fill + + + + + + + True + Families: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 3 + 4 + 2 + 3 + fill + + + + + + + True + True + False + True + 10 + + True + * + False + + + 4 + 5 + 0 + 1 + + + + + + + True + True + False + True + 10 + + True + * + False + + + 4 + 5 + 1 + 2 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 4 + 5 + 2 + 3 + + + + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + 1 + 5 + 3 + 8 + fill + + + + + + + + True + <b>Status</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + 5 + 1 + 2 + + + + + + True + GTK_PROGRESS_LEFT_TO_RIGHT + 0 + 0.10000000149 + PANGO_ELLIPSIZE_NONE + + + 0 + 5 + 0 + 1 + fill + + + 0