示例#1
0
def run(database, document, *args, **kwargs):
    """
    Loops through the families that the person is a child in, and display
    the information about the other children.
    """
    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)
    stab = QuickTable(sdb)
    # display the title
    sdoc.title(_("All Names of All People"))
    sdoc.paragraph("")
    matches = 0
    stab.columns(_("Name"), _("Primary Name"), _("Name Type"))
    names = [] # name, person
    for person in database.iter_people():
        primary_name = person.get_primary_name()
        if primary_name:
            names += [(nd.display_name(primary_name),
                       person,
                       str(primary_name.get_type()))]
        names += [(nd.display_name(name),
                   person,
                   str(name.get_type())) for name in
                  person.get_alternate_names()]

    matches = 0
    for (name, person, name_type) in sorted(names, key=lambda x: x[0]):
        stab.row(name, person, name_type)
        matches += 1
    sdoc.paragraph(_("Total names %d") % matches)
    sdoc.paragraph("")
    stab.write(sdoc)
示例#2
0
    def __init__(self, dbstate, uistate, handle1, handle2, cb_update=None,
            expand_context_info=True):
        ManagedWindow.__init__(self, uistate, [], self.__class__)
        self.database = dbstate.db
        self.pr1 = self.database.get_person_from_handle(handle1)
        self.pr2 = self.database.get_person_from_handle(handle2)
        self.update = cb_update

        self.define_glade('mergeperson', _GLADE_FILE)
        self.set_window(self._gladeobj.toplevel,
                        self.get_widget("person_title"),
                        _("Merge People"))

        # Detailed selection widgets
        name1 = name_displayer.display_name(self.pr1.get_primary_name())
        name2 = name_displayer.display_name(self.pr2.get_primary_name())
        entry1 = self.get_widget("name1")
        entry2 = self.get_widget("name2")
        entry1.set_text(name1)
        entry2.set_text(name2)
        if entry1.get_text() == entry2.get_text():
            for widget_name in ('name1', 'name2', 'name_btn1', 'name_btn2'):
                self.get_widget(widget_name).set_sensitive(False)

        entry1 = self.get_widget("gender1")
        entry2 = self.get_widget("gender2")
        entry1.set_text(sex[self.pr1.get_gender()])
        entry2.set_text(sex[self.pr2.get_gender()])
        if entry1.get_text() == entry2.get_text():
            for widget_name in ('gender1', 'gender2', 'gender_btn1',
                    'gender_btn2'):
                self.get_widget(widget_name).set_sensitive(False)

        gramps1 = self.pr1.get_gramps_id()
        gramps2 = self.pr2.get_gramps_id()
        entry1 = self.get_widget("gramps1")
        entry2 = self.get_widget("gramps2")
        entry1.set_text(gramps1)
        entry2.set_text(gramps2)
        if entry1.get_text() == entry2.get_text():
            for widget_name in ('gramps1', 'gramps2', 'gramps_btn1',
                    'gramps_btn2'):
                self.get_widget(widget_name).set_sensitive(False)

        # Main window widgets that determine which handle survives
        rbutton1 = self.get_widget("handle_btn1")
        rbutton_label1 = self.get_widget("label_handle_btn1")
        rbutton_label2 = self.get_widget("label_handle_btn2")
        rbutton_label1.set_label(name1 + " [" + gramps1 + "]")
        rbutton_label2.set_label(name2 + " [" + gramps2 + "]")
        rbutton1.connect("toggled", self.on_handle1_toggled)
        expander2 = self.get_widget("expander2")
        self.expander_handler = expander2.connect("notify::expanded",
                                                  self.cb_expander2_activated)
        expander2.set_expanded(expand_context_info)

        self.connect_button("person_help", self.cb_help)
        self.connect_button("person_ok", self.cb_merge)
        self.connect_button("person_cancel", self.close)
        self.show()
    def main(self):
        """
        Main method.
        """
        self.total_relations_found = 0
        yield True
        self.default_person = self.dbstate.db.get_default_person()
        active_person = self.get_active_object("Person")
        if self.default_person == None:
            self.set_text(_("No Home Person set."))
            return
        if active_person == None:
            self.set_text(_("No Active Person set."))
            return
        self.cache = set()
        self.queue = [(self.default_person.handle,
                       (None, (_("self"), self.default_person.handle, [])))]
        default_name = self.default_person.get_primary_name()
        active_name = active_person.get_primary_name()
        self.set_text("")
        self.render_text((_("Looking for relationship between\n") +
                           _("  <b>%s</b> (Home Person) and\n") +
                           _("  <b>%s</b> (Active Person)...\n")) %
                         (name_displayer.display_name(default_name),
                          name_displayer.display_name(active_name)))
        yield True
        relationship = self.relationship_calc.get_one_relationship(
            self.dbstate.db, self.default_person, active_person)
        while self.queue:
            current_handle, current_path = self.queue.pop(0)
            if current_handle == active_person.handle:
                self.total_relations_found += 1
                self.append_text(_("Found relation #%d: \n   ") % self.total_relations_found)

                self.link(name_displayer.display_name(active_name), "Person", active_person.handle)
                if relationship:
                    self.append_text(" [%s]" % relationship)
                self.selected_handles.clear()
                self.selected_handles.add(active_person.handle)
                self.pretty_print(current_path)
                self.append_text("\n")
                if self.default_person.handle != active_person.handle:
                    self.append_text(_("Paused.\nPress Continue to search for additional relations.\n"))
                    self.pause()
                    yield False
                else:
                    break
            elif current_handle in self.cache:
                continue
            self.cache.add(current_handle)
            relatives = self.get_relatives(current_handle, current_path)
            for items in relatives:
                person_handle = items[0]
                path = items[1]
                if person_handle is not None: # and person_handle not in self.cache:
                    self.queue.append((person_handle, path))
            yield True
        self.append_text(_("\nSearch completed. %d relations found.") % self.total_relations_found)
        yield False
    def pretty_print(self, path):
        """
        Print a path to a person, with links.
        """
        # (path, (relation_text, handle, [p1, [p2]]))
        more_path = path[0]
        text = path[1][0]
        handle = path[1][1]
        parents = path[1][2:]
        person = self.dbstate.db.get_person_from_handle(handle)
        if person is None:
            return
        name = person.get_primary_name()
        self.selected_handles.add(person.handle)
        for parent in parents:
            if parent:
                p = self.dbstate.db.get_person_from_handle(parent)
                if p:
                    self.selected_handles.add(p.handle)

        if text != "self":
            self.append_text(_("\n   %s of ") % text)
            self.link(name_displayer.display_name(name), "Person", handle)
            relationship = self.relationship_calc.get_one_relationship(
                self.dbstate.db, self.default_person, person)
            if relationship:
                self.append_text(" [%s]" % relationship)
            if more_path is not None:
                self.pretty_print(more_path)
