7137: Fix updating of events gramplets
This commit is contained in:
parent
3d64617ca1
commit
7a713e84d2
@ -23,6 +23,7 @@ from gui.editors import EditEvent
|
||||
from gen.lib import EventRoleType
|
||||
from ListModel import ListModel, NOSORT
|
||||
from gen.plug import Gramplet
|
||||
from gui.dbguielement import DbGUIElement
|
||||
from gen.ggettext import gettext as _
|
||||
from gen.display.name import displayer as name_displayer
|
||||
import DateHandler
|
||||
@ -30,7 +31,12 @@ import Errors
|
||||
import Utils
|
||||
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.
|
||||
"""
|
||||
@ -40,6 +46,19 @@ class Events(Gramplet):
|
||||
self.gui.get_container_widget().add(self.gui.WIDGET)
|
||||
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):
|
||||
"""
|
||||
Build the GUI interface.
|
||||
@ -62,6 +81,7 @@ class Events(Gramplet):
|
||||
"""
|
||||
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_date = DateHandler.get_date(event)
|
||||
event_sort = '%012d' % event.get_date_object().get_sort_value()
|
||||
@ -134,6 +154,7 @@ class PersonEvents(Events):
|
||||
active_handle = self.get_active('Person')
|
||||
|
||||
self.model.clear()
|
||||
self.callman.unregister_all()
|
||||
if active_handle:
|
||||
self.display_person(active_handle)
|
||||
else:
|
||||
@ -184,7 +205,9 @@ class FamilyEvents(Events):
|
||||
active_handle = self.get_active('Family')
|
||||
|
||||
self.model.clear()
|
||||
self.callman.unregister_all()
|
||||
if active_handle:
|
||||
self.callman.register_obj(active)
|
||||
self.display_family(active_handle)
|
||||
else:
|
||||
self.set_has_data(False)
|
||||
|
Loading…
Reference in New Issue
Block a user