0738: Color pedigree view name boxes.

This commit is contained in:
SNoiraud 2016-08-30 21:55:05 +02:00
parent d739c5193f
commit f1e3c9500e

View File

@ -174,7 +174,7 @@ class _PersonWidgetBase(Gtk.DrawingArea):
class PersonBoxWidgetCairo(_PersonWidgetBase):
"""Draw person box using cairo library"""
def __init__(self, view, format_helper, dbstate, person, alive, maxlines,
image=None):
image=None, tags=False):
_PersonWidgetBase.__init__(self, view, format_helper, person)
self.set_size_request(120, 25)
# Required for tooltip and mouse-over
@ -193,6 +193,13 @@ class PersonBoxWidgetCairo(_PersonWidgetBase):
else:
gender = None
self.bgcolor, self.bordercolor = color_graph_box(alive, gender)
if tags and person:
for tag_handle in person.get_tag_list():
# For the complete tag, don't modify the default color
# which is black (#000000000000)
tag = dbstate.db.get_tag_from_handle(tag_handle)
if tag.get_color() != "#000000000000": # only if the color
self.bgcolor = tag.get_color() # is not black
self.bgcolor = hex_to_rgb_float(self.bgcolor)
self.bordercolor = hex_to_rgb_float(self.bordercolor)
@ -504,6 +511,7 @@ class PedigreeView(NavigationView):
('interface.pedview-layout', 0),
('interface.pedview-show-images', True),
('interface.pedview-show-marriage', True),
('interface.pedview-show-tags', False),
('interface.pedview-tree-direction', 2),
('interface.pedview-show-unknown-people', True),
)
@ -549,6 +557,8 @@ class PedigreeView(NavigationView):
# Hide marriage data by default
self.show_marriage_data = self._config.get(
'interface.pedview-show-marriage')
# Show person with tag color
self.show_tag_color = self._config.get('interface.pedview-show-tags')
# Tree draw direction
self.tree_direction = self._config.get('interface.pedview-tree-direction')
self.cb_change_scroll_direction(None, self.tree_direction < 2)
@ -929,7 +939,8 @@ class PedigreeView(NavigationView):
# No person -> show empty box
#
pbw = PersonBoxWidgetCairo(self, self.format_helper,
self.dbstate, None, False, 0, None)
self.dbstate, None, False, 0, None,
tags=self.show_tag_color)
if i > 0 and lst[((i+1) // 2) - 1]:
fam_h = None
@ -952,7 +963,8 @@ class PedigreeView(NavigationView):
image = True
pbw = PersonBoxWidgetCairo(self, self.format_helper,
self.dbstate, lst[i][0], lst[i][3], height, image)
self.dbstate, lst[i][0], lst[i][3], height, image,
tags=self.show_tag_color)
lst[i][4] = pbw
if height < 7:
pbw.set_tooltip_text(self.format_helper.format_person(
@ -1917,6 +1929,16 @@ class PedigreeView(NavigationView):
self.menu.popup(None, None, None, None, 0, event.time)
return 1
def cb_update_show_tags(self, client, cnxn_id, entry, data):
"""
Called when the configuration menu changes the tags setting.
"""
if entry == 'True':
self.show_tag_color = True
else:
self.show_tag_color = False
self.rebuild_trees(self.get_active())
def cb_update_show_images(self, client, cnxn_id, entry, data):
"""
Called when the configuration menu changes the images setting.
@ -1989,6 +2011,8 @@ class PedigreeView(NavigationView):
self.cb_update_show_images)
self._config.connect('interface.pedview-show-marriage',
self.cb_update_show_marriage)
self._config.connect('interface.pedview-show-tags',
self.cb_update_show_tags)
self._config.connect('interface.pedview-show-unknown-people',
self.cb_update_show_unknown_people)
self._config.connect('interface.pedview-tree-direction',
@ -2023,6 +2047,9 @@ class PedigreeView(NavigationView):
configdialog.add_checkbox(grid,
_('Show unknown people'),
2, 'interface.pedview-show-unknown-people')
configdialog.add_checkbox(grid,
_('Show tags'),
3, 'interface.pedview-show-tags')
configdialog.add_combo(grid,
_('Tree style'),
4, 'interface.pedview-layout',