示例#5
0
 def get_name(self, person, maiden_name = None):
     """ Return person's name, unless maiden_name given, 
         unless married_name listed. 
     """
     # Get all of a person's names:
     primary_name = person.get_primary_name()
     married_name = None
     names = [primary_name] + person.get_alternate_names()
     for name in names:
         if int(name.get_type()) == NameType.MARRIED:
             married_name = name
             break # use first
     # Now, decide which to use:
     if maiden_name is not None:
         if married_name is not None:
             name = Name(married_name)
         else:
             name = Name(primary_name)
             surname = Surname()
             surname.set_surname(maiden_name)
             name.set_surname_list([surname])
     else:
         name = Name(primary_name)
     name.set_display_as(self.name_format)
     return _nd.display_name(name)
示例#6
0
 def name_from_gramps_id(self, gramps_id):
     if self.namespace == 'Person':
         person = self.db.get_person_from_gramps_id(gramps_id)
         name = _nd.display_name(person.get_primary_name())
     elif self.namespace == 'Family':
         family = self.db.get_family_from_gramps_id(gramps_id)
         name = family_name(family, self.db)
     elif self.namespace == 'Event':
         event = self.db.get_event_from_gramps_id(gramps_id)
         name = str(event.get_type)
     elif self.namespace == 'Place':
         place = self.db.get_place_from_gramps_id(gramps_id)
         name = _pd.display(self.db, place)
     elif self.namespace == 'Source':
         source = self.db.get_source_from_gramps_id(gramps_id)
         name = source.get_title()
     elif self.namespace == 'Citation':
         citation = self.db.get_citation_from_gramps_id(gramps_id)
         name = citation.get_page()
     elif self.namespace == 'Media':
         obj = self.db.get_media_from_gramps_id(gramps_id)
         name = obj.get_path()
     elif self.namespace == 'Repository':
         repo = self.db.get_repository_from_gramps_id(gramps_id)
         name = repo.get_name()
     elif self.namespace == 'Note':
         note = self.db.get_note_from_gramps_id(gramps_id)
         name = note.get()
     return name
 def main(self):
     self.set_text(_("Processing..."))
     database = self.dbstate.db
     personList = database.iter_people()
     result = []
     text = ''
     today = Today()
     for cnt, person in enumerate(personList):
         birth_ref = person.get_birth_ref()
         death_ref = person.get_death_ref()
         if (birth_ref and not death_ref):
             birth = database.get_event_from_handle(birth_ref.ref)
             birth_date = birth.get_date_object()
             if birth_date.is_regular():
                 birthday_this_year = Date(today.get_year(), birth_date.get_month(), birth_date.get_day())
                 next_age = birthday_this_year - birth_date
                 # (0 year, months, days) between now and birthday of this year (positive if passed):
                 diff = today - birthday_this_year
                 # about number of days the diff is:
                 diff_days = diff[1] * 30 + diff[2]
                 if next_age[0] < self.max_age:
                     if diff_days <= 0: #not yet passed
                         result.append((diff_days, next_age, birth_date, person))
                     else: #passed; add it for next year's birthday
                         result.append((diff_days - 365, next_age[0] + 1, birth_date, person))
     # Reverse sort on number of days from now:
     result.sort(key=lambda item: -item[0])
     self.clear_text()
     for diff, age, date, person in result:
         name = person.get_primary_name()
         self.append_text("%s: " % gramps.gen.datehandler.displayer.display(date))
         self.link(name_displayer.display_name(name), "Person", person.handle)
         self.append_text(" (%s)\n" % age)
     self.append_text("", scroll_to="begin")
示例#8
0
def _get_styled(name, callname, placeholder=False,
                trans_text=glocale.translation.sgettext, name_format=None):
    """
    Return a StyledText object with the name formatted according to the
    parameters:

    @param callname: whether the callname should be used instead of the first
        name (CALLNAME_REPLACE), underlined within the first name
        (CALLNAME_UNDERLINE_ADD) or not used at all (CALLNAME_DONTUSE).
    @param placeholder: whether a series of underscores should be inserted as a
        placeholder if first name or surname are missing.
    @param trans_text: allow deferred translation of strings
    @type trans_text: a GrampsLocale sgettext instance
    trans_text is a defined keyword (see po/update_po.py, po/genpot.sh)
    :param name_format: optional format to control display of person's name
    :type name_format: None or int
    """

    # Make a copy of the name object so we don't mess around with the real
    # data.
    n = Name(source=name)

    # Insert placeholders.
    if placeholder:
        if not n.first_name:
            n.first_name = "____________"
        if not n.surname:
            n.surname = "____________"

    if n.call:
        if callname == CALLNAME_REPLACE:
            # Replace first name with call name.
            n.first_name = n.call
        elif callname == CALLNAME_UNDERLINE_ADD:
            if n.call not in n.first_name:
                # Add call name to first name.
                # translators: used in French+Russian, ignore otherwise
                n.first_name = trans_text('"%(callname)s" (%(firstname)s)') % {
                                             'callname':  n.call,
                                             'firstname': n.first_name }

    real_format = name_displayer.get_default_format()
    if name_format is not None:
        name_displayer.set_default_format(name_format)
    text = name_displayer.display_name(n)
    name_displayer.set_default_format(real_format)
    tags = []

    if n.call:
        if callname == CALLNAME_UNDERLINE_ADD:
            # "name" in next line is on purpose: only underline the call name
            # if it was a part of the *original* first name
            if n.call in name.first_name:
                # Underline call name
                callpos = text.find(n.call)
                tags = [StyledTextTag(StyledTextTagType.UNDERLINE, True,
                            [(callpos, callpos + len(n.call))])]

    return StyledText(text, tags)
示例#9
0
 def build_menu_names(self, name):
     if name:
         ntext = name_displayer.display_name(name)
         submenu_label = '%s: %s' % (_('Name'), ntext)
     else:
         submenu_label = _('New Name')
     menu_label = _('Name Editor')
     return (menu_label,submenu_label)
示例#10
0
 def build_menu_names(self, name):
     if name:
         ntext = name_displayer.display_name(name)
         submenu_label = _('%(str1)s: %(str2)s') % {'str1' : _('Name'),
                                                    'str2' : ntext}
     else:
         submenu_label = _('New Name')
     menu_label = _('Name Editor')
     return (menu_label,submenu_label)
示例#11
0
 def column_mother(self, data):
     handle = data[0]
     cached, value = self.get_cached_value(handle, "MOTHER")
     if not cached:
         if data[3]:
             person = self.db.get_person_from_handle(data[3])
             value = name_displayer.display_name(person.primary_name)
         else:
             value = ""
         self.set_cached_value(handle, "MOTHER", value)
     return value
