Add a couple more place displayer options
This commit is contained in:
parent
fff6a5ce15
commit
2f4682acbd
@ -295,6 +295,7 @@ register('preferences.name-format', 1)
|
||||
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"))
|
||||
|
@ -56,6 +56,15 @@ class PlaceDisplay(object):
|
||||
else:
|
||||
lang = config.get('preferences.place-lang')
|
||||
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]
|
||||
else:
|
||||
places = places[index:]
|
||||
|
||||
names = [item[0] for item in places]
|
||||
|
||||
if config.get('preferences.place-number'):
|
||||
@ -68,4 +77,12 @@ class PlaceDisplay(object):
|
||||
|
||||
return ", ".join(names)
|
||||
|
||||
def _find_populated_place(places):
|
||||
populated_place = None
|
||||
for index, item in enumerate(places):
|
||||
if int(item[1]) in [PlaceType.HAMLET, PlaceType.VILLAGE,
|
||||
PlaceType.TOWN, PlaceType.CITY]:
|
||||
populated_place = index
|
||||
return populated_place
|
||||
|
||||
displayer = PlaceDisplay()
|
||||
|
@ -483,7 +483,7 @@ class GrampsPreferences(ConfigureDialog):
|
||||
self.add_behavior_panel,
|
||||
self.add_famtree_panel,
|
||||
self.add_formats_panel,
|
||||
self.add_place_panel,
|
||||
self.add_places_panel,
|
||||
self.add_text_panel,
|
||||
self.add_prefix_panel,
|
||||
self.add_date_panel,
|
||||
@ -1098,7 +1098,7 @@ class GrampsPreferences(ConfigureDialog):
|
||||
row += 1
|
||||
return _('Display'), grid
|
||||
|
||||
def add_place_panel(self, configdialog):
|
||||
def add_places_panel(self, configdialog):
|
||||
row = 0
|
||||
grid = Gtk.Grid()
|
||||
grid.set_border_width(12)
|
||||
@ -1117,6 +1117,20 @@ class GrampsPreferences(ConfigureDialog):
|
||||
row, 'preferences.place-reverse', stop=3)
|
||||
row += 1
|
||||
|
||||
# Place restriction
|
||||
obox = Gtk.ComboBoxText()
|
||||
formats = [_("Full place name"),
|
||||
_("-> Hamlet/VillageTown/City"),
|
||||
_("Hamlet/VillageTown/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'))
|
||||
grid.attach(lwidget, 0, row, 1, 1)
|
||||
grid.attach(obox, 1, row, 2, 1)
|
||||
row += 1
|
||||
|
||||
self.add_entry(grid, _("Language"),
|
||||
row, 'preferences.place-lang')
|
||||
row += 1
|
||||
@ -1178,6 +1192,10 @@ class GrampsPreferences(ConfigureDialog):
|
||||
active = obj.get_active()
|
||||
config.set('behavior.check-for-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'),
|
||||
|
Loading…
Reference in New Issue
Block a user