[meld: 167/180] dirdiff, tree: Give tree styles colours from the sourceview theme
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 167/180] dirdiff, tree: Give tree styles colours from the sourceview theme
- Date: Thu, 23 Jul 2015 21:45:24 +0000 (UTC)
commit 4901a07ea54a091f9c42e0a84f298430f0ca3401
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Jul 4 08:03:53 2015 +1000
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.
data/styles/meld-base.xml | 2 +-
meld/dirdiff.py | 2 +-
meld/tree.py | 31 ++++++++++++-------------------
3 files changed, 14 insertions(+), 21 deletions(-)
---
diff --git a/data/styles/meld-base.xml b/data/styles/meld-base.xml
index dbdb76a..3ef4c25 100644
--- a/data/styles/meld-base.xml
+++ b/data/styles/meld-base.xml
@@ -10,7 +10,7 @@
<style name="meld:error" background="#fce94f" foreground="#faad3d" line-background="#fade0a"/>
<style name="meld:inline" background="#8ac2ff"/>
<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:current-chunk-highlight" background="rgba(255, 255, 255, 0.5)"/>
</style-scheme>
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index ccbe450..82eeed9 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -376,7 +376,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
column.pack_start(renicon, False)
column.pack_start(rentext, True)
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),
weight=col_index(tree.COL_WEIGHT, i),
strikethrough=col_index(tree.COL_STRIKE, i))
diff --git a/meld/tree.py b/meld/tree.py
index a84dd99..416fdda 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -16,16 +16,17 @@
import os
from gi.repository import GLib
+from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_STYLE, \
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)
-
+from meld.misc import colour_lookup_with_fallback
from meld.vc._vc import \
STATE_IGNORED, STATE_NONE, STATE_NORMAL, STATE_NOCHANGE, \
STATE_ERROR, STATE_EMPTY, STATE_NEW, \
@@ -53,23 +54,13 @@ class DiffTreeStore(Gtk.TreeStore):
roman, italic = Pango.Style.NORMAL, Pango.Style.ITALIC
normal, bold = Pango.Weight.NORMAL, Pango.Weight.BOLD
- def lookup(name, default):
- try:
- found, colour = style.lookup_color(name)
- if found:
- colour = colour.to_string()
- else:
- colour = default
- 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")
+ lookup = colour_lookup_with_fallback
+ unk_fg = lookup("meld:unknown-text", "foreground")
+ new_fg = lookup("meld:insert", "foreground")
+ mod_fg = lookup("meld:replace", "foreground")
+ del_fg = lookup("meld:delete", "foreground")
+ err_fg = lookup("meld:error", "foreground")
+ con_fg = lookup("meld:conflict", "foreground")
self.text_attributes = [
# foreground, style, weight, strikethrough
@@ -158,6 +149,8 @@ class DiffTreeStore(Gtk.TreeStore):
self.set_value(it, col_idx(COL_ICON, pane), icon)
# FIXME: This is horrible, but EmblemCellRenderer crashes
# 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)
fg, style, weight, strike = self.text_attributes[state]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]