[d-feet: 1/2] Honor theme's foreground color



commit e6488e6c0fd0416c54ecff1dd682f0ae8aa4c6fb
Author: Guido Günther <agx sigxcpu org>
Date:   Wed May 9 12:37:43 2018 +0200

    Honor theme's foreground color
    
    This makes property names readable on dark themes like adwaita-dark.

 src/dfeet/introspection_helper.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/dfeet/introspection_helper.py b/src/dfeet/introspection_helper.py
index 68e3cd6..7edbdc4 100644
--- a/src/dfeet/introspection_helper.py
+++ b/src/dfeet/introspection_helper.py
@@ -1,16 +1,24 @@
 # -*- coding: utf-8 -*-
 
-from gi.repository import GObject, Gio
+from gi.repository import GObject, Gio, Gtk
 from dfeet import dbus_utils
 
+_style_context = None
+_fg_color = "#000000"
+
+def fg_color():
+    global _style_context, _fg_color
+    if _style_context is None:
+        _style_context = Gtk.StyleContext()
+        color = _style_context.get_color(Gtk.StateFlags.NORMAL)
+        _fg_color = "#%x%x%x" % (color.red * 255, color.green * 255, color.blue * 255)
+    return _fg_color
 
 def args_signature_markup(arg_signature):
     return '<small><span foreground="#2E8B57">%s</span></small>' % (arg_signature)
 
-
 def args_name_markup(arg_name):
-    return '<small><span foreground="#000000">%s</span></small>' % (arg_name)
-
+    return '<small><span foreground="%s">%s</span></small>' % (fg_color(), arg_name)
 
 class DBusNode(GObject.GObject):
     """object to represent a DBus Node (object path)"""


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]