* src/DbPrompter.py: add callback for progressbar

* src/GrampsXMLDB.py: pass callback task
* src/ReadXML.py: handle progress callback, fix placeobj error
* src/gramps_main.py: define progress bar callback


svn: r4544
This commit is contained in:
Don Allingham 2005-05-11 02:35:50 +00:00
parent ffc5f987e9
commit eafdceff00
5 changed files with 28 additions and 13 deletions

View File

@ -1,3 +1,9 @@
2005-05-10 Don Allingham <don@gramps-project.org>
* src/DbPrompter.py: add callback for progressbar
* src/GrampsXMLDB.py: pass callback task
* src/ReadXML.py: handle progress callback, fix placeobj error
* src/gramps_main.py: define progress bar callback
2005-05-10 Eero Tamminen <eerot@sf>
* src/plugins/StatisticsChart.po: add gettext _() to three strings
where it was missing

View File

@ -313,7 +313,7 @@ class ImportDbPrompter:
elif filetype == const.app_gramps_xml:
choose.destroy()
import ReadXML
ReadXML.importData(self.parent.db,filename)
ReadXML.importData(self.parent.db,filename,self.parent.update_bar)
return True
elif filetype == const.app_gedcom:
choose.destroy()

View File

@ -50,7 +50,7 @@ class GrampsXMLDB(GrampsInMemDB):
self.readonly = mode == "r"
ReadXML.importData(self,name,use_trans=False)
ReadXML.importData(self,name,callback,use_trans=False)
self.bookmarks = self.metadata.get('bookmarks')
if self.bookmarks == None:

View File

@ -325,9 +325,8 @@ class GrampsParser:
self.media_file_map = {}
self.callback = callback
self.entries = 0
self.count = 0
self.increment = 100
self.increment = 500
self.event = None
self.name = None
self.tempDefault = None
@ -362,7 +361,7 @@ class GrampsParser:
"comment" : (None, self.stop_comment),
"created" : (self.start_created, None),
"ref" : (None, self.stop_ref),
"database" : (None, None),
"database" : (None, self.stop_database),
"phone" : (None, self.stop_phone),
"date" : (None, self.stop_date),
"cause" : (None, self.stop_cause),
@ -618,10 +617,9 @@ class GrampsParser:
title = attrs['id']
self.placeobj.set_title(title)
self.locations = 0
if self.num_places > 0:
if self.callback != None and self.count % self.increment == 0:
self.callback(float(self.count)/float(self.entries))
self.count = self.count + 1
if self.callback != None and self.count % self.increment == 0:
self.callback(True)
self.count += 1
def start_location(self,attrs):
"""Bypass the function calls for this one, since it appears to
@ -718,6 +716,8 @@ class GrampsParser:
self.db.bookmarks.append(person.get_handle())
def start_person(self,attrs):
if self.callback != None and self.count % self.increment == 0:
self.callback(True)
new_id = self.map_gid(attrs['id'])
try:
self.person = self.db.find_person_from_handle(attrs['handle'],self.trans)
@ -780,7 +780,7 @@ class GrampsParser:
def start_family(self,attrs):
if self.callback != None and self.count % self.increment == 0:
self.callback(float(self.count)/float(self.entries))
self.callback(True)
self.count = self.count + 1
handle = self.map_fid(attrs["id"])
try:
@ -939,6 +939,9 @@ class GrampsParser:
def stop_people(self,*tag):
pass
def stop_database(self,*tag):
self.callback(False)
def stop_object(self,*tag):
self.db.commit_media_object(self.object,self.trans,self.change)
self.object = None
@ -1110,8 +1113,6 @@ class GrampsParser:
self.num_places = int(attrs['places'])
else:
self.num_places = 0
self.entries = int(attrs["people"]) + int(attrs["families"]) + \
self.num_places + self.num_srcs
def start_pos(self,attrs):
self.person.position = (int(attrs["x"]), int(attrs["y"]))

View File

@ -325,6 +325,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.filter_btn = self.gtop.get_widget("filter1")
self.toolbar_btn = self.gtop.get_widget("toolbar2")
self.statusbar = self.gtop.get_widget("statusbar")
self.progress = self.statusbar.get_children()[0]
self.progress.set_pulse_step(0.01)
self.filter_list = self.gtop.get_widget("filter_list")
self.views = self.gtop.get_widget("views")
@ -1232,7 +1234,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
try:
import ReadXML
ReadXML.importData(self.db,dbname,None)
ReadXML.importData(self.db,dbname,self.update_bar)
except:
DisplayTrace.DisplayTrace()
@ -1243,6 +1245,12 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
os.rmdir(tmpdir_path)
self.import_tool_callback()
def update_bar(self,percent):
if percent:
self.progress.pulse()
else:
self.progress.set_fraction(0)
def read_file(self,filename,callback=None):
self.topWindow.set_resizable(False)
mode = "w"