From 99b7fc8815cc35739a9db23b9acc7300d6b70033 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 17 Jan 2017 08:42:22 -0600 Subject: [PATCH 1/5] Fix updatecallback to show first progress step --- gramps/gen/updatecallback.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gramps/gen/updatecallback.py b/gramps/gen/updatecallback.py index 6d80d0832..3e8539d60 100644 --- a/gramps/gen/updatecallback.py +++ b/gramps/gen/updatecallback.py @@ -72,7 +72,7 @@ class UpdateCallback: Reset the count to zero. """ self.count = 0 - self.oldval = 0 + self.oldval = -1 self.oldtime = 0 self.text = text @@ -96,7 +96,7 @@ class UpdateCallback: Called when the count is updated. """ self.count += 1 - if not count: + if count is None: count = self.count newval = int(100 * count/self.total) newtime = time.time() From a860a9d80b6c4ccfb4ceb828450ab5498d626c37 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 17 Jan 2017 08:49:21 -0600 Subject: [PATCH 2/5] Fix export assistant, proper parent for popup progress and dialog --- gramps/gui/plug/export/_exportassistant.py | 3 ++- gramps/gui/plug/export/_exportoptions.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gramps/gui/plug/export/_exportassistant.py b/gramps/gui/plug/export/_exportassistant.py index fdad88e3b..8d2040d60 100644 --- a/gramps/gui/plug/export/_exportassistant.py +++ b/gramps/gui/plug/export/_exportassistant.py @@ -274,7 +274,8 @@ class ExportAssistant(ManagedWindow, Gtk.Assistant): # add new content if config_box_class: self.option_box_instance = config_box_class( - self.person, self.dbstate, self.uistate, track=self.track) + self.person, self.dbstate, self.uistate, track=self.track, + window=self.window) box = self.option_box_instance.get_option_box() vbox.add(box) else: diff --git a/gramps/gui/plug/export/_exportoptions.py b/gramps/gui/plug/export/_exportoptions.py index ce0796393..6ce2fc379 100644 --- a/gramps/gui/plug/export/_exportoptions.py +++ b/gramps/gui/plug/export/_exportoptions.py @@ -62,11 +62,11 @@ class Progress: Mirros the same interface that the ExportAssistant uses in the selection, but this is for the preview selection. """ - def __init__(self, uistate): + def __init__(self, parent): from gi.repository import Gtk self.pm = ProgressMeter(_("Selecting Preview Data"), _('Selecting...'), - parent=uistate.window) + parent=parent) self.progress_cnt = 0 self.title = _("Selecting...") while Gtk.events_pending(): @@ -106,11 +106,12 @@ class WriterOptionBox: the options. """ - def __init__(self, person, dbstate, uistate, track=[]): + def __init__(self, person, dbstate, uistate, track=[], window=None): self.person = person self.dbstate = dbstate self.uistate = uistate self.track = track + self.window = window self.preview_dbase = None self.preview_button = None self.preview_proxy_button = {} @@ -256,7 +257,7 @@ class WriterOptionBox: Calculate previews to see the selected data. """ self.parse_options() - pm = Progress(self.uistate) + pm = Progress(self.window) self.preview_dbase = self.get_filtered_database(self.dbstate.db, pm, preview=True) pm.close() self.preview_button.set_sensitive(0) @@ -673,7 +674,7 @@ class WriterOptionBox: from ...dialog import ErrorDialog ErrorDialog(_("Cannot edit a system filter"), _("Please select a different filter to edit"), - parent=self.uistate.window) + parent=self.window) def edit_filter_save(self, filterdb, namespace): """ From a937d151af86d676573d8eee02a7f594ea7e5c29 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 17 Jan 2017 08:51:29 -0600 Subject: [PATCH 3/5] fix export assistant to show textual progress steps and first step --- gramps/gui/plug/export/_exportassistant.py | 3 +++ gramps/gui/plug/export/_exportoptions.py | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gramps/gui/plug/export/_exportassistant.py b/gramps/gui/plug/export/_exportassistant.py index 8d2040d60..1064e5676 100644 --- a/gramps/gui/plug/export/_exportassistant.py +++ b/gramps/gui/plug/export/_exportassistant.py @@ -640,6 +640,9 @@ class ExportAssistant(ManagedWindow, Gtk.Assistant): self.progressbar.set_fraction(min(value/100.0, 1.0)) if text: self.progressbar.set_text("%s: %d%%" % (text, value)) + self.confirm.set_label( + _("Please wait while your data is selected and exported") + + "\n" + text) else: self.progressbar.set_text("%d%%" % value) while Gtk.events_pending(): diff --git a/gramps/gui/plug/export/_exportoptions.py b/gramps/gui/plug/export/_exportoptions.py index 6ce2fc379..6586f30e4 100644 --- a/gramps/gui/plug/export/_exportoptions.py +++ b/gramps/gui/plug/export/_exportoptions.py @@ -587,8 +587,8 @@ class WriterOptionBox: if self.private: if progress: progress.reset(_("Filtering private data")) - progress.progress_cnt += 1 progress.update(progress.progress_cnt) + progress.progress_cnt += 1 dbase = PrivateProxyDb(dbase) # If the restrict flag is set, apply the LivingProxyDb @@ -596,8 +596,8 @@ class WriterOptionBox: if self.restrict_num > 0: if progress: progress.reset(_("Filtering living persons")) - progress.progress_cnt += 1 progress.update(progress.progress_cnt) + progress.progress_cnt += 1 mode = [None, # include living LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY, LivingProxyDb.MODE_REPLACE_COMPLETE_NAME, @@ -613,8 +613,8 @@ class WriterOptionBox: if self.cfilter != None and not self.cfilter.is_empty(): if progress: progress.reset(_("Applying selected person filter")) - progress.progress_cnt += 1 progress.update(progress.progress_cnt) + progress.progress_cnt += 1 dbase = FilterProxyDb( dbase, self.cfilter) @@ -623,17 +623,17 @@ class WriterOptionBox: if self.nfilter != None and not self.nfilter.is_empty(): if progress: progress.reset(_("Applying selected note filter")) - progress.progress_cnt += 1 progress.update(progress.progress_cnt) + progress.progress_cnt += 1 dbase = FilterProxyDb( dbase, note_filter=self.nfilter) # Apply the ReferencedBySelection elif proxy_name == "reference": - if progress: + if self.reference_num > 0 and progress: progress.reset(_("Filtering referenced records")) - progress.progress_cnt += 1 progress.update(progress.progress_cnt) + progress.progress_cnt += 1 if self.reference_num == 0: pass elif self.reference_num == 1: From 8fa6fad67afafa60451df74c8893752276766dd9 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 17 Jan 2017 08:53:53 -0600 Subject: [PATCH 4/5] Fix Gedcom export to have a more detailed progress indication --- gramps/plugins/export/exportgedcom.py | 46 +++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/gramps/plugins/export/exportgedcom.py b/gramps/plugins/export/exportgedcom.py index a7c4b4aa1..d97d6206d 100644 --- a/gramps/plugins/export/exportgedcom.py +++ b/gramps/plugins/export/exportgedcom.py @@ -129,6 +129,7 @@ PEDIGREE_TYPES = { ChildRefType.FOSTER: 'Foster', } +NOTES_PER_PERSON = 104 # fudge factor to make progress meter a bit smoother #------------------------------------------------------------------------- # # sort_handles_by_id @@ -217,15 +218,10 @@ class GedcomWriter(UpdateCallback): def __init__(self, database, user, option_box=None): UpdateCallback.__init__(self, user.callback) - self.total = 100 self.dbase = database self.dirname = None self.gedcom_file = None - - # The number of different stages other than any of the optional filters - # which the write_gedcom_file method will call. - self.progress_cnt = 5 - + self.progress_cnt = 0 self.setup(option_box) def setup(self, option_box): @@ -245,6 +241,15 @@ class GedcomWriter(UpdateCallback): self.dirname = os.path.dirname (filename) with open(filename, "w", encoding='utf-8') as self.gedcom_file: + person_len = self.dbase.get_number_of_people() + family_len = self.dbase.get_number_of_families() + source_len = self.dbase.get_number_of_sources() + repo_len = self.dbase.get_number_of_repositories() + note_len = self.dbase.get_number_of_notes() / NOTES_PER_PERSON + + total_steps = (person_len + family_len + source_len + repo_len + + note_len) + self.set_total(total_steps) self._header(filename) self._submitter() self._individuals() @@ -391,9 +396,7 @@ class GedcomWriter(UpdateCallback): people will be confused when the progress bar is idle. """ - self.reset(_("Writing individuals")) - self.progress_cnt += 1 - self.update(self.progress_cnt) + self.set_text(_("Writing individuals")) phandles = self.dbase.iter_person_handles() sorted_list = [] @@ -405,6 +408,7 @@ class GedcomWriter(UpdateCallback): sorted_list.sort() for data in sorted_list: + self.update() self._person(self.dbase.get_person_from_handle(data[1])) def _person(self, person): @@ -797,9 +801,7 @@ class GedcomWriter(UpdateCallback): """ Write out the list of families, sorting by Gramps ID. """ - self.reset(_("Writing families")) - self.progress_cnt += 1 - self.update(self.progress_cnt) + self.set_text(_("Writing families")) # generate a list of (GRAMPS_ID, HANDLE) pairs. This list # can then be sorted by the sort routine, which will use the # first value of the tuple as the sort key. @@ -809,6 +811,7 @@ class GedcomWriter(UpdateCallback): # loop through the sorted list, pulling of the handle. This list # has already been sorted by GRAMPS_ID for family_handle in [hndl[1] for hndl in sorted_list]: + self.update() self._family(self.dbase.get_family_from_handle(family_handle)) def _family(self, family): @@ -963,13 +966,12 @@ class GedcomWriter(UpdateCallback): """ Write out the list of sources, sorting by Gramps ID. """ - self.reset(_("Writing sources")) - self.progress_cnt += 1 - self.update(self.progress_cnt) + self.set_text(_("Writing sources")) sorted_list = sort_handles_by_id(self.dbase.get_source_handles(), self.dbase.get_source_from_handle) for (source_id, handle) in sorted_list: + self.update() source = self.dbase.get_source_from_handle(handle) if source is None: continue self._writeln(0, '@%s@' % source_id, 'SOUR') @@ -998,13 +1000,16 @@ class GedcomWriter(UpdateCallback): """ Write out the list of notes, sorting by Gramps ID. """ - self.reset(_("Writing notes")) - self.progress_cnt += 1 - self.update(self.progress_cnt) + self.set_text(_("Writing notes")) + note_cnt = 0 sorted_list = sort_handles_by_id(self.dbase.get_note_handles(), self.dbase.get_note_from_handle) for note_handle in [hndl[1] for hndl in sorted_list]: + # the following makes the progress bar a bit smoother + if not note_cnt % NOTES_PER_PERSON: + self.update() + note_cnt += 1 note = self.dbase.get_note_from_handle(note_handle) if note is None: continue self._note_record(note) @@ -1036,15 +1041,14 @@ class GedcomWriter(UpdateCallback): +1 RIN {0:1} +1 <> {0:1} """ - self.reset(_("Writing repositories")) - self.progress_cnt += 1 - self.update(self.progress_cnt) + self.set_text(_("Writing repositories")) sorted_list = sort_handles_by_id(self.dbase.get_repository_handles(), self.dbase.get_repository_from_handle) # GEDCOM only allows for a single repository per source for (repo_id, handle) in sorted_list: + self.update() repo = self.dbase.get_repository_from_handle(handle) if repo is None: continue self._writeln(0, '@%s@' % repo_id, 'REPO' ) From e7e1976222aa3010ddfdd70be88e65975e13dce4 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 17 Jan 2017 10:31:49 -0600 Subject: [PATCH 5/5] Add set_text method to updatecallback to allow progress text changes --- gramps/gen/updatecallback.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gramps/gen/updatecallback.py b/gramps/gen/updatecallback.py index 3e8539d60..9042e69b7 100644 --- a/gramps/gen/updatecallback.py +++ b/gramps/gen/updatecallback.py @@ -76,6 +76,13 @@ class UpdateCallback: self.oldtime = 0 self.text = text + def set_text(self, text): + """ + Set the text. + """ + self.text = text + self.oldval = -1 + def set_total(self, total): """ Set the total.