From 224bef8af3746d4a723b5f803c6e90e20f3d0a8f Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 19 Dec 2004 23:37:40 +0000 Subject: [PATCH] * src/DbPrompter.py: Add display messages during load * src/GrampsBSDDB.py: Add display messages during load * src/gramps_main.py: Add display messages during load svn: r3820 --- ChangeLog | 3 +++ src/DbPrompter.py | 10 +++++++++- src/GrampsBSDDB.py | 2 +- src/gramps_main.py | 35 +++++++++++++++++++++-------------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee7ffdb47..627e8b653 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ 2004-12-19 Don Allingham + * src/DbPrompter.py: Add display messages during load + * src/GrampsBSDDB.py: Add display messages during load + * src/gramps_main.py: Add display messages during load * src/DisplayModels.py: use a dictionary to handle reverse indices instead of list.index function. Drastically reduces time are larger lists. diff --git a/src/DbPrompter.py b/src/DbPrompter.py index f0d1705ff..94bf9f759 100644 --- a/src/DbPrompter.py +++ b/src/DbPrompter.py @@ -386,7 +386,15 @@ def open_native(parent,filename,filetype): parent.db = GrampsBSDDB.GrampsBSDDB() msgxml = gtk.glade.XML(const.gladeFile, "load_message","gramps") msg_top = msgxml.get_widget('load_message') - parent.read_file(filename) + msg_label = msgxml.get_widget('message') + + def update_msg(msg): + msg_label.set_text("%s" % msg) + msg_label.set_use_markup(True) + while gtk.events_pending(): + gtk.main_iteration() + + parent.read_file(filename,update_msg) msg_top.destroy() success = True elif filetype == const.app_gramps_xml: diff --git a/src/GrampsBSDDB.py b/src/GrampsBSDDB.py index adb62abcf..89f80647b 100644 --- a/src/GrampsBSDDB.py +++ b/src/GrampsBSDDB.py @@ -27,6 +27,7 @@ Provides the Berkeley DB (BSDDB) database backend for GRAMPS import os import time import locale +from gettext import gettext as _ from RelLib import * from GrampsDbBase import * @@ -120,7 +121,6 @@ class GrampsBSDDB(GrampsDbBase): self.name_group = db.DB(self.env) self.name_group.set_flags(db.DB_DUP) self.name_group.open(name, "name_group", db.DB_HASH, flags=db.DB_CREATE) - self.id_trans = db.DB(self.env) self.id_trans.set_flags(db.DB_DUP) self.id_trans.open(name, "idtrans", db.DB_HASH, flags=db.DB_CREATE) diff --git a/src/gramps_main.py b/src/gramps_main.py index 251ce7ba9..896b84325 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -1068,7 +1068,7 @@ class Gramps: os.rmdir(tmpdir_path) self.import_tool_callback() - def read_file(self,filename): + def read_file(self,filename,callback=None): self.topWindow.set_resizable(gtk.FALSE) filename = os.path.normpath(os.path.abspath(filename)) @@ -1090,7 +1090,7 @@ class Gramps: return 0 try: - if self.load_database(filename) == 1: + if self.load_database(filename,callback) == 1: if filename[-1] == '/': filename = filename[:-1] name = os.path.basename(filename) @@ -1540,17 +1540,12 @@ class Gramps: else: return GrampsCfg.get_nameof()(person) - def load_progress(self,value): - self.statusbar.set_progress_percentage(value) - while gtk.events_pending(): - gtk.main_iteration() - def status_text(self,text): self.statusbar.set_status(text) while gtk.events_pending(): gtk.main_iteration() - def post_load(self,name): + def post_load(self,name,callback=None): self.db.set_save_path(name) res = self.db.get_researcher() owner = GrampsCfg.get_researcher() @@ -1558,22 +1553,31 @@ class Gramps: if res.get_name() == "" and owner.get_name(): self.db.set_researcher(owner) + if callback: + callback(_('Setting up bookmarks...')) self.setup_bookmarks() GrampsGconfKeys.save_last_file(name) self.gtop.get_widget("filter").set_text("") - self.statusbar.set_progress_percentage(1.0) - + if callback: + callback(_('Building Person list...')) self.people_view.change_db(self.db) + if callback: + callback(_('Building Place list...')) self.place_view.change_db(self.db) + if callback: + callback(_('Building Source list...')) self.source_view.change_db(self.db) + if callback: + callback(_('Building Media list...')) self.media_view.change_db(self.db) self.relationship = self.RelClass(self.db) self.change_active_person(self.find_initial_person()) self.goto_active_person() - self.statusbar.set_progress_percentage(0.0) + if callback: + callback(_('Setup complete')) return 1 def find_initial_person(self): @@ -1585,18 +1589,21 @@ class Gramps: person = self.db.get_person_from_handle(the_ids[0]) return person - def load_database(self,name): + def load_database(self,name,callback=None): filename = name self.status_text(_("Loading %s...") % name) - if self.db.load(filename,self.load_progress) == 0: + if callback: + callback(_('Opening database...')) + + if self.db.load(filename,callback) == 0: self.status_text('') return 0 self.status_text('') - val = self.post_load(name) + val = self.post_load(name,callback) return val def setup_bookmarks(self):