示例#12
0
def _get_styled(name, callname, placeholder=False, name_format=None):
    """
    Return a StyledText object with the name formatted according to the
    parameters:

    @param callname: whether the callname should be used instead of the first
        name (CALLNAME_REPLACE), underlined within the first name
        (CALLNAME_UNDERLINE_ADD) or not used at all (CALLNAME_DONTUSE).
    @param placeholder: whether a series of underscores should be inserted as a
        placeholder if first name or surname are missing.
    """

    # Make a copy of the name object so we don't mess around with the real
    # data.
    n = Name(source=name)

    # Insert placeholders.
    if placeholder:
        if not n.first_name:
            n.first_name = "____________"
        if not n.surname:
            n.surname = "____________"

    if n.call:
        if callname == CALLNAME_REPLACE:
            # Replace first name with call name.
            n.first_name = n.call
        elif callname == CALLNAME_UNDERLINE_ADD:
            if n.call not in n.first_name:
                # Add call name to first name.
                n.first_name = "\"%(call)s\" (%(first)s)" % {
                        'call':  n.call,
                        'first': n.first_name}

    real_format = name_displayer.get_default_format()
    if name_format is not None:
        name_displayer.set_default_format(name_format)
    text = name_displayer.display_name(n)
    name_displayer.set_default_format(real_format)
    tags = []

    if n.call:
        if callname == CALLNAME_UNDERLINE_ADD:
            # "name" in next line is on purpose: only underline the call name
            # if it was a part of the *original* first name
            if n.call in name.first_name:
                # Underline call name
                callpos = text.find(n.call)
                tags = [StyledTextTag(StyledTextTagType.UNDERLINE, True,
                            [(callpos, callpos + len(n.call))])]

    return StyledText(text, tags)
示例#13
0
 def display_alternate_names(self, active_person):
     """
     Display other names of the person
     """
     try:
         nlist = active_person.get_alternate_names()
         if len(nlist) > 0:
             for altname in nlist:
                 name_type = str(altname.get_type())
                 text = name_displayer.display_name(altname)
                 self.add_row(name_type, text)
             self.display_separator()
     except:
         pass
示例#14
0
 def row(self, index, name):
     """
     Returns the row of the model in group index, and name as a
     list
     """
     return [name_displayer.display_name(name),
             str(name.get_type()),
             (index, name),
             self.colweight(index),
             name.get_group_as(),
             self.hassource(name),
             self.notepreview(name),
             name.get_privacy(),
            ]
示例#15
0
文件: whatsnext.py 项目: pat49/gramps
    def __process_person_2(self, person):

        missingbits = []

        primary_name = person.get_primary_name()
        name = name_displayer.display_name(primary_name)
        if not name:
            name = _("(person with unknown name)")

        if self.__person_complete_handle is not None and self.__person_complete_handle not in person.get_tag_list():
            missingbits.append(_("person not complete"))

        if missingbits:
            self.link(name, "Person", person.get_handle())
            self.append_text(_(": %(list)s\n") % {"list": _(", ").join(missingbits)})
            self.__counter += 1
    def main(self):
        """Main function of the Birthdays gramplet"""
        self.set_text(_("Processing..."))
        database = self.dbstate.db
        person_list = database.iter_people()
        self.result = []

        ignore_tag_handle = ""
        only_tag_handle = ""
        tag_name_ignore = self.opt_ignore.get_value()
        tag_name_only = self.opt_only.get_value()
        tag_handles = database.get_tag_handles()
        for handle in tag_handles:
            tag = database.get_tag_from_handle(handle)
            # overwrite ignore_handle and only_handle to user selection
            # if a handle is selected
            if tag_name_ignore == tag.get_name():
                ignore_tag_handle = tag.get_handle()
            if tag_name_only == tag.get_name():
                only_tag_handle = tag.get_handle()

        for person in list(person_list):
            pers_tag_handles = person.get_tag_list()
            if ignore_tag_handle in pers_tag_handles:
                pass  # ignore person
            elif only_tag_handle in pers_tag_handles or only_tag_handle == "":
                # calculate age and days until birthday
                self.__calculate(database, person)

        # Reverse sort on number of days from now:
        self.result.sort(key=lambda item: -item[0])
        self.clear_text()

        # handle text shown in gramplet
        for diff, age, date, person in self.result:
            name = person.get_primary_name()
            displayer = gramps.gen.datehandler.displayer
            self.append_text("{}: ".format(displayer.display(date)))
            self.link(name_displayer.display_name(name), "Person",
                      person.handle)
            self.append_text(" ({})\n".format(age))
        self.append_text("", scroll_to="begin")
示例#17
0
    def check_person(self, person_handle, search_words):
        """
        Check if person name and id contains all words of the search.
        """
        try:
            # try used for not person handles
            # and other problems to get person
            person = self.dbstate.db.get_person_from_handle(person_handle)
        except:
            return False

        if person:
            name = displayer.display_name(person.get_primary_name()).lower()
            search_str = name + person.gramps_id.lower()
            for word in search_words:
                if word not in search_str:
                    # if some of words not present in the person name
                    return False
            return person
        return False
示例#18
0
    def __process_person(self, person, append_list):

        if person.get_handle() in self.__processed_persons:
            return

        self.__processed_persons[person.get_handle()] = True

        missingbits = []

        primary_name = person.get_primary_name()

        if not primary_name.get_first_name():
            missingbits.append(_("first name unknown"))

        if not primary_name.get_surname():
            missingbits.append(_("surname unknown"))

        name = name_displayer.display_name(primary_name)
        if not name:
            name = _("(person with unknown name)")

        has_birth = False

        for event_ref in person.get_primary_event_ref_list():
            event = self.dbstate.db.get_event_from_handle(event_ref.ref)
            if event.get_type() not in [EventType.BIRTH, EventType.DEATH]:
                continue
            missingbits.extend(self.__process_event(event))
            if event.get_type() == EventType.BIRTH:
                has_birth = True

        if not has_birth:
            missingbits.append(_("birth event missing"))

        if missingbits:
            self.link(name, 'Person', person.get_handle())
            self.append_text(_(": %(list)s\n") % {
                'list': _(", ").join(missingbits)})
            self.__counter += 1

        append_list.append(person)
示例#19
0
    def __process_person(self, person, append_list):

        if person.get_handle() in self.__processed_persons:
            return

        self.__processed_persons[person.get_handle()] = True

        missingbits = []

        primary_name = person.get_primary_name()

        if not primary_name.get_first_name():
            missingbits.append(_("first name unknown"))

        if not primary_name.get_surname():
            missingbits.append(_("surname unknown"))

        name = name_displayer.display_name(primary_name)
        if not name:
            name = _("(person with unknown name)")

        has_birth = False

        for event_ref in person.get_primary_event_ref_list():
            event = self.dbstate.db.get_event_from_handle(event_ref.ref)
            if event.get_type() not in [EventType.BIRTH, EventType.DEATH]:
                continue
            missingbits.extend(self.__process_event(event))
            if event.get_type() == EventType.BIRTH:
                has_birth = True

        if not has_birth:
            missingbits.append(_("birth event missing"))

        if missingbits:
            self.link(name, 'Person', person.get_handle())
            self.append_text(
                _(": %(list)s\n") % {'list': _(", ").join(missingbits)})
            self.__counter += 1

        append_list.append(person)
