Commit 4901a07e authored by Kai Willadsen's avatar Kai Willadsen

dirdiff, tree: Give tree styles colours from the sourceview theme

Obviously this is a bit weird, but it's basically the least-worst
option right now.
parent e3e8cb38
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<style name="meld:error" background="#fce94f" foreground="#faad3d" line-background="#fade0a"/> <style name="meld:error" background="#fce94f" foreground="#faad3d" line-background="#fade0a"/>
<style name="meld:inline" background="#8ac2ff"/> <style name="meld:inline" background="#8ac2ff"/>
<style name="meld:current-line-highlight" background="#ffff00"/> <style name="meld:current-line-highlight" background="#ffff00"/>
<style name="meld:unknown-text" background="#888888"/> <style name="meld:unknown-text" foreground="#888888"/>
<style name="meld:syncpoint-outline" foreground="#555555"/> <style name="meld:syncpoint-outline" foreground="#555555"/>
<style name="meld:current-chunk-highlight" background="rgba(255, 255, 255, 0.5)"/> <style name="meld:current-chunk-highlight" background="rgba(255, 255, 255, 0.5)"/>
</style-scheme> </style-scheme>
...@@ -376,7 +376,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component): ...@@ -376,7 +376,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
column.pack_start(renicon, False) column.pack_start(renicon, False)
column.pack_start(rentext, True) column.pack_start(rentext, True)
column.set_attributes(rentext, markup=col_index(tree.COL_TEXT, i), column.set_attributes(rentext, markup=col_index(tree.COL_TEXT, i),
foreground=col_index(tree.COL_FG, i), foreground_rgba=col_index(tree.COL_FG, i),
style=col_index(tree.COL_STYLE, i), style=col_index(tree.COL_STYLE, i),
weight=col_index(tree.COL_WEIGHT, i), weight=col_index(tree.COL_WEIGHT, i),
strikethrough=col_index(tree.COL_STRIKE, i)) strikethrough=col_index(tree.COL_STRIKE, i))
......
...@@ -16,16 +16,17 @@ ...@@ -16,16 +16,17 @@
import os import os
from gi.repository import GLib from gi.repository import GLib
from gi.repository import Gdk
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Pango from gi.repository import Pango
COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_STYLE, \ COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_STYLE, \
COL_WEIGHT, COL_STRIKE, COL_END = list(range(10)) COL_WEIGHT, COL_STRIKE, COL_END = list(range(10))
COL_TYPES = (str, str, str, str, str, str, Pango.Style, COL_TYPES = (str, str, str, str, str, Gdk.RGBA, Pango.Style,
Pango.Weight, bool) Pango.Weight, bool)
from meld.misc import colour_lookup_with_fallback
from meld.vc._vc import \ from meld.vc._vc import \
STATE_IGNORED, STATE_NONE, STATE_NORMAL, STATE_NOCHANGE, \ STATE_IGNORED, STATE_NONE, STATE_NORMAL, STATE_NOCHANGE, \
STATE_ERROR, STATE_EMPTY, STATE_NEW, \ STATE_ERROR, STATE_EMPTY, STATE_NEW, \
...@@ -53,23 +54,13 @@ class DiffTreeStore(Gtk.TreeStore): ...@@ -53,23 +54,13 @@ class DiffTreeStore(Gtk.TreeStore):
roman, italic = Pango.Style.NORMAL, Pango.Style.ITALIC roman, italic = Pango.Style.NORMAL, Pango.Style.ITALIC
normal, bold = Pango.Weight.NORMAL, Pango.Weight.BOLD normal, bold = Pango.Weight.NORMAL, Pango.Weight.BOLD
def lookup(name, default): lookup = colour_lookup_with_fallback
try: unk_fg = lookup("meld:unknown-text", "foreground")
found, colour = style.lookup_color(name) new_fg = lookup("meld:insert", "foreground")
if found: mod_fg = lookup("meld:replace", "foreground")
colour = colour.to_string() del_fg = lookup("meld:delete", "foreground")
else: err_fg = lookup("meld:error", "foreground")
colour = default con_fg = lookup("meld:conflict", "foreground")
except AttributeError:
colour = default
return colour
unk_fg = lookup("unknown-text", "#888888")
new_fg = lookup("insert-text", "#008800")
mod_fg = lookup("replace-text", "#0044dd")
del_fg = lookup("delete-text", "#880000")
err_fg = lookup("error-text", "#ffff00")
con_fg = lookup("conflict-text", "#ff0000")
self.text_attributes = [ self.text_attributes = [
# foreground, style, weight, strikethrough # foreground, style, weight, strikethrough
...@@ -158,6 +149,8 @@ class DiffTreeStore(Gtk.TreeStore): ...@@ -158,6 +149,8 @@ class DiffTreeStore(Gtk.TreeStore):
self.set_value(it, col_idx(COL_ICON, pane), icon) self.set_value(it, col_idx(COL_ICON, pane), icon)
# FIXME: This is horrible, but EmblemCellRenderer crashes # FIXME: This is horrible, but EmblemCellRenderer crashes
# if you try to give it a Gdk.Color property # if you try to give it a Gdk.Color property
if tint:
tint = tint.to_string() if tint else None
self.set_value(it, col_idx(COL_TINT, pane), tint) self.set_value(it, col_idx(COL_TINT, pane), tint)
fg, style, weight, strike = self.text_attributes[state] fg, style, weight, strike = self.text_attributes[state]
......
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