From da052634022e0acece4b629736a912355aed6351 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 20 Aug 2012 15:20:33 +0000 Subject: [PATCH] GTK3: use style_context to draw correct link color, and to set shade color (not ideal, but better) svn: r20234 --- src/gui/widgets/labels.py | 24 +++++++++++++++++------- src/plugins/view/relview.py | 11 +++++++++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/gui/widgets/labels.py b/src/gui/widgets/labels.py index 87bdf4a4a..7c342323c 100644 --- a/src/gui/widgets/labels.py +++ b/src/gui/widgets/labels.py @@ -50,6 +50,7 @@ from gi.repository import Pango # #------------------------------------------------------------------------- from gen.constfunc import has_display, win +from gui.utils import rgb_to_hex #------------------------------------------------------------------------- # @@ -77,12 +78,22 @@ class LinkLabel(Gtk.EventBox): def __init__(self, label, func, handle, emph=False, theme="CLASSIC"): self.theme = theme self.emph = emph + + GObject.GObject.__init__(self) + + st_cont = self.get_style_context() + col = st_cont.lookup_color('link_color') + if col[0]: + self.color = rgb_to_hex((col[1].red, col[1].green, col[1].blue)) + else: + self.color = 'blue' + if emph: #emphasize a link if theme == "CLASSIC": format = 'underline="single" weight="heavy" style="italic"' elif theme == "WEBPAGE": - format = 'foreground="blue" weight="heavy"' + format = 'foreground="' + self.color + '" weight="heavy"' else: raise AttributeError("invalid theme: '%s'" % theme) elif emph is None: @@ -98,11 +109,10 @@ class LinkLabel(Gtk.EventBox): if theme == "CLASSIC": format = 'underline="single"' elif theme == "WEBPAGE": - format = 'foreground="blue"' + format = 'foreground="' + self.color + '"' else: raise AttributeError("invalid theme: '%s'" % theme) - GObject.GObject.__init__(self) self.orig_text = cgi.escape(label[0]) self.gender = label[1] self.decoration = format @@ -139,10 +149,10 @@ class LinkLabel(Gtk.EventBox): if self.emph: #emphasize a link if self.theme == "CLASSIC": - format = 'foreground="blue" underline="single" '\ + format = 'foreground="' + self.color + '" underline="single" '\ 'weight="heavy" style="italic"' elif self.theme == "WEBPAGE": - format = 'underline="single" foreground="blue" '\ + format = 'underline="single" foreground="' + self.color + '" '\ 'weight="heavy"' else: raise AttributeError("invalid theme: '%s'" % theme) @@ -157,9 +167,9 @@ class LinkLabel(Gtk.EventBox): else: #no emphasize, a link if self.theme == "CLASSIC": - format = 'foreground="blue" underline="single"' + format = 'foreground="' + self.color + '" underline="single"' elif self.theme == "WEBPAGE": - format = 'underline="single" foreground="blue"' + format = 'underline="single" foreground="' + self.color + '"' else: raise AttributeError("invalid theme: '%s'" % theme) diff --git a/src/plugins/view/relview.py b/src/plugins/view/relview.py index c38eab202..7198b092e 100644 --- a/src/plugins/view/relview.py +++ b/src/plugins/view/relview.py @@ -151,8 +151,6 @@ class RelationshipView(NavigationView): uistate.connect('nameformat-changed', self.build_tree) self.redrawing = False - self.color = Gdk.RGBA() - self.color.parse("White") self.child = None self.old_handle = None @@ -313,6 +311,15 @@ 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()