示例#20
0
 def main(self):
     self.set_text(_("Processing..."))
     database = self.dbstate.db
     personList = database.iter_people()
     result = []
     text = ''
     today = Today()
     for cnt, person in enumerate(personList):
         birth_ref = person.get_birth_ref()
         death_ref = person.get_death_ref()
         if (birth_ref and not death_ref):
             birth = database.get_event_from_handle(birth_ref.ref)
             birth_date = birth.get_date_object()
             if birth_date.is_regular():
                 birthday_this_year = Date(today.get_year(),
                                           birth_date.get_month(),
                                           birth_date.get_day())
                 next_age = birthday_this_year - birth_date
                 # (0 year, months, days) between now and birthday of this year (positive if passed):
                 diff = today - birthday_this_year
                 # about number of days the diff is:
                 diff_days = diff[1] * 30 + diff[2]
                 if next_age[0] < self.max_age:
                     if diff_days <= 0:  #not yet passed
                         result.append(
                             (diff_days, next_age, birth_date, person))
                     else:  #passed; add it for next year's birthday
                         result.append((diff_days - 365, next_age[0] + 1,
                                        birth_date, person))
     # Reverse sort on number of days from now:
     result.sort(key=lambda item: -item[0])
     self.clear_text()
     for diff, age, date, person in result:
         name = person.get_primary_name()
         self.append_text("%s: " %
                          gramps.gen.datehandler.displayer.display(date))
         self.link(name_displayer.display_name(name), "Person",
                   person.handle)
         self.append_text(" (%s)\n" % age)
     self.append_text("", scroll_to="begin")
示例#21
0
 def column_mother(self, data):
     if data[3]:
         person = self.db.get_person_from_handle(data[3])
         return name_displayer.display_name(person.primary_name)
     else:
         return ""
示例#22
0
    def __init__(self,
                 dbstate,
                 uistate,
                 handle1,
                 handle2,
                 cb_update=None,
                 expand_context_info=True):
        ManagedWindow.__init__(self, uistate, [], self.__class__)
        self.database = dbstate.db
        self.pr1 = self.database.get_person_from_handle(handle1)
        self.pr2 = self.database.get_person_from_handle(handle2)
        self.update = cb_update

        self.define_glade('mergeperson', _GLADE_FILE)
        self.set_window(self._gladeobj.toplevel,
                        self.get_widget("person_title"), _("Merge People"))

        # Detailed selection widgets
        name1 = name_displayer.display_name(self.pr1.get_primary_name())
        name2 = name_displayer.display_name(self.pr2.get_primary_name())
        entry1 = self.get_widget("name1")
        entry2 = self.get_widget("name2")
        entry1.set_text(name1)
        entry2.set_text(name2)
        if entry1.get_text() == entry2.get_text():
            for widget_name in ('name1', 'name2', 'name_btn1', 'name_btn2'):
                self.get_widget(widget_name).set_sensitive(False)

        entry1 = self.get_widget("gender1")
        entry2 = self.get_widget("gender2")
        entry1.set_text(sex[self.pr1.get_gender()])
        entry2.set_text(sex[self.pr2.get_gender()])
        if entry1.get_text() == entry2.get_text():
            for widget_name in ('gender1', 'gender2', 'gender_btn1',
                                'gender_btn2'):
                self.get_widget(widget_name).set_sensitive(False)

        gramps1 = self.pr1.get_gramps_id()
        gramps2 = self.pr2.get_gramps_id()
        entry1 = self.get_widget("gramps1")
        entry2 = self.get_widget("gramps2")
        entry1.set_text(gramps1)
        entry2.set_text(gramps2)
        if entry1.get_text() == entry2.get_text():
            for widget_name in ('gramps1', 'gramps2', 'gramps_btn1',
                                'gramps_btn2'):
                self.get_widget(widget_name).set_sensitive(False)

        # Main window widgets that determine which handle survives
        rbutton1 = self.get_widget("handle_btn1")
        rbutton_label1 = self.get_widget("label_handle_btn1")
        rbutton_label2 = self.get_widget("label_handle_btn2")
        rbutton_label1.set_label(name1 + " [" + gramps1 + "]")
        rbutton_label2.set_label(name2 + " [" + gramps2 + "]")
        rbutton1.connect("toggled", self.on_handle1_toggled)
        expander2 = self.get_widget("expander2")
        self.expander_handler = expander2.connect("notify::expanded",
                                                  self.cb_expander2_activated)
        expander2.set_expanded(expand_context_info)

        self.connect_button("person_help", self.cb_help)
        self.connect_button("person_ok", self.cb_merge)
        self.connect_button("person_cancel", self.close)
        self.show()
示例#23
0
    def display(self, tobj, person):
        """Fill text buffer tobj with detailed info on person person."""
        normal = tobj.create_tag()
        normal.set_property('indent', 10)
        normal.set_property('pixels-above-lines', 1)
        normal.set_property('pixels-below-lines', 1)
        indent = tobj.create_tag()
        indent.set_property('indent', 30)
        indent.set_property('pixels-above-lines', 1)
        indent.set_property('pixels-below-lines', 1)
        title = tobj.create_tag()
        title.set_property('weight', Pango.Weight.BOLD)
        title.set_property('scale', 1.2)
        self.add(tobj, title, name_displayer.display(person))
        self.add(tobj, normal, "%s:\t%s" % (_('ID'), person.get_gramps_id()))
        self.add(tobj, normal,
                 "%s:\t%s" % (_('Gender'), sex[person.get_gender()]))
        bref = person.get_birth_ref()
        if bref:
            self.add(tobj, normal,
                     "%s:\t%s" % (_('Birth'), self.get_event_info(bref.ref)))
        dref = person.get_death_ref()
        if dref:
            self.add(tobj, normal,
                     "%s:\t%s" % (_('Death'), self.get_event_info(dref.ref)))

        nlist = person.get_alternate_names()
        if len(nlist) > 0:
            self.add(tobj, title, _("Alternate Names"))
            for name in nlist:
                self.add(tobj, normal, name_displayer.display_name(name))

        elist = person.get_event_ref_list()
        if len(elist) > 0:
            self.add(tobj, title, _("Events"))
            for event_ref in person.get_event_ref_list():
                event_handle = event_ref.ref
                role = event_ref.get_role()
                name = str(
                    self.database.get_event_from_handle(
                        event_handle).get_type())
                if role.is_primary():
                    self.add(
                        tobj, normal,
                        "%s:\t%s" % (name, self.get_event_info(event_handle)))
                else:
                    self.add(
                        tobj, normal, "%s (%s):\t%s" %
                        (name, role, self.get_event_info(event_handle)))
        plist = person.get_parent_family_handle_list()

        if len(plist) > 0:
            self.add(tobj, title, _("Parents"))
            for fid in person.get_parent_family_handle_list():
                (fname, mname, gid) = self.get_parent_info(fid)
                self.add(tobj, normal, "%s:\t%s" % (_('Family ID'), gid))
                if fname:
                    self.add(tobj, indent, "%s:\t%s" % (_('Father'), fname))
                if mname:
                    self.add(tobj, indent, "%s:\t%s" % (_('Mother'), mname))
        else:
            self.add(tobj, normal, _("No parents found"))

        self.add(tobj, title, _("Spouses"))
        slist = person.get_family_handle_list()
        if len(slist) > 0:
            for fid in slist:
                (fname, mname, pid) = self.get_parent_info(fid)
                family = self.database.get_family_from_handle(fid)
                self.add(tobj, normal, "%s:\t%s" % (_('Family ID'), pid))
                spouse_id = ReportUtils.find_spouse(person, family)
                if spouse_id:
                    spouse = self.database.get_person_from_handle(spouse_id)
                    self.add(tobj, indent,
                             "%s:\t%s" % (_('Spouse'), name_of(spouse)))
                relstr = str(family.get_relationship())
                self.add(tobj, indent, "%s:\t%s" % (_('Type'), relstr))
                event = ReportUtils.find_marriage(self.database, family)
                if event:
                    self.add(
                        tobj, indent,
                        "%s:\t%s" % (_('Marriage'),
                                     self.get_event_info(event.get_handle())))
                for child_ref in family.get_child_ref_list():
                    child = self.database.get_person_from_handle(child_ref.ref)
                    self.add(tobj, indent,
                             "%s:\t%s" % (_('Child'), name_of(child)))
        else:
            self.add(tobj, normal, _("No spouses or children found"))

        alist = person.get_address_list()
        if len(alist) > 0:
            self.add(tobj, title, _("Addresses"))
            for addr in alist:
                location = ", ".join([
                    addr.get_street(),
                    addr.get_city(),
                    addr.get_state(),
                    addr.get_country(),
                    addr.get_postal_code(),
                    addr.get_phone()
                ])
                self.add(tobj, normal, location.strip())
