Ejemplo n.º 1
0
    def add(self, obj):
        person = Person()

        # attempt to get the current surname
        (model, pathlist) = self.selection.get_selected_rows()
        name = Name()
        #the editor requires a surname
        name.add_surname(Surname())
        name.set_primary_surname(0)
        basepers = None
        if len(pathlist) == 1:
            path = pathlist[0]
            pathids = path.get_indices()
            if len(pathids) == 1:
                path = Gtk.TreePath((pathids[0], 0))
            iter_ = model.get_iter(path)
            handle = model.get_handle_from_iter(iter_)
            basepers = self.dbstate.db.get_person_from_handle(handle)
        if basepers:
            preset_name(basepers, name)
        person.set_primary_name(name)
        try:
            EditPerson(self.dbstate, self.uistate, [], person)
        except WindowActiveError:
            pass
Ejemplo n.º 2
0
    def latin_american_child(self, parent):
        """
        If SURNAME_GUESSING is latin american, then find a child
        and return their name for the father or mother.

        parent = "mother" | "father"
        """
        name = Name()
        #the editor requires a surname
        name.add_surname(Surname())
        name.set_primary_surname(0)
        # for each child, find one with a last name
        for ref in self.obj.get_child_ref_list():
            child = self.db.get_person_from_handle(ref.ref)
            if child:
                pname = child.get_primary_name()
                preset_name(child, name)
                if len(name.get_surname_list()) < 2:
                    return name
                else:
                    #return first for the father, and last for the mother
                    if parent == 'father':
                        name.set_surname_list(name.get_surname_list()[0])
                        return name
                    else:
                        name.set_surname_list(name.get_surname_list()[-1])
                        return name
        return name
Ejemplo n.º 3
0
    def add(self, *obj):
        person = Person()

        # attempt to get the current surname
        (model, pathlist) = self.selection.get_selected_rows()
        name = Name()
        #the editor requires a surname
        name.add_surname(Surname())
        name.set_primary_surname(0)
        basepers = None
        if len(pathlist) == 1:
            path = pathlist[0]
            pathids = path.get_indices()
            if len(pathids) == 1:
                path = Gtk.TreePath((pathids[0], 0))
            iter_ = model.get_iter(path)
            handle = model.get_handle_from_iter(iter_)
            basepers = self.dbstate.db.get_person_from_handle(handle)
        if basepers:
            preset_name(basepers, name)
        person.set_primary_name(name)
        try:
            EditPerson(self.dbstate, self.uistate, [], person)
        except WindowActiveError:
            pass
Ejemplo n.º 4
0
    def latin_american_child(self, parent):
        """
        If SURNAME_GUESSING is latin american, then find a child
        and return their name for the father or mother.

        parent = "mother" | "father"
        """
        name = Name()
        #the editor requires a surname
        name.add_surname(Surname())
        name.set_primary_surname(0)
        # for each child, find one with a last name
        for ref in self.obj.get_child_ref_list():
            child = self.db.get_person_from_handle(ref.ref)
            if child:
                pname = child.get_primary_name()
                preset_name(child, name)
                if len(name.get_surname_list()) < 2:
                    return name
                else:
                    #return first for the father, and last for the mother
                    if parent == 'father':
                        name.set_surname_list(name.get_surname_list()[0])
                        return name
                    else:
                        name.set_surname_list(name.get_surname_list()[-1])
                        return name
        return name
Ejemplo n.º 5
0
 def north_american(self):
     """
     Child inherits name from father
     """
     name = Name()
     #the editor requires a surname
     name.add_surname(Surname())
     name.set_primary_surname(0)
     father_handle = self.family.get_father_handle()
     if father_handle:
         father = self.dbstate.db.get_person_from_handle(father_handle)
         preset_name(father, name)
     return name
Ejemplo n.º 6
0
 def north_american(self):
     """
     Child inherits name from father
     """
     name = Name()
     #the editor requires a surname
     name.add_surname(Surname())
     name.set_primary_surname(0)
     father_handle = self.family.get_father_handle()
     if father_handle:
         father = self.dbstate.db.get_person_from_handle(father_handle)
         preset_name(father, name)
     return name
Ejemplo n.º 7
0
 def latin_american(self):
     """
     Child inherits name from father and mother
     """
     name = Name()
     #the editor requires a surname
     name.add_surname(Surname())
     name.set_primary_surname(0)
     if self.family:
         father_handle = self.family.get_father_handle()
         mother_handle = self.family.get_mother_handle()
         father = self.dbstate.db.get_person_from_handle(father_handle)
         mother = self.dbstate.db.get_person_from_handle(mother_handle)
         if not father and not mother:
             return name
         if not father:
             preset_name(mother, name)
             return name
         if not mother:
             preset_name(father, name)
             return name
         #we take first surname, and keep that
         mothername = Name()
         preset_name(mother, mothername)
         preset_name(father, name)
         mothersurname = mothername.get_surname_list()[0]
         mothersurname.set_primary(False)
         name.set_surname_list([name.get_surname_list()[0], mothersurname])
         return name
     else:
         return name
Ejemplo n.º 8
0
 def latin_american(self):
     """
     Child inherits name from father and mother
     """
     name = Name()
     #the editor requires a surname
     name.add_surname(Surname())
     name.set_primary_surname(0)
     if self.family:
         father_handle = self.family.get_father_handle()
         mother_handle = self.family.get_mother_handle()
         father = self.dbstate.db.get_person_from_handle(father_handle)
         mother = self.dbstate.db.get_person_from_handle(mother_handle)
         if not father and not mother:
             return name
         if not father:
             preset_name(mother, name)
             return name
         if not mother:
             preset_name(father, name)
             return name
         #we take first surname, and keep that
         mothername = Name()
         preset_name(mother, mothername)
         preset_name(father, name)
         mothersurname = mothername.get_surname_list()[0]
         mothersurname.set_primary(False)
         name.set_surname_list([name.get_surname_list()[0], mothersurname])
         return name
     else:
         return name
Ejemplo n.º 9
0
 def north_american_child(self):
     """
     If SURNAME_GUESSING is north american, then find a child
     and return their name for the father.
     """
     # for each child, find one with a last name
     name = Name()
     #the editor requires a surname
     name.add_surname(Surname())
     name.set_primary_surname(0)
     for ref in self.obj.get_child_ref_list():
         child = self.db.get_person_from_handle(ref.ref)
         if child:
             preset_name(child, name)
             return name
     return name
Ejemplo n.º 10
0
 def north_american_child(self):
     """
     If SURNAME_GUESSING is north american, then find a child
     and return their name for the father.
     """
     # for each child, find one with a last name
     name = Name()
     #the editor requires a surname
     name.add_surname(Surname())
     name.set_primary_surname(0)
     for ref in self.obj.get_child_ref_list():
         child = self.db.get_person_from_handle(ref.ref)
         if child:
             preset_name(child, name)
             return name
     return name
Ejemplo n.º 11
0
 def add_child_to_fam(self, obj, event, handle):
     if button_activated(event, _LEFT_BUTTON):
         callback = lambda x: self.callback_add_child(x, handle)
         person = Person()
         name = Name()
         #the editor requires a surname
         name.add_surname(Surname())
         name.set_primary_surname(0)
         family = self.dbstate.db.get_family_from_handle(handle)
         father = self.dbstate.db.get_person_from_handle(
                                     family.get_father_handle())
         if father:
             preset_name(father, name)
         person.set_primary_name(name)
         try:
             EditPerson(self.dbstate, self.uistate, [], person,
                        callback=callback)
         except WindowActiveError:
             pass