7942: Implement place displayer

This commit is contained in:
Nick Hall 2014-10-28 14:13:32 +00:00
parent 46b2f0a169
commit 28bc8ba590
62 changed files with 321 additions and 228 deletions

View File

@ -295,6 +295,7 @@ register('preferences.hide-ep-msg', False)
register('preferences.invalid-date-format', "<b>%s</b>")
register('preferences.iprefix', 'I%04d')
register('preferences.name-format', 1)
register('preferences.place-format', 0)
register('preferences.patronimic-surname', False)
register('preferences.no-given-text', "[%s]" % _("Missing Given Name"))
register('preferences.no-record-text', "[%s]" % _("Missing Record"))

View File

@ -0,0 +1,68 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2014 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.
#
"""
Class handling displaying of places.
"""
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from ..utils.location import get_location_list
try:
from ..config import config
WITH_GRAMPS_CONFIG=True
except ImportError:
WITH_GRAMPS_CONFIG=False
#-------------------------------------------------------------------------
#
# PlaceDisplay class
#
#-------------------------------------------------------------------------
class PlaceDisplay(object):
def __init__(self):
if WITH_GRAMPS_CONFIG:
self.default_format = config.get('preferences.place-format')
else:
self.default_format = 0
def display_event(self, db, event):
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())
def display(self, db, place, date=None):
if not place:
return ""
if self.default_format == 0:
return place.title
elif self.default_format == 1:
names = [item[0] for item in get_location_list(db, place, date)]
return ", ".join(names)
displayer = PlaceDisplay()

View File

@ -35,6 +35,7 @@ from ...datehandler import parser
from ...lib.eventtype import EventType
from . import Rule
from ...utils.db import get_participant_from_event
from ...display.place import displayer as place_displayer
#-------------------------------------------------------------------------
#
@ -87,8 +88,8 @@ class HasEventBase(Rule):
place_id = event.get_place_handle()
if place_id:
place = db.get_place_from_handle(place_id)
place_name = place.get_title()
if not self.match_substring(2, place_name):
place_title = place_displayer.display(db, place)
if not self.match_substring(2, place_title):
return False
else:
return False

View File

@ -32,6 +32,7 @@ _ = glocale.translation.gettext
#
#-------------------------------------------------------------------------
from ....datehandler import parser
from ....display.place import displayer as place_displayer
from ....lib.eventtype import EventType
from .. import Rule
@ -74,7 +75,8 @@ class HasData(Rule):
place_id = event.get_place_handle()
if place_id:
place = db.get_place_from_handle(place_id)
if not self.match_substring(2, place.get_title()):
place_title = place_displayer.display(db, place)
if not self.match_substring(2, place_title):
# No match
return False
else:

View File

@ -32,6 +32,7 @@ _ = glocale.translation.gettext
#
#-------------------------------------------------------------------------
from ....datehandler import parser
from ....display.place import displayer as place_displayer
from ....lib.eventtype import EventType
from ....lib.eventroletype import EventRoleType
from .. import Rule
@ -78,7 +79,8 @@ class HasBirth(Rule):
place_id = event.get_place_handle()
if place_id:
place = db.get_place_from_handle(place_id)
if not self.match_substring(1, place.get_title()):
place_title = place_displayer.display(db, place)
if not self.match_substring(1, place_title):
# No match: wrong place
continue
else:

View File

@ -32,6 +32,7 @@ _ = glocale.translation.gettext
#
#-------------------------------------------------------------------------
from ....datehandler import parser
from ....display.place import displayer as place_displayer
from ....lib.eventroletype import EventRoleType
from ....lib.eventtype import EventType
from .. import Rule
@ -78,7 +79,8 @@ class HasDeath(Rule):
place_id = event.get_place_handle()
if place_id:
place = db.get_place_from_handle(place_id)
if not self.match_substring(1, place.get_title()):
place_title = place_displayer.display(db, place)
if not self.match_substring(1, place_title):
# No match: wrong place
continue
else:

View File

@ -32,6 +32,7 @@ _ = glocale.translation.gettext
#
#-------------------------------------------------------------------------
from ....datehandler import parser
from ....display.place import displayer as place_displayer
from ....lib.eventtype import EventType
from .. import Rule
@ -87,7 +88,8 @@ class HasFamilyEvent(Rule):
place_id = event.get_place_handle()
if place_id:
place = db.get_place_from_handle(place_id)
if not self.match_substring(2, place.get_title()):
place_title = place_displayer.display(db, place)
if not self.match_substring(2, place_title):
val = 0
else:
val = 0

View File

@ -41,6 +41,7 @@ _ = glocale.translation.gettext
#
#------------------------------------------------------------------------
from ...datehandler import get_date
from ...display.place import displayer as place_displayer
from ...utils.file import media_path_full
from ..docgen import IndexMark, INDEX_TYPE_ALP
from ...constfunc import cuni
@ -115,10 +116,11 @@ def roman(num):
#-------------------------------------------------------------------------
def place_name(db, place_handle):
if place_handle:
place = db.get_place_from_handle(place_handle).get_title()
place = db.get_place_from_handle(place_handle)
name = place_displayer.display(db, place)
else:
place = ""
return cuni(place)
name = ""
return cuni(name)
#-------------------------------------------------------------------------
#

View File

