Subject: [PATCH] gitk: Add user-configurable branch bg color

From: Manuel Bua <[email-masked]>
Date: Sat, 16 Mar 2013 21:05:40 +0100

In some cases, the default branch background color (green) isn't
an optimal choice, thus it can be difficult to read.

This provides a way for the user to customize the color used to
fill the rectangle around the branch name, by choosing another
one from the "Preferences" dialog.

The default behavior of using "green" as the default color is
maintained.

Signed-off-by: Manuel Bua <[email-masked]>
---
 gitk | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/gitk b/gitk
index b3706fc..310c9a9 100755
--- a/gitk
+++ b/gitk
@@ -2720,7 +2720,7 @@ proc savestuff {w} {
     global maxwidth showneartags showlocalchanges
     global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
     global cmitmode wrapcomment datetimeformat limitdiffs
-    global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor
+    global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor branchcolor
     global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
     global hideremotes want_ttk maxrefs
 
@@ -2760,6 +2760,7 @@ proc savestuff {w} {
 	puts $f [list set selectbgcolor $selectbgcolor]
 	puts $f [list set extdifftool $extdifftool]
 	puts $f [list set perfile_attrs $perfile_attrs]
+	puts $f [list set branchcolor $branchcolor]
 
 	puts $f "set geometry(main) [wm geometry .]"
 	puts $f "set geometry(state) [wm state .]"
@@ -6344,7 +6345,7 @@ proc bindline {t id} {
 proc drawtags {id x xt y1} {
     global idtags idheads idotherrefs mainhead
     global linespc lthickness
-    global canv rowtextx curview fgcolor bgcolor ctxbut
+    global canv rowtextx curview fgcolor bgcolor ctxbut branchcolor
 
     set marks {}
     set ntags 0
@@ -6399,7 +6400,7 @@ proc drawtags {id x xt y1} {
 	} else {
 	    # draw a head or other ref
 	    if {[incr nheads -1] >= 0} {
-		set col green
+		set col $branchcolor
 		if {$tag eq $mainhead} {
 		    set font mainfontbold
 		}
@@ -11033,7 +11034,7 @@ proc prefspage_general {notebook} {
 }
 
 proc prefspage_colors {notebook} {
-    global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
+    global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor branchcolor
 
     set page [create_prefs_page $notebook.colors]
 
@@ -11077,6 +11078,12 @@ proc prefspage_colors {notebook} {
     ${NS}::button $page.selbgbut -text [mc "Select bg"] \
 	-command [list choosecolor selectbgcolor {} $page.selbgsep [mc "background"] setselbg]
     grid x $page.selbgbut $page.selbgsep -sticky w
+    label $page.selbranchcolsep -padx 40 -relief sunk -background $branchcolor
+    ${NS}::button $page.selbranchcolbut -text [mc "Select branch bg"] \
+	-command [list choosecolor branchcolor {} $page.selbranchcolsep \
+			[mc "branch background"] \
+			setbranchcolor]
+    grid x $page.selbranchcolbut $page.selbranchcolsep -sticky w
     return $page
 }
 
@@ -11221,6 +11228,10 @@ proc setfg {c} {
     $canv itemconf markid -outline $c
 }
 
+proc setbranchcolor {c} {
+	reloadcommits
+}
+
 proc prefscan {} {
     global oldprefs prefstop
 
@@ -11742,6 +11753,7 @@ set diffcontext 3
 set ignorespace 0
 set worddiff ""
 set markbgcolor "#e0e0ff"
+set branchcolor green
 
 set circlecolors {white blue gray blue blue}
 
-- 
1.8.2