From dedb5122cb682da069d2d23e25f2ea3b0d54f094 Mon Sep 17 00:00:00 2001 From: romjerome Date: Sat, 14 Jan 2017 09:44:17 +0100 Subject: [PATCH] 9899: try to get labels on Family according to status --- gramps/gen/config.py | 2 ++ gramps/gen/plug/report/utils.py | 26 +++++++++++++++++++ gramps/gui/configure.py | 8 ++++++ .../gui/editors/displaytabs/eventembedlist.py | 5 ++-- gramps/gui/editors/editfamily.py | 22 +++++++++++----- .../filters/sidebar/_familysidebarfilter.py | 5 ++-- gramps/gui/glade/editfamily.glade | 6 ++--- gramps/gui/merge/mergeperson.py | 5 ++-- gramps/gui/selectors/selectfamily.py | 5 ++-- gramps/gui/utils.py | 25 ++++++++++++++++++ gramps/gui/widgets/reorderfam.py | 5 ++-- gramps/plugins/textreport/familygroup.py | 23 ++++++++++++++-- gramps/plugins/textreport/tagreport.py | 4 +-- gramps/plugins/view/familyview.py | 8 +++--- gramps/plugins/view/geofamclose.py | 6 +++-- gramps/plugins/view/geofamily.py | 6 +++-- gramps/plugins/view/relview.py | 7 ++--- gramps/plugins/webreport/narrativeweb.py | 4 +-- 18 files changed, 135 insertions(+), 37 deletions(-) diff --git a/gramps/gen/config.py b/gramps/gen/config.py index 098c9f6b7..2c82b49a7 100644 --- a/gramps/gen/config.py +++ b/gramps/gen/config.py @@ -269,6 +269,8 @@ register('preferences.use-last-view', False) register('preferences.last-view', '') register('preferences.last-views', []) register('preferences.family-relation-type', 3) # UNKNOWN +register('preferences.father-label', "%s" % _("Father")) +register('preferences.mother-label', "%s" % _("Mother")) register('preferences.age-display-precision', 1) register('preferences.color-gender-male-alive', '#b8cee6') register('preferences.color-gender-male-death', '#b8cee6') diff --git a/gramps/gen/plug/report/utils.py b/gramps/gen/plug/report/utils.py index 796c0b058..8f4282553 100644 --- a/gramps/gen/plug/report/utils.py +++ b/gramps/gen/plug/report/utils.py @@ -40,10 +40,12 @@ import os #------------------------------------------------------------------------ from ...const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext +from gramps.gen.config import config from ...datehandler import get_date from ...display.place import displayer as _pd from ...utils.file import media_path_full from ..docgen import IndexMark, INDEX_TYPE_ALP +from ...relationship import get_relationship_calculator # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh def _T_(value): @@ -392,3 +394,27 @@ def get_family_filters(database, family, the_filters = [all_families, d_fams, ans] the_filters.extend(CustomFilters.get_filters('Family')) return the_filters + +def parents_labels(db, family, glocale): + """ + Get the label for parent + """ + father = db.get_person_from_handle(family.get_father_handle()) + mother = db.get_person_from_handle(family.get_mother_handle()) + + rel_father = config.get("preferences.father-label") + rel_mother = config.get("preferences.mother-label") + + if len(family.get_child_ref_list()) > 0: + rel_father = _('Father') + rel_mother = _('Mother') + if father.gender == 0: + rel_father = rel_mother + if mother.gender == 1: + rel_mother = rel_father + else: + rc = get_relationship_calculator(True, glocale) + rel_father = rc.get_one_relationship(db, mother, father) + rel_mother = rc.get_one_relationship(db, father, mother) + + return [rel_father[0].upper()+rel_father[1:].lower(), rel_mother[0].upper()+rel_mother[1:].lower()] diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index da941f4bc..024081e8f 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -1072,6 +1072,14 @@ class GrampsPreferences(ConfigureDialog): grid.attach(obox, 1, row, 2, 1) row += 1 + father_entry = self.add_entry(grid, _("Label for parent male"), + row, 'preferences.father-label') + row += 1 + + mother_entry = self.add_entry(grid, _("Label for parent female"), + row, 'preferences.mother-label') + row += 1 + #height multiple surname table self.add_pos_int_entry(grid, _('Height multiple surname box (pixels)'), diff --git a/gramps/gui/editors/displaytabs/eventembedlist.py b/gramps/gui/editors/displaytabs/eventembedlist.py index 30e7bcb62..c819fb5c0 100644 --- a/gramps/gui/editors/displaytabs/eventembedlist.py +++ b/gramps/gui/editors/displaytabs/eventembedlist.py @@ -35,6 +35,7 @@ from gi.repository import GLib #------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext +from gramps.gen.config import config from gramps.gen.lib import Event, EventRef, EventRoleType, EventType from gramps.gen.errors import WindowActiveError from ...ddtargets import DdTargets @@ -57,8 +58,8 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList): _WORKGROUP = EventRefModel._ROOTINDEX _WORKNAME = _("Family") - _FATHNAME = _("Father") - _MOTHNAME = _("Mother") + _FATHNAME = config.get("preferences.father-label") + _MOTHNAME = config.get("preferences.mother-label") _MSG = { 'add' : _('Add a new family event'), diff --git a/gramps/gui/editors/editfamily.py b/gramps/gui/editors/editfamily.py index 5d8d5e702..8e97a72a3 100644 --- a/gramps/gui/editors/editfamily.py +++ b/gramps/gui/editors/editfamily.py @@ -79,6 +79,7 @@ from gramps.gen.utils.db import (get_birth_or_fallback, get_death_or_fallback, get_marriage_or_fallback, preset_name, family_name) from ..selectors import SelectorFactory from gramps.gen.utils.id import create_id +from ..utils import parents_labels from gramps.gen.const import URL_MANUAL_SECT1 #------------------------------------------------------------------------- @@ -515,6 +516,9 @@ class EditFamily(EditPrimary): # FIXME: remove if we can use show() self.window.show_all = self.window.show + self.father_label = self.top.get_object('label589') + self.mother_label = self.top.get_object('label574') + self.fbirth = self.top.get_object('fbirth') self.fdeath = self.top.get_object('fdeath') self.fbirth_label = self.top.get_object('label578') @@ -533,9 +537,9 @@ class EditFamily(EditPrimary): self.mbutton_del = self.top.get_object('mbutton_del') self.mbutton_edit = self.top.get_object('mbutton_edit') - self.mbutton_index.set_tooltip_text(_("Select a person as the mother")) - self.mbutton_add.set_tooltip_text(_("Add a new person as the mother")) - self.mbutton_del.set_tooltip_text(_("Remove the person as the mother")) + self.mbutton_index.set_tooltip_text(_("Select a woman")) + self.mbutton_add.set_tooltip_text(_("Add a woman")) + self.mbutton_del.set_tooltip_text(_("Remove the person as woman")) self.mbutton_edit.connect('button-press-event', self.edit_mother) self.mbutton_edit.connect('key-press-event', self.edit_mother) @@ -548,9 +552,9 @@ class EditFamily(EditPrimary): self.fbutton_del = self.top.get_object('fbutton_del') self.fbutton_edit = self.top.get_object('fbutton_edit') - self.fbutton_index.set_tooltip_text(_("Select a person as the father")) - self.fbutton_add.set_tooltip_text(_("Add a new person as the father")) - self.fbutton_del.set_tooltip_text(_("Remove the person as the father")) + self.fbutton_index.set_tooltip_text(_("Select a man")) + self.fbutton_add.set_tooltip_text(_("Add a man")) + self.fbutton_del.set_tooltip_text(_("Remove the person as man")) self.fbutton_edit.connect('button-press-event', self.edit_father) self.fbutton_edit.connect('key-press-event', self.edit_father) @@ -679,6 +683,12 @@ class EditFamily(EditPrimary): self.phandles = [_f for _f in self.phandles if _f] + parents = parents_labels(self.db, self.obj) + self.father_label.set_label(parents[0][0].upper()+parents[0][1:].lower()) + self.fbutton_del.set_tooltip_text(_("Remove %s") % parents[0].lower()) + self.mother_label.set_label(parents[1][0].upper()+parents[1][1:].lower()) + self.mbutton_del.set_tooltip_text(_("Remove %s") % parents[1].lower()) + def get_start_date(self): """ Get the start date for a family, usually a marriage date, or diff --git a/gramps/gui/filters/sidebar/_familysidebarfilter.py b/gramps/gui/filters/sidebar/_familysidebarfilter.py index 6a82ca3a6..9e2932942 100644 --- a/gramps/gui/filters/sidebar/_familysidebarfilter.py +++ b/gramps/gui/filters/sidebar/_familysidebarfilter.py @@ -40,6 +40,7 @@ from gi.repository import Gtk # #------------------------------------------------------------------------- from ... import widgets +from gramps.gen.config import config from gramps.gen.lib import Event, EventType, Family, FamilyRelType from .. import build_filter_model from . import SidebarFilter @@ -109,8 +110,8 @@ class FamilySidebarFilter(SidebarFilter): self.rtype.get_child().set_width_chars(5) self.add_text_entry(_('ID'), self.filter_id) - self.add_text_entry(_('Father'), self.filter_father) - self.add_text_entry(_('Mother'), self.filter_mother) + self.add_text_entry(config.get("preferences.father-label"), self.filter_father) + self.add_text_entry(config.get("preferences.mother-label"), self.filter_mother) self.add_text_entry(_('Child'), self.filter_child) self.add_entry(_('Relationship'), self.rtype) self.add_entry(_('Family Event'), self.etype) diff --git a/gramps/gui/glade/editfamily.glade b/gramps/gui/glade/editfamily.glade index a634982e5..1f5f507e7 100644 --- a/gramps/gui/glade/editfamily.glade +++ b/gramps/gui/glade/editfamily.glade @@ -157,7 +157,6 @@ True False start - Father/partner1 @@ -189,7 +188,7 @@ - Father + Father, Partner, Spouse @@ -435,7 +434,6 @@ True False start - Mother/partner2 @@ -467,7 +465,7 @@ - Mother + Mother, Partner, Spouse diff --git a/gramps/gui/merge/mergeperson.py b/gramps/gui/merge/mergeperson.py index f54e51527..ce1b2a4f7 100644 --- a/gramps/gui/merge/mergeperson.py +++ b/gramps/gui/merge/mergeperson.py @@ -38,6 +38,7 @@ from gi.repository import Pango #------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext +from gramps.gen.config import config from gramps.gen.plug.report import utils from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.place import displayer as place_displayer @@ -228,10 +229,10 @@ class MergePerson(ManagedWindow): KEYVAL % {'key': _('Family ID'), 'value': gid}) if fname: self.add(tobj, indent, - KEYVAL % {'key': _('Father'), 'value': fname}) + KEYVAL % {'key': config.get("preferences.father-label"), 'value': fname}) if mname: self.add(tobj, indent, - KEYVAL % {'key': _('Mother'), 'value': mname}) + KEYVAL % {'key': config.get("preferences.mother-label"), 'value': mname}) else: self.add(tobj, normal, _("No parents found")) diff --git a/gramps/gui/selectors/selectfamily.py b/gramps/gui/selectors/selectfamily.py index f5c7c4969..caa378a11 100644 --- a/gramps/gui/selectors/selectfamily.py +++ b/gramps/gui/selectors/selectfamily.py @@ -32,6 +32,7 @@ #------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext +from gramps.gen.config import config from ..views.treemodels import FamilyModel from .baseselector import BaseSelector from gramps.gui.display import display_help @@ -67,8 +68,8 @@ class SelectFamily(BaseSelector): def get_column_titles(self): return [ (_('ID'), 75, BaseSelector.TEXT, 0), - (_('Father'), 200, BaseSelector.TEXT, 1), - (_('Mother'), 200, BaseSelector.TEXT, 2), + (config.get("preferences.father-label"), 200, BaseSelector.TEXT, 1), + (config.get("preferences.mother-label"), 200, BaseSelector.TEXT, 2), (_('Last Change'), 150, BaseSelector.TEXT, 7), ] diff --git a/gramps/gui/utils.py b/gramps/gui/utils.py index f78acb679..f3c2e89da 100644 --- a/gramps/gui/utils.py +++ b/gramps/gui/utils.py @@ -57,6 +57,7 @@ from gramps.gen.constfunc import has_display, is_quartz, mac, win from gramps.gen.config import config from gramps.gen.plug.utils import available_updates from gramps.gen.errors import WindowActiveError +from gramps.gen.relationship import RelationshipCalculator #------------------------------------------------------------------------- # @@ -685,3 +686,27 @@ def text_to_clipboard(text): clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(), Gdk.SELECTION_CLIPBOARD) clipboard.set_text(text, -1) + +def parents_labels(db, family): + """ + Get the label for parent + """ + father = db.get_person_from_handle(family.get_father_handle()) + mother = db.get_person_from_handle(family.get_mother_handle()) + + rel_father = config.get("preferences.father-label") + rel_mother = config.get("preferences.mother-label") + + if len(family.get_child_ref_list()) > 0: + rel_father = _('Father') + rel_mother = _('Mother') + if father.gender == 0: + rel_father = rel_mother + if mother.gender == 1: + rel_mother = rel_father + else: + rc = RelationshipCalculator() + rel_father = rc.get_one_relationship(db, mother, father) + rel_mother = rc.get_one_relationship(db, father, mother) + + return [rel_father.split()[-1], rel_mother.split()[-1]] diff --git a/gramps/gui/widgets/reorderfam.py b/gramps/gui/widgets/reorderfam.py index 03e70d92e..fb7be3347 100644 --- a/gramps/gui/widgets/reorderfam.py +++ b/gramps/gui/widgets/reorderfam.py @@ -45,6 +45,7 @@ _LOG = logging.getLogger("gui.widgets.reorderfam") #------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext +from gramps.gen.config import config from gramps.gen.db import DbTxn from ..listmodel import ListModel from ..managedwindow import ManagedWindow @@ -81,8 +82,8 @@ class Reorder(ManagedWindow): self.ptree = xml.get_object('ptree') self.pmodel = ListModel(self.ptree, - [(_('Father'), -1, 200), - (_('Mother'), -1, 200), + [(config.get("preferences.father-label"), -1, 200), + (config.get("preferences.mother-label"), -1, 200), ('', -1, 0)]) self.ftree = xml.get_object('ftree') diff --git a/gramps/plugins/textreport/familygroup.py b/gramps/plugins/textreport/familygroup.py index 49ffd85bd..de4cc8409 100644 --- a/gramps/plugins/textreport/familygroup.py +++ b/gramps/plugins/textreport/familygroup.py @@ -38,6 +38,7 @@ from functools import partial #------------------------------------------------------------------------ from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext +from gramps.gen.config import config from gramps.gen.lib import EventRoleType, EventType, NoteType, Person from gramps.gen.plug.menu import BooleanOption, FamilyOption, FilterOption from gramps.gen.plug.report import Report @@ -616,8 +617,26 @@ class FamilyGroup(Report): self.doc.end_paragraph() family = self.db.get_family_from_handle(family_handle) + parents = utils.parents_labels(self.db, family, self._locale) - self.dump_parent(self._("Husband"), family.get_father_handle()) + rel_father = config.get("preferences.father-label") + rel_mother = config.get("preferences.mother-label") + + nb_children = len(family.get_child_ref_list()) + father = self.db.get_person_from_handle(family.get_father_handle()) + mother = self.db.get_person_from_handle(family.get_mother_handle()) + if nb_children > 0: + rel_father = self._("Father") + rel_mother = self._("Mother") + if father.gender == 0: + rel_father = rel_mother + if mother.gender == 1: + rel_mother = rel_father + else: + rel_father = parents[0] + rel_mother = parents[1] + + self.dump_parent(rel_father, family.get_father_handle()) self.doc.start_paragraph("FGR-blank") self.doc.end_paragraph() @@ -626,7 +645,7 @@ class FamilyGroup(Report): self.doc.start_paragraph("FGR-blank") self.doc.end_paragraph() - self.dump_parent(self._("Wife"), family.get_mother_handle()) + self.dump_parent(rel_mother, family.get_mother_handle()) length = len(family.get_child_ref_list()) if length > 0: diff --git a/gramps/plugins/textreport/tagreport.py b/gramps/plugins/textreport/tagreport.py index 4d47efe00..11c17e2dd 100644 --- a/gramps/plugins/textreport/tagreport.py +++ b/gramps/plugins/textreport/tagreport.py @@ -245,13 +245,13 @@ class TagReport(Report): self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') - self.doc.write_text(self._("Father")) + self.doc.write_text(self._("Father, Partner, Spouse")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') - self.doc.write_text(self._("Mother")) + self.doc.write_text(self._("Mother, Partner, Spouse")) self.doc.end_paragraph() self.doc.end_cell() diff --git a/gramps/plugins/view/familyview.py b/gramps/plugins/view/familyview.py index 24c3c203e..6503b497c 100644 --- a/gramps/plugins/view/familyview.py +++ b/gramps/plugins/view/familyview.py @@ -77,8 +77,8 @@ class FamilyView(ListView): # column definitions COLUMNS = [ (_('ID'), TEXT, None), - (_('Father'), TEXT, None), - (_('Mother'), TEXT, None), + (config.get("preferences.father-label"), TEXT, None), + (config.get("preferences.mother-label"), TEXT, None), (_('Relationship'), TEXT, None), (_('Marriage Date'), MARKUP, None), (_('Private'), ICON, 'gramps-lock'), @@ -202,9 +202,9 @@ class FamilyView(ListView): self.all_action = Gtk.ActionGroup(name=self.title + "/FamilyAll") self.all_action.add_actions([ - ('MakeFatherActive', None, _("Make Father Active Person"), + ('MakeFatherActive', None, _("Make %s Active Person") % config.get("preferences.father-label"), None, None, self._make_father_active), - ('MakeMotherActive', None, _("Make Mother Active Person"), + ('MakeMotherActive', None, _("Make %s Active Person") % config.get("preferences.mother-label"), None, None, self._make_mother_active), ('QuickReport', None, _("Quick View"), None, None, None), ]) diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index d0c81ea4e..b5a9fb5a3 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -605,7 +605,8 @@ class GeoFamClose(GeoGraphyView): if handle: father = dbstate.db.get_person_from_handle(handle) if father: - comment = _("Father : %(id)s : %(name)s") % { + comment = _("%(father)s : %(id)s : %(name)s") % { + 'father': config.get("preferences.father-label"), 'id': father.gramps_id, 'name': _nd.display(father)} self._createmap_for_one_person(father, color, @@ -614,7 +615,8 @@ class GeoFamClose(GeoGraphyView): if handle: mother = dbstate.db.get_person_from_handle(handle) if mother: - comment = _("Mother : %(id)s : %(name)s") % { + comment = _("%(mother)s : %(id)s : %(name)s") % { + 'mother': config.get("preferences.mother-label"), 'id': mother.gramps_id, 'name': _nd.display(mother)} self._createmap_for_one_person(mother, color, diff --git a/gramps/plugins/view/geofamily.py b/gramps/plugins/view/geofamily.py index 78825118b..0dd72c90a 100644 --- a/gramps/plugins/view/geofamily.py +++ b/gramps/plugins/view/geofamily.py @@ -342,7 +342,8 @@ class GeoFamily(GeoGraphyView): if handle: father = dbstate.db.get_person_from_handle(handle) if father: - comment = _("Father : %(id)s : %(name)s") % { + comment = _("%(father)s : %(id)s : %(name)s") % { + 'father': config.get("preferences.father-label"), 'id': father.gramps_id, 'name': _nd.display(father)} self._createpersonmarkers(dbstate, father, @@ -351,7 +352,8 @@ class GeoFamily(GeoGraphyView): if handle: mother = dbstate.db.get_person_from_handle(handle) if mother: - comment = _("Mother : %(id)s : %(name)s") % { + comment = _("%(mother)s : %(id)s : %(name)s") % { + 'mother': config.get("preferences.mother-label"), 'id': mother.gramps_id, 'name': _nd.display(mother)} self._createpersonmarkers(dbstate, mother, diff --git a/gramps/plugins/view/relview.py b/gramps/plugins/view/relview.py index 9caf7970b..28e3d19db 100644 --- a/gramps/plugins/view/relview.py +++ b/gramps/plugins/view/relview.py @@ -67,7 +67,7 @@ from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.place import displayer as place_displayer from gramps.gen.utils.file import media_path_full from gramps.gen.utils.alive import probably_alive -from gramps.gui.utils import open_file_with_default_application +from gramps.gui.utils import open_file_with_default_application, parents_labels from gramps.gen.datehandler import displayer, get_date from gramps.gen.utils.thumbnails import get_thumbnail_image from gramps.gen.config import config @@ -896,8 +896,9 @@ class RelationshipView(NavigationView): 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()) + parents = parents_labels(self.dbstate.db, family) + self.write_person(parents[0][0].upper()+parents[0][1:].lower(), family.get_father_handle()) + self.write_person(parents[1][0].upper()+parents[1][1:].lower(), family.get_mother_handle()) if self.show_siblings: active = self.get_active() diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 855edea19..82a01dc44 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -7436,7 +7436,7 @@ class PersonPages(BasePage): # The parent may not be birth father in ths family, because it # may be a step family. However, it will be odd to display the # parent as anything other than "Father" - reln = self._("Father") + reln = self._("Father, Partner, Spouse") else: # Stepfather may not always be quite right (for example, it may # actually be StepFather-in-law), but it is too expensive to @@ -7450,7 +7450,7 @@ class PersonPages(BasePage): mother_handle = family.get_mother_handle() if mother_handle: if mother_handle == birthmother: - reln = self._("Mother") + reln = self._("Mother, Partner, Spouse"") else: reln = self._("Stepmother") trow = Html("tr") + (self.display_parent(mother_handle, reln, None))