* 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
This commit is contained in:
Martin Hawlisch 2005-04-06 09:40:41 +00:00
parent b00f2e8645
commit 5b44756832
6 changed files with 45 additions and 34 deletions

View File

@ -1,3 +1,16 @@
2005-04-06 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* 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 <rjt-gramps@thegrindstone.me.uk> 2005-04-04 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/plugins/ScratchPad.py: made clear buttons sensitive to contents of * src/plugins/ScratchPad.py: made clear buttons sensitive to contents of
list and current selection. Added support for PERSON_LINK dnd. list and current selection. Added support for PERSON_LINK dnd.

View File

@ -90,23 +90,23 @@ class FamilyView:
def __init__(self,parent): def __init__(self,parent):
self.parent = parent self.parent = parent
self.parent.connect('database-changed',self.change_db)
self.top = parent.gtop self.top = parent.gtop
self.family = None self.family = None
self.cadded = [ 0, 0 ] self.cadded = [ 0, 0 ]
self.in_drag = False self.in_drag = False
self.init_interface() self.init_interface()
self.change_db()
def change_db(self): def change_db(self,db):
self.parent.db.connect('family-add', self.update_callback) db.connect('family-add', self.update_callback)
self.parent.db.connect('family-update', self.update_callback) db.connect('family-update', self.update_callback)
self.parent.db.connect('family-delete', self.update_callback) db.connect('family-delete', self.update_callback)
self.parent.db.connect('family-rebuild', self.load_family) db.connect('family-rebuild', self.load_family)
self.parent.db.connect('person-add', self.update_callback) db.connect('person-add', self.update_callback)
self.parent.db.connect('person-update', self.update_callback) db.connect('person-update', self.update_callback)
self.parent.db.connect('person-delete', self.update_callback) db.connect('person-delete', self.update_callback)
self.parent.db.connect('person-rebuild', self.load_family) db.connect('person-rebuild', self.load_family)
def update_callback(self,handle): def update_callback(self,handle):
self.load_family() self.load_family()

View File

@ -164,6 +164,9 @@ class DispBox:
class PedigreeView: class PedigreeView:
def __init__(self,parent,canvas,update,status_bar,lp): def __init__(self,parent,canvas,update,status_bar,lp):
self.parent = parent self.parent = parent
self.parent.connect('database-changed',self.change_db)
self.canvas = canvas self.canvas = canvas
self.canvas_items = [] self.canvas_items = []
self.boxes = [] self.boxes = []
@ -181,6 +184,17 @@ class PedigreeView:
self.anchor = None self.anchor = None
self.canvas.parent.connect('button-press-event',self.on_canvas_press) 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): def clear(self):
for i in self.canvas_items: for i in self.canvas_items:
i.destroy() i.destroy()

View File

@ -91,11 +91,6 @@ class PeopleView:
self.person_tree.connect('button-press-event', self.person_tree.connect('button-press-event',
self.on_plist_button_press) 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 # DnD support
# #
@ -187,10 +182,10 @@ class PeopleView:
self.person_model = PeopleModel.PeopleModel(db,self.DataFilter) self.person_model = PeopleModel.PeopleModel(db,self.DataFilter)
self.person_tree.set_model(self.person_model) self.person_tree.set_model(self.person_model)
self.parent.db.connect('person-add', self.person_added) db.connect('person-add', self.person_added)
self.parent.db.connect('person-update', self.person_updated) db.connect('person-update', self.person_updated)
self.parent.db.connect('person-delete', self.person_removed) db.connect('person-delete', self.person_removed)
self.parent.db.connect('person-rebuild', self.redisplay_person_list) db.connect('person-rebuild', self.redisplay_person_list)
self.apply_filter() self.apply_filter()
def remove_from_person_list(self,person): def remove_from_person_list(self,person):

View File

@ -81,7 +81,6 @@ class SourceView:
self.topWindow = self.glade.get_widget("gramps") self.topWindow = self.glade.get_widget("gramps")
self.columns = [] self.columns = []
self.change_db(db)
def build_columns(self): def build_columns(self):
for column in self.columns: for column in self.columns:

View File

@ -1667,23 +1667,13 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
GrampsKeys.save_last_file(name) GrampsKeys.save_last_file(name)
self.gtop.get_widget("filter").set_text("") self.gtop.get_widget("filter").set_text("")
if callback: self.emit("database-changed", (self.db,))
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.relationship = self.RelClass(self.db) self.relationship = self.RelClass(self.db)
self.change_active_person(self.find_initial_person()) 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: if callback:
callback(_('Setup complete')) callback(_('Setup complete'))
self.enable_buttons(True) self.enable_buttons(True)