From 170ae90bcb978cefb0727b818943066387afa833 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 10 Apr 2006 20:56:09 +0000 Subject: [PATCH] Handle active person and Pedigree startup issues svn: r6306 --- gramps2/ChangeLog | 4 ++++ gramps2/src/DataViews/_PedigreeView.py | 27 ++++++++++++++++++++++++++ gramps2/src/DataViews/_PersonView.py | 5 +---- gramps2/src/PageView.py | 1 - 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d49338865..15c3b2cc9 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -7,6 +7,10 @@ * src/ArgHandler.py: Get rid of obsolete self.parent. 2006-04-10 Don Allingham + * src/DateViews/_PersonView.py: goto active person after a redraw. + * src/DataViews/_PedigreeViews.py: optimize the screen draws, + redrawing only when the view is displayed and when the data needs + to be updated. * src/Editors/_EditFamily.py: Fix adding of spouse after family has been created diff --git a/gramps2/src/DataViews/_PedigreeView.py b/gramps2/src/DataViews/_PedigreeView.py index 0f3cbdfde..634a1c3fd 100644 --- a/gramps2/src/DataViews/_PedigreeView.py +++ b/gramps2/src/DataViews/_PedigreeView.py @@ -522,6 +522,18 @@ class PedigreeView(PageView.PersonNavView): PageView.PersonNavView.define_actions(self) self.add_action('HomePerson',gtk.STOCK_HOME, "_Home", callback=self.home) + def build_tree(self): + """ + This is called by the parent class when the view becomes visible. Since + all handling of visibility is now in rebuild_trees, see that for more + information. + """ + active = self.dbstate.get_active_person() + if active: + self.rebuild_trees(active.handle) + else: + self.rebuild_trees(None) + def change_db(self,db): """ Callback associated with DbState. Whenenver the database @@ -539,6 +551,7 @@ class PedigreeView(PageView.PersonNavView): self.rebuild_trees(None) def goto_active_person(self,handle=None): + self.dirty = True if handle: self.rebuild_trees(handle) self.handle_history(handle) @@ -546,18 +559,21 @@ class PedigreeView(PageView.PersonNavView): self.rebuild_trees(None) def person_updated_cb(self,handle_list): + self.dirty = True if self.dbstate.active: self.rebuild_trees(self.dbstate.active.handle) else: self.rebuild_trees(None) def person_rebuild(self): + self.dirty = True if self.dbstate.active: self.rebuild_trees(self.dbstate.active.handle) else: self.rebuild_trees(None) def person_edited_cb(self, p1=None, p2=None): + self.dirty = True pass def request_resize(self): @@ -580,6 +596,17 @@ class PedigreeView(PageView.PersonNavView): person = None if person_handle: person = self.dbstate.db.get_person_from_handle( person_handle) + + # Eliminate unnecessary redraws. If the window is active, clear the + # dirty flag, and redraw. If we are not begin displayed, set the dirty + # flag and do nothing. + + if not self.active or not self.dirty: + self.dirty = True + return + else: + self.dirty = False + if self.tree_style == 1: # format of the definition is: # ((each box of the pedigree has a node here), diff --git a/gramps2/src/DataViews/_PersonView.py b/gramps2/src/DataViews/_PersonView.py index b5c2cbb56..58c3c2bdb 100644 --- a/gramps2/src/DataViews/_PersonView.py +++ b/gramps2/src/DataViews/_PersonView.py @@ -253,13 +253,9 @@ class PersonView(PageView.PersonNavView): db.connect('person-update', self.person_updated) db.connect('person-delete', self.person_removed) db.connect('person-rebuild', self.build_tree) -# self.build_tree() self.generic_filter_widget.apply_filter() def goto_active_person(self,obj=None): - self.goto_active_person_2(None) - - def goto_active_person_2(self,obj=None): """ Callback (and usable function) that selects the active person in the display tree. @@ -359,6 +355,7 @@ class PersonView(PageView.PersonNavView): self.model.tooltip_column, True) self.build_columns() + self.goto_active_person() self.dirty = False else: self.dirty = True diff --git a/gramps2/src/PageView.py b/gramps2/src/PageView.py index 497489c9f..01978ea96 100644 --- a/gramps2/src/PageView.py +++ b/gramps2/src/PageView.py @@ -73,7 +73,6 @@ class PageView: self.active = False def set_active(self): - print self, self.active, self.dirty self.active = True if self.dirty: self.uistate.set_busy_cursor(True)