@ -31,9 +31,9 @@ from ..lib.handle import Handle
from ..datehandler import displayer
from ..utils.string import gender as gender_map
from ..utils.db import get_birth_or_fallback, get_death_or_fallback
from ..plug.report.utils import place_name
from ..display.name import displayer as name_displayer
from ..display.place import displayer as place_displayer
from ..lib import EventType
from ..config import config
from ..const import GRAMPS_LOCALE as glocale
@ -309,8 +309,7 @@ class SimpleAccess(object):
event_handle = ref.get_reference_handle()
if event_handle:
event = self.dbase.get_event_from_handle(event_handle)
place_handle = event.get_place_handle()
return place_name(self.dbase, place_handle)
return place_displayer.display_event(self.dbase, event)
return ''
def spouse(self, person):
@ -391,8 +390,7 @@ class SimpleAccess(object):
events = [ evnt for evnt in elist
if event.type == EventType.MARRIAGE ]
if events:
place_handle = events[0].get_place_handle()
return place_name(self.dbase, place_handle)
return place_displayer.display_event(self.dbase, events[0])
return ''
def marriage_date(self, person):
@ -618,8 +616,7 @@ class SimpleAccess(object):
assert(event is None or isinstance(event, Event))
if event:
place_handle = event.get_place_handle()
return place_name(self.dbase, place_handle)
return place_displayer.display_event(self.dbase, event)
else:
return ''
@ -994,9 +991,9 @@ class SimpleAccess(object):
return "%s: [%s]" % (_(object_class),
self.gid(obj))
elif isinstance(obj, Place):
place_title = place_displayer.display(self.dbase, obj)
return "%s: %s [%s]" % (_(object_class),
place_name(self.dbase,
obj.handle),
place_title,
self.gid(obj))
elif isinstance(obj, Repository):
return "%s: %s [%s]" % (_(object_class),
@ -1044,8 +1041,8 @@ class SimpleAccess(object):
elif isinstance(obj, Citation):
return "[%s]" % (self.gid(obj))
elif isinstance(obj, Place):
return "%s [%s]" % (place_name(self.dbase,
obj.handle),
place_title = place_displayer.display(self.dbase, obj)
return "%s [%s]" % (place_title,
self.gid(obj))
elif isinstance(obj, Repository):
return "%s [%s]" % (obj.type,

View File

@ -39,6 +39,7 @@ to make sure these remain in sync with the rest of the design.
from .lib import Date
from .utils.db import get_birth_or_fallback
from .display.name import displayer as _nd
from .display.place import displayer as _pd
from .const import GRAMPS_LOCALE as glocale
#-------------------------------------------------------------------------
@ -184,7 +185,8 @@ class Sort(object):
if not a_id:
return 0
a_obj = self.database.get_place_from_handle(a_id)
return glocale.sort_key(a_obj.title)
title = _pd.display(self.database, a_obj)
return glocale.sort_key(title)
## def by_event_place(self, a_id, b_id):
## """Sort routine for comparing two events by their places. """
@ -207,9 +209,8 @@ class Sort(object):
if not a_id:
return 0
evt_a = self.database.get_event_from_handle(a_id)
plc_a = self.database.get_place_from_handle(evt_a.get_place_handle())
plc_a_title = plc_a.title if plc_a else ""
return glocale.sort_key(plc_a_title)
title = _pd.display_event(self.database, evt_a)
return glocale.sort_key(title)
## def by_event_description(self, a_id, b_id):
## """Sort routine for comparing two events by their descriptions. """

View File

@ -37,6 +37,7 @@ LOG = logging.getLogger(".gui.utils.db")
from ..lib.nameorigintype import NameOriginType
from ..lib.surname import Surname
from ..display.name import displayer as name_displayer
from ..display.place import displayer as place_displayer
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from ..constfunc import cuni
@ -345,7 +346,7 @@ def navigation_label(db, nav_type, handle):
elif nav_type == 'Place':
obj = db.get_place_from_handle(handle)
if obj:
label = obj.get_title()
label = place_displayer.display(db, obj)
elif nav_type == 'Source':
obj = db.get_source_from_handle(handle)
if obj:

View File

@ -38,6 +38,7 @@ from cgi import escape
from ..lib import EventType
from ..datehandler import get_date
from ..display.name import displayer as name_displayer
from ..display.place import displayer as place_displayer
from .db import (get_birth_or_fallback, get_death_or_fallback,
get_marriage_or_fallback)
@ -121,7 +122,7 @@ class FormattingHelper(object):
text = ""
place = self.dbstate.db.get_place_from_handle(place_handle)
if place:
place_title = place.get_title()
place_title = place_displayer.display(self.dbstate.db, place)
if place_title != "":
if len(place_title) > 25:
text = place_title[:24]+"..."

View File

@ -21,28 +21,34 @@
"""
Location utility functions
"""
from ..lib.date import Today
#-------------------------------------------------------------------------
#
# get_location_list
#
#-------------------------------------------------------------------------
def get_location_list(db, place):
def get_location_list(db, place, date=None):
"""
Return a list of place names for display.
"""
if date is None:
date = Today()
visited = [place.handle]
lines = [place.name]
while len(place.get_placeref_list()) > 0:
handle = place.get_placeref_list()[0].ref
if handle in visited:
lines = [(place.name, place.get_type())]
while True:
handle = None
for placeref in place.get_placeref_list():
ref_date = placeref.get_date_object()
if ref_date.is_empty() or date.match(ref_date):
handle = placeref.ref
if handle is None or handle in visited:
break
else:
visited.append(handle)
place = db.get_place_from_handle(handle)
if place is None:
break
lines.append(place.name)
visited.append(handle)
lines.append((place.name, place.get_type()))
return lines
#-------------------------------------------------------------------------
@ -50,25 +56,16 @@ def get_location_list(db, place):
# get_main_location
#
#-------------------------------------------------------------------------
def get_main_location(db, place):
def get_main_location(db, place, date=None):
"""
Find all places in the hierarchy above the given place, and return the
result as a dictionary of place types and names.
"""
visited = [place.handle]
items = {int(place.get_type()): place.name}
while len(place.get_placeref_list()) > 0:
handle = place.get_placeref_list()[0].ref
if handle in visited:
break
else:
visited.append(handle)
place = db.get_place_from_handle(handle)
if place is None:
break
items[int(place.get_type())] = place.name
return items
return dict([(int(place_type), name)
for name, place_type
in get_location_list(db, place, date)
if not place_type.is_custom()])
#-------------------------------------------------------------------------
#
# get_locations

View File

@ -52,6 +52,7 @@ from gramps.gen.const import IMAGE_DIR, URL_MANUAL_PAGE, GRAMPS_LOCALE as glocal
from gramps.gen.config import config
from gramps.gen.lib import NoteType
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from .display import display_help
from .managedwindow import ManagedWindow
from gramps.gen.errors import WindowActiveError
@ -381,7 +382,7 @@ class ClipPlace(ClipHandleWrapper):
value = self._db.get_place_from_handle(self._handle)
if value:
self._title = value.gramps_id
self._value = value.get_title()
self._value = place_displayer.display(self._db, value)
def is_valid(self):
data = pickle.loads(self._obj)
@ -1636,12 +1637,8 @@ def short(val,size=60):
else:
return val
def place_title(db,event):
pid = event.get_place_handle()
if pid:
return db.get_place_from_handle(pid).get_title()
else:
return ''
def place_title(db, event):
return place_displayer.display_event(db, event)
def gen_del_obj(func, t):
return lambda l : func(l, t)

View File

@ -999,6 +999,20 @@ class GrampsPreferences(ConfigureDialog):
table.attach(obox, 1, 3, row, row+1, yoptions=0)
row += 1
# Place format:
obox = Gtk.ComboBoxText()
formats = [_('Title'), _('Automatic')]
list(map(obox.append_text, formats))
active = config.get('preferences.place-format')
if active >= len(formats):
active = 0
obox.set_active(active)
obox.connect('changed', self.place_format_changed)
lwidget = BasicLabel("%s: " % _('Place format'))
table.attach(lwidget, 0, 1, row, row+1, yoptions=0)
table.attach(obox, 1, 3, row, row+1, yoptions=0)
row += 1
# Age precision:
# precision=1 for "year", 2: "year, month" or 3: "year, month, days"
obox = Gtk.ComboBoxText()
@ -1159,6 +1173,12 @@ class GrampsPreferences(ConfigureDialog):
_('Changing the date format will not take '
'effect until the next time Gramps is started.'))
def place_format_changed(self, obj):
config.set('preferences.place-format', obj.get_active())
OkDialog(_('Change is not immediate'),
_('Changing the place format will not take '
'effect until the next time Gramps is started.'))
def date_calendar_changed(self, obj):
config.set('preferences.calendar-format-report', obj.get_active())

View File

@ -39,6 +39,7 @@ _ = glocale.translation.gettext
#
#-------------------------------------------------------------------------
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.utils.db import family_name, get_participant_from_event
#-------------------------------------------------------------------------
@ -127,7 +128,7 @@ class BackRefModel(Gtk.ListStore):
p = self.db.get_place_from_handle(ref[1])
if not p:
continue
name = p.get_title()
name = place_displayer.display(self.db, p)
gid = p.gramps_id
handle = p.handle
elif dtype == 'Repository':

View File

@ -33,6 +33,7 @@ import cgi
#-------------------------------------------------------------------------
from gramps.gen.datehandler import get_date
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.utils.string import gender as gender_map
from gramps.gen.lib import EventType
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
@ -120,9 +121,7 @@ class ChildModel(Gtk.ListStore):
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return place_displayer.display_event(self.db, event)
return ""
def column_death_place(self, data):
@ -130,7 +129,5 @@ class ChildModel(Gtk.ListStore):
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return place_displayer.display_event(self.db, event)
return ""

View File

@ -50,6 +50,7 @@ from gramps.gen.lib import EventRoleType
from gramps.gen.datehandler import get_date, get_date_valid
from gramps.gen.config import config
from gramps.gen.utils.db import get_participant_from_event
from gramps.gen.display.place import displayer as place_displayer
#-------------------------------------------------------------------------
#
@ -160,9 +161,7 @@ class EventRefModel(Gtk.TreeStore):
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return place_displayer.display_event(self.db, event)
return ""
def column_participant(self, event_ref):

View File

@ -37,6 +37,7 @@ from gi.repository import Gtk
#
#-------------------------------------------------------------------------
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.utils.lds import TEMPLES
#-------------------------------------------------------------------------
@ -51,21 +52,13 @@ class LdsModel(Gtk.ListStore):
def __init__(self, lds_list, db):
Gtk.ListStore.__init__(self, str, str, str, str, str, bool, object)
self.db = db
for lds_ord in lds_list:
self.append(row=[
lds_ord.type2str(),
get_date(lds_ord),
lds_ord.status2str(),
TEMPLES.name(lds_ord.get_temple()),
self.column_place(lds_ord),
place_displayer.display_event(db, lds_ord),
lds_ord.get_privacy(),
lds_ord,
])
def column_place(self, lds_ord):
if lds_ord:
place_handle = lds_ord.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return ""

View File

@ -56,6 +56,7 @@ from ..widgets import (MonitoredEntry, PrivacyButton, MonitoredTagList,
MonitoredDataType)
from gramps.gen.errors import ValidationError
from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.display.place import displayer as place_displayer
from ..dialog import ErrorDialog
from ..glade import Glade
@ -85,7 +86,7 @@ class EditPlace(EditPrimary):
def get_menu_title(self):
if self.obj and self.obj.get_handle():
title = self.obj.get_title()
title = place_displayer.display(self.db, self.obj)
dialog_title = _('Place: %s') % title
else:
dialog_title = _('New Place')
@ -275,7 +276,7 @@ class EditPlace(EditPrimary):
(uses_dupe_id, id) = self._uses_duplicate_id()
if uses_dupe_id:
prim_object = self.get_from_gramps_id(id)
name = prim_object.get_title()
name = place_displayer.display(self.db, prim_object)
msg1 = _("Cannot save place. ID already exists.")
msg2 = _("You have attempted to use the existing Gramps ID with "
"value %(id)s. This value is already used by '"
@ -287,14 +288,15 @@ class EditPlace(EditPrimary):
return
with DbTxn('', self.db) as trans:
place_title = place_displayer.display(self.db, self.obj)
if not self.obj.get_handle():
self.db.add_place(self.obj, trans)
msg = _("Add Place (%s)") % self.obj.get_title()
msg = _("Add Place (%s)") % place_title
else:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_place_gramps_id())
self.db.commit_place(self.obj, trans)
msg = _("Edit Place (%s)") % self.obj.get_title()
msg = _("Edit Place (%s)") % place_title
trans.set_description(msg)
self.close()
@ -318,8 +320,8 @@ class DeletePlaceQuery(object):
self.event_list = event_list
def query_response(self):
with DbTxn(_("Delete Place (%s)") % self.obj.get_title(),
self.db) as trans:
place_title = place_displayer.display(self.db, self.obj)
with DbTxn(_("Delete Place (%s)") % place_title, self.db) as trans:
self.db.disable_signals()
place_handle = self.obj.get_handle()

View File

@ -68,6 +68,7 @@ from gramps.gen.filters import rules
from ..autocomp import StandardCustomSelector, fill_entry
from ..selectors import SelectorFactory
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.db import family_name
from gramps.gen.utils.string import conf_strings
from gramps.gen.constfunc import cuni
@ -345,7 +346,7 @@ class MyID(Gtk.Box):
name = str(event.get_type)
elif self.namespace == 'Place':
place = self.db.get_place_from_gramps_id(gramps_id)
name = place.get_title()
name = _pd.display(self.db, place)
elif self.namespace == 'Source':
source = self.db.get_source_from_gramps_id(gramps_id)
name = source.get_title()
@ -992,7 +993,7 @@ class ShowResults(ManagedWindow):
gid = citation.get_gramps_id()
elif self.namespace == 'Place':
place = self.db.get_place_from_handle(handle)
name = place.get_title()
name = _pd.display(self.db, place)
gid = place.get_gramps_id()
elif self.namespace == 'Media':
obj = self.db.get_object_from_handle(handle)
@ -1024,7 +1025,8 @@ class ShowResults(ManagedWindow):
elif self.namespace == 'Citation':
sortname = self.db.get_citation_from_handle(handle).get_page()
elif self.namespace == 'Place':
sortname = self.db.get_place_from_handle(handle).get_title()
place = self.db.get_place_from_handle(handle)
sortname = _pd.display(self.db, place)
elif self.namespace == 'Media':
sortname = self.db.get_object_from_handle(handle).get_description()
elif self.namespace == 'Repository':

View File

@ -56,6 +56,7 @@ from .editnote import EditNote
from ..selectors import SelectorFactory
from ..ddtargets import DdTargets
from gramps.gen.errors import WindowActiveError
from gramps.gen.display.place import displayer as place_displayer
#-------------------------------------------------------------------------
#
@ -316,7 +317,8 @@ class PlaceEntry(ObjEntry):
return self.db.get_place_from_handle(handle)
def get_label(self, place):
return "%s [%s]" % (place.get_title(), place.gramps_id)
place_title = place_displayer.display(self.db, place)
return "%s [%s]" % (place_title, place.gramps_id)
def call_editor(self, obj=None):
if obj is None:

View File

@ -40,6 +40,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.const import URL_MANUAL_PAGE
from ..display import display_help
from gramps.gen.datehandler import get_date
@ -282,7 +283,7 @@ class MergePerson(ManagedWindow):
if handle:
event = self.database.get_event_from_handle(handle)
date = get_date(event)
place = self.place_name(event)
place = place_displayer.display_event(self.database, event)
if date:
return ("%s, %s" % (date, place)) if place else date
else:
@ -290,15 +291,6 @@ class MergePerson(ManagedWindow):
else:
return ""
def place_name(self, event):
"""Return place name of an event as string."""
place_id = event.get_place_handle()
if place_id:
place = self.database.get_place_from_handle(place_id)
return place.get_title()
else:
return ""
def cb_help(self, obj):
"""Display the relevant portion of Gramps manual"""
display_help(webpage = WIKI_HELP_PAGE, section = WIKI_HELP_SEC)

View File

@ -58,6 +58,7 @@ from ..managedwindow import ManagedWindow
from ..dialog import OptionDialog
from ..selectors import SelectorFactory
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.filters import GenericFilterFactory, GenericFilter, rules
from gramps.gen.constfunc import (conv_to_unicode, uni_to_gui, get_curr_dir,
STRTYPE, cuni)
@ -1358,7 +1359,7 @@ class GuiPlaceListOption(Gtk.HBox):
self.__track, skip=skip_list)
place = sel.run()
if place:
place_name = place.get_title()
place_name = _pd.display(self.__db, place)
gid = place.get_gramps_id()
self.__model.append([place_name, gid])
self.__update_value()
@ -1410,7 +1411,7 @@ class GuiPlaceListOption(Gtk.HBox):
for gid in value.split():
place = self.__db.get_place_from_gramps_id(gid)
if place:
place_name = place.get_title()
place_name = _pd.display(self.__db, place)
self.__model.append([place_name, gid])
def clean_up(self):

View File

@ -42,6 +42,7 @@ from gi.repository import Gtk
from gramps.gen.datehandler import format_time, get_date, get_date_valid
from gramps.gen.lib import Event, EventType
from gramps.gen.utils.db import get_participant_from_event
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.config import config
from gramps.gen.constfunc import cuni
from .flatbasemodel import FlatBaseModel
@ -131,7 +132,9 @@ class EventModel(FlatBaseModel):
def column_place(self,data):
if data[COLUMN_PLACE]:
return self.db.get_place_from_handle(data[COLUMN_PLACE]).get_title()
event = Event()
event.unserialize(data)
return place_displayer.display_event(self.db, event)
else:
return ''

View File

@ -57,6 +57,7 @@ _ = glocale.translation.gettext
from gramps.gen.lib import (Name, EventRef, EventType, EventRoleType,
FamilyRelType, ChildRefType, NoteType)
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.datehandler import format_time, get_date, get_date_valid
from .lru import LRU
from .flatbasemodel import FlatBaseModel
@ -383,12 +384,9 @@ class PeopleBaseModel(object):
br.unserialize(local)
event = self.db.get_event_from_handle(br.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title:
return cgi.escape(place_title)
place_title = place_displayer.display_event(self.db, event)
if place_title:
return cgi.escape(place_title)
except:
return ''
@ -400,13 +398,9 @@ class PeopleBaseModel(object):
if (etype in [EventType.BAPTISM, EventType.CHRISTEN] and
er.get_role() == EventRoleType.PRIMARY):
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
place_title = place_displayer.display_event(self.db, event)
if place_title:
return "<i>%s</i>" % cgi.escape(place_title)
return ""
def column_death_place(self, data):
@ -418,12 +412,9 @@ class PeopleBaseModel(object):
dr.unserialize(local)
event = self.db.get_event_from_handle(dr.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title:
return cgi.escape(place_title)
place_title = place_displayer.display_event(self.db, event)
if place_title:
return cgi.escape(place_title)
except:
return ''
@ -436,12 +427,9 @@ class PeopleBaseModel(object):
EventType.CAUSE_DEATH]
and er.get_role() == EventRoleType.PRIMARY):
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title != "":
return "<i>" + cgi.escape(place_title) + "</i>"
place_title = place_displayer.display_event(self.db, event)
if place_title:
return "<i>%s</i>" % cgi.escape(place_title)
return ""
def _get_parents_data(self, data):

View File

@ -59,6 +59,7 @@ from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.datehandler import parser
from gramps.gen.display.place import displayer as place_displayer
#------------------------------------------------------------------------
#
@ -424,7 +425,7 @@ class Extract(object):
"return place for given event"
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle).get_title()
place = place_displayer.display_event(self.db, event)
if place:
return [place]
return [_T_("Place missing")]
@ -437,7 +438,7 @@ class Extract(object):
event = self.db.get_event_from_handle(event_handle)
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle).get_title()
place = place_displayer.display_event(self.db, event)
if place:
places.append(place)
else:

