git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/5] gitk: set intitial colors of swatches using the available helper

From
Johannes Sixt via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 6, 2026, 06:40 UTC
Message-ID
<ab16ec6276e448db3c8150e58e2f08d137317198.1785998419.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2194.git.1785998419.gitgitgadget@gmail.com>
From: Johannes Sixt <j6t@kdbg.org>

After the user has selected a color in the Preferences dialog, the helper proc prefspage_set_colorswatches is used update the colors shown in the Preferences dialog. Use this proc also after the Preferences dialog is constructed to show the initial colors. This keeps the procedure that gives the UI elements their colors in a single place.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 gitk-git/gitk | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 0f3571050b..f5eb963b86 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -11801,8 +11801,6 @@ proc prefspage_general {notebook} {
 }
 
 proc prefspage_colors {notebook} {
-    global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
-    global diffbgcolors linkfgcolor
     global themeloader
 
     set page [create_prefs_page $notebook.colors]
@@ -11834,63 +11832,64 @@ proc prefspage_colors {notebook} {
 
     ttk::label $page.cdisp -text [mc "Colors: press to choose"] -font mainfontbold
     grid $page.cdisp - -sticky w -pady 10
-    label $page.bg -padx 40 -relief sunk -background $bgcolor
+    label $page.bg -padx 40 -relief sunk
     ttk::button $page.bgbut -text [mc "Background"] \
         -command [list choosecolor bgcolor {} $page [mc "background"]]
     grid x $page.bgbut $page.bg -sticky w
 
-    label $page.fg -padx 40 -relief sunk -background $fgcolor
+    label $page.fg -padx 40 -relief sunk
     ttk::button $page.fgbut -text [mc "Foreground"] \
         -command [list choosecolor fgcolor {} $page [mc "foreground"]]
     grid x $page.fgbut $page.fg -sticky w
 
-    label $page.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
+    label $page.diffold -padx 40 -relief sunk
     ttk::button $page.diffoldbut -text [mc "Diff: old lines"] \
         -command [list choosecolor diffcolors 0 $page [mc "diff old lines"]]
     grid x $page.diffoldbut $page.diffold -sticky w
 
-    label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]
+    label $page.diffoldbg -padx 40 -relief sunk
     ttk::button $page.diffoldbgbut -text [mc "Diff: old lines bg"] \
         -command [list choosecolor diffbgcolors 0 $page [mc "diff old lines bg"]]
     grid x $page.diffoldbgbut $page.diffoldbg -sticky w
 
-    label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
+    label $page.diffnew -padx 40 -relief sunk
     ttk::button $page.diffnewbut -text [mc "Diff: new lines"] \
         -command [list choosecolor diffcolors 1 $page [mc "diff new lines"]]
     grid x $page.diffnewbut $page.diffnew -sticky w
 
-    label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]
+    label $page.diffnewbg -padx 40 -relief sunk
     ttk::button $page.diffnewbgbut -text [mc "Diff: new lines bg"] \
         -command [list choosecolor diffbgcolors 1 $page [mc "diff new lines bg"]]
     grid x $page.diffnewbgbut $page.diffnewbg -sticky w
 
-    label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
+    label $page.hunksep -padx 40 -relief sunk
     ttk::button $page.hunksepbut -text [mc "Diff: hunk header"] \
         -command [list choosecolor diffcolors 2 $page [mc "diff hunk header"]]
     grid x $page.hunksepbut $page.hunksep -sticky w
 
-    label $page.markbgsep -padx 40 -relief sunk -background $markbgcolor
+    label $page.markbgsep -padx 40 -relief sunk
     ttk::button $page.markbgbut -text [mc "Marked line bg"] \
         -command [list choosecolor markbgcolor {} $page [mc "marked line background"]]
     grid x $page.markbgbut $page.markbgsep -sticky w
 
-    label $page.selbgsep -padx 40 -relief sunk -background $selectbgcolor
+    label $page.selbgsep -padx 40 -relief sunk
     ttk::button $page.selbgbut -text [mc "Select bg"] \
         -command [list choosecolor selectbgcolor {} $page [mc "background"]]
     grid x $page.selbgbut $page.selbgsep -sticky w
 
-    label $page.linkfg -padx 40 -relief sunk -background $linkfgcolor
+    label $page.linkfg -padx 40 -relief sunk
     ttk::button $page.linkfgbut -text [mc "Link"] \
         -command [list choosecolor linkfgcolor {} $page [mc "link"]]
     grid x $page.linkfgbut $page.linkfg -sticky w
 
     grid columnconfigure $page 2 -weight 1
+    prefspage_set_colorswatches $page
 
     return $page
 }
 
 proc prefspage_set_colorswatches {page} {
-    global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
+    global bgcolor fgcolor diffcolors selectbgcolor markbgcolor
     global diffbgcolors linkfgcolor
 
     $page.bg configure -background $bgcolor
-- 
gitgitgadget
Previous: Johannes Sixt via GitGitGadgetNext: mark
Message 2 of 27 in “gitk: make color preferences visually more pleasing and better usable”
  1. 0/5 gitk: make color preferences visually more pleasing and better usableJohannes Sixt via GitGitGadget, Aug 6, 2026
  2. 1/5 gitk: set intitial colors of swatches using the available helperJohannes Sixt via GitGitGadget, Aug 6, 2026
  3. markAug 7, 2026
  4. 2/5 gitk: condense repetitive code around color buttons into foreach loopsJohannes Sixt via GitGitGadget, Aug 6, 2026
  5. markAug 7, 2026
  6. 3/5 gitk: show color preferences on the button instead of the labelJohannes Sixt via GitGitGadget, Aug 6, 2026
  7. markAug 7, 2026
  8. Johannes SixtAug 8, 2026
  9. 4/5 gitk: use more natural language for labels of color preferencesJohannes Sixt via GitGitGadget, Aug 6, 2026
  10. 5/5 gitk: avoid constructing dialog titles from text piecesJohannes Sixt via GitGitGadget, Aug 6, 2026
  11. markAug 7, 2026
  12. Johannes SixtAug 8, 2026
  13. Mark LevedahlAug 8, 2026
  14. Johannes SixtAug 9, 2026
  15. Junio C HamanoAug 8, 2026
  16. Johannes SixtAug 9, 2026
  17. 0/6 gitk: make color preferences visually more pleasing and better usableJohannes Sixt via GitGitGadget, Aug 12, 2026
  18. 1/6 gitk: set intitial colors of swatches using the available helperJohannes Sixt via GitGitGadget, Aug 12, 2026
  19. 2/6 gitk: condense repetitive code around color buttons into foreach loopsJohannes Sixt via GitGitGadget, Aug 12, 2026
  20. 3/6 gitk: show color preferences on the button instead of the labelJohannes Sixt via GitGitGadget, Aug 12, 2026
  21. Mark LevedahlAug 13, 2026
  22. 4/6 gitk: use more natural language for labels of color preferencesJohannes Sixt via GitGitGadget, Aug 12, 2026
  23. Mark LevedahlAug 13, 2026
  24. Johannes SixtAug 13, 2026
  25. Mark LevedahlAug 13, 2026
  26. 5/6 gitk: avoid constructing dialog titles from text piecesJohannes Sixt via GitGitGadget, Aug 12, 2026
  27. 6/6 gitk: move UI for generic colors above diff colorsJohannes Sixt via GitGitGadget, Aug 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.