rewrote session log gramplet to be simpler and more complete

svn: r11572
This commit is contained in:
Doug Blank 2009-01-05 02:31:57 +00:00
parent d76e9a8363
commit fe3d9d6b0e

View File

@ -152,59 +152,53 @@ class LogGramplet(Gramplet):
self.tooltip = _("Click name to change active\nDouble-click name to edit") self.tooltip = _("Click name to change active\nDouble-click name to edit")
self.set_text(_("Log for this Session")) self.set_text(_("Log for this Session"))
self.gui.force_update = True # will always update, even if minimized self.gui.force_update = True # will always update, even if minimized
self.append_text("\n--------------------\n") self.last_log = None
self.history = {} self.append_text("\n")
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('person-add', self.log_person_add) self.append_text("Opened data base -----------\n")
self.dbstate.db.connect('person-delete', self.log_person_delete) self.dbstate.db.connect('person-add',
self.dbstate.db.connect('person-update', self.log_person_update) lambda handles: self.log(_('Person'), _('Added'), handles))
self.dbstate.db.connect('family-add', self.log_family_add) self.dbstate.db.connect('person-delete',
self.dbstate.db.connect('family-delete', self.log_family_delete) lambda handles: self.log(_('Person'), _('Deleted'), handles))
self.dbstate.db.connect('family-update', self.log_family_update) self.dbstate.db.connect('person-update',
lambda handles: self.log(_('Person'), _('Edited'), handles))
self.dbstate.db.connect('family-add',
lambda handles: self.log(_('Family'), _('Added'), handles))
self.dbstate.db.connect('family-delete',
lambda handles: self.log(_('Family'), _('Deleted'), handles))
self.dbstate.db.connect('family-update',
lambda handles: self.log(_('Family'), _('Added'), handles))
def on_load(self):
if len(self.gui.data) > 0:
self.show_duplicates = self.gui.data[0]
else:
self.show_duplicates = "no"
def on_save(self):
self.gui.data = [self.show_duplicates]
def active_changed(self, handle): def active_changed(self, handle):
self.log_active_changed(handle) self.log(_('Person'), _('Selected'), [handle])
# FIXME: added support for family display and clicks def log(self, ltype, action, handles):
def log_person_add(self, handles): for handle in set(handles):
self.get_person(handles, _("Added")) if self.last_log == (ltype, action, handle):
def log_person_delete(self, handles): continue
self.get_person(handles, _("Deleted")) self.last_log = (ltype, action, handle)
def log_person_update(self, handles): self.append_text("%s: " % action)
self.get_person(handles, _("Updated")) if ltype == _("Person"):
def log_family_add(self, handles): person = self.dbstate.db.get_person_from_handle(handle)
self.append_text(_("Added") + ": family\n" ) name = name_displayer.display(person)
def log_family_delete(self, handles): elif ltype == _("Family"):
self.append_text(_("Deleted") + ": family\n" ) family = self.dbstate.db.get_family_from_handle(handle)
def log_family_update(self, handles): father_name = _("unknown")
self.append_text(_("Updated") + ": family\n" ) mother_name = _("unknown")
def log_active_changed(self, handles): if family:
self.get_person([handles], _("Selected")) father_handle = family.get_father_handle()
if father_handle:
def get_person(self, handles, ltype): father = self.dbstate.db.get_person_from_handle(father_handle)
for person_handle in handles: if father:
if ((self.show_duplicates == "no" and father_name = name_displayer.display(father)
ltype + ": " + person_handle not in self.history) or mother_handle = family.get_mother_handle()
self.show_duplicates == "yes"): if mother_handle:
self.append_text("%s: " % ltype) mother = self.dbstate.db.get_person_from_handle(mother_handle)
self.history[ltype + ": " + person_handle] = 1 mother_name = name_displayer.display(mother)
person = self.dbstate.db.get_person_from_handle(person_handle) name = _("%s and %s") % (mother_name, father_name)
if person: self.link(name, ltype, handle)
self.link(name_displayer.display(person), 'Person', self.append_text("\n")
person_handle)
else:
self.link(_("Unknown"), 'Person', person_handle)
self.append_text("\n")
class TopSurnamesGramplet(Gramplet): class TopSurnamesGramplet(Gramplet):
def init(self): def init(self):