[meld] bin/meld: Work-around for GTK+ 3.14 background drawing, part 2
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] bin/meld: Work-around for GTK+ 3.14 background drawing, part 2
- Date: Sat, 25 Oct 2014 01:01:09 +0000 (UTC)
commit f9c4e540385adfb5c22b8d747c0e2a8fc42ffe37
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Oct 25 10:55:22 2014 +1000
bin/meld: Work-around for GTK+ 3.14 background drawing, part 2
Commit 61f53b0c reset the drawn background to transparent, which works
for most drawing, but looks terrible as soon as any text is selected.
This commit adds a secondary horrible hack that tries to reproduce the
selected text background colour once we've reset the main widget
background. This does use a horrible undocumented internal CSS class
that GtkTextView applies when rendering text, but it's the only way
that I could find that should hopefully work across different themes.
bin/meld | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 5ca3344..9e7394a 100755
--- a/bin/meld
+++ b/bin/meld
@@ -196,9 +196,20 @@ def setup_resources():
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
if Gtk.get_minor_version() >= 13:
+ # Retrieve the selection colour from GtkTextView. Ideally, we'd do this
+ # on MeldSourceView, but we don't really want to import that here.
+ style = Gtk.StyleContext()
+ widget_path = Gtk.WidgetPath()
+ widget_path.append_type(Gtk.TextView)
+ style.set_path(widget_path)
+ # This is basically indefensible internal GTK+ ABI, but... whatever.
+ style.add_class(Gtk.STYLE_CLASS_VIEW)
+ color = style.get_background_color(Gtk.StateFlags.SELECTED).to_string()
+
fixes_provider = Gtk.CssProvider()
fixes_provider.load_from_data(
- "MeldSourceView { background-color: rgba(0.0, 0.0, 0.0, 0.0); }")
+ "MeldSourceView { background-color: rgba(0.0, 0.0, 0.0, 0.0); } "
+ "MeldSourceView:selected { background-color: %s; } " % color)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), fixes_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]