Commit 281583a0 by Kai Willadsen

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.
parent fb085b23
......@@ -196,12 +196,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)
......
......@@ -419,6 +419,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"),
......@@ -1529,6 +1532,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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment