def __process_family_2(self, family, person1, person2): missingbits = [] if person1 is UnknownPerson or person1 is None: name1 = _("(unknown person)") else: name1 = name_displayer.display(person1) if not name1: name1 = _("(person with unknown name)") if person2 is UnknownPerson or person2 is None: name2 = _("(unknown person)") else: name2 = name_displayer.display(person2) if not name2: name2 = _("(person with unknown name)") name = _("%(name1)s and %(name2)s") % {'name1': name1, 'name2': name2} if self.__family_complete_handle is not None and \ self.__family_complete_handle not in family.get_tag_list(): missingbits.append(_("family not complete")) if missingbits: self.link(name, 'Family', family.get_handle()) self.append_text( _(": %(list)s\n") % {'list': _(", ").join(missingbits)}) self.__counter += 1
def update_parent_label(self): handle = self.obj.get_family_handle() if handle: family = self.dbstate.db.get_family_from_handle(handle) f = self.dbstate.db.get_person_from_handle( family.get_father_handle()) m = self.dbstate.db.get_person_from_handle( family.get_mother_handle()) if f and m: label = _("%(father)s and %(mother)s [%(gramps_id)s]") % { 'father': name_displayer.display(f), 'mother': name_displayer.display(m), 'gramps_id': family.gramps_id, } elif f: label = _("%(father)s [%(gramps_id)s]") % { 'father': name_displayer.display(f), 'gramps_id': family.gramps_id, } elif m: label = _("%(mother)s [%(gramps_id)s]") % { 'mother': name_displayer.display(m), 'gramps_id': family.gramps_id, } else: # No translation for bare gramps_id label = "[%(gramps_id)s]" % { 'gramps_id': family.gramps_id, } else: label = "" self.parents.set_text(label)
def display_parents(self, active_person): """ Display the parents of the active person. """ family_handle = active_person.get_main_parents_family_handle() if family_handle: family = self.dbstate.db.get_family_from_handle(family_handle) handle = family.get_father_handle() if handle: father = self.dbstate.db.get_person_from_handle(handle) father_name = name_displayer.display(father) else: father_name = _('Unknown') handle = family.get_mother_handle() if handle: mother = self.dbstate.db.get_person_from_handle(handle) mother_name = name_displayer.display(mother) else: mother_name = _('Unknown') else: father_name = _('Unknown') mother_name = _('Unknown') self.add_row(_('Father'), father_name) self.add_row(_('Mother'), mother_name)
def _createmap_for_one_family(self, family): """ Create all markers for one family : all event's places with a lat/lon. """ dbstate = self.dbstate try: person = dbstate.db.get_person_from_handle( family.get_father_handle()) except: return family_id = family.gramps_id if person is None: # family without father ? person = dbstate.db.get_person_from_handle( family.get_mother_handle()) if person is None: person = dbstate.db.get_person_from_handle( self.uistate.get_active('Person')) if person is not None: family_list = person.get_family_handle_list() if len(family_list) > 0: fhandle = family_list[0] # first is primary fam = dbstate.db.get_family_from_handle(fhandle) handle = fam.get_father_handle() father = dbstate.db.get_person_from_handle(handle) if father: comment = _("Father : %s : %s") % (father.gramps_id, _nd.display(father)) self._createpersonmarkers(dbstate, father, comment, family_id) handle = fam.get_mother_handle() mother = dbstate.db.get_person_from_handle(handle) if mother: comment = _("Mother : %s : %s") % (mother.gramps_id, _nd.display(mother)) self._createpersonmarkers(dbstate, mother, comment, family_id) index = 0 child_ref_list = fam.get_child_ref_list() if child_ref_list: for child_ref in child_ref_list: child = dbstate.db.get_person_from_handle( child_ref.ref) if child: index += 1 comment = _("Child : %(id)s - %(index)d " ": %(name)s") % { 'id': child.gramps_id, 'index': index, 'name': _nd.display(child) } self._createpersonmarkers(dbstate, child, comment, family_id) else: comment = _("Person : %(id)s %(name)s has no family.") % { 'id': person.gramps_id, 'name': _nd.display(person) } self._createpersonmarkers(dbstate, person, comment, family_id)
def _get_subject(options, dbase): """ Attempts to determine the subject of a set of options. The subject would likely be a person (using a PersonOption) or a filter (using a FilterOption) options: The ReportOptions class dbase: the database for which it corresponds """ if not hasattr(options, "menu"): return "" menu = options.menu option_names = menu.get_all_option_names() if not option_names: return _("Entire Database") for name in option_names: option = menu.get_option_by_name(name) if isinstance(option, FilterOption): return option.get_filter().get_name() elif isinstance(option, PersonOption): gid = option.get_value() person = dbase.get_person_from_gramps_id(gid) return _nd.display(person) elif isinstance(option, FamilyOption): family = dbase.get_family_from_gramps_id(option.get_value()) if not family: return "" family_id = family.get_gramps_id() fhandle = family.get_father_handle() mhandle = family.get_mother_handle() if fhandle: father = dbase.get_person_from_handle(fhandle) father_name = _nd.display(father) else: father_name = _("unknown father") if mhandle: mother = dbase.get_person_from_handle(mhandle) mother_name = _nd.display(mother) else: mother_name = _("unknown mother") name = _("%(father)s and %(mother)s (%(id)s)") % { 'father': father_name, 'mother': mother_name, 'id': family_id } return name return ""
def get_menu_title(self): if self.obj and self.obj.get_handle(): name = name_displayer.display(self.obj) title = _('Person: %(name)s') % {'name': name} else: name = name_displayer.display(self.obj) if name: title = _('New Person: %(name)s') % {'name': name} else: title = _('New Person') return title
def main(self): """ Fill the data structures with the active data. This initializes all data. """ self.gui.fan.reset_generations() active_handle = self.get_active('Person') person = self.dbstate.db.get_person_from_handle(active_handle) if not person: name = None else: name = name_displayer.display(person) parents = self.have_parents(person) child = self.have_children(person) self.gui.fan.data[0][0] = (name, person, parents, child) for current in range(1, self.generations): parent = 0 # name, person, parents, children for (n, p, q, c) in self.gui.fan.data[current - 1]: # Get father's details: person = self.get_parent(p, "male") if person: name = name_displayer.display(person) else: name = None if current == self.generations - 1: parents = self.have_parents(person) else: parents = None self.gui.fan.data[current][parent] = (name, person, parents, None) if person is None: # start,stop,male/right,state self.gui.fan.angle[current][parent][ 3] = self.gui.fan.COLLAPSED parent += 1 # Get mother's details: person = self.get_parent(p, "female") if person: name = name_displayer.display(person) else: name = None if current == self.generations - 1: parents = self.have_parents(person) else: parents = None self.gui.fan.data[current][parent] = (name, person, parents, None) if person is None: # start,stop,male/right,state self.gui.fan.angle[current][parent][ 3] = self.gui.fan.COLLAPSED parent += 1 self.gui.fan.queue_draw()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Associations state tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: ManagedWindow.__init__(self,uistate,[], self.__class__) stats_list = [] plist = dbstate.db.get_person_handles(sort_handles=True) for handle in plist: person = dbstate.db.get_person_from_handle(handle) name1 = name_displayer.display(person) refs = person.get_person_ref_list() if refs: for ref in person.serialize()[-1]: (a, b, c, two, value) = ref person2 = dbstate.db.get_person_from_handle(two) name2 = name_displayer.display(person2) stats_list.append((name1, value, name2)) if uistate: titles = [ (_('Name'), 0, 200), (_('Type of link'), 1, 200), (_('Of'), 2, 200), ] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in stats_list: model.add(entry, entry[0]) window = Gtk.Window() window.set_default_size(800, 600) s = Gtk.ScrolledWindow() s.add(treeview) window.add(s) window.show_all() self.set_window(window, None, self.label) self.show() else: print('\t%s'*3 % ('Name','Type of link','Of')) print() for entry in stats_list: print('\t%s'*3 % entry)
def __process_family(self, family, person1, person2, append_list): if family.get_handle() in self.__processed_families: return self.__processed_families[family.get_handle()] = True missingbits = [] if person1 is UnknownPerson or person1 is None: name1 = _("(unknown person)") else: name1 = name_displayer.display(person1) if not name1: name1 = _("(person with unknown name)") if person2 is UnknownPerson or person2 is None: name2 = _("(unknown person)") else: name2 = name_displayer.display(person2) if not name2: name2 = _("(person with unknown name)") name = _("%(name1)s and %(name2)s") % {'name1': name1, 'name2': name2} has_marriage = False for event_ref in family.get_event_ref_list(): event = self.dbstate.db.get_event_from_handle(event_ref.ref) if event.get_type() not in [EventType.MARRIAGE, EventType.DIVORCE]: continue missingbits.extend(self.__process_event(event)) if event.get_type() == EventType.MARRIAGE: has_marriage = True if family.get_relationship() == FamilyRelType.MARRIED: if not has_marriage: missingbits.append(_("marriage event missing")) elif family.get_relationship() == FamilyRelType.UNKNOWN: missingbits.append(_("relation type unknown")) if missingbits: self.link(name, 'Family', family.get_handle()) self.append_text( _(": %(list)s\n") % {'list': _(", ").join(missingbits)}) self.__counter += 1 append_list.append((family, person1, person2))
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Associations state tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: ManagedWindow.__init__(self, uistate, [], self.__class__) stats_list = [] plist = dbstate.db.get_person_handles(sort_handles=True) for handle in plist: person = dbstate.db.get_person_from_handle(handle) name1 = name_displayer.display(person) refs = person.get_person_ref_list() if refs: for ref in person.serialize()[-1]: (a, b, c, two, value) = ref person2 = dbstate.db.get_person_from_handle(two) name2 = name_displayer.display(person2) stats_list.append((name1, value, name2)) if uistate: titles = [ (_('Name'), 0, 200), (_('Type of link'), 1, 200), (_('Of'), 2, 200), ] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in stats_list: model.add(entry, entry[0]) window = Gtk.Window() window.set_default_size(800, 600) s = Gtk.ScrolledWindow() s.add(treeview) window.add(s) window.show_all() self.set_window(window, None, self.label) self.show() else: print('\t%s' * 3 % ('Name', 'Type of link', 'Of')) print() for entry in stats_list: print('\t%s' * 3 % entry)
def ok_clicked(self, obj): name = name_displayer.display(self.person) msg = _("Reorder Relationships: %s") % name with DbTxn(msg, self.dbstate.db) as trans: self.dbstate.db.commit_person(self.person, trans) self.close()
def get_data(self): if not self._data or self.changed: self._data = [self.obj.get_event_ref_list()] self._groups = [(self.obj.get_handle(), self._WORKNAME, '')] # own family events family_handle_list = self.obj.get_family_handle_list() if family_handle_list: for family_handle in family_handle_list: family = self.dbstate.db.get_family_from_handle( family_handle) father_handle = family.get_father_handle() mother_handle = family.get_mother_handle() if self.obj.get_handle() == father_handle: handlepartner = mother_handle else: handlepartner = father_handle if handlepartner: partner = self.dbstate.db.get_person_from_handle( handlepartner) groupname = name_displayer.display(partner) else: groupname = self._UNKNOWNNAME self._data.append(family.get_event_ref_list()) self._groups.append( (family_handle, self._FAMNAME, groupname)) self.changed = False return self._data
def call_edit_childref(self, ref): p = self.dbstate.db.get_person_from_handle(ref.ref) n = name_displayer.display(p) try: EditChildRef(n, self.dbstate, self.uistate, self.track, ref, self.child_ref_edited) except Errors.WindowActiveError: pass
def _select_person(self, obj): SelectPerson = SelectorFactory('Person') sel = SelectPerson(self.dbstate, self.uistate, self.track) person = sel.run() if person: self.obj.ref = person.get_handle() self.person_label.set_text(name_displayer.display(person))
def calc_title(self, center): """Calculate the title of the report""" name = "" if center is not None: name = name_displayer.display(center) # feature request 2356: avoid genitive form self.text = _("Ancestor Graph for %s") % name self.set_box_height_width()
def add_child(self, child, spouse): """ Add a child to the model. """ name = name_displayer.display(child) if spouse: spouse = name_displayer.display(spouse) birth = get_birth_or_fallback(self.dbstate.db, child) birth_date, birth_sort, birth_place = self.get_date_place(birth) death = get_death_or_fallback(self.dbstate.db, child) death_date, death_sort, death_place = self.get_date_place(death) self.model.add((child.get_handle(), name, birth_date, birth_sort, death_date, death_sort, spouse))
def log(self, ltype, action, handles): for handle in set(handles): if self.last_log == (ltype, action, handle): continue self.last_log = (ltype, action, handle) self.timestamp() self.append_text("%s: " % _(action)) if action == 'Deleted': transaction = self.dbstate.db.transaction if ltype == 'Person': name = 'a person' if transaction is not None: for i in transaction.get_recnos(reverse=True): (obj_type, trans_type, hndl, old_data, dummy) = \ transaction.get_record(i) if (obj_type == PERSON_KEY and trans_type == TXNDEL and hndl == handle): person = Person() person.unserialize(old_data) name = name_displayer.display(person) break elif ltype == 'Family': name = 'a family' if transaction is not None: for i in transaction.get_recnos(reverse=True): (obj_type, trans_type, hndl, old_data, dummy) = \ transaction.get_record(i) if (obj_type == FAMILY_KEY and trans_type == TXNDEL and hndl == handle): family = Family() family.unserialize(old_data) name = family_name(family, self.dbstate.db, name) break self.append_text(name) else: if ltype == 'Person': person = self.dbstate.db.get_person_from_handle(handle) name = name_displayer.display(person) elif ltype == 'Family': family = self.dbstate.db.get_family_from_handle(handle) name = family_name(family, self.dbstate.db, 'a family') self.link(name, ltype, handle) self.append_text("\n")
def fill_parents(self): for handle in self.parent_list: family = self.dbstate.db.get_family_from_handle(handle) fhandle = family.get_father_handle() mhandle = family.get_mother_handle() fname = "" if fhandle: father = self.dbstate.db.get_person_from_handle(fhandle) if father: fname = name_displayer.display(father) mname = "" if mhandle: mother = self.dbstate.db.get_person_from_handle(mhandle) if mother: mname = name_displayer.display(mother) self.pmodel.add([fname, mname, handle])
def __init__(self, obj_list, db): gtk.ListStore.__init__(self, str, str, str, object) self.db = db for obj in obj_list: p = self.db.get_person_from_handle(obj.ref) if p: data = [name_displayer.display(p), p.gramps_id, obj.rel, obj] else: data = ['unknown', 'unknown', obj.rel, obj] self.append(row=data)
def person_event_name(event, person): """ Build a name for an event based on the primary person's information. """ if not event.get_description(): text = EVENT_PERSON_STR % { 'event_name' : str(event.get_type()), 'person' : name_displayer.display(person), } event.set_description(text)
def get_person_filters(person, include_single=True): """ Return a list of filters that are relevant for the given person @param person: the person the filters should apply to. @type person: L{Person} @param include_single: include a filter to include the single person @type person: boolean """ from Filters import GenericFilter, Rules, CustomFilters from gen.display.name import displayer as name_displayer if person: name = name_displayer.display(person) gramps_id = person.get_gramps_id() else: # Do this in case of command line options query (show=filter) name = _("PERSON") gramps_id = '' if include_single: filt_id = GenericFilter() filt_id.set_name(name) filt_id.add_rule(Rules.Person.HasIdOf([gramps_id])) all = GenericFilter() all.set_name(_("Entire Database")) all.add_rule(Rules.Person.Everyone([])) des = GenericFilter() # feature request 2356: avoid genitive form des.set_name(_("Descendants of %s") % name) des.add_rule(Rules.Person.IsDescendantOf([gramps_id, 1])) df = GenericFilter() # feature request 2356: avoid genitive form df.set_name(_("Descendant Families of %s") % name) df.add_rule(Rules.Person.IsDescendantFamilyOf([gramps_id, 1])) ans = GenericFilter() # feature request 2356: avoid genitive form ans.set_name(_("Ancestors of %s") % name) ans.add_rule(Rules.Person.IsAncestorOf([gramps_id, 1])) com = GenericFilter() com.set_name(_("People with common ancestor with %s") % name) com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id])) if include_single: the_filters = [filt_id, all, des, df, ans, com] else: the_filters = [all, des, df, ans, com] the_filters.extend(CustomFilters.get_filters('Person')) return the_filters
def _get_father_and_mother_name(self, event): """ Return the father and mother name of a family event """ dbstate = self.dbstate family_list = [ dbstate.db.get_family_from_handle(ref_handle) for (ref_type, ref_handle) in dbstate.db.find_backlink_handles(event.handle) if ref_type == 'Family' ] fnam = mnam = _("Unknown") if family_list: for family in family_list: handle = family.get_father_handle() father = dbstate.db.get_person_from_handle(handle) handle = family.get_mother_handle() mother = dbstate.db.get_person_from_handle(handle) fnam = _nd.display(father) if father else _("Unknown") mnam = _nd.display(mother) if mother else _("Unknown") return (fnam, mnam)
def fill_family(self): for handle in self.family_list: family = self.dbstate.db.get_family_from_handle(handle) fhandle = family.get_father_handle() mhandle = family.get_mother_handle() name = "" if fhandle and fhandle != self.person.handle: spouse = self.dbstate.db.get_person_from_handle(fhandle) if spouse: name = name_displayer.display(spouse) elif mhandle: spouse = self.dbstate.db.get_person_from_handle(mhandle) if spouse: name = name_displayer.display(spouse) reltype = str(family.get_relationship()) self.fmodel.add([name, reltype, handle])
def add_to_tree(self, parent_id, sib_id, person_handle): item_id = self.model.insert_after(parent_id, sib_id) person = self.db.get_person_from_handle(person_handle) self.model.set(item_id, 0, name_displayer.display(person)) self.model.set(item_id, 1, person_handle) prev_id = None for family_handle in person.get_family_handle_list(): family = self.db.get_family_from_handle(family_handle) for child_ref in family.get_child_ref_list(): prev_id = self.add_to_tree(item_id, prev_id, child_ref.ref) return item_id
def load_parent(self, handle, name_obj, birth_obj, birth_label, death_obj, death_label, btn_index, btn_add, btn_del, btn_edit): # is a parent used here: is_used = handle is not None # now we display the area: if is_used: db = self.db person = db.get_person_from_handle(handle) name = "%s [%s]" % (name_displayer.display(person), person.gramps_id) birth = get_birth_or_fallback(db, person) self.callman.register_handles({'person': [handle]}) if birth: #if event changes it view needs to update self.callman.register_handles({'event': [birth.get_handle()]}) birth_label.set_label("%s:" % birth.get_type()) death = get_death_or_fallback(db, person) if death: #if event changes it view needs to update self.callman.register_handles({'event': [death.get_handle()]}) death_label.set_label("%s:" % death.get_type()) btn_edit.set_tooltip_text(_('Edit %s') % name) btn_index.hide() btn_add.hide() btn_del.show() btn_edit.show() else: name = "" birth = None death = None btn_index.show() btn_add.show() btn_del.hide() btn_edit.hide() if name_obj: name_obj.set_text(name) if birth: birth_str = DateHandler.displayer.display(birth.get_date_object()) else: birth_str = "" birth_obj.set_text(birth_str) if death: death_str = DateHandler.displayer.display(death.get_date_object()) else: death_str = "" death_obj.set_text(death_str)
def name(self, person): """ Return the name of the person, or and empty string if the person is None @param person: Person object @type person: L{gen.lib.Person} @return: Returns the name of the person based of the program preferences @rtype: unicode """ if type(person) in [str, unicode]: person = self.dbase.get_person_from_handle(person) assert(isinstance(person, (gen.lib.Person, NoneType))) if person: return name_displayer.display(person) else: return u''
def _setup_fields(self): if self.obj.ref: p = self.dbstate.db.get_person_from_handle(self.obj.ref) self.person_label.set_text(name_displayer.display(p)) self.street = MonitoredEntry( self.top.get_object("relationship"), self.obj.set_relation, self.obj.get_relation, self.db.readonly) self.priv = PrivacyButton( self.top.get_object("private"), self.obj, self.db.readonly)
def remove(self, obj): """ Remove a person from the database. """ for sel in self.selected_handles(): person = self.dbstate.db.get_person_from_handle(sel) self.active_person = person name = name_displayer.display(person) msg = _('Deleting the person will remove the person ' 'from the database.') msg = "%s %s" % (msg, Utils.data_recover_msg) QuestionDialog(_('Delete %s?') % name, msg, _('_Delete Person'), self.delete_person_response)
def main(self): active_handle = self.get_active('Person') if not active_handle: self.set_text(_("No Active Person selected.")) return self.set_text("") self.center_person = self.dbstate.db.get_person_from_handle( active_handle) if self.center_person is None: return name = name_displayer.display(self.center_person) # feature request 2356: avoid genitive form title = _("Descendants of %s") % name self.append_text(title) self.append_text("\n\n") self.dump(1, self.center_person) self.append_text("", scroll_to="begin")
def _get_spouse_data(self, data): spouses_names = u"" for family_handle in data[COLUMN_FAMILY]: family = self.db.get_family_from_handle(family_handle) for spouse_id in [ family.get_father_handle(), family.get_mother_handle() ]: if not spouse_id: continue if spouse_id == data[0]: continue spouse = self.db.get_person_from_handle(spouse_id) if spouses_names: spouses_names += ", " spouses_names += name_displayer.display(spouse) return spouses_names
def display_person(self, active_person): """ Display details of the active person. """ self.load_person_image(active_person) self.name.set_text(name_displayer.display(active_person)) self.clear_table() self.display_alternate_names(active_person) self.display_parents(active_person) self.display_separator() self.display_type(active_person, EventType(EventType.BIRTH)) self.display_type(active_person, EventType(EventType.BAPTISM)) self.display_type(active_person, EventType(EventType.DEATH)) self.display_type(active_person, EventType(EventType.BURIAL)) self.display_separator() self.display_attribute(active_person, _('Occupation')) self.display_attribute(active_person, _('Title')) self.display_attribute(active_person, _('Religion'))