View File

@ -62,6 +62,7 @@ from gramps.gen.lib.eventroletype import EventRoleType
from gramps.gui.plug.export import WriterOptionBox
from gramps.gen.utils.string import gender as gender_map
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as _pd
from gramps.gui.glade import Glade
#-------------------------------------------------------------------------
@ -413,8 +414,7 @@ class CSVWriter(object):
birthdate = self.format_date( birth)
place_handle = birth.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
birthplace = place.get_title()
birthplace = _pd.display_event(self.db, birth)
birthsource = get_primary_source_title(self.db, birth)
# Baptism:
baptismdate = ""
@ -428,8 +428,7 @@ class CSVWriter(object):
baptismdate = self.format_date( baptism)
place_handle = baptism.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
baptismplace = place.get_title()
baptismplace = _pd.display_event(self.db, baptism)
baptismsource = get_primary_source_title(self.db, baptism)
# Death:
deathdate = ""
@ -442,8 +441,7 @@ class CSVWriter(object):
deathdate = self.format_date( death)
place_handle = death.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
deathplace = place.get_title()
deathplace = _pd.display_event(self.db, death)
deathsource = get_primary_source_title(self.db, death)
# Burial:
burialdate = ""
@ -457,8 +455,7 @@ class CSVWriter(object):
burialdate = self.format_date( burial)
place_handle = burial.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
burialplace = place.get_title()
burialplace = _pd.display_event(self.db, burial)
burialsource = get_primary_source_title(self.db, burial)
# Write it out:
self.write_csv(grampsid_ref, surname, first_name, callname,
@ -518,8 +515,7 @@ class CSVWriter(object):
mdate = self.format_date( event)
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
mplace = place.get_title()
mplace = _pd.display_event(self.db, event)
source = get_primary_source_title(self.db, event)
note = ''
self.write_csv(marriage_id, father_id, mother_id, mdate,

View File

@ -56,6 +56,7 @@ from gramps.gen.utils.file import media_path_full
from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.constfunc import cuni
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
#-------------------------------------------------------------------------
#
@ -1364,7 +1365,7 @@ class GedcomWriter(UpdateCallback):
+1 <<NOTE_STRUCTURE>> {0:M}
"""
if place is None: return
place_name = place.get_title()
place_name = place_displayer.display(self.dbase, place)
self._writeln(level, "PLAC", place_name.replace('\r', ' '), limit=120)
longitude = place.get_longitude()
latitude = place.get_latitude()

View File

@ -52,6 +52,7 @@ from gramps.gui.plug.export import WriterOptionBox
from gramps.gen.utils.alive import probably_alive
from gramps.gui.glade import Glade
from gramps.gen.config import config
from gramps.gen.display.place import displayer as _pd
class GeneWebWriter(object):
def __init__(self, database, filename, user, option_box=None):
@ -273,8 +274,7 @@ class GeneWebWriter(object):
b_date = self.format_date( birth.get_date_object())
place_handle = birth.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
b_place = place.get_title()
b_place = _pd.display_event(self.db, birth)
if probably_alive(person,self.db):
d_date = ""
@ -288,8 +288,7 @@ class GeneWebWriter(object):
d_date = self.format_date( death.get_date_object())
place_handle = death.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
d_place = place.get_title()
d_place = _pd.display_event(self.db, death)
retval = retval + "%s " % b_date
if b_place != "":
@ -375,16 +374,14 @@ class GeneWebWriter(object):
m_date = self.format_date( event.get_date_object())
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
m_place = place.get_title()
m_place = _pd.display_event(self.db, event)
m_source = self.get_primary_source( event.get_citation_list())
if event.get_type() == EventType.ENGAGEMENT:
engaged = 1
eng_date = self.format_date( event.get_date_object())
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
eng_place = place.get_title()
eng_place = _pd.display_event(self.db, event)
eng_source = self.get_primary_source( event.get_citation_list())
if event.get_type() == EventType.DIVORCE:
divorced = 1

View File

@ -52,6 +52,7 @@ from gramps.gui.plug.export import WriterOptionBox
from gramps.gen.utils.db import family_name
from gramps.gen.lib import Date, EventType
from gramps.gui.glade import Glade
from gramps.gen.display.place import displayer as _pd
class CalendarWriter(object):
def __init__(self, database, filename, user, option_box=None):
@ -135,8 +136,8 @@ class CalendarWriter(object):
# feature requests 2356, 1657: avoid genitive form
text = _("Marriage of %s") % family_name(family, self.db)
if place_handle:
place = self.db.get_place_from_handle(place_handle)
self.write_vevent( text, m_date, place.get_title())
place_title = _pd.display_event(self.db, event)
self.write_vevent( text, m_date, place_title)
else:
self.write_vevent( text, m_date)
@ -150,11 +151,11 @@ class CalendarWriter(object):
b_date = birth.get_date_object()
place_handle = birth.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
# feature requests 2356, 1657: avoid genitive form
place_title = _pd.display_event(self.db, birth)
self.write_vevent(_("Birth of %s") %
person.get_primary_name().get_name(),
b_date, place.get_title())
b_date, place_title)
else:
# feature requests 2356, 1657: avoid genitive form
self.write_vevent(_("Birth of %s") %
@ -168,12 +169,12 @@ class CalendarWriter(object):
d_date = death.get_date_object()
place_handle = death.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
# feature requests 2356, 1657: avoid genitive form
place_title = _pd.display_event(self.db, death)
self.write_vevent(_("Death of %s") %
person.get_primary_name().get_name(),
d_date,
place.get_title())
place_title)
else:
# feature requests 2356, 1657: avoid genitive form
self.write_vevent(_("Death of %s") %

View File

@ -25,6 +25,7 @@ _ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
@ -49,10 +50,7 @@ class Children(Gramplet):
if event:
event_date = get_date(event)
event_sort = '%012d' % event.get_date_object().get_sort_value()
handle = event.get_place_handle()
if handle:
place = self.dbstate.db.get_place_from_handle(handle)
event_place = place.get_title()
event_place = place_displayer.display_event(self.dbstate.db, event)
return (event_date, event_sort, event_place)
def edit_person(self, treeview):

View File

@ -25,6 +25,7 @@ from gramps.gui.dbguielement import DbGUIElement
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import (get_participant_from_event,
get_birth_or_fallback,
@ -93,10 +94,7 @@ class Events(Gramplet, DbGUIElement):
event_sort = '%012d' % event.get_date_object().get_sort_value()
person_age = self.column_age(event)
person_age_sort = self.column_sort_age(event)
place = ''
handle = event.get_place_handle()
if handle:
place = self.dbstate.db.get_place_from_handle(handle).get_title()
place = place_displayer.display_event(self.dbstate.db, event)
participants = get_participant_from_event(self.dbstate.db,
event_ref.ref)

View File

@ -22,6 +22,7 @@ from gramps.gen.lib import EventType, EventRoleType
from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.datehandler import get_date
@ -229,7 +230,7 @@ class PersonDetails(Gramplet):
date = get_date(event)
handle = event.get_place_handle()
if handle:
place = self.dbstate.db.get_place_from_handle(handle).get_title()
place = place_displayer.display_event(self.dbstate.db, event)
retval = _('%(date)s - %(place)s.') % {'date' : date,
'place' : place}
else:

View File

@ -24,6 +24,7 @@ from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
@ -109,7 +110,7 @@ class PersonResidence(Gramplet):
place = ''
handle = event.get_place_handle()
if handle:
place = self.dbstate.db.get_place_from_handle(handle).get_title()
place = place_displayer.display_event(self.dbstate.db, event)
self.model.add((event.get_handle(), date, place))
def edit_event(self, treeview):

View File

@ -23,7 +23,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.utils.file import media_path_full
from gramps.gen.utils.location import get_location_list
from gramps.gen.display.place import displayer as place_displayer
from gi.repository import Gtk
from gi.repository import Pango
@ -110,7 +110,8 @@ class PlaceDetails(Gramplet):
Display details of the active place.
"""
self.load_place_image(place)
self.title.set_text(place.get_title())
title = place_displayer.display(self.dbstate.db, place)
self.title.set_text(title)
self.clear_table()
self.add_row(_('Name'), place.get_name())

View File

@ -60,6 +60,7 @@ from gramps.gen.utils.file import media_path_full, find_file
from gramps.gui.thumbnails import get_thumbnail_path
from gramps.gen.relationship import get_relationship_calculator
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.display.place import displayer as place_displayer
#------------------------------------------------------------------------
#
@ -505,10 +506,7 @@ class RelGraphReport(Report):
elif self.includedates:
return self._get_date(event.get_date_object())
elif self.use_place:
place_handle = event.get_place_handle()
place = self.database.get_place_from_handle(place_handle)
if place and place.get_title():
return place.get_title()
return place_displayer.display_event(self.database, event)
return ''
#------------------------------------------------------------------------

View File

@ -59,6 +59,7 @@ from gramps.gen.utils.id import create_id
from gramps.gen.lib.eventroletype import EventRoleType
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE
from gramps.gen.config import config
from gramps.gen.display.place import displayer as place_displayer
#-------------------------------------------------------------------------
#
@ -817,7 +818,8 @@ class CSVParser(object):
LOG.debug("get_or_create_place: looking for: %s", place_name)
for place_handle in self.db.iter_place_handles():
place = self.db.get_place_from_handle(place_handle)
if place.get_title() == place_name:
place_title = place_displayer.display(self.db, place)
if place_title == place_name:
return (0, place)
place = Place()
place.set_title(place_name)

View File

@ -143,6 +143,7 @@ from gramps.gen.lib.const import IDENTICAL, DIFFERENT
from gramps.gen.lib import (StyledText, StyledTextTag, StyledTextTagType)
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE, UNITYPE, win
from gramps.plugins.lib.libplaceimport import PlaceImport
from gramps.gen.display.place import displayer as place_displayer
# string.whitespace in some configuration is changed if it is imported
# after setting locale (adding '0xa0')
@ -4400,9 +4401,10 @@ class GedcomParser(UpdateCallback):
state.msg += sub_state.msg
if sub_state.place:
place_title = place_displayer.display(self.dbase, sub_state.place)
sub_state.place_fields.load_place(self.place_import,
sub_state.place,
sub_state.place.get_title())
place_title)
def __lds_temple(self, line, state):
"""
@ -4960,9 +4962,10 @@ class GedcomParser(UpdateCallback):
state.msg += sub_state.msg
if sub_state.place:
place_title = place_displayer.display(self.dbase, sub_state.place)
sub_state.place_fields.load_place(self.place_import,
sub_state.place,
sub_state.place.get_title())
place_title)
def __family_source(self, line, state):
"""
@ -5292,7 +5295,8 @@ class GedcomParser(UpdateCallback):
self.__undefined)
state.msg += sub_state.msg
sub_state.pf.load_place(self.place_import, place, place.get_title())
place_title = place_displayer.display(self.dbase, place)
sub_state.pf.load_place(self.place_import, place, place_title)
self.dbase.commit_place(place, self.trans)