示例#24
0
    def display(self, tobj, person):
        """Fill text buffer tobj with detailed info on person person."""
        normal = tobj.create_tag()
        normal.set_property('indent', 10)
        normal.set_property('pixels-above-lines', 1)
        normal.set_property('pixels-below-lines', 1)
        indent = tobj.create_tag()
        indent.set_property('indent', 30)
        indent.set_property('pixels-above-lines', 1)
        indent.set_property('pixels-below-lines', 1)
        title = tobj.create_tag()
        title.set_property('weight', Pango.Weight.BOLD)
        title.set_property('scale', 1.2)
        self.add(tobj, title, name_displayer.display(person))
        self.add(tobj, normal, KEYVAL % {
            'key': _('ID'),
            'value': person.get_gramps_id()
        })
        self.add(
            tobj, normal, KEYVAL % {
                'key': _('Gender'),
                'value': sex[person.get_gender()]
            })
        bref = person.get_birth_ref()
        if bref:
            self.add(
                tobj, normal, KEYVAL % {
                    'key': _('Birth'),
                    'value': self.get_event_info(bref.ref)
                })
        dref = person.get_death_ref()
        if dref:
            self.add(
                tobj, normal, KEYVAL % {
                    'key': _('Death'),
                    'value': self.get_event_info(dref.ref)
                })

        nlist = person.get_alternate_names()
        if len(nlist) > 0:
            self.add(tobj, title, _("Alternate Names"))
            for name in nlist:
                self.add(tobj, normal, name_displayer.display_name(name))

        elist = person.get_event_ref_list()
        if len(elist) > 0:
            self.add(tobj, title, _("Events"))
            for event_ref in person.get_event_ref_list():
                event_handle = event_ref.ref
                role = event_ref.get_role()
                name = str(
                    self.database.get_event_from_handle(
                        event_handle).get_type())
                ev_info = self.get_event_info(event_handle)
                if role.is_primary():
                    self.add(tobj, normal, KEYVAL % {
                        'key': name,
                        'value': ev_info
                    })
                else:
                    self.add(
                        tobj,
                        normal,  # translators: needed for French
                        "%(name)s (%(role)s):\t%(info)s" % {
                            'name': name,
                            'role': role,
                            'info': ev_info
                        })
        plist = person.get_parent_family_handle_list()

        if len(plist) > 0:
            self.add(tobj, title, _("Parents"))
            for fid in person.get_parent_family_handle_list():
                (fname, mname, gid) = self.get_parent_info(fid)
                self.add(tobj, normal, KEYVAL % {
                    'key': _('Family ID'),
                    'value': gid
                })
                if fname:
                    self.add(tobj, indent, KEYVAL % {
                        'key': _('Father'),
                        'value': fname
                    })
                if mname:
                    self.add(tobj, indent, KEYVAL % {
                        'key': _('Mother'),
                        'value': mname
                    })
        else:
            self.add(tobj, normal, _("No parents found"))

        self.add(tobj, title, _("Spouses"))
        slist = person.get_family_handle_list()
        if len(slist) > 0:
            for fid in slist:
                (fname, mname, pid) = self.get_parent_info(fid)
                family = self.database.get_family_from_handle(fid)
                self.add(tobj, normal, KEYVAL % {
                    'key': _('Family ID'),
                    'value': pid
                })
                spouse_id = utils.find_spouse(person, family)
                if spouse_id:
                    spouse = self.database.get_person_from_handle(spouse_id)
                    self.add(
                        tobj, indent, KEYVAL % {
                            'key': _('Spouse'),
                            'value': name_of(spouse)
                        })
                relstr = str(family.get_relationship())
                self.add(tobj, indent, KEYVAL % {
                    'key': _('Type'),
                    'value': relstr
                })
                event = utils.find_marriage(self.database, family)
                if event:
                    m_info = self.get_event_info(event.get_handle())
                    self.add(tobj, indent, KEYVAL % {
                        'key': _('Marriage'),
                        'value': m_info
                    })
                for child_ref in family.get_child_ref_list():
                    child = self.database.get_person_from_handle(child_ref.ref)
                    self.add(
                        tobj, indent, KEYVAL % {
                            'key': _('Child'),
                            'value': name_of(child)
                        })
        else:
            self.add(tobj, normal, _("No spouses or children found"))

        alist = person.get_address_list()
        if len(alist) > 0:
            self.add(tobj, title, _("Addresses"))
            for addr in alist:
                # TODO for Arabic, should the next line's comma be translated?
                location = ", ".join([
                    addr.get_street(),
                    addr.get_city(),
                    addr.get_state(),
                    addr.get_country(),
                    addr.get_postal_code(),
                    addr.get_phone()
                ])
                self.add(tobj, normal, location.strip())
