Commit efe46678 authored by Kai Willadsen's avatar Kai Willadsen

Update CSS colour locations to handle style scheme changes instead

parent 84db9989
......@@ -23,6 +23,7 @@ from gi.repository import Gdk
from gi.repository import Gtk
from meld.misc import get_common_theme
from meld.settings import meldsettings
class DiffMap(Gtk.DrawingArea):
......@@ -41,7 +42,8 @@ class DiffMap(Gtk.DrawingArea):
self._scroll_height = 0
self._setup = False
self._width = 10
self.do_style_updated()
meldsettings.connect('changed', self.on_setting_changed)
self.on_setting_changed(meldsettings, 'style-scheme')
def setup(self, scrollbar, change_chunk_fn):
for (o, h) in self._handlers:
......@@ -71,9 +73,9 @@ class DiffMap(Gtk.DrawingArea):
def on_diffs_changed(self, *args):
self._cached_map = None
def do_style_updated(self, *args):
Gtk.DrawingArea.do_style_updated(self)
self.fill_colors, self.line_colors = get_common_theme()
def on_setting_changed(self, meldsettings, key):
if key == 'style-scheme':
self.fill_colors, self.line_colors = get_common_theme()
def on_scrollbar_style_updated(self, scrollbar):
value = GObject.Value(int)
......
......@@ -19,6 +19,7 @@ from gi.repository import GtkSource
from meld.conf import _
from meld.const import MODE_REPLACE, MODE_DELETE, MODE_INSERT
from meld.misc import get_common_theme
from meld.settings import meldsettings
# Fixed size of the renderer. Ideally this would be font-dependent and
# would adjust to other textview attributes, but that's both quite difficult
......@@ -66,7 +67,14 @@ class GutterRendererChunkAction(GtkSource.GutterRendererPixbuf):
self.filediff = filediff
self.filediff.connect("action-mode-changed",
self.on_container_mode_changed)
self.do_style_updated()
meldsettings.connect('changed', self.on_setting_changed)
self.on_setting_changed(meldsettings, 'style-scheme')
def on_setting_changed(self, meldsettings, key):
if key == 'style-scheme':
#meldsettings.style_scheme
self.fill_colors, self.line_colors = get_common_theme()
def do_activate(self, start, area, event):
line = start.get_line()
......@@ -110,11 +118,6 @@ class GutterRendererChunkAction(GtkSource.GutterRendererPixbuf):
copy_down.connect('activate', copy_chunk, chunk, False)
return copy_menu
def do_style_updated(self):
# GtkSource.GutterRendererPixbuf.do_style_updated(self)
# FIXME: Should be self.get_view() or something, but when and how?
self.fill_colors, self.line_colors = get_common_theme()
def do_draw(self, context, background_area, cell_area, start, end, state):
line = start.get_line()
chunk_index = self.linediffer.locate_chunk(self.from_pane, line)[0]
......
......@@ -43,7 +43,7 @@ class LinkMap(Gtk.DrawingArea):
self.view_indices = [filediff.textview.index(t) for t in self.views]
self.on_setting_changed(meldsettings, 'font')
self.do_style_updated()
self.on_setting_changed(meldsettings, 'style-scheme')
def on_setting_changed(self, settings, key):
if key == 'font':
......@@ -53,10 +53,8 @@ class LinkMap(Gtk.DrawingArea):
line_height_points = metrics.get_ascent() + metrics.get_descent()
self.line_height = line_height_points // 1024
self.queue_draw()
def do_style_updated(self, *args):
Gtk.DrawingArea.do_style_updated(self)
self.fill_colors, self.line_colors = get_common_theme()
elif key == 'style-scheme':
self.fill_colors, self.line_colors = get_common_theme()
def do_draw(self, context):
if not self.filediff:
......
......@@ -175,8 +175,6 @@ def colour_lookup_with_fallback(name, attribute):
def get_common_theme():
# TODO: Everywhere that calls get_common_theme needs to bind to the
# gsettings style-scheme key instead of triggering on style_updated
lookup = colour_lookup_with_fallback
fill_colours = {
"insert": lookup("meld:insert", "background"),
......
......@@ -109,7 +109,7 @@ class MeldSourceView(GtkSource.View):
meldsettings.connect('changed', self.on_setting_changed)
self.on_setting_changed(meldsettings, 'font')
self.do_style_updated()
self.on_setting_changed(meldsettings, 'style-scheme')
def late_bind(self):
settings.bind(
......@@ -138,24 +138,21 @@ class MeldSourceView(GtkSource.View):
def on_setting_changed(self, settings, key):
if key == 'font':
self.override_font(meldsettings.font)
elif key == 'style-scheme':
self.highlight_color = colour_lookup_with_fallback(
"meld:current-line-highlight", "background")
self.syncpoint_color = colour_lookup_with_fallback(
"meld:syncpoint-outline", "foreground")
self.fill_colors, self.line_colors = get_common_theme()
tag = self.get_buffer().get_tag_table().lookup("inline")
tag.props.background_rgba = colour_lookup_with_fallback(
"meld:inline", "background")
def do_realize(self):
bind_settings(self)
return GtkSource.View.do_realize(self)
def do_style_updated(self):
GtkSource.View.do_style_updated(self)
self.highlight_color = colour_lookup_with_fallback(
"meld:current-line-highlight", "background")
self.syncpoint_color = colour_lookup_with_fallback(
"meld:syncpoint-outline", "foreground")
self.fill_colors, self.line_colors = get_common_theme()
tag = self.get_buffer().get_tag_table().lookup("inline")
tag.props.background_rgba = colour_lookup_with_fallback(
"meld:inline", "background")
def do_draw_layer(self, layer, context):
if layer != Gtk.TextViewLayer.BELOW:
return GtkSource.View.do_draw_layer(self, layer, context)
......
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