[meld] Rework treeviews to use text colour values from gtkrc
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Rework treeviews to use text colour values from gtkrc
- Date: Tue, 4 Sep 2012 20:32:30 +0000 (UTC)
commit caa7251428ccfb8fedca102dc507aa4f1de37481
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Jan 2 11:56:18 2012 +1000
Rework treeviews to use text colour values from gtkrc
data/gtkrc | 14 +++++++++++
meld/dirdiff.py | 7 ++++-
meld/tree.py | 67 +++++++++++++++++++++++++++++++++++-------------------
meld/vcview.py | 5 ++-
4 files changed, 65 insertions(+), 28 deletions(-)
---
diff --git a/data/gtkrc b/data/gtkrc
index 78d845f..4c8ccce 100644
--- a/data/gtkrc
+++ b/data/gtkrc
@@ -3,16 +3,30 @@ style "meld-color-scheme"
{
color["insert-bg"] = "DarkSeaGreen1"
color["insert-outline"] = shade(0.8, @insert-bg)
+ color["insert-text"] = "#008800"
+
color["delete-bg"] = "White"
color["delete-outline"] = shade(0.8, @delete-bg)
+ color["delete-text"] = "#880000"
+
color["replace-bg"] = "#ddeeff"
color["replace-outline"] = shade(0.8, @replace-bg)
+ color["replace-text"] = "#0044dd"
+
color["conflict-bg"] = "Pink"
color["conflict-outline"] = shade(0.8, @conflict-bg)
+ color["conflict-text"] = "#ffffff"
+
color["error-bg"] = "#fce94f"
color["error-outline"] = shade(0.8, @error-bg)
+ color["error-text"] = "#ff0000"
+
color["inline-bg"] = "LightSteelBlue2"
color["inline-fg"] = "Red"
+
+ color["unknown-text"] = "#888888"
+
color["current-line-highlight"] = "#ffff00"
}
widget "meldapp.*" style : lowest "meld-color-scheme"
+
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index d744cf4..60f2f63 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -266,6 +266,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.widget.ensure_style()
self.set_num_panes(num_panes)
+
+ self.widget.connect("style-set", self.model.on_style_set)
+
self.focus_in_events = []
self.focus_out_events = []
for treeview in self.treeview:
@@ -286,8 +289,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
column.pack_start(rentext, expand=1)
col_index = self.model.column_index
column.set_attributes(rentext, text=col_index(tree.COL_TEXT,i),
- foreground=col_index(tree.COL_FG, i),
- background=col_index(tree.COL_BG, i),
+ foreground_gdk=col_index(tree.COL_FG, i),
+ background_gdk=col_index(tree.COL_BG, 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 926d135..47419c4 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -22,7 +22,8 @@ import pango
COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_BG, COL_STYLE, \
COL_WEIGHT, COL_STRIKE, COL_END = range(11)
-COL_TYPES = (str, str, str, str, str, str, str, pango.Style, pango.Weight, bool)
+COL_TYPES = (str, str, str, str, str, gtk.gdk.Color, gtk.gdk.Color,
+ pango.Style, pango.Weight, bool)
from meld.vc._vc import \
@@ -42,38 +43,56 @@ class DiffTreeStore(gtk.TreeStore):
self.ntree = ntree
self._setup_default_styles()
- def _setup_default_styles(self):
+ def on_style_set(self, widget, prev_style):
+ style = widget.get_style()
+ self._setup_default_styles(style)
+
+ def _setup_default_styles(self, style=None):
roman, italic = pango.STYLE_NORMAL, pango.STYLE_ITALIC
normal, bold = pango.WEIGHT_NORMAL, pango.WEIGHT_BOLD
+ if style:
+ lookup = lambda color_id, default: style.lookup_color(color_id)
+ else:
+ lookup = lambda color_id, default: gtk.gdk.color_parse(default)
+
+ 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", "#ff0000")
+ err_bg = lookup("error-bg", "#ffff00")
+ con_fg = lookup("conflict-text", "#ff0000")
+ con_bg = lookup("conflict-bg", "#ffdddd")
+
self.text_attributes = [
# foreground, background, style, weight, strikethrough
- ("#888888", None, roman, normal, None), # STATE_IGNORED
- ("#888888", None, roman, normal, None), # STATE_NONE
- (None, None, roman, normal, None), # STATE_NORMAL
- (None, None, italic, normal, None), # STATE_NOCHANGE
- ("#ff0000", "yellow", roman, bold, None), # STATE_ERROR
- ("#888888", None, italic, normal, None), # STATE_EMPTY
- ("#008800", None, roman, bold, None), # STATE_NEW
- ("#880000", None, roman, bold, None), # STATE_MODIFIED
- ("#ff0000", "#ffeeee", roman, bold, None), # STATE_CONFLICT
- ("#880000", None, roman, bold, True), # STATE_REMOVED
- ("#888888", None, roman, normal, True), # STATE_MISSING
+ (unk_fg, None, roman, normal, None), # STATE_IGNORED
+ (unk_fg, None, roman, normal, None), # STATE_NONE
+ (None, None, roman, normal, None), # STATE_NORMAL
+ (None, None, italic, normal, None), # STATE_NOCHANGE
+ (err_fg, err_bg, roman, bold, None), # STATE_ERROR
+ (unk_fg, None, italic, normal, None), # STATE_EMPTY
+ (new_fg, None, roman, bold, None), # STATE_NEW
+ (mod_fg, None, roman, bold, None), # STATE_MODIFIED
+ (con_fg, con_bg, roman, bold, None), # STATE_CONFLICT
+ (del_fg, None, roman, bold, True), # STATE_REMOVED
+ (unk_fg, None, roman, normal, True), # STATE_MISSING
]
self.icon_details = [
# file-icon, folder-icon, file-tint, folder-tint
- ("text-x-generic", "folder", None, None), # IGNORED
- ("text-x-generic", "folder", None, None), # NONE
- ("text-x-generic", "folder", None, None), # NORMAL
- ("text-x-generic", "folder", None, None), # NOCHANGE
- (None, None , None, None), # ERROR
- (None, None , None, None), # EMPTY
- ("text-x-generic", "folder", "#008800", None), # NEW
- ("text-x-generic", "folder", "#880000", None), # MODIFIED
- ("text-x-generic", "folder", "#880000", None), # CONFLICT
- ("text-x-generic", "folder", "#880000", None), # REMOVED
- ("text-x-generic", "folder", "#888888", "#888888"), # MISSING
+ ("text-x-generic", "folder", None, None), # IGNORED
+ ("text-x-generic", "folder", None, None), # NONE
+ ("text-x-generic", "folder", None, None), # NORMAL
+ ("text-x-generic", "folder", None, None), # NOCHANGE
+ (None, None , None, None), # ERROR
+ (None, None , None, None), # EMPTY
+ ("text-x-generic", "folder", new_fg, None), # NEW
+ ("text-x-generic", "folder", mod_fg, None), # MODIFIED
+ ("text-x-generic", "folder", con_fg, None), # CONFLICT
+ ("text-x-generic", "folder", del_fg, None), # REMOVED
+ ("text-x-generic", "folder", unk_fg, unk_fg), # MISSING
]
assert len(self.icon_details) == len(self.text_attributes) == STATE_MAX
diff --git a/meld/vcview.py b/meld/vcview.py
index 7cf57e1..410c7b0 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -159,6 +159,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
button.props.icon_name = button.props.stock_id
self.tempdirs = []
self.model = VcTreeStore()
+ self.widget.connect("style-set", self.model.on_style_set)
self.treeview.set_model(self.model)
self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.treeview.set_headers_visible(1)
@@ -175,8 +176,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
icon_tint=col_index(tree.COL_TINT, 0))
column.set_attributes(rentext,
text=col_index(tree.COL_TEXT, 0),
- foreground=col_index(tree.COL_FG, 0),
- background=col_index(tree.COL_BG, 0),
+ foreground_gdk=col_index(tree.COL_FG, 0),
+ background_gdk=col_index(tree.COL_BG, 0),
style=col_index(tree.COL_STYLE, 0),
weight=col_index(tree.COL_WEIGHT, 0),
strikethrough=col_index(tree.COL_STRIKE, 0))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]