Skip to content

Commit fdaba07

Browse files
committed
gitk: restore ui colors after cancelling config dialog
gitk provides a dialog to configure many ui colors. Any color element changed in the dialog takes immediate effect before closing the dialog. While cancelling the dialog after changing one or more colors avoids saving the modified colors, the user must restart gitk to restore the prior color set. This unfortunate behavior results because gitk does not have a single routine to update all of the ui colors. The prior commit eliminated the key impediment to having such a routine. So, let's create a routine to update all configured colors at once, use this when modifying colors, and also invoke this after restoring the prior set if the dialog is cancelled. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 100f597 commit fdaba07

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

gitk

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11660,53 +11660,43 @@ proc prefspage_colors {notebook} {
1166011660
grid $page.cdisp - -sticky w -pady 10
1166111661
label $page.ui -padx 40 -relief sunk -background $uicolor
1166211662
ttk::button $page.uibut -text [mc "Interface"] \
11663-
-command [list choosecolor uicolor {} $page [mc "interface"] setui]
11663+
-command [list choosecolor uicolor {} $page [mc "interface"]]
1166411664
grid x $page.uibut $page.ui -sticky w
1166511665
label $page.bg -padx 40 -relief sunk -background $bgcolor
1166611666
ttk::button $page.bgbut -text [mc "Background"] \
11667-
-command [list choosecolor bgcolor {} $page [mc "background"] setbg]
11667+
-command [list choosecolor bgcolor {} $page [mc "background"]]
1166811668
grid x $page.bgbut $page.bg -sticky w
1166911669
label $page.fg -padx 40 -relief sunk -background $fgcolor
1167011670
ttk::button $page.fgbut -text [mc "Foreground"] \
11671-
-command [list choosecolor fgcolor {} $page [mc "foreground"] setfg]
11671+
-command [list choosecolor fgcolor {} $page [mc "foreground"]]
1167211672
grid x $page.fgbut $page.fg -sticky w
1167311673
label $page.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
1167411674
ttk::button $page.diffoldbut -text [mc "Diff: old lines"] \
11675-
-command [list choosecolor diffcolors 0 $page [mc "diff old lines"] \
11676-
[list $ctext tag conf d0 -foreground]]
11675+
-command [list choosecolor diffcolors 0 $page [mc "diff old lines"]]
1167711676
grid x $page.diffoldbut $page.diffold -sticky w
1167811677
label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]
1167911678
ttk::button $page.diffoldbgbut -text [mc "Diff: old lines bg"] \
11680-
-command [list choosecolor diffbgcolors 0 $page \
11681-
[mc "diff old lines bg"] \
11682-
[list $ctext tag conf d0 -background]]
11679+
-command [list choosecolor diffbgcolors 0 $page [mc "diff old lines bg"]]
1168311680
grid x $page.diffoldbgbut $page.diffoldbg -sticky w
1168411681
label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
1168511682
ttk::button $page.diffnewbut -text [mc "Diff: new lines"] \
11686-
-command [list choosecolor diffcolors 1 $page [mc "diff new lines"] \
11687-
[list $ctext tag conf dresult -foreground]]
11683+
-command [list choosecolor diffcolors 1 $page [mc "diff new lines"]]
1168811684
grid x $page.diffnewbut $page.diffnew -sticky w
1168911685
label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]
1169011686
ttk::button $page.diffnewbgbut -text [mc "Diff: new lines bg"] \
11691-
-command [list choosecolor diffbgcolors 1 $page \
11692-
[mc "diff new lines bg"] \
11693-
[list $ctext tag conf dresult -background]]
11687+
-command [list choosecolor diffbgcolors 1 $page [mc "diff new lines bg"]]
1169411688
grid x $page.diffnewbgbut $page.diffnewbg -sticky w
1169511689
label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
1169611690
ttk::button $page.hunksepbut -text [mc "Diff: hunk header"] \
11697-
-command [list choosecolor diffcolors 2 $page \
11698-
[mc "diff hunk header"] \
11699-
[list $ctext tag conf hunksep -foreground]]
11691+
-command [list choosecolor diffcolors 2 $page [mc "diff hunk header"]]
1170011692
grid x $page.hunksepbut $page.hunksep -sticky w
1170111693
label $page.markbgsep -padx 40 -relief sunk -background $markbgcolor
1170211694
ttk::button $page.markbgbut -text [mc "Marked line bg"] \
11703-
-command [list choosecolor markbgcolor {} $page \
11704-
[mc "marked line background"] \
11705-
[list $ctext tag conf omark -background]]
11695+
-command [list choosecolor markbgcolor {} $page [mc "marked line background"]]
1170611696
grid x $page.markbgbut $page.markbgsep -sticky w
1170711697
label $page.selbgsep -padx 40 -relief sunk -background $selectbgcolor
1170811698
ttk::button $page.selbgbut -text [mc "Select bg"] \
11709-
-command [list choosecolor selectbgcolor {} $page [mc "background"] setselbg]
11699+
-command [list choosecolor selectbgcolor {} $page [mc "background"]]
1171011700
grid x $page.selbgbut $page.selbgsep -sticky w
1171111701
return $page
1171211702
}
@@ -11794,14 +11784,14 @@ proc choose_extdiff {} {
1179411784
}
1179511785
}
1179611786
11797-
proc choosecolor {v vi prefspage x cmd} {
11787+
proc choosecolor {v vi prefspage x} {
1179811788
global $v
1179911789
1180011790
set c [tk_chooseColor -initialcolor [lindex [set $v] $vi] \
1180111791
-title [mc "Gitk: choose color for %s" $x]]
1180211792
if {$c eq {}} return
1180311793
lset $v $vi $c
11804-
eval $cmd $c
11794+
set_gui_colors
1180511795
prefspage_set_colorswatches $prefspage
1180611796
}
1180711797
@@ -11855,6 +11845,22 @@ proc setfg {c} {
1185511845
$canv itemconf markid -outline $c
1185611846
}
1185711847
11848+
proc set_gui_colors {} {
11849+
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11850+
global diffbgcolors
11851+
11852+
setui $uicolor
11853+
setbg $bgcolor
11854+
setfg $fgcolor
11855+
$ctext tag conf d0 -foreground [lindex $diffcolors 0]
11856+
$ctext tag conf d0 -background [lindex $diffbgcolors 0]
11857+
$ctext tag conf dresult -foreground [lindex $diffcolors 1]
11858+
$ctext tag conf dresult -background [lindex $diffbgcolors 1]
11859+
$ctext tag conf hunksep -foreground [lindex $diffcolors 2]
11860+
$ctext tag conf omark -background $markbgcolor
11861+
setselbg $selectbgcolor
11862+
}
11863+
1185811864
proc prefscan {} {
1185911865
global oldprefs prefstop
1186011866
global {*}$::config_variables
@@ -11865,6 +11871,7 @@ proc prefscan {} {
1186511871
catch {destroy $prefstop}
1186611872
unset prefstop
1186711873
fontcan
11874+
set_gui_colors
1186811875
}
1186911876
1187011877
proc prefsok {} {
@@ -12567,8 +12574,6 @@ eval font create textfontbold [fontflags textfont 1]
1256712574
parsefont uifont $uifont
1256812575
eval font create uifont [fontflags uifont]
1256912576
12570-
setui $uicolor
12571-
1257212577
setoptions
1257312578
1257412579
# check that we can find a .git directory somewhere...
@@ -12757,6 +12762,8 @@ if {[tk windowingsystem] eq "win32"} {
1275712762
focus -force .
1275812763
}
1275912764
12765+
set_gui_colors
12766+
1276012767
getcommits {}
1276112768
1276212769
# Local variables:

0 commit comments

Comments
 (0)