Skip to content

Commit 100f597

Browse files
committed
gitk: set config dialog color swatches in one place
gitk's color selection dialog uses a number of "label" widgets to show the current value of each selectable color. This uses the -background color property of label widgets, and this property is overwritten when the full ui color set is refreshed. The swatch colors are set individually using code passed into the chooser dialog, so there is no common routine to set all after updating the global ui colors. Let's replace this with a single routine that does set all swatches, removing a key impediment to restoring the ui colors if the dialog is cancelled. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 3e43143 commit 100f597

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

gitk

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11660,57 +11660,73 @@ 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.ui [mc "interface"] setui]
11663+
-command [list choosecolor uicolor {} $page [mc "interface"] setui]
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.bg [mc "background"] setbg]
11667+
-command [list choosecolor bgcolor {} $page [mc "background"] setbg]
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.fg [mc "foreground"] setfg]
11671+
-command [list choosecolor fgcolor {} $page [mc "foreground"] setfg]
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.diffold [mc "diff old lines"] \
11675+
-command [list choosecolor diffcolors 0 $page [mc "diff old lines"] \
1167611676
[list $ctext tag conf d0 -foreground]]
1167711677
grid x $page.diffoldbut $page.diffold -sticky w
1167811678
label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]
1167911679
ttk::button $page.diffoldbgbut -text [mc "Diff: old lines bg"] \
11680-
-command [list choosecolor diffbgcolors 0 $page.diffoldbg \
11680+
-command [list choosecolor diffbgcolors 0 $page \
1168111681
[mc "diff old lines bg"] \
1168211682
[list $ctext tag conf d0 -background]]
1168311683
grid x $page.diffoldbgbut $page.diffoldbg -sticky w
1168411684
label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
1168511685
ttk::button $page.diffnewbut -text [mc "Diff: new lines"] \
11686-
-command [list choosecolor diffcolors 1 $page.diffnew [mc "diff new lines"] \
11686+
-command [list choosecolor diffcolors 1 $page [mc "diff new lines"] \
1168711687
[list $ctext tag conf dresult -foreground]]
1168811688
grid x $page.diffnewbut $page.diffnew -sticky w
1168911689
label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]
1169011690
ttk::button $page.diffnewbgbut -text [mc "Diff: new lines bg"] \
11691-
-command [list choosecolor diffbgcolors 1 $page.diffnewbg \
11691+
-command [list choosecolor diffbgcolors 1 $page \
1169211692
[mc "diff new lines bg"] \
1169311693
[list $ctext tag conf dresult -background]]
1169411694
grid x $page.diffnewbgbut $page.diffnewbg -sticky w
1169511695
label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
1169611696
ttk::button $page.hunksepbut -text [mc "Diff: hunk header"] \
11697-
-command [list choosecolor diffcolors 2 $page.hunksep \
11697+
-command [list choosecolor diffcolors 2 $page \
1169811698
[mc "diff hunk header"] \
1169911699
[list $ctext tag conf hunksep -foreground]]
1170011700
grid x $page.hunksepbut $page.hunksep -sticky w
1170111701
label $page.markbgsep -padx 40 -relief sunk -background $markbgcolor
1170211702
ttk::button $page.markbgbut -text [mc "Marked line bg"] \
11703-
-command [list choosecolor markbgcolor {} $page.markbgsep \
11703+
-command [list choosecolor markbgcolor {} $page \
1170411704
[mc "marked line background"] \
1170511705
[list $ctext tag conf omark -background]]
1170611706
grid x $page.markbgbut $page.markbgsep -sticky w
1170711707
label $page.selbgsep -padx 40 -relief sunk -background $selectbgcolor
1170811708
ttk::button $page.selbgbut -text [mc "Select bg"] \
11709-
-command [list choosecolor selectbgcolor {} $page.selbgsep [mc "background"] setselbg]
11709+
-command [list choosecolor selectbgcolor {} $page [mc "background"] setselbg]
1171011710
grid x $page.selbgbut $page.selbgsep -sticky w
1171111711
return $page
1171211712
}
1171311713
11714+
proc prefspage_set_colorswatches {page} {
11715+
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11716+
global diffbgcolors
11717+
11718+
$page.ui configure -background $uicolor
11719+
$page.bg configure -background $bgcolor
11720+
$page.fg configure -background $fgcolor
11721+
$page.diffold configure -background [lindex $diffcolors 0]
11722+
$page.diffoldbg configure -background [lindex $diffbgcolors 0]
11723+
$page.diffnew configure -background [lindex $diffcolors 1]
11724+
$page.diffnewbg configure -background [lindex $diffbgcolors 1]
11725+
$page.hunksep configure -background [lindex $diffcolors 2]
11726+
$page.markbgsep configure -background $markbgcolor
11727+
$page.selbgsep configure -background $selectbgcolor
11728+
}
11729+
1171411730
proc prefspage_fonts {notebook} {
1171511731
set page [create_prefs_page $notebook.fonts]
1171611732
ttk::label $page.cfont -text [mc "Fonts: press to choose"] -font mainfontbold
@@ -11778,15 +11794,15 @@ proc choose_extdiff {} {
1177811794
}
1177911795
}
1178011796
11781-
proc choosecolor {v vi w x cmd} {
11797+
proc choosecolor {v vi prefspage x cmd} {
1178211798
global $v
1178311799
1178411800
set c [tk_chooseColor -initialcolor [lindex [set $v] $vi] \
1178511801
-title [mc "Gitk: choose color for %s" $x]]
1178611802
if {$c eq {}} return
11787-
$w conf -background $c
1178811803
lset $v $vi $c
1178911804
eval $cmd $c
11805+
prefspage_set_colorswatches $prefspage
1179011806
}
1179111807
1179211808
proc setselbg {c} {

0 commit comments

Comments
 (0)