From 84e76de2b15fddb3de533d7e05ff95e2c4c5930a Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 18 Dec 2017 23:39:36 +0000 Subject: [PATCH] Fix default foreground colour in list views for dark themes Issue #7749. --- gramps/gui/views/listview.py | 13 +++++++------ gramps/gui/views/treemodels/citationbasemodel.py | 4 ++-- gramps/gui/views/treemodels/eventmodel.py | 2 +- gramps/gui/views/treemodels/familymodel.py | 2 +- gramps/gui/views/treemodels/mediamodel.py | 2 +- gramps/gui/views/treemodels/notemodel.py | 2 +- gramps/gui/views/treemodels/peoplemodel.py | 2 +- gramps/gui/views/treemodels/placemodel.py | 2 +- gramps/gui/views/treemodels/repomodel.py | 2 +- gramps/gui/views/treemodels/sourcemodel.py | 2 +- gramps/gui/views/treemodels/treebasemodel.py | 3 ++- 11 files changed, 19 insertions(+), 17 deletions(-) diff --git a/gramps/gui/views/listview.py b/gramps/gui/views/listview.py index 4d43c8bae..73019b49d 100644 --- a/gramps/gui/views/listview.py +++ b/gramps/gui/views/listview.py @@ -67,7 +67,7 @@ from ..dialog import QuestionDialog, QuestionDialog2, ErrorDialog from ..editors import FilterEditor from ..ddtargets import DdTargets from ..plug.quick import create_quickreport_menu, create_web_connect_menu -from ..utils import is_right_click +from ..utils import is_right_click, rgb_to_hex from ..widgets.interactivesearchbox import InteractiveSearchBox #---------------------------------------------------------------- @@ -281,11 +281,12 @@ class ListView(NavigationView): function because we don't want to set the color of untagged rows. ''' fg_color = model.get_value(iter_, model.color_column()) - #for color errors, typically color column is badly set - if fg_color: - renderer.set_property('foreground', fg_color) - else: - LOG.debug('Bad color set: ' + str(fg_color)) + if not fg_color: + context = self.list.get_style_context() + color = context.get_color(Gtk.StateFlags.ACTIVE) + fg_color = rgb_to_hex((color.red, color.green, color.blue)) + + renderer.set_property('foreground', fg_color) def set_active(self): """ diff --git a/gramps/gui/views/treemodels/citationbasemodel.py b/gramps/gui/views/treemodels/citationbasemodel.py index 76991d028..10c953306 100644 --- a/gramps/gui/views/treemodels/citationbasemodel.py +++ b/gramps/gui/views/treemodels/citationbasemodel.py @@ -139,7 +139,7 @@ class CitationBaseModel: tag_handle = data[0] cached, tag_color = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[COLUMN_TAGS]: tag = self.db.get_tag_from_handle(handle) @@ -300,7 +300,7 @@ class CitationBaseModel: tag_handle = data[0] cached, tag_color = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[COLUMN2_TAGS]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/eventmodel.py b/gramps/gui/views/treemodels/eventmodel.py index 0c43a5e7d..a2ae83096 100644 --- a/gramps/gui/views/treemodels/eventmodel.py +++ b/gramps/gui/views/treemodels/eventmodel.py @@ -208,7 +208,7 @@ class EventModel(FlatBaseModel): tag_handle = data[0] cached, tag_color = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[COLUMN_TAGS]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/familymodel.py b/gramps/gui/views/treemodels/familymodel.py index 64d23fb7c..b5de07723 100644 --- a/gramps/gui/views/treemodels/familymodel.py +++ b/gramps/gui/views/treemodels/familymodel.py @@ -220,7 +220,7 @@ class FamilyModel(FlatBaseModel): tag_handle = data[0] cached, tag_color = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[13]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/mediamodel.py b/gramps/gui/views/treemodels/mediamodel.py index 9e8c9acd3..aa146da59 100644 --- a/gramps/gui/views/treemodels/mediamodel.py +++ b/gramps/gui/views/treemodels/mediamodel.py @@ -171,7 +171,7 @@ class MediaModel(FlatBaseModel): tag_handle = data[0] cached, tag_color = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[11]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/notemodel.py b/gramps/gui/views/treemodels/notemodel.py index 444c82680..82ab7e61e 100644 --- a/gramps/gui/views/treemodels/notemodel.py +++ b/gramps/gui/views/treemodels/notemodel.py @@ -148,7 +148,7 @@ class NoteModel(FlatBaseModel): tag_handle = data[0] cached, value = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[Note.POS_TAGS]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/peoplemodel.py b/gramps/gui/views/treemodels/peoplemodel.py index e5b483c1a..8563141bd 100644 --- a/gramps/gui/views/treemodels/peoplemodel.py +++ b/gramps/gui/views/treemodels/peoplemodel.py @@ -538,7 +538,7 @@ class PeopleBaseModel(BaseModel): tag_handle = data[0] cached, value = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[COLUMN_TAGS]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/placemodel.py b/gramps/gui/views/treemodels/placemodel.py index f180f01f9..7e87534e7 100644 --- a/gramps/gui/views/treemodels/placemodel.py +++ b/gramps/gui/views/treemodels/placemodel.py @@ -201,7 +201,7 @@ class PlaceBaseModel: tag_handle = data[0] cached, value = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[16]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/repomodel.py b/gramps/gui/views/treemodels/repomodel.py index 02790f7d1..01415c7f2 100644 --- a/gramps/gui/views/treemodels/repomodel.py +++ b/gramps/gui/views/treemodels/repomodel.py @@ -253,7 +253,7 @@ class RepositoryModel(FlatBaseModel): tag_handle = data[0] cached, tag_color = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[8]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/sourcemodel.py b/gramps/gui/views/treemodels/sourcemodel.py index 62ef58e9a..92996cd3c 100644 --- a/gramps/gui/views/treemodels/sourcemodel.py +++ b/gramps/gui/views/treemodels/sourcemodel.py @@ -143,7 +143,7 @@ class SourceModel(FlatBaseModel): tag_handle = data[0] cached, value = self.get_cached_value(tag_handle, "TAG_COLOR") if not cached: - tag_color = "#000000000000" + tag_color = "" tag_priority = None for handle in data[11]: tag = self.db.get_tag_from_handle(handle) diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index ca361f2be..3f6f3fa88 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -898,7 +898,8 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): if node.handle is None: # Header rows dont get the foreground color set if col == self.color_column(): - return "#000000000000" + #color must not be utf-8 + return "" # Return the node name for the first column if col == 0: