Add extra place displayer options

This commit is contained in:
Nick Hall 2015-05-31 16:50:24 +01:00
parent 25e62a7797
commit fff6a5ce15
5 changed files with 57 additions and 14 deletions

View File

@ -293,6 +293,9 @@ register('preferences.invalid-date-format', "<b>%s</b>")
register('preferences.iprefix', 'I%04d')
register('preferences.name-format', 1)
register('preferences.place-auto', True)
register('preferences.place-number', False)
register('preferences.place-reverse', False)
register('preferences.place-lang', '')
register('preferences.patronimic-surname', False)
register('preferences.no-given-text', "[%s]" % _("Missing Given Name"))
register('preferences.no-record-text', "[%s]" % _("Missing Record"))

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2014 Nick Hall
# Copyright (C) 2014-2015 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -29,6 +29,7 @@ Class handling displaying of places.
#-------------------------------------------------------------------------
from ..config import config
from ..utils.location import get_location_list
from ..lib import PlaceType
#-------------------------------------------------------------------------
#
@ -53,7 +54,18 @@ class PlaceDisplay(object):
if not config.get('preferences.place-auto'):
return place.title
else:
names = [item[0] for item in get_location_list(db, place, date)]
lang = config.get('preferences.place-lang')
places = get_location_list(db, place, date, lang)
names = [item[0] for item in places]
if config.get('preferences.place-number'):
if len(places) > 1 and int(places[0][1]) == PlaceType.NUMBER:
names = names[1:]
names[0] = places[0][0] + ' ' + names[0]
if config.get('preferences.place-reverse'):
names.reverse()
return ", ".join(names)
displayer = PlaceDisplay()

View File

@ -59,6 +59,7 @@ class PlaceType(GrampsType):
HAMLET = 17
FARM = 18
BUILDING = 19
NUMBER = 20
_CUSTOM = CUSTOM
_DEFAULT = UNKNOWN
@ -85,6 +86,7 @@ class PlaceType(GrampsType):
(HAMLET, _("Hamlet"), "Hamlet"),
(FARM, _("Farm"), "Farm"),
(BUILDING, _("Building"), "Building"),
(NUMBER, _("Number"), "Number"),
]
def __init__(self, value=None):

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2013-2014 Nick Hall
# Copyright (C) 2013-2015 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -28,14 +28,14 @@ from ..lib.date import Today
# get_location_list
#
#-------------------------------------------------------------------------
def get_location_list(db, place, date=None):
def get_location_list(db, place, date=None, lang=''):
"""
Return a list of place names for display.
"""
if date is None:
date = Today()
visited = [place.handle]
lines = [(__get_name(place, date), place.get_type())]
lines = [(__get_name(place, date, lang), place.get_type())]
while True:
handle = None
for placeref in place.get_placeref_list():
@ -49,14 +49,20 @@ def get_location_list(db, place, date=None):
if place is None:
break
visited.append(handle)
lines.append((__get_name(place, date), place.get_type()))
lines.append((__get_name(place, date, lang), place.get_type()))
return lines
def __get_name(place, date):
def __get_name(place, date, lang):
local_name = '?'
for place_name in place.get_all_names():
name_date = place_name.get_date_object()
if name_date.is_empty() or date.match(name_date):
name_lang = place_name.get_language()
if name_lang == '':
local_name = place_name.get_value()
if place_name.get_language() == lang:
return place_name.get_value()
return local_name
#-------------------------------------------------------------------------
#

View File

@ -483,6 +483,7 @@ class GrampsPreferences(ConfigureDialog):
self.add_behavior_panel,
self.add_famtree_panel,
self.add_formats_panel,
self.add_place_panel,
self.add_text_panel,
self.add_prefix_panel,
self.add_date_panel,
@ -998,12 +999,6 @@ class GrampsPreferences(ConfigureDialog):
grid.attach(obox, 1, row, 2, 1)
row += 1
# Automatic place title generation
self.add_checkbox(grid,
_("Enable automatic place title generation"),
row, 'preferences.place-auto', stop=3)
row += 1
# Age precision:
# precision=1 for "year", 2: "year, month" or 3: "year, month, days"
obox = Gtk.ComboBoxText()
@ -1103,6 +1098,31 @@ class GrampsPreferences(ConfigureDialog):
row += 1
return _('Display'), grid
def add_place_panel(self, configdialog):
row = 0
grid = Gtk.Grid()
grid.set_border_width(12)
grid.set_column_spacing(6)
grid.set_row_spacing(6)
self.add_checkbox(grid, _("Enable automatic place title generation"),
row, 'preferences.place-auto', stop=3)
row += 1
self.add_checkbox(grid, _("Suppress comma after house number"),
row, 'preferences.place-number', stop=3)
row += 1
self.add_checkbox(grid, _("Reverse display order"),
row, 'preferences.place-reverse', stop=3)
row += 1
self.add_entry(grid, _("Language"),
row, 'preferences.place-lang')
row += 1
return _('Places'), grid
def add_text_panel(self, configdialog):
row = 0
grid = Gtk.Grid()