Skip to content

Commit 8ccb2d4

Browse files
committed
gitk: use config variables to define and load a theme
gitk uses themed tk, but has no capability to alter the theme defined by Tk. While there are documented ways to install other themes, and to make one the default, these methods are obscure at best. Instead, let's offer two config variables: - theme this is the name of the theme to use, and must be available. - themeloader - this is the full pathname of a tcl script that will load one or more themes into the Tk namespace. By default, theme is set to the theme active when Tk is started, and themeloader = {}. These variables must be defined to something else to have any user visible effect. Signed-off-by: Mark Levedahl <[email protected]>
1 parent fe2005e commit 8ccb2d4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

gitk

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,7 @@ proc setoptions {} {
22152215
}
22162216
22172217
proc setttkstyle {} {
2218+
global theme
22182219
eval font configure TkDefaultFont [fontflags mainfont]
22192220
eval font configure TkTextFont [fontflags textfont]
22202221
eval font configure TkHeadingFont [fontflags mainfont]
@@ -2224,6 +2225,10 @@ proc setttkstyle {} {
22242225
eval font configure TkIconFont [fontflags uifont]
22252226
eval font configure TkMenuFont [fontflags uifont]
22262227
eval font configure TkSmallCaptionFont [fontflags uifont]
2228+
2229+
if {[catch {ttk::style theme use $theme} err]} {
2230+
set theme [ttk::style theme use]
2231+
}
22272232
}
22282233
22292234
# Make a menu and submenus.
@@ -12618,6 +12623,9 @@ set circleoutlinecolor $fgcolor
1261812623
set foundbgcolor yellow
1261912624
set currentsearchhitbgcolor orange
1262012625
12626+
set theme [ttk::style theme use]
12627+
set themeloader {}
12628+
1262112629
# button for popping up context menus
1262212630
if {[tk windowingsystem] eq "aqua" && [package vcompare $::tcl_version 8.7] < 0} {
1262312631
set ctxbut <Button-2>
@@ -12701,6 +12709,8 @@ set config_variables {
1270112709
tagfgcolor
1270212710
tagoutlinecolor
1270312711
textfont
12712+
theme
12713+
themeloader
1270412714
uicolor
1270512715
uifgcolor
1270612716
uifgdisabledcolor
@@ -12800,7 +12810,10 @@ set nullid "0000000000000000000000000000000000000000"
1280012810
set nullid2 "0000000000000000000000000000000000000001"
1280112811
set nullfile "/dev/null"
1280212812
12803-
setttkstyle
12813+
if {[file exists $themeloader]} {
12814+
source $themeloader
12815+
}
12816+
1280412817
set appname "gitk"
1280512818
1280612819
set runq {}
@@ -12916,6 +12929,7 @@ if {[tk windowingsystem] eq "win32"} {
1291612929
focus -force .
1291712930
}
1291812931
12932+
setttkstyle
1291912933
set_gui_colors
1292012934
1292112935
getcommits {}

0 commit comments

Comments
 (0)