Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parents and spouse labels in relationship view #1843

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 55 additions & 7 deletions gramps/plugins/view/relview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,33 @@ def write_parents(self, family_handle, person=None):
)
self.row += 1 # now advance it
else:
self.write_label(_("%s:") % _("Parents"), family, True, person)
self.write_person(_("Father"), family.get_father_handle())
self.write_person(_("Mother"), family.get_mother_handle())
if family:
father = mother = None
hd21 = family.get_father_handle()
if hd21:
father = self.dbstate.db.get_person_from_handle(hd21).gender
hd22 = family.get_mother_handle()
if hd22:
mother = self.dbstate.db.get_person_from_handle(hd22).gender

parent1 = parent2 = ""
if father == Person.MALE:
parent1 = _("Father")
elif father == Person.FEMALE:
parent1 = _("Mother")
else:
parent1 = _("Parent")
Comment on lines +1120 to +1125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this block into a function to avoid duplication.
Something like this:

parent1 = self.__get_parent_label(father)
parent2 = self.__get_parent_label(mother)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly, I am not a coder. I can hack what others have thought up.

The process I have is to determine the label for the person slotted in the Father/Parent1 slot based upon their gender and then do the same for the person in the Mather/Parent2 slot.

Using my code, I actually have a Female in the F/P1 slot and the father/sperm donor in the M/P2 slot.\ for the labels Mother and Father.


if mother == Person.FEMALE:
parent2 = _("Mother")
elif mother == Person.MALE:
parent2 = _("Father")
else:
parent2 = _("Parent")

self.write_label(_("%s:") % _("Parents"), family, True, person)
self.write_person(parent1, family.get_father_handle())
self.write_person(parent2, family.get_mother_handle())

if self.show_siblings:
active = self.get_active()
Expand Down Expand Up @@ -1618,10 +1642,20 @@ def write_family(self, family_handle, person=None):

father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
spouse = spouse1 = spouse2 = None
hd21 = family.get_father_handle()
if hd21:
spouse1 = self.dbstate.db.get_person_from_handle(hd21).gender
hd22 = family.get_mother_handle()
if hd22:
spouse2 = self.dbstate.db.get_person_from_handle(hd22).gender

if self.get_active() == father_handle:
handle = mother_handle
spouse = spouse2
else:
handle = father_handle
spouse = spouse1

# collapse button
if self.check_collapsed(person.handle, family_handle):
Expand Down Expand Up @@ -1651,11 +1685,25 @@ def write_family(self, family_handle, person=None):
else:
# show "V Family: ..." and the rest
self.write_label(_("%s:") % _("Family"), family, False, person)
if handle or family.get_relationship() != FamilyRelType.UNKNOWN:
box = self.write_person(_("Spouse"), handle)
if family.get_relationship() == FamilyRelType.MARRIED:
if spouse == Person.MALE:
box = self.write_person(_("Husband"), handle)
elif spouse == Person.FEMALE:
box = self.write_person(_("Wife"), handle)
else:
box = self.write_person(_("Spouse"), handle)
elif family.get_relationship() == FamilyRelType.CIVIL_UNION:
if spouse == Person.MALE:
box = self.write_person(_("Husband"), handle)
elif spouse == Person.FEMALE:
box = self.write_person(_("Wife"), handle)
else:
box = self.write_person(_("Spouse"), handle)
else:
box = self.write_person(_("Partner"), handle)

if not self.write_relationship_events(box, family):
self.write_relationship(box, family)
if not self.write_relationship_events(box, family):
self.write_relationship(box, family)

hbox = Gtk.Box()
if self.check_collapsed(family.handle, "CHILDREN"):
Expand Down