示例#25
0
    def familypage(self, report, title, family_handle):
        """
        Create a family page

        @param: report        -- The instance of the main report class for
                                 this report
        @param: title         -- Is the title of the web page
        @param: family_handle -- The handle for the family to add
        """
        family = report.database.get_family_from_handle(family_handle)
        if not family:
            return
        BasePage.__init__(self, report, title, family.get_gramps_id())
        ldatec = family.get_change_time()

        self.bibli = Bibliography()
        self.uplink = True
        family_name = self.report.get_family_name(family)
        self.page_title = family_name

        self.familymappages = report.options["familymappages"]

        output_file, sio = self.report.create_file(family.get_handle(), "fam")
        result = self.write_header(family_name)
        familydetailpage, dummy_head, dummy_body, outerwrapper = result

        # begin FamilyDetaill division
        with Html("div", class_="content",
                  id="RelationshipDetail") as relationshipdetail:
            outerwrapper += relationshipdetail

            # family media list for initial thumbnail
            if self.create_media:
                media_list = family.get_media_list()
                # If Event pages are not being created, then we need to display
                # the family event media here
                if not self.inc_events:
                    for evt_ref in family.get_event_ref_list():
                        event = self.r_db.get_event_from_handle(evt_ref.ref)
                        media_list += event.get_media_list()

            relationshipdetail += Html(
                "h2", self.page_title, inline=True) + (
                    Html('sup') + (Html('small') +
                                   self.get_citation_links(
                                       family.get_citation_list())))

            # display relationships
            families = self.display_family_relationships(family, None)
            if families is not None:
                relationshipdetail += families

            # display additional images as gallery
            if self.create_media and media_list:
                addgallery = self.disp_add_img_as_gallery(media_list, family)
                if addgallery:
                    relationshipdetail += addgallery

            # Narrative subsection
            notelist = family.get_note_list()
            if notelist:
                relationshipdetail += self.display_note_list(notelist, Family)

            # display family LDS ordinance...
            family_lds_ordinance_list = family.get_lds_ord_list()
            if family_lds_ordinance_list:
                relationshipdetail += self.display_lds_ordinance(family)

            # get attribute list
            attrlist = family.get_attribute_list()
            if attrlist:
                attrsection, attrtable = self.display_attribute_header()
                self.display_attr_list(attrlist, attrtable)
                relationshipdetail += attrsection

            # for use in family map pages...
            if self.report.options["familymappages"]:
                name_format = self.report.options['name_format']
                fhandle = mhandle = father = mother = None
                relationshipdetail += Html("h4", _("Family map"), inline=True)
                mapdetail = Html("br")
                fhandle = family.get_father_handle()
                for handle, dummy_url in self.report.fam_link.items():
                    if fhandle == handle:
                        father = self.r_db.get_person_from_handle(fhandle)
                        break
                if father:
                    primary_name = father.get_primary_name()
                    name = Name(primary_name)
                    name.set_display_as(name_format)
                    fname = html_escape(_nd.display_name(name))
                    mapdetail += self.family_map_link_for_parent(fhandle, fname)
                mapdetail += Html("br")
                mhandle = family.get_mother_handle()
                for handle, dummy_url in self.report.fam_link.items():
                    if mhandle == handle:
                        mother = self.r_db.get_person_from_handle(mhandle)
                        break
                if mother:
                    primary_name = mother.get_primary_name()
                    name = Name(primary_name)
                    name.set_display_as(name_format)
                    mname = html_escape(_nd.display_name(name))
                    mapdetail += self.family_map_link_for_parent(mhandle, mname)
                relationshipdetail += mapdetail

            # source references
            srcrefs = self.display_ind_sources(family)
            if srcrefs:
                relationshipdetail += srcrefs

        # add clearline for proper styling
        # add footer section
        footer = self.write_footer(ldatec)
        outerwrapper += (FULLCLEAR, footer)

        # send page out for processing
        # and close the file
        self.xhtml_writer(familydetailpage, output_file, sio, ldatec)
示例#26
0
 def process_person(self, handle, generation, what):
     if generation > self.max_generations:
         return
     person = self.dbstate.db.get_person_from_handle(handle)
     family_list = person.get_parent_family_handle_list()
     if what == "f":
         if len(family_list) > 0:
             family = self.dbstate.db.get_family_from_handle(family_list[0])
             father = family.get_father_handle()
             mother = family.get_mother_handle()
             if father:
                 self.process_person(father, generation + 1, "f")
                 self.set_box(generation, 1)
                 self.process_person(father, generation + 1, "sf")
                 self.process_person(father, generation + 1, "m")
             elif mother:
                 self.set_box(generation, 1)
     elif what[0] == "s":
         boxes = self.get_boxes(generation, what)
         if what[-1] == 'f':
             if self.box_mode == "UTF":
                 boxes = boxes.replace("+", "\u250c")
             else:
                 boxes = boxes.replace("+", "/")
         else:
             if self.box_mode == "UTF":
                 boxes = boxes.replace("+", "\u2514")
             else:
                 boxes = boxes.replace("+", "\\")
         self.append_text(boxes)
         self.link(name_displayer.display_name(person.get_primary_name()),
                   'Person', person.handle,
                   tooltip=_("Click to make active\n") + \
                       _("Right-click to edit"))
         if self.show_dates:
             self.append_text(" ")
             self.render_text(self.info_string(person))
         self.append_text("\n")
         if generation not in self._generations:
             self._generations[generation] = []
         self._generations[generation].append(handle)
     elif what == "a":
         if self.box_mode == "UTF":
             self.append_text("o" + ("\u2500" * 3))
         elif self.box_mode == "ASCII":
             self.append_text("o---")
         self.append_text(
             "%s  " %
             name_displayer.display_name(person.get_primary_name()))
         if self.show_dates:
             self.render_text(self.info_string(person))
         self.append_text("\n")
         if generation not in self._generations:
             self._generations[generation] = []
         self._generations[generation].append(handle)
     elif what == "m":
         if len(family_list) > 0:
             family = self.dbstate.db.get_family_from_handle(family_list[0])
             mother = family.get_mother_handle()
             if mother:
                 self.process_person(mother, generation + 1, "f")
                 self.process_person(mother, generation + 1, "sm")
                 self.set_box(generation, 0)
                 self.process_person(mother, generation + 1, "m")
         self.set_box(generation, 0)  # regardless, turn off line if on
