diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 6acb63682..3f7db0d87 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -2,6 +2,9 @@ * src/GrampsDb/_WriteXML.py (write_place_obj): Always write ptitle. * src/GrampsDb/_ReadXML.py: Prase file and ptitle tags. * example/gramps/example.gramps: Update XML example. + * src/Exporter.py: Set initial person in case there's no active. + * src/ViewManager.py (find_initial_person): Remove method. + * src/GrampsDb/_GrampsDbBase.py (find_initial_person): Add method. 2006-01-28 Don Allingham * src/DisplayTabs.py: hook up event ref editor diff --git a/gramps2/src/Exporter.py b/gramps2/src/Exporter.py index 2f68057f7..a3fea9082 100644 --- a/gramps2/src/Exporter.py +++ b/gramps2/src/Exporter.py @@ -75,14 +75,10 @@ class Exporter: """ self.dbstate = dbstate self.uistate = uistate - # self.parent_window = parent_window if self.dbstate.active: self.person = self.dbstate.active else: - pass - # FIXME: find_initial_person needs to move into dbstate or db - # and then it will be available here - # self.person = self.parent.find_initial_person() + self.person = self.dbstate.db.find_initial_person() self.build_exports() self.format_option = None diff --git a/gramps2/src/GrampsDb/_GrampsDbBase.py b/gramps2/src/GrampsDb/_GrampsDbBase.py index 491b40ccb..12dc58eb7 100644 --- a/gramps2/src/GrampsDb/_GrampsDbBase.py +++ b/gramps2/src/GrampsDb/_GrampsDbBase.py @@ -989,6 +989,14 @@ class GrampsDbBase(GrampsDBCallback): """ assert False, "Needs to be overridden in the derived class" + def find_initial_person(self): + person = self.get_default_person() + if not person: + the_ids = self.get_gramps_ids(PERSON_KEY) + if the_ids: + person = self.get_person_from_gramps_id(min(the_ids)) + return person + def _validated_id_prefix(self, val, default): if val: try: diff --git a/gramps2/src/ViewManager.py b/gramps2/src/ViewManager.py index 006e1e0da..5ed759970 100644 --- a/gramps2/src/ViewManager.py +++ b/gramps2/src/ViewManager.py @@ -784,7 +784,7 @@ class ViewManager: GrampsKeys.save_last_file(name) self.relationship = self.RelClass(self.state.db) - self.state.change_active_person(self.find_initial_person()) + self.state.change_active_person(self.state.db.find_initial_person()) self.change_page(None,None) self.state.db.undo_callback = self.change_undo_label self.state.db.redo_callback = self.change_redo_label @@ -844,15 +844,6 @@ class ViewManager: import Plugins Plugins.ToolPlugins(self.state,self.uistate,[]) - def find_initial_person(self): - person = self.state.db.get_default_person() - if not person: - the_ids = self.state.db.get_person_handles(sort_handles=False) - if the_ids: - the_ids.sort() - person = self.state.db.get_person_from_handle(the_ids[0]) - return person - def scratchpad(self,obj): import ScratchPad ScratchPad.ScratchPadWindow(self.state, self)