From 5b44756832bb4a5d15373b6a5f1905dee08d85be Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Wed, 6 Apr 2005 09:40:41 +0000 Subject: [PATCH] * src/gramps_main.py (post_load): Emit "database-changed" signal instead of calling change_db(). * src/PedView.py: Connect to "database-changed" signal and handle person-update signals to redraw the view. * src/FamilyView.py (__init__) connect to database-changed signal, dont call change_cb because on initialisation there is no real database. (change_db): use database parameter supplied by signal emission. * src/PeopleView.py (__init__) dont connect the signals, this will be done by change_db, (change_db): Use supplied database. * src/SourceView.py (__init__): dont call change_cb because on initialisation there is no real database and this will be done by the signal. svn: r4304 --- gramps2/ChangeLog | 13 +++++++++++++ gramps2/src/FamilyView.py | 20 ++++++++++---------- gramps2/src/PedView.py | 14 ++++++++++++++ gramps2/src/PeopleView.py | 13 ++++--------- gramps2/src/SourceView.py | 1 - gramps2/src/gramps_main.py | 18 ++++-------------- 6 files changed, 45 insertions(+), 34 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 0c5b751cc..47ee1c776 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,16 @@ +2005-04-06 Martin Hawlisch + * src/gramps_main.py (post_load): Emit "database-changed" signal instead of + calling change_db(). + * src/PedView.py: Connect to "database-changed" signal and handle person-update signals + to redraw the view. + * src/FamilyView.py (__init__) connect to database-changed signal, dont call + change_cb because on initialisation there is no real database. (change_db): + use database parameter supplied by signal emission. + * src/PeopleView.py (__init__) dont connect the signals, this will be done by change_db, + (change_db): Use supplied database. + * src/SourceView.py (__init__): dont call change_cb because on initialisation + there is no real database and this will be done by the signal. + 2005-04-04 Richard Taylor * src/plugins/ScratchPad.py: made clear buttons sensitive to contents of list and current selection. Added support for PERSON_LINK dnd. diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index fb9f8f50f..309a295b1 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -90,23 +90,23 @@ class FamilyView: def __init__(self,parent): self.parent = parent + self.parent.connect('database-changed',self.change_db) self.top = parent.gtop self.family = None self.cadded = [ 0, 0 ] self.in_drag = False self.init_interface() - self.change_db() - def change_db(self): - self.parent.db.connect('family-add', self.update_callback) - self.parent.db.connect('family-update', self.update_callback) - self.parent.db.connect('family-delete', self.update_callback) - self.parent.db.connect('family-rebuild', self.load_family) + def change_db(self,db): + db.connect('family-add', self.update_callback) + db.connect('family-update', self.update_callback) + db.connect('family-delete', self.update_callback) + db.connect('family-rebuild', self.load_family) - self.parent.db.connect('person-add', self.update_callback) - self.parent.db.connect('person-update', self.update_callback) - self.parent.db.connect('person-delete', self.update_callback) - self.parent.db.connect('person-rebuild', self.load_family) + db.connect('person-add', self.update_callback) + db.connect('person-update', self.update_callback) + db.connect('person-delete', self.update_callback) + db.connect('person-rebuild', self.load_family) def update_callback(self,handle): self.load_family() diff --git a/gramps2/src/PedView.py b/gramps2/src/PedView.py index bbf4fb83e..4ec346557 100644 --- a/gramps2/src/PedView.py +++ b/gramps2/src/PedView.py @@ -164,6 +164,9 @@ class DispBox: class PedigreeView: def __init__(self,parent,canvas,update,status_bar,lp): self.parent = parent + + self.parent.connect('database-changed',self.change_db) + self.canvas = canvas self.canvas_items = [] self.boxes = [] @@ -181,6 +184,17 @@ class PedigreeView: self.anchor = None self.canvas.parent.connect('button-press-event',self.on_canvas_press) + def change_db(self,db): + # Reconnect signals + db.connect('person-add', self.person_updated_cb) + db.connect('person-update', self.person_updated_cb) + db.connect('person-delete', self.person_updated_cb) + db.connect('person-rebuild', self.person_updated_cb) + + def person_updated_cb(self,handle_list): + # Redraw view on changes of persons + self.load_canvas(self.active_person) + def clear(self): for i in self.canvas_items: i.destroy() diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index 4ad605deb..d88e930f4 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -91,11 +91,6 @@ class PeopleView: self.person_tree.connect('button-press-event', self.on_plist_button_press) - self.parent.db.connect('person-add', self.person_added) - self.parent.db.connect('person-update', self.person_updated) - self.parent.db.connect('person-delete', self.person_removed) - self.parent.db.connect('person-rebuild', self.redisplay_person_list) - # # DnD support # @@ -187,10 +182,10 @@ class PeopleView: self.person_model = PeopleModel.PeopleModel(db,self.DataFilter) self.person_tree.set_model(self.person_model) - self.parent.db.connect('person-add', self.person_added) - self.parent.db.connect('person-update', self.person_updated) - self.parent.db.connect('person-delete', self.person_removed) - self.parent.db.connect('person-rebuild', self.redisplay_person_list) + db.connect('person-add', self.person_added) + db.connect('person-update', self.person_updated) + db.connect('person-delete', self.person_removed) + db.connect('person-rebuild', self.redisplay_person_list) self.apply_filter() def remove_from_person_list(self,person): diff --git a/gramps2/src/SourceView.py b/gramps2/src/SourceView.py index 0b03973c7..35ccb12c0 100644 --- a/gramps2/src/SourceView.py +++ b/gramps2/src/SourceView.py @@ -81,7 +81,6 @@ class SourceView: self.topWindow = self.glade.get_widget("gramps") self.columns = [] - self.change_db(db) def build_columns(self): for column in self.columns: diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 32567fca5..3730348a0 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -1667,23 +1667,13 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): GrampsKeys.save_last_file(name) self.gtop.get_widget("filter").set_text("") - if callback: - callback(_('Building Person list...')) - self.people_view.change_db(self.db) - self.family_view.change_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.emit("database-changed", (self.db,)) + self.relationship = self.RelClass(self.db) self.change_active_person(self.find_initial_person()) - self.goto_active_person() + self.goto_active_person() # TODO: This should emit a signal so other views can update itself + if callback: callback(_('Setup complete')) self.enable_buttons(True)