Skip to content

Commit cca8cf6

Browse files
committed
Add place name to information
1 parent ddebca1 commit cca8cf6

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

CombinedView/combinedview.gpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
id = 'combinedview',
2323
name = _("Combined"),
2424
description = _("A view showing relationships and events for a person"),
25-
version = '1.0.14',
25+
version = '1.0.15',
2626
gramps_target_version = '5.1',
2727
status = STABLE,
2828
fname = 'combinedview.py',

CombinedView/combinedview.py

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class CombinedView(NavigationView):
116116
('preferences.relation-shade', True),
117117
('preferences.releditbtn', True),
118118
('preferences.show-tags', True),
119+
('preferences.vertical-details', True),
119120
)
120121

121122
def __init__(self, pdata, dbstate, uistate, nav_group=0):
@@ -142,6 +143,7 @@ def __init__(self, pdata, dbstate, uistate, nav_group=0):
142143
self.show_siblings = self._config.get('preferences.family-siblings')
143144
self.show_details = self._config.get('preferences.family-details')
144145
self.show_tags = self._config.get('preferences.show-tags')
146+
self.vertical = self._config.get('preferences.vertical-details')
145147
self.use_shade = self._config.get('preferences.relation-shade')
146148
self.theme = self._config.get('preferences.relation-display-theme')
147149
self.toolbar_visible = config.get('interface.toolbar-on')
@@ -186,6 +188,7 @@ def config_update(self, client, cnxn_id, entry, data):
186188
self.show_siblings = self._config.get('preferences.family-siblings')
187189
self.show_details = self._config.get('preferences.family-details')
188190
self.show_tags = self._config.get('preferences.show-tags')
191+
self.vertical = self._config.get('preferences.vertical-details')
189192
self.redraw()
190193

191194
def build_tree(self):
@@ -861,6 +864,49 @@ def drag_data_get(widget, context, sel_data, info, time):
861864
sel_data.set(dnd_type.atom_drag_type, 8, pickle.dumps(data))
862865
return drag_data_get
863866

867+
def info_box(self, handle):
868+
if self.vertical:
869+
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
870+
else:
871+
box = Gtk.Box()
872+
box.set_spacing(6)
873+
874+
person = self.dbstate.db.get_person_from_handle(handle)
875+
if not person:
876+
return box
877+
878+
birth = get_birth_or_fallback(self.dbstate.db, person)
879+
label1 = widgets.MarkupLabel(self.format_box(birth, EventType.BIRTH))
880+
box.pack_start(label1, False, False, 0)
881+
882+
death = get_death_or_fallback(self.dbstate.db, person)
883+
label2 = widgets.MarkupLabel(self.format_box(death, EventType.DEATH))
884+
box.pack_start(label2, False, False, 0)
885+
886+
return box
887+
888+
def format_box(self, event, main_type):
889+
if event:
890+
dobj = event.get_date_object()
891+
pname = place_displayer.display_event(self.dbstate.db, event)
892+
value = {
893+
'abbrev': event.type.get_abbreviation(),
894+
'date' : displayer.display(dobj),
895+
'place' : pname
896+
}
897+
else:
898+
return ''
899+
900+
if pname and not dobj.is_empty():
901+
info = _('%(abbrev)s %(date)s in %(place)s') % value
902+
else:
903+
info = _('%(abbrev)s %(date)s%(place)s') % value
904+
905+
if event.type != main_type:
906+
return '<i>%s</i>' % escape(info)
907+
else:
908+
return escape(info)
909+
864910
def info_string(self, handle):
865911
person = self.dbstate.db.get_person_from_handle(handle)
866912
if not person:
@@ -1488,9 +1534,9 @@ def write_participant(self, person, attrs):
14881534
hbox.set_spacing(6)
14891535
hbox.pack_start(link_label, False, False, 0)
14901536
if self.show_details:
1491-
value = self.info_string(handle)
1492-
if value:
1493-
hbox.pack_start(widgets.MarkupLabel(value), False, False, 0)
1537+
box = self.info_box(handle)
1538+
if box:
1539+
hbox.pack_start(box, False, False, 0)
14941540
if button is not None:
14951541
hbox.pack_start(button, False, False, 0)
14961542
if self.show_tags:
@@ -1814,9 +1860,9 @@ def write_person(self, title, handle):
18141860
hbox.set_spacing(6)
18151861
hbox.pack_start(link_label, False, False, 0)
18161862
if self.show_details:
1817-
value = self.info_string(handle)
1818-
if value:
1819-
hbox.pack_start(widgets.MarkupLabel(value), False, False, 0)
1863+
box = self.info_box(handle)
1864+
if box:
1865+
hbox.pack_start(box, False, False, 0)
18201866
if button is not None:
18211867
hbox.pack_start(button, False, False, 0)
18221868
if self.show_tags:
@@ -1871,9 +1917,9 @@ def write_child(self, handle, index, child_should_be_linked):
18711917
person = self.dbstate.db.get_person_from_handle(handle)
18721918
hbox.pack_start(link_label, False, False, 0)
18731919
if self.show_details:
1874-
value = self.info_string(handle)
1875-
if value:
1876-
hbox.pack_start(widgets.MarkupLabel(value), False, False, 0)
1920+
box = self.info_box(handle)
1921+
if box:
1922+
hbox.pack_start(box, False, False, 0)
18771923
if button is not None:
18781924
hbox.pack_start(button, False, False, 0)
18791925
if self.show_tags:
@@ -2112,6 +2158,8 @@ def config_connect(self):
21122158
self.config_update)
21132159
self._config.connect("preferences.show-tags",
21142160
self.config_update)
2161+
self._config.connect("preferences.vertical-details",
2162+
self.config_update)
21152163
config.connect("interface.toolbar-on",
21162164
self.shade_update)
21172165

@@ -2149,12 +2197,15 @@ def content_panel(self, configdialog):
21492197
configdialog.add_checkbox(grid,
21502198
_('Show Details'),
21512199
0, 'preferences.family-details')
2200+
configdialog.add_checkbox(grid,
2201+
_('Vertical Details'),
2202+
1, 'preferences.vertical-details')
21522203
configdialog.add_checkbox(grid,
21532204
_('Show Siblings'),
2154-
1, 'preferences.family-siblings')
2205+
2, 'preferences.family-siblings')
21552206
configdialog.add_checkbox(grid,
21562207
_('Show Tags'),
2157-
2, 'preferences.show-tags')
2208+
3, 'preferences.show-tags')
21582209

21592210
return _('Content'), grid
21602211

0 commit comments

Comments
 (0)