示例#27
0
 def process_person(self, handle, generation, what):
     if generation > self.max_generations:
         return
     person = self.dbstate.db.get_person_from_handle(handle)
     family_list = person.get_parent_family_handle_list()
     if what == "f":
         if len(family_list) > 0:
             family = self.dbstate.db.get_family_from_handle(family_list[0])
             father = family.get_father_handle()
             mother = family.get_mother_handle()
             if father:
                 self.process_person(father, generation + 1, "f")
                 self.set_box(generation, 1)
                 self.process_person(father, generation + 1, "sf")
                 self.process_person(father, generation + 1, "m")
             elif mother:
                 self.set_box(generation, 1)
     elif what[0] == "s":
         boxes = self.get_boxes(generation, what)
         if what[-1] == 'f':
             if self.box_mode == "UTF":
                 boxes = boxes.replace("+", "\u250c")
             else:
                 boxes = boxes.replace("+", "/")
         else:
             if self.box_mode == "UTF":
                 boxes = boxes.replace("+", "\u2514")
             else:
                 boxes = boxes.replace("+", "\\")
         self.append_text(boxes)
         self.link(name_displayer.display_name(person.get_primary_name()),
                   'Person', person.handle,
                   tooltip=_("Click to make active\n") + \
                       _("Right-click to edit"))
         if self.show_dates:
             self.append_text(" ")
             self.render_text(self.info_string(person))
         self.append_text("\n")
         if generation not in self._generations:
             self._generations[generation] = []
         self._generations[generation].append(handle)
     elif what == "a":
         if self.box_mode == "UTF":
             self.append_text("o" + ("\u2500" * 3))
         elif self.box_mode == "ASCII":
             self.append_text("o---")
         self.append_text("%s  " % name_displayer.display_name(person.get_primary_name()))
         if self.show_dates:
             self.render_text(self.info_string(person))
         self.append_text("\n")
         if generation not in self._generations:
             self._generations[generation] = []
         self._generations[generation].append(handle)
     elif what == "m":
         if len(family_list) > 0:
             family = self.dbstate.db.get_family_from_handle(family_list[0])
             mother = family.get_mother_handle()
             if mother:
                 self.process_person(mother, generation + 1, "f")
                 self.process_person(mother, generation + 1, "sm")
                 self.set_box(generation, 0)
                 self.process_person(mother, generation + 1, "m")
         self.set_box(generation, 0) # regardless, turn off line if on
    def main(self):
        """
        Main method.
        """
        self.total_relations_found = 0
        yield True
        self.default_person = self.dbstate.db.get_default_person()
        active_person = self.get_active_object("Person")
        if self.default_person == None:
            self.set_text(_("No Home Person set."))
            return
        if active_person == None:
            self.set_text(_("No Active Person set."))
            return
        self.cache = set()
        self.queue = [(self.default_person.handle,
                       (None, (_("self"), self.default_person.handle, [])))]
        default_name = self.default_person.get_primary_name()
        active_name = active_person.get_primary_name()
        self.set_text("")
        self.render_text((_("Looking for relationship between\n") +
                          _("  <b>%s</b> (Home Person) and\n") +
                          _("  <b>%s</b> (Active Person)...\n")) %
                         (name_displayer.display_name(default_name),
                          name_displayer.display_name(active_name)))
        yield True
        relationship = self.relationship_calc.get_one_relationship(
            self.dbstate.db, self.default_person, active_person)
        while self.queue:
            current_handle, current_path = self.queue.pop(0)
            if current_handle == active_person.handle:
                self.total_relations_found += 1
                self.append_text(
                    _("Found relation #%d: \n   ") %
                    self.total_relations_found)

                self.link(name_displayer.display_name(active_name), "Person",
                          active_person.handle)
                if relationship:
                    self.append_text(" [%s]" % relationship)
                self.selected_handles.clear()
                self.selected_handles.add(active_person.handle)
                self.pretty_print(current_path)
                self.append_text("\n")
                if self.default_person.handle != active_person.handle:
                    self.append_text(
                        _("Paused.\nPress Continue to search for additional relations.\n"
                          ))
                    self.pause()
                    yield False
                else:
                    break
            elif current_handle in self.cache:
                continue
            self.cache.add(current_handle)
            relatives = self.get_relatives(current_handle, current_path)
            for items in relatives:
                person_handle = items[0]
                path = items[1]
                if person_handle is not None:  # and person_handle not in self.cache:
                    self.queue.append((person_handle, path))
            yield True
        self.append_text(
            _("\nSearch completed. %d relations found.") %
            self.total_relations_found)
        yield False
示例#29
0
def _get_styled(name,
                callname,
                placeholder=False,
                trans_text=glocale.translation.sgettext,
                name_format=None):
    """
    Return a StyledText object with the name formatted according to the
    parameters:

    @param callname: whether the callname should be used instead of the first
        name (CALLNAME_REPLACE), underlined within the first name
        (CALLNAME_UNDERLINE_ADD) or not used at all (CALLNAME_DONTUSE).
    @param placeholder: whether a series of underscores should be inserted as a
        placeholder if first name or surname are missing.
    @param trans_text: allow deferred translation of strings
    @type trans_text: a GrampsLocale sgettext instance
    trans_text is a defined keyword (see po/update_po.py, po/genpot.sh)
    :param name_format: optional format to control display of person's name
    :type name_format: None or int
    """

    # Make a copy of the name object so we don't mess around with the real
    # data.
    n = Name(source=name)

    # Insert placeholders.
    if placeholder:
        if not n.first_name:
            n.first_name = "____________"
        if not n.surname:
            n.surname = "____________"

    if n.call:
        if callname == CALLNAME_REPLACE:
            # Replace first name with call name.
            n.first_name = n.call
        elif callname == CALLNAME_UNDERLINE_ADD:
            if n.call not in n.first_name:
                # Add call name to first name.
                # translators: used in French+Russian, ignore otherwise
                n.first_name = trans_text('"%(callname)s" (%(firstname)s)') % {
                    'callname': n.call,
                    'firstname': n.first_name
                }

    real_format = name_displayer.get_default_format()
    if name_format is not None:
        name_displayer.set_default_format(name_format)
    text = name_displayer.display_name(n)
    name_displayer.set_default_format(real_format)
    tags = []

    if n.call:
        if callname == CALLNAME_UNDERLINE_ADD:
            # "name" in next line is on purpose: only underline the call name
            # if it was a part of the *original* first name
            if n.call in name.first_name:
                # Underline call name
                callpos = text.find(n.call)
                tags = [
                    StyledTextTag(StyledTextTagType.UNDERLINE, True,
                                  [(callpos, callpos + len(n.call))])
                ]

    return StyledText(text, tags)
