ui/crumbs/persistenttooltip: fix colours on darker themes

Darker gtk+ themes, such as the one used in Ubuntu Unity, revealed that the
PersistentTooltip styling wasn't setting the label colour correctly.

Set the label foreground colour to the tooltip_fg_colour value as read from
gtk-color-scheme property of the system settings.

(From Poky rev: 0934cfcea5986dbdc50e7159ee907c70b0b3e587)

(Bitbake rev: ab15ef585e51e4c85a4a55aa6b35fbf3b53f3805)

Signed-off-by: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Lock 2012-03-20 15:45:33 -07:00 committed by Richard Purdie
parent f460c2f10d
commit e587c1ef3f
1 changed files with 21 additions and 5 deletions

View File

@ -38,6 +38,11 @@ class PersistentTooltip(gtk.Window):
def __init__(self, markup):
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
# Inherit the system theme for a tooltip
style = gtk.rc_get_style_by_paths(gtk.settings_get_default(),
'gtk-tooltip', 'gtk-tooltip', gobject.TYPE_NONE)
self.set_style(style)
# The placement of the close button on the tip should reflect how the
# window manager of the users system places close buttons. Try to read
# the metacity gconf key to determine whether the close button is on the
@ -96,17 +101,28 @@ class PersistentTooltip(gtk.Window):
hbox.show()
vbox.pack_end(hbox, True, True, 6)
self.label = gtk.Label()
# We want to match the colours of the normal tooltips, as dictated by
# the users gtk+-2.0 theme, wherever possible - on some systems this
# requires explicitly setting a fg_color for the label which matches the
# tooltip_fg_color
settings = gtk.settings_get_default()
colours = settings.get_property('gtk-color-scheme').split('\n')
# remove any empty lines, there's likely to be a trailing one after
# calling split on a dictionary-like string
colours = filter(None, colours)
for col in colours:
item, val = col.split(': ')
if item == 'tooltip_fg_color':
style = self.label.get_style()
style.fg[gtk.STATE_NORMAL] = gtk.gdk.color_parse(val)
self.label.set_style(style)
break # we only care for the tooltip_fg_color
self.label.set_markup(markup)
self.label.show()
hbox.pack_end(self.label, True, True, 6)
self.connect("key-press-event", self._catch_esc_cb)
# Inherit the system theme for a tooltip
style = gtk.rc_get_style_by_paths(gtk.settings_get_default(),
'gtk-tooltip', 'gtk-tooltip', gobject.TYPE_NONE)
self.set_style(style)
self.add(vbox)
"""