Skip to content

gitk: small quality of life improvements for themed Tk #1909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 53 additions & 7 deletions gitk-git/gitk
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,31 @@ proc setoptions {} {
option add *Listbox.font mainfont startupFile
}

proc createttkimages {} {
global uicolor

image create bitmap img:myVerticalSash -foreground $uicolor -data {
#define xbm_width 5
#define xbm_height 47
static unsigned char xbm_bits[] = {
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0e,
0x00, 0x00, 0x0e, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
}

image create bitmap img:myHorizontalSash -foreground $uicolor -data {
#define xbm_width 47
#define xbm_height 5
static unsigned char xbm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x04, 0x00, 0x00,
0xff, 0xff, 0x93, 0xe4, 0xff, 0x7f, 0x00, 0x00, 0x90, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
}
}

proc setttkstyle {} {

eval font configure TkDefaultFont [fontflags mainfont]
eval font configure TkTextFont [fontflags textfont]
eval font configure TkHeadingFont [fontflags mainfont]
Expand All @@ -2143,6 +2167,16 @@ proc setttkstyle {} {
eval font configure TkIconFont [fontflags uifont]
eval font configure TkMenuFont [fontflags uifont]
eval font configure TkSmallCaptionFont [fontflags uifont]

createttkimages

ttk::style element create myVerticalSash image img:myVerticalSash -sticky ew

ttk::style element create myHorizontalSash image img:myHorizontalSash -sticky ns

ttk::style layout Vertical.Sash { myVerticalSash }

ttk::style layout Horizontal.Sash { myHorizontalSash }
}

# Make a menu and submenus.
Expand Down Expand Up @@ -11767,13 +11801,11 @@ proc prefspage_general {notebook} {
grid x $page.tabstopl $page.tabstop -sticky w

${NS}::label $page.wrapcommentl -text [mc "Wrap comment text"]
${NS}::combobox $page.wrapcomment -values {none char word} -state readonly \
-textvariable wrapcomment
makedroplist $page.wrapcomment wrapcomment "none" "char" "word"
grid x $page.wrapcommentl $page.wrapcomment -sticky w

${NS}::label $page.wrapdefaultl -text [mc "Wrap other text"]
${NS}::combobox $page.wrapdefault -values {none char word} -state readonly \
-textvariable wrapdefault
makedroplist $page.wrapdefault wrapdefault "none" "char" "word"
grid x $page.wrapdefaultl $page.wrapdefault -sticky w

${NS}::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
Expand Down Expand Up @@ -11827,7 +11859,7 @@ proc prefspage_colors {notebook} {
grid $page.cdisp - -sticky w -pady 10
label $page.ui -padx 40 -relief sunk -background $uicolor
${NS}::button $page.uibut -text [mc "Interface"] \
-command [list choosecolor uicolor {} $page.ui [mc "interface"] setui]
-command [list choosecolor uicolor {} $page.ui [mc "interface"] setui_dialog]
grid x $page.uibut $page.ui -sticky w
label $page.bg -padx 40 -relief sunk -background $bgcolor
${NS}::button $page.bgbut -text [mc "Background"] \
Expand Down Expand Up @@ -11993,6 +12025,12 @@ proc setselbg {c} {
# radiobuttons look bad. This chooses white for selectColor if the
# background color is light, or black if it is dark.
proc setui {c} {
global use_ttk

if {$use_ttk} {
return
}

if {[tk windowingsystem] eq "win32"} { return }
set bg [winfo rgb . $c]
set selc black
Expand All @@ -12002,6 +12040,14 @@ proc setui {c} {
tk_setPalette background $c selectColor $selc
}

proc setui_dialog {c} {
global uicolor

setui $c

createttkimages
}

proc setbg {c} {
global bglist

Expand Down Expand Up @@ -12702,8 +12748,6 @@ eval font create textfontbold [fontflags textfont 1]
parsefont uifont $uifont
eval font create uifont [fontflags uifont]

setui $uicolor

setoptions

# check that we can find a .git directory somewhere...
Expand Down Expand Up @@ -12784,6 +12828,8 @@ if {![info exists have_ttk]} {
set use_ttk [expr {$have_ttk && $want_ttk}]
set NS [expr {$use_ttk ? "ttk" : ""}]

setui $uicolor

if {$use_ttk} {
setttkstyle
}
Expand Down
Loading