示例#30
0
    def display(self, tobj, person):
        """Fill text buffer tobj with detailed info on person person."""
        normal = tobj.create_tag()
        normal.set_property('indent', 10)
        normal.set_property('pixels-above-lines', 1)
        normal.set_property('pixels-below-lines', 1)
        indent = tobj.create_tag()
        indent.set_property('indent', 30)
        indent.set_property('pixels-above-lines', 1)
        indent.set_property('pixels-below-lines', 1)
        title = tobj.create_tag()
        title.set_property('weight', Pango.Weight.BOLD)
        title.set_property('scale', 1.2)
        self.add(tobj, title, name_displayer.display(person))
        self.add(tobj, normal, KEYVAL % {'key': _('ID'),
                                         'value': person.get_gramps_id()})
        self.add(tobj, normal, KEYVAL % {'key': _('Gender'),
                                         'value': sex[person.get_gender()]})
        bref = person.get_birth_ref()
        if bref:
            self.add(tobj, normal,
                     KEYVAL % {'key': _('Birth'),
                               'value': self.get_event_info(bref.ref)})
        dref = person.get_death_ref()
        if dref:
            self.add(tobj, normal,
                     KEYVAL % {'key': _('Death'),
                               'value': self.get_event_info(dref.ref)})

        nlist = person.get_alternate_names()
        if len(nlist) > 0:
            self.add(tobj, title, _("Alternate Names"))
            for name in nlist:
                self.add(tobj, normal,
                         name_displayer.display_name(name))

        elist = person.get_event_ref_list()
        if len(elist) > 0:
            self.add(tobj, title, _("Events"))
            for event_ref in person.get_event_ref_list():
                event_handle = event_ref.ref
                role = event_ref.get_role()
                name = str(
                    self.database.get_event_from_handle(event_handle).get_type())
                ev_info = self.get_event_info(event_handle)
                if role.is_primary():
                    self.add(tobj, normal,
                             KEYVAL % {'key': name, 'value': ev_info})
                else:
                    self.add(tobj, normal, # translators: needed for French
                             "%(name)s (%(role)s):\t%(info)s"
                                 % {'name': name, 'role': role,
                                    'info': ev_info})
        plist = person.get_parent_family_handle_list()

        if len(plist) > 0:
            self.add(tobj, title, _("Parents"))
            for fid in person.get_parent_family_handle_list():
                (fname, mname, gid) = self.get_parent_info(fid)
                self.add(tobj, normal,
                         KEYVAL % {'key': _('Family ID'), 'value': gid})
                if fname:
                    self.add(tobj, indent,
                             KEYVAL % {'key': _('Father'), 'value': fname})
                if mname:
                    self.add(tobj, indent,
                             KEYVAL % {'key': _('Mother'), 'value': mname})
        else:
            self.add(tobj, normal, _("No parents found"))

        self.add(tobj, title, _("Spouses"))
        slist = person.get_family_handle_list()
        if len(slist) > 0:
            for fid in slist:
                (fname, mname, pid) = self.get_parent_info(fid)
                family = self.database.get_family_from_handle(fid)
                self.add(tobj, normal,
                         KEYVAL % {'key': _('Family ID'), 'value': pid})
                spouse_id = utils.find_spouse(person, family)
                if spouse_id:
                    spouse = self.database.get_person_from_handle(spouse_id)
                    self.add(tobj, indent, KEYVAL % {'key': _('Spouse'),
                                                     'value': name_of(spouse)})
                relstr = str(family.get_relationship())
                self.add(tobj, indent,
                         KEYVAL % {'key': _('Type'), 'value': relstr})
                event = utils.find_marriage(self.database, family)
                if event:
                    m_info = self.get_event_info(event.get_handle())
                    self.add(tobj, indent,
                             KEYVAL % {'key': _('Marriage'), 'value': m_info})
                for child_ref in family.get_child_ref_list():
                    child = self.database.get_person_from_handle(child_ref.ref)
                    self.add(tobj, indent, KEYVAL % {'key': _('Child'),
                                                     'value': name_of(child)})
        else:
            self.add(tobj, normal, _("No spouses or children found"))

        alist = person.get_address_list()
        if len(alist) > 0:
            self.add(tobj, title, _("Addresses"))
            for addr in alist:
                location = ", ".join([addr.get_street(), addr.get_city(),
                                     addr.get_state(), addr.get_country(),
                                     addr.get_postal_code(), addr.get_phone()])
                self.add(tobj, normal, location.strip())
示例#31
0
    def display(self, tobj, person):
        """Fill text buffer tobj with detailed info on person person."""
        normal = tobj.create_tag()
        normal.set_property("indent", 10)
        normal.set_property("pixels-above-lines", 1)
        normal.set_property("pixels-below-lines", 1)
        indent = tobj.create_tag()
        indent.set_property("indent", 30)
        indent.set_property("pixels-above-lines", 1)
        indent.set_property("pixels-below-lines", 1)
        title = tobj.create_tag()
        title.set_property("weight", Pango.Weight.BOLD)
        title.set_property("scale", 1.2)
        self.add(tobj, title, name_displayer.display(person))
        self.add(tobj, normal, "%s:\t%s" % (_("ID"), person.get_gramps_id()))
        self.add(tobj, normal, "%s:\t%s" % (_("Gender"), sex[person.get_gender()]))
        bref = person.get_birth_ref()
        if bref:
            self.add(tobj, normal, "%s:\t%s" % (_("Birth"), self.get_event_info(bref.ref)))
        dref = person.get_death_ref()
        if dref:
            self.add(tobj, normal, "%s:\t%s" % (_("Death"), self.get_event_info(dref.ref)))

        nlist = person.get_alternate_names()
        if len(nlist) > 0:
            self.add(tobj, title, _("Alternate Names"))
            for name in nlist:
                self.add(tobj, normal, name_displayer.display_name(name))

        elist = person.get_event_ref_list()
        if len(elist) > 0:
            self.add(tobj, title, _("Events"))
            for event_ref in person.get_event_ref_list():
                event_handle = event_ref.ref
                role = event_ref.get_role()
                name = str(self.database.get_event_from_handle(event_handle).get_type())
                if role.is_primary():
                    self.add(tobj, normal, "%s:\t%s" % (name, self.get_event_info(event_handle)))
                else:
                    self.add(tobj, normal, "%s (%s):\t%s" % (name, role, self.get_event_info(event_handle)))
        plist = person.get_parent_family_handle_list()

        if len(plist) > 0:
            self.add(tobj, title, _("Parents"))
            for fid in person.get_parent_family_handle_list():
                (fname, mname, gid) = self.get_parent_info(fid)
                self.add(tobj, normal, "%s:\t%s" % (_("Family ID"), gid))
                if fname:
                    self.add(tobj, indent, "%s:\t%s" % (_("Father"), fname))
                if mname:
                    self.add(tobj, indent, "%s:\t%s" % (_("Mother"), mname))
        else:
            self.add(tobj, normal, _("No parents found"))

        self.add(tobj, title, _("Spouses"))
        slist = person.get_family_handle_list()
        if len(slist) > 0:
            for fid in slist:
                (fname, mname, pid) = self.get_parent_info(fid)
                family = self.database.get_family_from_handle(fid)
                self.add(tobj, normal, "%s:\t%s" % (_("Family ID"), pid))
                spouse_id = ReportUtils.find_spouse(person, family)
                if spouse_id:
                    spouse = self.database.get_person_from_handle(spouse_id)
                    self.add(tobj, indent, "%s:\t%s" % (_("Spouse"), name_of(spouse)))
                relstr = str(family.get_relationship())
                self.add(tobj, indent, "%s:\t%s" % (_("Type"), relstr))
                event = ReportUtils.find_marriage(self.database, family)
                if event:
                    self.add(tobj, indent, "%s:\t%s" % (_("Marriage"), self.get_event_info(event.get_handle())))
                for child_ref in family.get_child_ref_list():
                    child = self.database.get_person_from_handle(child_ref.ref)
                    self.add(tobj, indent, "%s:\t%s" % (_("Child"), name_of(child)))
        else:
            self.add(tobj, normal, _("No spouses or children found"))

        alist = person.get_address_list()
        if len(alist) > 0:
            self.add(tobj, title, _("Addresses"))
            for addr in alist:
                location = ", ".join(
                    [
                        addr.get_street(),
                        addr.get_city(),
                        addr.get_state(),
                        addr.get_country(),
                        addr.get_postal_code(),
                        addr.get_phone(),
                    ]
                )
                self.add(tobj, normal, location.strip())
示例#32
0
 def column_mother(self, data):
     if data[3]:
         person = self.db.get_person_from_handle(data[3])
         return name_displayer.display_name(person.primary_name)
     else:
         return ""