[meld] filediff: Repaint TextView background for modified CSS (bgo#741287)



commit 8ebdb67243efb87f39c971cbbfe4d90040dd6617
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Dec 13 08:34:04 2014 +1000

    filediff: Repaint TextView background for modified CSS (bgo#741287)
    
    In cases when we've messed with our TextView's CSS to fix GTK+ 3.14
    regressions, we need to also repaint the background because some themes
    don't otherwise do so. Specifically, this breaks oxygen-gtk3 such that
    diff regions have a background colour, but the rest of the text view
    is unpainted, which is pretty terrible.

 bin/meld         |    6 +++++-
 meld/filediff.py |    8 ++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 060b15e..0691b9a 100755
--- a/bin/meld
+++ b/bin/meld
@@ -204,12 +204,16 @@ def setup_resources():
         style.set_path(widget_path)
         # This is basically indefensible internal GTK+ ABI, but... whatever.
         style.add_class(Gtk.STYLE_CLASS_VIEW)
+        old_bg_color = style.get_background_color(
+            Gtk.StateFlags.NORMAL).to_string()
         color = style.get_background_color(Gtk.StateFlags.SELECTED).to_string()
 
         fixes_provider = Gtk.CssProvider()
         fixes_provider.load_from_data(
+            "@define-color override-background-color %s; "
             "MeldSourceView { background-color: rgba(0.0, 0.0, 0.0, 0.0); } "
-            "MeldSourceView:selected { background-color: %s; } " % color)
+            "MeldSourceView:selected { background-color: %s; } " %
+            (old_bg_color, color))
         Gtk.StyleContext.add_provider_for_screen(
             Gdk.Screen.get_default(), fixes_provider,
             Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
diff --git a/meld/filediff.py b/meld/filediff.py
index daa3166..f8b6b98 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -421,6 +421,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             tag = buf.get_tag_table().lookup("inline")
             tag.props.background_rgba = lookup("inline-bg", "LightSteelBlue2")
 
+        override_bg = style.lookup_color("override-background-color")
+        self.override_bg = override_bg[1] if override_bg[0] else None
+
         self.fill_colors = {"insert"  : lookup("insert-bg", "DarkSeaGreen1"),
                             "delete"  : lookup("insert-bg", "DarkSeaGreen1"),
                             "conflict": lookup("conflict-bg", "Pink"),
@@ -1531,6 +1534,11 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         width, height = view_allocation.width, view_allocation.height
         context.set_line_width(1.0)
 
+        if self.override_bg:
+            context.set_source_rgba(*self.override_bg)
+            context.rectangle(0, 0, width, height)
+            context.fill()
+
         for change in self.linediffer.single_changes(pane, bounds):
             ypos0 = textview.get_y_for_line_num(change[1]) - visible.y
             ypos1 = textview.get_y_for_line_num(change[2]) - visible.y


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