Commit fe22c6d4 authored by Kai Willadsen's avatar Kai Willadsen

sourceview: Move MeldBuffer creation and styling from FileDiff

parent 3cb578f3
......@@ -177,11 +177,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.warned_bad_comparison = False
for v in self.textview:
buf = meldbuffer.MeldBuffer()
buf = v.get_buffer()
buf.connect('begin_user_action',
self.on_textbuffer_begin_user_action)
buf.connect('end_user_action', self.on_textbuffer_end_user_action)
v.set_buffer(buf)
buf.data.connect('file-changed', self.notify_file_changed)
v.late_bind()
self._keymask = 0
......@@ -218,7 +217,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.in_nested_textview_gutter_expose = False
self._cached_match = CachedSequenceMatcher()
for buf in self.textbuffer:
buf.create_tag("inline")
buf.connect("notify::has-selection",
self.update_text_actions_sensitivity)
......@@ -229,10 +227,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.findbar = findbar.FindBar(self.grid)
self.grid.attach(self.findbar.widget, 1, 2, 5, 1)
self.widget.ensure_style()
self.on_style_updated(self.widget)
self.widget.connect("style-updated", self.on_style_updated)
self.set_num_panes(num_panes)
self.cursor = CursorDetails()
self.connect("current-diff-changed", self.on_current_diff_changed)
......@@ -309,16 +303,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.findbar.start_find_previous(self.focus_pane)
self.keymask &= ~mod_key
def on_style_updated(self, widget):
style = widget.get_style_context()
for buf in self.textbuffer:
tag = buf.get_tag_table().lookup("inline")
tag.props.background_rgba = colour_lookup_with_fallback(
style, "inline-bg", "LightSteelBlue2")
self.queue_draw()
def on_focus_change(self):
self.keymask = 0
......
......@@ -21,6 +21,8 @@ from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import GtkSource
import meldbuffer
from meld.misc import colour_lookup_with_fallback, get_common_theme
from meld.settings import bind_settings, settings
......@@ -101,6 +103,12 @@ class MeldSourceView(GtkSource.View):
self.animating_chunks = []
self.syncpoints = []
buf = meldbuffer.MeldBuffer()
buf.create_tag("inline")
self.set_buffer(buf)
self.do_style_updated()
def late_bind(self):
settings.bind(
'show-line-numbers', self, 'show-line-numbers',
......@@ -129,7 +137,7 @@ class MeldSourceView(GtkSource.View):
bind_settings(self)
return GtkSource.View.do_realize(self)
def do_style_updated(self, *args):
def do_style_updated(self):
GtkSource.View.do_style_updated(self)
style = self.get_style_context()
......@@ -139,6 +147,10 @@ class MeldSourceView(GtkSource.View):
style, "syncpoint-outline", "#555555")
self.fill_colors, self.line_colors = get_common_theme(style)
tag = self.get_buffer().get_tag_table().lookup("inline")
tag.props.background_rgba = colour_lookup_with_fallback(
style, "inline-bg", "LightSteelBlue2")
def do_draw(self, context):
windows = [
......
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