diff --git a/gramps/gen/config.py b/gramps/gen/config.py
index fa9196739..ebd971ec6 100644
--- a/gramps/gen/config.py
+++ b/gramps/gen/config.py
@@ -247,11 +247,8 @@ register('preferences.hide-ep-msg', False)
register('preferences.invalid-date-format', "%s")
register('preferences.iprefix', 'I%04d')
register('preferences.name-format', 1)
+register('preferences.place-format', 0)
register('preferences.place-auto', True)
-register('preferences.place-number', False)
-register('preferences.place-reverse', False)
-register('preferences.place-restrict', 0)
-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"))
diff --git a/gramps/gen/const.py b/gramps/gen/const.py
index 5196f355f..a38acf177 100644
--- a/gramps/gen/const.py
+++ b/gramps/gen/const.py
@@ -112,6 +112,7 @@ VERSION_DIR = os.path.join(
CUSTOM_FILTERS = os.path.join(VERSION_DIR, "custom_filters.xml")
REPORT_OPTIONS = os.path.join(HOME_DIR, "report_options.xml")
TOOL_OPTIONS = os.path.join(HOME_DIR, "tool_options.xml")
+PLACE_FORMATS = os.path.join(HOME_DIR, "place_formats.xml")
ENV_DIR = os.path.join(HOME_DIR, "env")
TEMP_DIR = os.path.join(HOME_DIR, "temp")
diff --git a/gramps/gen/display/place.py b/gramps/gen/display/place.py
index 0df0d0e59..cdd2f3ca2 100644
--- a/gramps/gen/display/place.py
+++ b/gramps/gen/display/place.py
@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2014-2015 Nick Hall
+# Copyright (C) 2014-2017 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
@@ -22,15 +22,43 @@
Class handling displaying of places.
"""
+#---------------------------------------------------------------
+#
+# Python imports
+#
+#---------------------------------------------------------------
+import os
+import xml.dom.minidom
+
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
+from ..const import PLACE_FORMATS
from ..config import config
from ..utils.location import get_location_list
from ..lib import PlaceType
+#-------------------------------------------------------------------------
+#
+# PlaceFormat class
+#
+#-------------------------------------------------------------------------
+class PlaceFormat:
+ def __init__(self, name, levels, language, street, reverse):
+ self.name = name
+ self.levels = levels
+ self.language = language
+ self.street = street
+ self.reverse = reverse
+
+ def to_xml(self):
+ return (' \n' %
+ (self.name, self.levels, self.language,
+ self.street, self.reverse))
+
#-------------------------------------------------------------------------
#
# PlaceDisplay class
@@ -38,51 +66,121 @@ from ..lib import PlaceType
#-------------------------------------------------------------------------
class PlaceDisplay:
- def display_event(self, db, event):
+ def __init__(self):
+ self.place_formats = []
+ self.default_format = config.get('preferences.place-format')
+ if os.path.exists(PLACE_FORMATS):
+ self.load_formats()
+ else:
+ pf = PlaceFormat('Full', ':', '', 0, False)
+ self.place_formats.append(pf)
+
+ def display_event(self, db, event, fmt=None):
if not event:
return ""
place_handle = event.get_place_handle()
if place_handle:
place = db.get_place_from_handle(place_handle)
- return self.display(db, place, event.get_date_object())
+ return self.display(db, place, event.get_date_object(), fmt)
else:
return ""
- def display(self, db, place, date=None):
+ def display(self, db, place, date=None, fmt=None):
if not place:
return ""
if not config.get('preferences.place-auto'):
return place.title
else:
- lang = config.get('preferences.place-lang')
- places = get_location_list(db, place, date, lang)
+ if fmt is None:
+ fmt = config.get('preferences.place-format')
+ pf = self.place_formats[fmt]
+ lang = pf.language
+ all_places = get_location_list(db, place, date, lang)
- if config.get('preferences.place-restrict') > 0:
- index = _find_populated_place(places)
- if index is not None:
- if config.get('preferences.place-restrict') == 1:
- places = places[:index+1]
+ # Apply format string to place list
+ index = _find_populated_place(all_places)
+ places = []
+ for slice in pf.levels.split(','):
+ parts = slice.split(':')
+ if len(parts) == 1:
+ offset = _get_offset(parts[0], index)
+ if offset is not None:
+ places.append(all_places[offset])
+ elif len(parts) == 2:
+ start = _get_offset(parts[0], index)
+ end = _get_offset(parts[1], index)
+ if start is None:
+ places.extend(all_places[:end])
+ elif end is None:
+ places.extend(all_places[start:])
else:
- places = places[index:]
+ places.extend(all_places[start:end])
- if config.get('preferences.place-number'):
+ if pf.street:
types = [item[1] for item in places]
try:
idx = types.index(PlaceType.NUMBER)
except ValueError:
idx = None
if idx is not None and len(places) > idx+1:
- combined = (places[idx][0] + ' ' + places[idx+1][0],
- places[idx+1][1])
+ if pf.street == 1:
+ combined = (places[idx][0] + ' ' + places[idx+1][0],
+ places[idx+1][1])
+ else:
+ combined = (places[idx+1][0] + ' ' + places[idx][0],
+ places[idx+1][1])
places = places[:idx] + [combined] + places[idx+2:]
names = [item[0] for item in places]
- if config.get('preferences.place-reverse'):
+ if pf.reverse:
names.reverse()
# TODO for Arabic, should the next line's comma be translated?
return ", ".join(names)
+ def get_formats(self):
+ return self.place_formats
+
+ def set_formats(self, formats):
+ self.place_formats = formats
+
+ def load_formats(self):
+ dom = xml.dom.minidom.parse(PLACE_FORMATS)
+ top = dom.getElementsByTagName('place_formats')
+
+ for fmt in top[0].getElementsByTagName('format'):
+ name = fmt.attributes['name'].value
+ levels = fmt.attributes['levels'].value
+ language = fmt.attributes['language'].value
+ street = int(fmt.attributes['street'].value)
+ reverse = fmt.attributes['reverse'].value == 'True'
+ pf = PlaceFormat(name, levels, language, street, reverse)
+ self.place_formats.append(pf)
+
+ dom.unlink()
+
+ def save_formats(self):
+ with open(PLACE_FORMATS, 'w') as fd:
+ fd.write('\n')
+ fd.write('\n')
+ for fmt in self.place_formats:
+ fd.write(fmt.to_xml())
+ fd.write('\n')
+
+def _get_offset(value, index):
+ if index is not None and value.startswith('p'):
+ try:
+ offset = int(value[1:])
+ except ValueError:
+ offset = 0
+ offset += index
+ else:
+ try:
+ offset = int(value)
+ except ValueError:
+ offset = None
+ return offset
+
def _find_populated_place(places):
populated_place = None
for index, item in enumerate(places):
diff --git a/gramps/gen/plug/report/stdoptions.py b/gramps/gen/plug/report/stdoptions.py
index b7bc19850..b926aa1a5 100644
--- a/gramps/gen/plug/report/stdoptions.py
+++ b/gramps/gen/plug/report/stdoptions.py
@@ -32,6 +32,7 @@ from ...config import config
from ...datehandler import get_date_formats, LANG_TO_DISPLAY, main_locale
from ...display.name import displayer as global_name_display
from ...lib.date import Today
+from ...display.place import displayer as _pd
from ..menu import EnumeratedListOption, BooleanOption, NumberOption
from ...proxy import PrivateProxyDb, LivingProxyDb
from ...utils.grampslocale import GrampsLocale
@@ -327,3 +328,16 @@ def add_gramps_id_option(menu, category, ownline=False):
include_id.add_item(1, _('Include'))
include_id.set_help(_("Whether to include Gramps IDs"))
menu.add_option(category, 'inc_id', include_id)
+
+def add_place_format_option(menu, category):
+ """
+ Insert an option for changing the report's place format to a
+ report-specific format instead of the user's Edit=>Preferences choice
+ """
+ place_format = EnumeratedListOption(_("Place format"), None)
+ place_format.add_item(None, _("Default"))
+ for number, fmt in enumerate(_pd.get_formats()):
+ place_format.add_item(number, fmt.name)
+ place_format.set_help(_("Select the format to display places"))
+ menu.add_option(category, "place_format", place_format)
+ return place_format
diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py
index 3e301ef28..25401f142 100644
--- a/gramps/gui/configure.py
+++ b/gramps/gui/configure.py
@@ -53,6 +53,7 @@ from gramps.gen.const import HOME_DIR, URL_WIKISTRING
from gramps.gen.datehandler import get_date_formats
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.name import NameDisplayError
+from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.alive import update_constants
from gramps.gen.utils.file import media_path
from gramps.gen.utils.keyword import (get_keywords, get_translation_from_keyword,
@@ -62,6 +63,7 @@ from gramps.gen.lib import Name, Surname, NameOriginType
from .managedwindow import ManagedWindow
from .widgets import MarkupLabel, BasicLabel
from .dialog import ErrorDialog, QuestionDialog2, OkDialog
+from .editors.editplaceformat import EditPlaceFormat
from .glade import Glade
from gramps.gen.plug.utils import available_updates
from .plug import PluginWindows
@@ -511,7 +513,6 @@ class GrampsPreferences(ConfigureDialog):
self.add_behavior_panel,
self.add_famtree_panel,
self.add_formats_panel,
- self.add_places_panel,
self.add_text_panel,
self.add_prefix_panel,
self.add_date_panel,
@@ -931,6 +932,13 @@ class GrampsPreferences(ConfigureDialog):
_nd.set_default_format(new_idx)
self.uistate.emit('nameformat-changed')
+ def cb_place_fmt_changed(self, obj):
+ """
+ Called when the place format is changed.
+ """
+ config.set('preferences.place-format', obj.get_active())
+ self.uistate.emit('placeformat-changed')
+
def cb_pa_sur_changed(self,*args):
"""
checkbox patronymic as surname changed, propagate to namedisplayer
@@ -1052,6 +1060,34 @@ class GrampsPreferences(ConfigureDialog):
grid.attach(obox, 1, row, 2, 1)
row += 1
+ # Place format:
+ self.pformat = Gtk.ComboBox()
+ renderer = Gtk.CellRendererText()
+ self.pformat.pack_start(renderer, True)
+ self.pformat.add_attribute(renderer, "text", 0)
+ self.cb_place_fmt_rebuild()
+ active = config.get('preferences.place-format')
+ self.pformat.set_active(active)
+ self.pformat.connect('changed', self.cb_place_fmt_changed)
+ lwidget = BasicLabel(_("%s: ") % _('Place format'))
+ lwidget.set_use_underline(True)
+ lwidget.set_mnemonic_widget(obox)
+ hbox = Gtk.Box()
+ self.fmt_btn = Gtk.Button(label=("%s..." % _('Edit')))
+ self.fmt_btn.connect('clicked', self.cb_place_fmt_dialog)
+ hbox.pack_start(self.pformat, True, True, 0)
+ hbox.pack_start(self.fmt_btn, False, False, 0)
+ grid.attach(lwidget, 0, row, 1, 1)
+ grid.attach(hbox, 1, row, 2, 1)
+ row += 1
+
+ auto = self.add_checkbox(grid,
+ _("Enable automatic place title generation"),
+ row, 'preferences.place-auto',
+ extra_callback=self.auto_title_changed)
+ self.auto_title_changed(auto)
+ row += 1
+
# Age precision:
# precision=1 for "year", 2: "year, month" or 3: "year, month, days"
obox = Gtk.ComboBoxText()
@@ -1151,66 +1187,13 @@ class GrampsPreferences(ConfigureDialog):
row += 1
return _('Display'), grid
- def add_places_panel(self, configdialog):
- grid = Gtk.Grid()
- grid.set_border_width(12)
- grid.set_column_spacing(6)
- grid.set_row_spacing(6)
-
- auto = self.add_checkbox(grid,
- _("Enable automatic place title generation"),
- 0, 'preferences.place-auto',
- extra_callback=self.auto_title_changed)
-
- row = 0
- grid2 = Gtk.Grid()
- grid2.set_border_width(12)
- grid2.set_column_spacing(6)
- grid2.set_row_spacing(6)
- grid.attach(grid2, 1, 1, 1, 1)
-
- self.place_widgets = []
- cbox = self.add_checkbox(grid2, _("Suppress comma after house number"),
- row, 'preferences.place-number', start=0)
- self.place_widgets.append(cbox)
- row += 1
-
- cbox = self.add_checkbox(grid2, _("Reverse display order"),
- row, 'preferences.place-reverse', start=0)
- self.place_widgets.append(cbox)
- row += 1
-
- # Place restriction
- obox = Gtk.ComboBoxText()
- formats = [_("Full place name"),
- _("-> Hamlet/Village/Town/City"),
- _("Hamlet/Village/Town/City ->")]
- list(map(obox.append_text, formats))
- active = config.get('preferences.place-restrict')
- obox.set_active(active)
- obox.connect('changed', self.place_restrict_changed)
- lwidget = BasicLabel(_("%s: ") % _('Restrict'))
- grid2.attach(lwidget, 0, row, 1, 1)
- grid2.attach(obox, 1, row, 2, 1)
- self.place_widgets.append(obox)
- row += 1
-
- entry = self.add_entry(grid2, _("Language"),
- row, 'preferences.place-lang')
- self.place_widgets.append(entry)
- row += 1
-
- self.auto_title_changed(auto)
-
- return _('Places'), grid
-
def auto_title_changed(self, obj):
"""
- Update sensitivity of place configuration widgets.
+ Update sensitivity of place format widget.
"""
- active = obj.get_active()
- for widget in self.place_widgets:
- widget.set_sensitive(active)
+ active = config.get('preferences.place-auto')
+ self.pformat.set_sensitive(active)
+ self.fmt_btn.set_sensitive(active)
def add_text_panel(self, configdialog):
row = 0
@@ -1258,6 +1241,23 @@ class GrampsPreferences(ConfigureDialog):
Gdk.RGBA.parse(color, hexval)
widget.set_rgba(color)
+ def cb_place_fmt_dialog(self, button):
+ """
+ Called to invoke the place format editor.
+ """
+ EditPlaceFormat(self.uistate, self.dbstate, self.track,
+ self.cb_place_fmt_rebuild)
+
+ def cb_place_fmt_rebuild(self):
+ """
+ Called to rebuild the place format list.
+ """
+ model = Gtk.ListStore(str)
+ for fmt in _pd.get_formats():
+ model.append([fmt.name])
+ self.pformat.set_model(model)
+ self.pformat.set_active(0)
+
def check_for_type_changed(self, obj):
active = obj.get_active()
if active == 0: # update
@@ -1281,10 +1281,6 @@ class GrampsPreferences(ConfigureDialog):
active = obj.get_active()
config.set('behavior.check-for-addon-updates', active)
- def place_restrict_changed(self, obj):
- active = obj.get_active()
- config.set('preferences.place-restrict', active)
-
def date_format_changed(self, obj):
config.set('preferences.date-format', obj.get_active())
OkDialog(_('Change is not immediate'),
diff --git a/gramps/gui/displaystate.py b/gramps/gui/displaystate.py
index 50a637fc9..47c11e44b 100644
--- a/gramps/gui/displaystate.py
+++ b/gramps/gui/displaystate.py
@@ -372,6 +372,7 @@ class DisplayState(Callback):
'filters-changed' : (str, ),
'filter-name-changed' : (str, str, str),
'nameformat-changed' : None,
+ 'placeformat-changed' : None,
'grampletbar-close-changed' : None,
'update-available' : (list, ),
'autobackup' : None,
diff --git a/gramps/gui/editors/editplaceformat.py b/gramps/gui/editors/editplaceformat.py
new file mode 100644
index 000000000..b1e457963
--- /dev/null
+++ b/gramps/gui/editors/editplaceformat.py
@@ -0,0 +1,157 @@
+#
+# Gramps - a GTK+/GNOME based genealogy program
+#
+# Copyright (C) 2017 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+#-------------------------------------------------------------------------
+#
+# GTK/Gnome modules
+#
+#-------------------------------------------------------------------------
+from gi.repository import Gtk
+
+#-------------------------------------------------------------------------
+#
+# Gramps modules
+#
+#-------------------------------------------------------------------------
+from ..managedwindow import ManagedWindow
+from ..glade import Glade
+from ..listmodel import ListModel
+from gramps.gen.errors import ValidationError
+from gramps.gen.display.place import displayer as _pd
+from gramps.gen.display.place import PlaceFormat
+from gramps.gen.const import GRAMPS_LOCALE as glocale
+_ = glocale.translation.gettext
+
+#-------------------------------------------------------------------------
+#
+# EditPlaceFormat
+#
+#-------------------------------------------------------------------------
+class EditPlaceFormat(ManagedWindow):
+ def __init__(self, uistate, dbstate, track, callback):
+ self.title = _('Place Format Editor')
+ ManagedWindow.__init__(self, uistate, track, EditPlaceFormat)
+ self.callback = callback
+ self.top = Glade()
+ self.set_window(self.top.toplevel, None, self.title, None)
+ self.setup_configs('interface.editplaceformat', 600, 400)
+ self.top.get_object('add').connect('clicked', self.__add)
+ self.top.get_object('remove').connect('clicked', self.__remove)
+ self.top.get_object('name').connect('changed', self.__name_changed)
+ self.top.get_object('levels').connect('validate', self._validate)
+ self.window.connect('response', self.__close)
+ self.model = None
+ self.formats = _pd.get_formats()
+ self.current_format = None
+ self.__populate_format_list()
+ self.show()
+
+ def build_menu_names(self, obj):
+ return (self.title, None)
+
+ def __populate_format_list(self):
+ flist = self.top.get_object('format_list')
+ self.model = ListModel(flist,
+ [(_('Format'), -1, 100)],
+ select_func=self.__format_changed)
+ for fmt in self.formats:
+ self.model.add([fmt.name])
+ self.model.select_row(0)
+
+ def __format_changed(self, selection):
+ if self.current_format is not None:
+ fmt = self.formats[self.current_format]
+ self.__save_format(fmt)
+ row = self.model.get_selected_row()
+ if row != -1:
+ fmt = self.formats[row]
+ self.__load_format(fmt)
+ self.current_format = row
+ if row == 0:
+ self.top.get_object('remove').set_sensitive(False)
+ self.top.get_object('name').set_sensitive(False)
+ self.top.get_object('levels').set_sensitive(False)
+ self.top.get_object('street').set_sensitive(False)
+ self.top.get_object('language').set_sensitive(False)
+ self.top.get_object('reverse').set_sensitive(False)
+ else:
+ self.top.get_object('remove').set_sensitive(True)
+ self.top.get_object('name').set_sensitive(True)
+ self.top.get_object('levels').set_sensitive(True)
+ self.top.get_object('street').set_sensitive(True)
+ self.top.get_object('language').set_sensitive(True)
+ self.top.get_object('reverse').set_sensitive(True)
+ self.top.get_object('levels').validate(force=True)
+
+ def __name_changed(self, entry):
+ store, iter_ = self.model.get_selected()
+ self.model.set(iter_, [entry.get_text()])
+
+ def _validate(self, widget, text):
+ for level in text.split(','):
+ parts = level.split(':')
+ if len(parts) < 1:
+ return ValidationError('Empty level')
+ if len(parts) > 2:
+ return ValidationError('Invalid slice')
+ for part in parts:
+ integer_str = part.replace('p', '')
+ if integer_str != '':
+ try:
+ integer = int(integer_str)
+ except ValueError:
+ return ValidationError('Invalid format string')
+
+ def __load_format(self, fmt):
+ self.top.get_object('name').set_text(fmt.name)
+ self.top.get_object('levels').set_text(fmt.levels)
+ self.top.get_object('street').set_active(fmt.street)
+ self.top.get_object('language').set_text(fmt.language)
+ self.top.get_object('reverse').set_active(fmt.reverse)
+
+ def __save_format(self, fmt):
+ fmt.name = self.top.get_object('name').get_text()
+ fmt.levels = self.top.get_object('levels').get_text()
+ fmt.street = self.top.get_object('street').get_active()
+ fmt.language = self.top.get_object('language').get_text()
+ fmt.reverse = self.top.get_object('reverse').get_active()
+
+ def __add(self, button):
+ name = _('New')
+ self.formats.append(PlaceFormat(name, ':', '', 0, False))
+ self.model.add([name])
+ self.model.select_row(len(self.formats)-1)
+
+ def __remove(self, button):
+ store, iter_ = self.model.get_selected()
+ if iter_:
+ self.current_format = None
+ del self.formats[self.model.get_selected_row()]
+ self.model.remove(iter_)
+ if self.model.get_selected_row() == -1:
+ self.model.select_row(len(self.formats)-1)
+
+ def __close(self, *obj):
+ row = self.model.get_selected_row()
+ fmt = self.formats[self.current_format]
+ self.__save_format(fmt)
+ _pd.save_formats()
+ self.callback()
+ self.close()
diff --git a/gramps/gui/glade/editplaceformat.glade b/gramps/gui/glade/editplaceformat.glade
new file mode 100644
index 000000000..3d80c2d54
--- /dev/null
+++ b/gramps/gui/glade/editplaceformat.glade
@@ -0,0 +1,254 @@
+
+
+
+
+
+
+
diff --git a/gramps/plugins/gramplet/persondetails.py b/gramps/plugins/gramplet/persondetails.py
index cb5eb726c..664021be4 100644
--- a/gramps/plugins/gramplet/persondetails.py
+++ b/gramps/plugins/gramplet/persondetails.py
@@ -50,6 +50,7 @@ class PersonDetails(Gramplet):
self.gui.get_container_widget().remove(self.gui.textview)
self.gui.get_container_widget().add(self.gui.WIDGET)
self.uistate.connect('nameformat-changed', self.update)
+ self.uistate.connect('placeformat-changed', self.update)
def build_gui(self):
"""
diff --git a/gramps/plugins/lib/libpersonview.py b/gramps/plugins/lib/libpersonview.py
index ecaf95e2c..d2f3f3ce7 100644
--- a/gramps/plugins/lib/libpersonview.py
+++ b/gramps/plugins/lib/libpersonview.py
@@ -157,6 +157,7 @@ class BasePersonView(ListView):
})
uistate.connect('nameformat-changed', self.build_tree)
+ uistate.connect('placeformat-changed', self.build_tree)
self.additional_uis.append(self.additional_ui())
diff --git a/gramps/plugins/lib/libplaceview.py b/gramps/plugins/lib/libplaceview.py
index 265477d62..21f88df22 100644
--- a/gramps/plugins/lib/libplaceview.py
+++ b/gramps/plugins/lib/libplaceview.py
@@ -130,6 +130,9 @@ class PlaceBaseView(ListView):
'BackSpace' : self.key_delete,
})
self.maptoolbtn = None
+
+ uistate.connect('placeformat-changed', self.build_tree)
+
self.additional_uis.append(self.additional_ui())
def navigation_type(self):
diff --git a/gramps/plugins/textreport/descendreport.py b/gramps/plugins/textreport/descendreport.py
index 811e542a6..ace71d2eb 100644
--- a/gramps/plugins/textreport/descendreport.py
+++ b/gramps/plugins/textreport/descendreport.py
@@ -226,7 +226,7 @@ class Printinfo:
This class must first be initialized with set_class_vars
"""
def __init__(self, doc, database, numbering, showmarriage, showdivorce,
- name_display, rlocale, want_ids):
+ name_display, rlocale, want_ids, pformat):
#classes
self._name_display = name_display
self.doc = doc
@@ -238,6 +238,7 @@ class Printinfo:
self.want_ids = want_ids
self._ = rlocale.translation.sgettext # needed for English
self._get_date = rlocale.get_date
+ self.pformat = pformat
def __date_place(self, event):
""" return the date and/or place an event happened """
@@ -245,7 +246,7 @@ class Printinfo:
date = self._get_date(event.get_date_object())
place_handle = event.get_place_handle()
if place_handle:
- place = _pd.display_event(self.database, event)
+ place = _pd.display_event(self.database, event, self.pformat)
return("%(event_abbrev)s %(date)s - %(place)s" % {
'event_abbrev': event.type.get_abbreviation(self._),
'date' : date,
@@ -474,9 +475,11 @@ class DescendantReport(Report):
stdoptions.run_name_format_option(self, menu)
+ pformat = menu.get_option_by_name("place_format").get_value()
+
self.obj_print = Printinfo(self.doc, self.database, obj, marrs, divs,
self._name_display, self._locale,
- self.want_ids)
+ self.want_ids, pformat)
def write_report(self):
self.doc.start_paragraph("DR-Title")
@@ -555,6 +558,8 @@ class DescendantOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category_name)
+ stdoptions.add_place_format_option(menu, category_name)
+
stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_living_people_option(menu, category_name)
diff --git a/gramps/plugins/textreport/detancestralreport.py b/gramps/plugins/textreport/detancestralreport.py
index 8f1215ec9..22561d9f2 100644
--- a/gramps/plugins/textreport/detancestralreport.py
+++ b/gramps/plugins/textreport/detancestralreport.py
@@ -168,6 +168,8 @@ class DetAncestorReport(Report):
stdoptions.run_name_format_option(self, menu)
self._nd = self._name_display
+ self.place_format = menu.get_option_by_name("place_format").get_value()
+
self.gen_handles = {}
self.prev_gen_handles = {}
@@ -440,7 +442,7 @@ class DetAncestorReport(Report):
else:
date = event.get_date_object().get_year()
- place = _pd.display_event(self._db, event)
+ place = _pd.display_event(self._db, event, self.place_format)
self.doc.start_paragraph('DAR-MoreDetails')
if date and place:
@@ -848,6 +850,8 @@ class DetAncestorOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category)
+ stdoptions.add_place_format_option(menu, category)
+
stdoptions.add_private_data_option(menu, category)
stdoptions.add_living_people_option(menu, category)
diff --git a/gramps/plugins/textreport/detdescendantreport.py b/gramps/plugins/textreport/detdescendantreport.py
index f193e8dee..6a452feac 100644
--- a/gramps/plugins/textreport/detdescendantreport.py
+++ b/gramps/plugins/textreport/detdescendantreport.py
@@ -201,6 +201,8 @@ class DetDescendantReport(Report):
stdoptions.run_name_format_option(self, menu)
+ self.place_format = menu.get_option_by_name("place_format").get_value()
+
self.__narrator = Narrator(self._db, self.verbose,
use_call, use_fulldate,
empty_date, empty_place,
@@ -474,7 +476,7 @@ class DetDescendantReport(Report):
else:
date = event.get_date_object().get_year()
- place = _pd.display_event(self._db, event)
+ place = _pd.display_event(self._db, event, self.place_format)
self.doc.start_paragraph('DDR-MoreDetails')
event_name = self._get_type(event.get_type())
@@ -1039,6 +1041,8 @@ class DetDescendantOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category)
+ stdoptions.add_place_format_option(menu, category)
+
stdoptions.add_private_data_option(menu, category)
stdoptions.add_living_people_option(menu, category)
diff --git a/gramps/plugins/textreport/familygroup.py b/gramps/plugins/textreport/familygroup.py
index 7455d0bf3..58e051710 100644
--- a/gramps/plugins/textreport/familygroup.py
+++ b/gramps/plugins/textreport/familygroup.py
@@ -117,13 +117,15 @@ class FamilyGroup(Report):
stdoptions.run_name_format_option(self, menu)
+ self.place_format = menu.get_option_by_name("place_format").get_value()
+
def dump_parent_event(self, name, event):
place = ""
date = ""
descr = ""
if event:
date = self._get_date(event.get_date_object())
- place = _pd.display_event(self.db, event)
+ place = _pd.display_event(self.db, event, self.place_format)
if place is None:
place = ''
descr = event.get_description()
@@ -438,7 +440,7 @@ class FamilyGroup(Report):
date = self._get_date(event.get_date_object())
place_handle = event.get_place_handle()
if place_handle:
- place = _pd.display_event(self.db, event)
+ place = _pd.display_event(self.db, event, self.place_format)
if place is None:
place = ''
@@ -736,6 +738,8 @@ class FamilyGroupOptions(MenuReportOptions):
self.__update_filters()
+ stdoptions.add_place_format_option(menu, category_name)
+
stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_living_people_option(menu, category_name)
diff --git a/gramps/plugins/textreport/indivcomplete.py b/gramps/plugins/textreport/indivcomplete.py
index c3b030f4f..33fc6e683 100644
--- a/gramps/plugins/textreport/indivcomplete.py
+++ b/gramps/plugins/textreport/indivcomplete.py
@@ -157,6 +157,8 @@ class IndivCompleteReport(Report):
stdoptions.run_name_format_option(self, menu)
+ self.place_format = menu.get_option_by_name("place_format").get_value()
+
self.home_person = self._db.get_default_person() # might be None
self.increlname = menu.get_option_by_name('incl_relname').get_value()
if self.increlname and self.home_person:
@@ -183,7 +185,7 @@ class IndivCompleteReport(Report):
place_handle = event.get_place_handle()
if place_handle:
place = self._db.get_place_from_handle(place_handle)
- place_name = _pd.display_event(self._db, event)
+ place_name = _pd.display_event(self._db, event, self.place_format)
place_endnote = self._cite_endnote(place)
# make sure it's translated, so it can be used below, in "combine"
ignore = _('%(str1)s in %(str2)s. ') % {'str1' : '', 'str2' : ''}
@@ -518,7 +520,8 @@ class IndivCompleteReport(Report):
place_handle = lds_ord.get_place_handle()
if place_handle:
place = self._db.get_place_from_handle(place_handle)
- place_name = _pd.display_event(self._db, lds_ord)
+ place_name = _pd.display_event(self._db, lds_ord,
+ self.place_format)
place_endnote = self._cite_endnote(place)
endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
self.doc.start_row()
@@ -716,7 +719,8 @@ class IndivCompleteReport(Report):
place_handle = lds_ord.get_place_handle()
if place_handle:
place = self._db.get_place_from_handle(place_handle)
- place_name = _pd.display_event(self._db, lds_ord)
+ place_name = _pd.display_event(self._db, lds_ord,
+ self.place_format)
place_endnote = self._cite_endnote(place)
endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
self.doc.start_row()
@@ -1083,6 +1087,8 @@ class IndivCompleteOptions(MenuReportOptions):
self.__update_filters()
+ stdoptions.add_place_format_option(menu, category_name)
+
stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_living_people_option(menu, category_name)
diff --git a/gramps/plugins/textreport/placereport.py b/gramps/plugins/textreport/placereport.py
index ee725f1ce..16167f750 100644
--- a/gramps/plugins/textreport/placereport.py
+++ b/gramps/plugins/textreport/placereport.py
@@ -105,6 +105,8 @@ class PlaceReport(Report):
stdoptions.run_name_format_option(self, menu)
self._nd = self._name_display
+ self.place_format = menu.get_option_by_name("place_format").get_value()
+
filter_option = menu.get_option_by_name('filter')
self.filter = filter_option.get_filter()
@@ -196,7 +198,7 @@ class PlaceReport(Report):
place_names += ' (%s)' % place_name.get_language()
place_details += [self._("places|All Names: %s") % place_names,]
self.doc.start_paragraph("PLC-PlaceTitle")
- place_title = _pd.display(self._db, place)
+ place_title = _pd.display(self._db, place, self.place_format)
self.doc.write_text(("%(nbr)s. %(place)s") % {'nbr' : place_nbr,
'place' : place_title})
self.doc.end_paragraph()
@@ -425,7 +427,7 @@ class PlaceOptions(MenuReportOptions):
if subject:
subject += " + "
place = self.__db.get_place_from_gramps_id(place_id)
- subject += _pd.display(self.__db, place)
+ subject += _pd.display(self.__db, place, self.place_format)
return subject
def add_menu_options(self, menu):
diff --git a/gramps/plugins/textreport/tagreport.py b/gramps/plugins/textreport/tagreport.py
index 495467bf5..ef8806a23 100644
--- a/gramps/plugins/textreport/tagreport.py
+++ b/gramps/plugins/textreport/tagreport.py
@@ -108,6 +108,8 @@ class TagReport(Report):
stdoptions.run_name_format_option(self, menu)
+ self.place_format = menu.get_option_by_name("place_format").get_value()
+
def write_report(self):
self.doc.start_paragraph("TR-Title")
# feature request 2356: avoid genitive form
@@ -439,7 +441,7 @@ class TagReport(Report):
for place_handle in place_list:
place = self.database.get_place_from_handle(place_handle)
- place_title = _pd.display(self.database, place)
+ place_title = _pd.display(self.database, place, self.place_format)
self.doc.start_row()
@@ -916,6 +918,8 @@ class TagOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category_name)
+ stdoptions.add_place_format_option(menu, category_name)
+
stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_living_people_option(menu, category_name)
diff --git a/gramps/plugins/view/eventview.py b/gramps/plugins/view/eventview.py
index 81f3200d8..16dd5e895 100644
--- a/gramps/plugins/view/eventview.py
+++ b/gramps/plugins/view/eventview.py
@@ -129,6 +129,7 @@ class EventView(ListView):
})
uistate.connect('nameformat-changed', self.build_tree)
+ uistate.connect('placeformat-changed', self.build_tree)
self.additional_uis.append(self.additional_ui())
diff --git a/gramps/plugins/view/pedigreeview.py b/gramps/plugins/view/pedigreeview.py
index 0a0d533a7..9f9722178 100644
--- a/gramps/plugins/view/pedigreeview.py
+++ b/gramps/plugins/view/pedigreeview.py
@@ -536,6 +536,7 @@ class PedigreeView(NavigationView):
self.dbstate = dbstate
self.dbstate.connect('database-changed', self.change_db)
uistate.connect('nameformat-changed', self.person_rebuild)
+ uistate.connect('placeformat-changed', self.person_rebuild)
self.format_helper = FormattingHelper(self.dbstate)
diff --git a/gramps/plugins/view/relview.py b/gramps/plugins/view/relview.py
index f06b62dff..01379c9a1 100644
--- a/gramps/plugins/view/relview.py
+++ b/gramps/plugins/view/relview.py
@@ -144,6 +144,7 @@ class RelationshipView(NavigationView):
dbstate.connect('database-changed', self.change_db)
uistate.connect('nameformat-changed', self.build_tree)
+ uistate.connect('placeformat-changed', self.build_tree)
self.redrawing = False
self.child = None