Fix shading colour in relationship view for dark themes

Fixes #7749.
This commit is contained in:
Nick Hall 2017-12-18 23:40:26 +00:00
parent 70fff6253d
commit 89592545f3
4 changed files with 68 additions and 41 deletions

View File

@ -32,6 +32,7 @@ from .photo import *
from .placeentry import *
from .monitoredwidgets import *
from .selectionwidget import SelectionWidget, Region
from .shadebox import *
from .shortlistcomboentry import *
from .springseparator import *
from .statusbar import Statusbar

View File

@ -0,0 +1,58 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2018 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.
#
__all__ = ["ShadeBox"]
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import logging
_LOG = logging.getLogger(".widgets.shadebox")
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# ShadeBox class
#
#-------------------------------------------------------------------------
class ShadeBox(Gtk.EventBox):
"""
An EventBox with a shaded background.
"""
def __init__(self, use_shade):
Gtk.EventBox.__init__(self)
self.use_shade = use_shade
def do_draw(self, cr):
if self.use_shade:
tv = Gtk.TextView()
tv_context = tv.get_style_context()
width = self.get_allocated_width()
height = self.get_allocated_height()
Gtk.render_background(tv_context, cr, 0, 0, width, height)
self.get_child().draw(cr)

View File

@ -316,15 +316,6 @@ class RelationshipView(NavigationView):
self.child = None
self.scroll = Gtk.ScrolledWindow()
st_cont = self.scroll.get_style_context()
col = st_cont.lookup_color('base_color')
if col[0]:
self.color = col[1]
else:
self.color = Gdk.RGBA()
self.color.parse("White")
self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.scroll.show()
@ -588,9 +579,7 @@ class RelationshipView(NavigationView):
grid.attach(eventbox, 0, 0, 2, 1)
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
grid.attach(eventbox, 1, 1, 1, 1)
subgrid = Gtk.Grid()
subgrid.set_column_spacing(12)
@ -887,9 +876,7 @@ class RelationshipView(NavigationView):
box = self.get_people_box(family.get_father_handle(),
family.get_mother_handle(),
post_msg=childmsg)
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
eventbox.add(box)
self.child.attach(eventbox, _PDATA_START, self.row,
_PDATA_STOP-_PDATA_START, 1)
@ -941,9 +928,7 @@ class RelationshipView(NavigationView):
else :
childmsg = _(" (only child)")
box = self.get_people_box(post_msg=childmsg)
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
eventbox.add(box)
self.child.attach(eventbox, _PDATA_START, self.row,
_PDATA_STOP-_PDATA_START, 1)
@ -971,9 +956,7 @@ class RelationshipView(NavigationView):
child_should_be_linked = (child_handle != active)
self.write_child(vbox, child_handle, i, child_should_be_linked)
i += 1
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
eventbox.add(vbox)
self.child.attach(eventbox, _CDATA_START-1, self.row,
_CDATA_STOP-_CDATA_START+1, 1)
@ -993,9 +976,6 @@ class RelationshipView(NavigationView):
name = self.get_name(handle, True)
link_label = widgets.LinkLabel(name, self._button_press,
handle, theme=self.theme)
if self.use_shade:
link_label.override_background_color(Gtk.StateType.NORMAL,
self.color)
if self._config.get('preferences.releditbtn'):
button = widgets.IconButton(self.edit_button_press,
handle)
@ -1038,7 +1018,7 @@ class RelationshipView(NavigationView):
_PLABEL_STOP-_PLABEL_START, 1)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
eventbox = Gtk.EventBox()
eventbox = widgets.ShadeBox(self.use_shade)
if handle:
name = self.get_name(handle, True)
person = self.dbstate.db.get_person_from_handle(handle)
@ -1052,8 +1032,6 @@ class RelationshipView(NavigationView):
emph = False
link_label = widgets.LinkLabel(name, self._button_press,
handle, emph, theme=self.theme)
if self.use_shade:
link_label.override_background_color(Gtk.StateType.NORMAL, self.color)
if self._config.get('preferences.releditbtn'):
button = widgets.IconButton(self.edit_button_press, handle)
button.set_tooltip_text(_('Edit Person (%s)') % name[0])
@ -1072,8 +1050,6 @@ class RelationshipView(NavigationView):
if value:
vbox.pack_start(widgets.MarkupLabel(value), True, True, 0)
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox.add(vbox)
self.child.attach(eventbox, _PDATA_START, self.row,
@ -1173,9 +1149,6 @@ class RelationshipView(NavigationView):
name = self.get_name(handle, True)
link_label = widgets.LinkLabel(name, link_func, handle, emph,
theme=self.theme)
if self.use_shade:
link_label.override_background_color(Gtk.StateType.NORMAL, self.color)
link_label.set_padding(3, 0)
if child_should_be_linked and self._config.get(
'preferences.releditbtn'):
@ -1390,9 +1363,7 @@ class RelationshipView(NavigationView):
else :
childmsg = _(" (no children)")
box = self.get_people_box(handle, post_msg=childmsg)
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
eventbox.add(box)
self.child.attach(eventbox, _PDATA_START, self.row,
_PDATA_STOP-_PDATA_START, 1)
@ -1437,9 +1408,7 @@ class RelationshipView(NavigationView):
else :
childmsg = _(" (no children)")
box = self.get_people_box(post_msg=childmsg)
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
eventbox.add(box)
self.child.attach(eventbox, _PDATA_START, self.row,
_PDATA_STOP-_PDATA_START, 1)
@ -1467,9 +1436,7 @@ class RelationshipView(NavigationView):
i += 1
self.row += 1
eventbox = Gtk.EventBox()
if self.use_shade:
eventbox.override_background_color(Gtk.StateType.NORMAL, self.color)
eventbox = widgets.ShadeBox(self.use_shade)
eventbox.add(vbox)
self.child.attach(eventbox, _CDATA_START-1, self.row,
_CDATA_STOP-_CDATA_START+1, 1)

View File

@ -441,6 +441,7 @@ gramps/gui/widgets/menuitem.py
gramps/gui/widgets/multitreeview.py
gramps/gui/widgets/placeentry.py
gramps/gui/widgets/selectionwidget.py
gramps/gui/widgets/shadebox.py
gramps/gui/widgets/shortlistcomboentry.py
gramps/gui/widgets/springseparator.py
gramps/gui/widgets/statusbar.py