View File

@ -39,6 +39,7 @@ from gramps.gen.lib.eventroletype import EventRoleType
from gramps.gen.lib.eventtype import EventType
from gramps.gen.lib.familyreltype import FamilyRelType
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.alive import probably_alive
from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.const import GRAMPS_LOCALE as glocale
@ -1452,7 +1453,7 @@ class Narrator(object):
bplace_handle = birth_event.get_place_handle()
if bplace_handle:
place = self.__db.get_place_from_handle(bplace_handle)
bplace = place.get_title()
bplace = _pd.display_event(self.__db, birth_event)
bdate_obj = birth_event.get_date_object()
bdate_full = bdate_obj and bdate_obj.get_day_valid()
bdate_mod = bdate_obj and \
@ -1561,7 +1562,7 @@ class Narrator(object):
dplace_handle = death_event.get_place_handle()
if dplace_handle:
place = self.__db.get_place_from_handle(dplace_handle)
dplace = place.get_title()
dplace = _pd.display_event(self.__db, death_event)
ddate_obj = death_event.get_date_object()
ddate_full = ddate_obj and ddate_obj.get_day_valid()
ddate_mod = ddate_obj and \
@ -1680,7 +1681,7 @@ class Narrator(object):
bplace_handle = burial.get_place_handle()
if bplace_handle:
place = self.__db.get_place_from_handle(bplace_handle)
bplace = place.get_title()
bplace = _pd.display_event(self.__db, burial)
bdate_obj = burial.get_date_object()
bdate_full = bdate_obj and bdate_obj.get_day_valid()
bdate_mod = bdate_obj and bdate_obj.get_modifier() != Date.MOD_NONE
@ -1790,7 +1791,7 @@ class Narrator(object):
bplace_handle = baptism.get_place_handle()
if bplace_handle:
place = self.__db.get_place_from_handle(bplace_handle)
bplace = place.get_title()
bplace = _pd.display_event(self.__db, baptism)
bdate_obj = baptism.get_date_object()
bdate_full = bdate_obj and bdate_obj.get_day_valid()
bdate_mod = bdate_obj and bdate_obj.get_modifier() != Date.MOD_NONE
@ -1900,7 +1901,7 @@ class Narrator(object):
cplace_handle = christening.get_place_handle()
if cplace_handle:
place = self.__db.get_place_from_handle(cplace_handle)
cplace = place.get_title()
cplace = _pd.display_event(self.__db, christening)
cdate_obj = christening.get_date_object()
cdate_full = cdate_obj and cdate_obj.get_day_valid()
cdate_mod = cdate_obj and cdate_obj.get_modifier() != Date.MOD_NONE
@ -2013,7 +2014,7 @@ class Narrator(object):
place_handle = event.get_place_handle()
if place_handle:
place_obj = self.__db.get_place_from_handle(place_handle)
place = place_obj.get_title()
place = _pd.display_event(self.__db, event)
relationship = family.get_relationship()
value_map = {

View File

@ -49,6 +49,7 @@ from gramps.gen.lib import EventType, PlaceType, Location
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.constfunc import STRTYPE, cuni
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale
@ -341,6 +342,10 @@ class PlaceFormat(GenericFormat):
otherwise, parse through a format string and put the place parts in
"""
def __init__(self, database, _in):
self.database = database
GenericFormat.__init__(self, _in)
def get_place(self, database, event):
""" A helper method for retrieving a place from an event """
if event:
@ -350,7 +355,7 @@ class PlaceFormat(GenericFormat):
return None
def _default_format(self, place):
return place.get_title()
return place_displayer.display(self.database, place)
def parse_format(self, database, place):
""" Parse the place """
@ -434,7 +439,7 @@ class EventFormat(GenericFormat):
def format_place():
""" start formatting a place in this event """
place_format = PlaceFormat(self.string_in)
place_format = PlaceFormat(self.database, self.string_in)
place = place_format.get_place(self.database, event)
return place_format.parse_format(self.database, place)
@ -891,7 +896,7 @@ class VariableParse(object):
""" sub to process a date
Given an event, get the place object, process the format,
return the result """
place_f = PlaceFormat(self._in)
place_f = PlaceFormat(self.database, self._in)
place = place_f.get_place(self.database, event)
if self.empty_item(place):
return

View File

@ -51,6 +51,7 @@ import cairo
#-------------------------------------------------------------------------
from gramps.gen.lib import EventType, Place, PlaceType, PlaceRef
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gui.views.navigationview import NavigationView
from gramps.gen.utils.libformatting import FormattingHelper
from gramps.gen.errors import WindowActiveError
@ -59,7 +60,6 @@ from gramps.gui.managedwindow import ManagedWindow
from gramps.gen.config import config
from gramps.gui.editors import EditPlace, EditEvent, EditFamily, EditPerson
from gramps.gui.selectors.selectplace import SelectPlace
from gramps.gen.utils.location import get_main_location
from gi.repository import OsmGpsMap as osmgpsmap
from . import constants
@ -906,9 +906,11 @@ class GeoGraphyView(OsmGps, NavigationView):
places_handle = self.dbstate.db.iter_place_handles()
nb_places = 0
gids = ""
place_title = _pd.display(self.dbstate.db, place)
for place_hdl in places_handle:
plce = self.dbstate.db.get_place_from_handle(place_hdl)
if plce.get_title() == place.get_title():
plce_title = _pd.display(self.dbstate.db, plce)
if plce_title == place_title:
nb_places += 1
if gids == "":
gids = plce.gramps_id
@ -926,7 +928,7 @@ class GeoGraphyView(OsmGps, NavigationView):
"%(bold_end)s.\n") % {
'bold_start' : '<b>',
'bold_end' : '</b>',
'title': '<b>' + place.get_title() + '</b>',
'title': '<b>' + place_title + '</b>',
'gid': gids}
)
else:

View File

@ -40,6 +40,7 @@ _ = glocale.translation.gettext
from gramps.plugins.lib.libmapservice import MapService
from gramps.gui.dialog import WarningDialog
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType
# Make upper case of translaed country so string search works later
@ -67,7 +68,7 @@ def _strip_leading_comma(descr):
def _build_title(db, place):
""" Builds descrition string for title parameter in url """
descr = place.get_title()
descr = place_displayer.display(db, place)
location = get_main_location(db, place)
parish = location.get(PlaceType.PARISH)
city = location.get(PlaceType.CITY)

View File

@ -36,6 +36,7 @@ _ = glocale.translation.gettext
#------------------------------------------------------------------------
from gramps.plugins.lib.libmapservice import MapService
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType
class GoogleMapService(MapService):
@ -63,6 +64,6 @@ class GoogleMapService(MapService):
self.url = "http://maps.google.com/maps?q=%s,%s" % (city, country)
return
titledescr = place.get_title()
titledescr = place_displayer.display(self.database, place)
self.url = "http://maps.google.com/maps?q=%s" % \
'+'.join(titledescr.split())

View File

@ -36,6 +36,7 @@ _ = glocale.translation.gettext
#------------------------------------------------------------------------
from gramps.plugins.lib.libmapservice import MapService
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType
class OpensStreetMapService(MapService):
@ -67,6 +68,6 @@ class OpensStreetMapService(MapService):
"search.php?q=%s%%2C%s" % (city, country)
return
titledescr = place.get_title()
titledescr = place_displayer.display(self.database, place)
self.url = "http://open.mapquestapi.com/nominatim/v1/"\
"search.php?q=%s" % '+'.join(titledescr.split())

View File

@ -56,6 +56,7 @@ from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.plugins.lib.libnarrate import Narrator
from gramps.gen.display.place import displayer as place_displayer
#------------------------------------------------------------------------
#
@ -425,11 +426,7 @@ class DetAncestorReport(Report):
else:
date = event.get_date_object().get_year()
ph = event.get_place_handle()
if ph:
place = self.db.get_place_from_handle(ph).get_title()
else:
place = ''
place = place_displayer.display_event(self.db, event)
self.doc.start_paragraph('DAR-MoreDetails')
evtName = self._get_type(event.get_type())

View File

@ -58,6 +58,7 @@ from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.plugins.lib.libnarrate import Narrator
from gramps.gen.display.place import displayer as place_displayer
#------------------------------------------------------------------------
#
@ -430,11 +431,7 @@ class DetDescendantReport(Report):
else:
date = event.get_date_object().get_year()
ph = event.get_place_handle()
if ph:
place = self.db.get_place_from_handle(ph).get_title()
else:
place = ''
place = place_displayer.display_event(self.db, event)
self.doc.start_paragraph('DDR-MoreDetails')
event_name = self._get_type(event.get_type())

View File

@ -47,6 +47,7 @@ from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
TableStyle, TableCellStyle,
FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from gramps.gen.display.place import displayer as place_displayer
#------------------------------------------------------------------------
#
@ -112,8 +113,7 @@ class FamilyGroup(Report):
descr = ""
if event:
date = self._get_date(event.get_date_object())
place_handle = event.get_place_handle()
place = ReportUtils.place_name(self.database,place_handle)
place = place_displayer.display_event(self.database, event)
descr = event.get_description()
if self.includeAttrs:
@ -404,7 +404,7 @@ class FamilyGroup(Report):
date = self._get_date(event.get_date_object())
place_handle = event.get_place_handle()
if place_handle:
place = self.database.get_place_from_handle(place_handle).get_title()
place = place_displayer.display_event(self.database, event)
self.doc.start_row()
self.doc.start_cell(text)

View File

@ -46,6 +46,7 @@ from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
FONT_SANS_SERIF, INDEX_TYPE_TOC,
PARA_ALIGN_CENTER, PARA_ALIGN_RIGHT)
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.plug.menu import (BooleanOption, FilterOption, PersonOption,
BooleanListOption)
from gramps.gen.plug.report import Report
@ -151,7 +152,7 @@ class IndivCompleteReport(Report):
place_handle = event.get_place_handle()
if place_handle:
place = self._db.get_place_from_handle(place_handle)
place_name = place.get_title()
place_name = place_displayer.display_event(self._db, event)
place_endnote = self._cite_endnote(place)
# make sure it's translated, so it can be used below, in "combine"
ignore1 = _('%(str1)s in %(str2)s. ') % {'str1':'', 'str2':''}
@ -459,7 +460,7 @@ class IndivCompleteReport(Report):
place_handle = lds_ord.get_place_handle()
if place_handle:
place = self._db.get_place_from_handle(place_handle)
place_name = place.get_title()
place_name = place_displayer.display_event(self._db, lds_ord)
place_endnote = self._cite_endnote(place)
endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
self.doc.start_row()
@ -568,7 +569,7 @@ class IndivCompleteReport(Report):
place_handle = lds_ord.get_place_handle()
if place_handle:
place = self._db.get_place_from_handle(place_handle)
place_name = place.get_title()
place_name = place_displayer.display_event(self._db, lds_ord)
place_endnote = self._cite_endnote(place)
endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
self.doc.start_row()

View File

@ -47,6 +47,7 @@ from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from gramps.gen.sort import Sort
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType
from gramps.gen.errors import ReportError
@ -164,9 +165,10 @@ class PlaceReport(Report):
self._("State: %s") % location.get(PlaceType.STATE, ''),
self._("Country: %s ") % location.get(PlaceType.COUNTRY, '')]
self.doc.start_paragraph("PLC-PlaceTitle")
place_title = place_displayer.display(self.database, place)
self.doc.write_text(("%(nbr)s. %(place)s") %
{'nbr' : place_nbr,
'place' : place.get_title()})
'place' : place_title})
self.doc.end_paragraph()
for item in place_details:

View File

@ -51,6 +51,7 @@ from gramps.gen.filters import GenericFilterFactory, rules
from gramps.gen.errors import ReportError
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import get_participant_from_event
from gramps.gen.display.place import displayer as place_displayer
#------------------------------------------------------------------------
#
@ -413,6 +414,7 @@ class TagReport(Report):
for place_handle in place_list:
place = self.database.get_place_from_handle(place_handle)
place_title = place_displayer.display(self.database, place)
self.doc.start_row()
@ -424,7 +426,7 @@ class TagReport(Report):
self.doc.start_cell('TR-TableCell')
self.doc.start_paragraph('TR-Normal')
self.doc.write_text(place.get_title())
self.doc.write_text(place_title)
self.doc.end_paragraph()
self.doc.end_cell()

View File

@ -51,6 +51,7 @@ from gramps.gui.managedwindow import ManagedWindow
from gramps.gui.display import display_help
from gramps.plugins.lib.libplaceimport import PlaceImport
from gramps.gen.utils.location import get_main_location
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType
from gramps.gui.plug import tool
@ -441,7 +442,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow):
self.place_import = PlaceImport(db)
for place in db.iter_places():
descr = place.get_title()
descr = place_displayer.display(db, place)
self.progress.step()
loc = get_main_location(db, place)
@ -568,7 +569,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow):
for (id, data) in self.name_list:
place = self.db.get_place_from_handle(id)
descr = place.get_title()
descr = place_displayer.display(self.db, place)
handle = self.model.append()
self.model.set_value(handle, 0, True)

View File

@ -59,6 +59,7 @@ from gramps.gen.db import DbTxn
from gramps.gen.errors import WindowActiveError
from gramps.gui.managedwindow import ManagedWindow
from gramps.gen.datehandler import displayer as _dd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.updatecallback import UpdateCallback
from gramps.gui.plug import tool
from gramps.gui.glade import Glade
@ -398,10 +399,8 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
text += '; %s' % date
# see if there is a place
place_handle = event.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle)
text += '; %s' % place.get_title()
if event.get_place_handle():
text += '; %s' % _pd.display_event(self.db, event)
return text

View File

@ -52,6 +52,7 @@ from gramps.gen.lib import EventRoleType, EventType
from gramps.gen.config import config
from gramps.gen.datehandler import displayer, get_date
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import PersonBookmarks
@ -390,7 +391,7 @@ class GeoClose(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
descr1 = _("%(eventtype)s : %(name)s") % {
'eventtype': evt,
@ -442,7 +443,7 @@ class GeoClose(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(
latitude, longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(
event.get_type())
eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \

View File

@ -55,6 +55,7 @@ from gramps.gen.lib import EventType
from gramps.gen.config import config
from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.pageview import PageView
from gramps.gui.editors import EditPlace
@ -208,7 +209,7 @@ class GeoEvents(GeoGraphyView):
if place_handle:
place = dbstate.db.get_place_from_handle(place_handle)
if place:
descr1 = place.get_title()
descr1 = _pd.display(dbstate.db, place)
longitude = place.get_longitude()
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8")
@ -261,7 +262,7 @@ class GeoEvents(GeoGraphyView):
None
)
else:
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
self._append_to_places_without_coord(
place.gramps_id, descr)

View File

@ -51,6 +51,7 @@ from gramps.gen.lib import EventRoleType, EventType
from gramps.gen.config import config
from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import FamilyBookmarks
@ -450,7 +451,7 @@ class GeoFamClose(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
descr1 = _("%(eventtype)s : %(name)s") % {
'eventtype': evt,
@ -502,7 +503,7 @@ class GeoFamClose(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(
latitude, longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(
event.get_type())
eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \

View File

@ -55,6 +55,7 @@ from gramps.gen.lib import EventRoleType, EventType
from gramps.gen.config import config
from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.pageview import PageView
from gramps.gui.editors import EditPlace
@ -205,7 +206,7 @@ class GeoFamily(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
descr1 = _("%(eventtype)s : %(name)s") % {
'eventtype': evt,
@ -246,7 +247,7 @@ class GeoFamily(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
(father_name, mother_name) = self._get_father_and_mother_name(event)
descr1 = "%s : %s - " % ( evt, father_name )

View File

@ -56,6 +56,7 @@ from gramps.gen.lib import EventRoleType, EventType
from gramps.gen.config import config
from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import PersonBookmarks
@ -286,7 +287,7 @@ class GeoMoves(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
descr1 = _("%(eventtype)s : %(name)s") % {
'eventtype': evt,
@ -338,7 +339,7 @@ class GeoMoves(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(
latitude, longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(
event.get_type())
eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \

View File

@ -57,6 +57,7 @@ from gramps.gen.lib import EventRoleType, EventType
from gramps.gen.config import config
from gramps.gen.datehandler import displayer
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.pageview import PageView
from gramps.gui.editors import EditPlace
@ -321,7 +322,7 @@ class GeoPerson(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
descr1 = _("%(eventtype)s : %(name)s") % {
'eventtype': evt,
@ -371,7 +372,7 @@ class GeoPerson(GeoGraphyView):
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude,
longitude, "D.D8")
descr = place.get_title()
descr = _pd.display(dbstate.db, place)
evt = EventType(event.get_type())
eyear = str("%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \
str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \

View File

@ -55,6 +55,7 @@ _ = glocale.translation.gettext
from gramps.gen.lib import EventType
from gramps.gen.config import config
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.utils.place import conv_lat_lon
from gramps.gui.views.pageview import PageView
from gramps.gui.editors import EditPlace
@ -199,7 +200,7 @@ class GeoPlaces(GeoGraphyView):
return
if self.nbplaces >= self._config.get("geography.max_places"):
return
descr = place.get_title()
descr = _pd.display(self.dbstate.db, place)
longitude = place.get_longitude()
latitude = place.get_latitude()
latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8")

View File

@ -69,6 +69,7 @@ from gramps.gui.views.navigationview import NavigationView
from gramps.gui.editors import EditPerson, EditFamily
from gramps.gui.editors import FilterEditor
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
@ -755,7 +756,7 @@ class RelationshipView(NavigationView):
dobj = event.get_date_object()
phandle = event.get_place_handle()
if phandle:
pname = self.place_name(phandle)
pname = place_displayer.display_event(self.dbstate.db, event)
else:
pname = None

View File

@ -132,6 +132,7 @@ from gramps.gui.thumbnails import get_thumbnail_path, run_thumbnailer
from gramps.gen.utils.image import image_size, resize_to_jpeg_buffer
from gramps.gen.mime import get_description
from gramps.gen.display.name import displayer as _nd
from gramps.gen.display.place import displayer as _pd
from gramps.gen.datehandler import displayer as _dd
from gramps.gen.proxy import LivingProxyDb
from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
@ -508,7 +509,7 @@ def get_gendex_data(database, event_ref):
if place_handle:
place = database.get_place_from_handle(place_handle)
if place:
poe = place.get_title()
poe = _pd.display(database, place)
return doe, poe
def format_date(date):
@ -1062,7 +1063,7 @@ class BasePage(object):
# 3 = place handle, 4 = event date, 5 = event type
found = any(data[3] == place_handle for data in place_lat_long)
if not found:
placetitle = place.get_title()
placetitle = _pd.display(self.dbase_, place)
latitude = place.get_latitude()
longitude = place.get_longitude()
if (latitude and longitude):
@ -1263,7 +1264,8 @@ class BasePage(object):
if place_handle:
place = self.dbase_.get_place_from_handle(place_handle)
if place:
place_hyper = self.place_link(place_handle, place.get_title(),
place_title = _pd.display(self.dbase_, place)
place_hyper = self.place_link(place_handle, place_title,
place.get_gramps_id(), uplink = True)
# begin ordinance rows
@ -3388,7 +3390,7 @@ class PlacePages(BasePage):
for place_handle in handle_list:
place = self.dbase_.get_place_from_handle(place_handle)
if place:
place_title = place.get_title()
place_title = _pd.display(self.dbase_, place)
ml = get_main_location(self.dbase_, place)
if place_title and not place_title.isspace():
@ -3456,7 +3458,7 @@ class PlacePages(BasePage):
of, sio = self.report.create_file(place_handle, "plc")
self.up = True
self.page_title = place.get_title()
self.page_title = _pd.display(self.dbase_, place)
placepage, head, body = self.write_header(_("Places"))
self.placemappages = self.report.options['placemappages']
@ -3505,7 +3507,7 @@ class PlacePages(BasePage):
if self.placemappages:
if (place and (place.lat and place.long)):
latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8")
placetitle = place.get_title()
placetitle = _pd.display(self.dbase_, place)
# add narrative-maps CSS...
fname = "/".join(["css", "narrative-maps.css"])
@ -7448,7 +7450,7 @@ class NavWebReport(Report):
def _add_place(self, place_handle, bkref_class, bkref_handle):
place = self.database.get_place_from_handle(place_handle)
place_name = place.get_title()
place_name = _pd.display(self.database, place)
place_fname = self.build_url_fname(place_handle, "plc",
False) + self.ext
self.obj_dict[Place][place_handle] = (place_fname, place_name,