git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitk: Add user-configurable branch bg color
@ 2013-03-16 20:05 Manuel Bua
       [not found] ` <CAJDDKr5XqX3dKLEiOAo7VeaofN37Q8aAN=GyMVf5-bGiiv9FDw@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Manuel Bua @ 2013-03-16 20:05 UTC (permalink / raw)
  To: git; +Cc: paulus, Manuel Bua

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 <manuel.bua@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gitk: Add user-configurable branch bg color
       [not found] ` <CAJDDKr5XqX3dKLEiOAo7VeaofN37Q8aAN=GyMVf5-bGiiv9FDw@mail.gmail.com>
@ 2013-03-17 12:46   ` Manuel Bua
  0 siblings, 0 replies; 2+ messages in thread
From: Manuel Bua @ 2013-03-17 12:46 UTC (permalink / raw)
  To: David Aguilar; +Cc: Paul Mackerras, Git Mailing List

On 03/17/2013 03:57 AM, David Aguilar wrote:
>
> > In some cases, the default branch background color (green) isn't
> > an optimal choice, thus it can be difficult to read.
>
> I'm just curious -- is it "difficult to read" because gitk does not 
> specify a foreground color, thus causing it to pickup a system default 
> (which can vary), or is it for a different reason?
>
> If this is the reason then I wonder whether gitk should explicitly set 
> a foreground color. Apologies if it already works that way -- I just 
> wanted to better understand the motivation behind this patch.
>

Yes, having gitk to specify a foreground color instead would probably 
solve it too: i can remember the branch rectangles were a lot more 
readable in the past, but this could probably be due to me using a dark 
system theme at the time.

For example, in my case it would look a lot more readable if the text 
was "white on green" instead of "black on green", that could be even 
hardcoded as it was with the "green" color, but the reason behind the 
choice to let the user customize it is that i think it is better to 
honour the user system colors giving the means to adjust it to match his 
actual system configuration, rather than overriding it.

Regards,
Manuel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-17 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-16 20:05 [PATCH] gitk: Add user-configurable branch bg color Manuel Bua
     [not found] ` <CAJDDKr5XqX3dKLEiOAo7VeaofN37Q8aAN=GyMVf5-bGiiv9FDw@mail.gmail.com>
2013-03-17 12:46   ` Manuel Bua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).