7137: Fix updating of events gramplets

This commit is contained in:
Nick Hall 2014-03-29 23:50:04 +00:00
parent 3d64617ca1
commit 7a713e84d2

View File

@ -23,6 +23,7 @@ from gui.editors import EditEvent
from gen.lib import EventRoleType from gen.lib import EventRoleType
from ListModel import ListModel, NOSORT from ListModel import ListModel, NOSORT
from gen.plug import Gramplet from gen.plug import Gramplet
from gui.dbguielement import DbGUIElement
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
from gen.display.name import displayer as name_displayer from gen.display.name import displayer as name_displayer
import DateHandler import DateHandler
@ -30,7 +31,12 @@ import Errors
import Utils import Utils
import gtk import gtk
class Events(Gramplet): class Events(Gramplet, DbGUIElement):
def __init__(self, gui, nav_group=0):
Gramplet.__init__(self, gui, nav_group)
DbGUIElement.__init__(self, self.dbstate.db)
""" """
Displays the events for a person or family. Displays the events for a person or family.
""" """
@ -40,6 +46,19 @@ class Events(Gramplet):
self.gui.get_container_widget().add(self.gui.WIDGET) self.gui.get_container_widget().add(self.gui.WIDGET)
self.gui.WIDGET.show() self.gui.WIDGET.show()
def _connect_db_signals(self):
"""
called on init of DbGUIElement, connect to db as required.
"""
self.callman.register_callbacks({'event-update': self.changed})
self.callman.connect_all(keys=['event'])
def changed(self, handle):
"""
Called when a registered event is updated.
"""
self.update()
def build_gui(self): def build_gui(self):
""" """
Build the GUI interface. Build the GUI interface.
@ -62,6 +81,7 @@ class Events(Gramplet):
""" """
Add an event to the model. Add an event to the model.
""" """
self.callman.register_handles({'event': [event_ref.ref]})
event = self.dbstate.db.get_event_from_handle(event_ref.ref) event = self.dbstate.db.get_event_from_handle(event_ref.ref)
event_date = DateHandler.get_date(event) event_date = DateHandler.get_date(event)
event_sort = '%012d' % event.get_date_object().get_sort_value() event_sort = '%012d' % event.get_date_object().get_sort_value()
@ -134,6 +154,7 @@ class PersonEvents(Events):
active_handle = self.get_active('Person') active_handle = self.get_active('Person')
self.model.clear() self.model.clear()
self.callman.unregister_all()
if active_handle: if active_handle:
self.display_person(active_handle) self.display_person(active_handle)
else: else:
@ -184,7 +205,9 @@ class FamilyEvents(Events):
active_handle = self.get_active('Family') active_handle = self.get_active('Family')
self.model.clear() self.model.clear()
self.callman.unregister_all()
if active_handle: if active_handle:
self.callman.register_obj(active)
self.display_family(active_handle) self.display_family(active_handle)
else: else:
self.set_has_data(False) self.set_has_data(False)