summaryrefslogtreecommitdiffstats
path: root/gitk-git/gitk
diff options
context:
space:
mode:
Diffstat (limited to 'gitk-git/gitk')
-rwxr-xr-xgitk-git/gitk419
1 files changed, 274 insertions, 145 deletions
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 3b6acfc592..2730274966 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2131,12 +2131,14 @@ proc ttk_toplevel {w args} {
return $w
}
-proc make_transient {window origin} {
+proc make_transient {window origin {geometry ""}} {
wm transient $window $origin
- # Windows fails to place transient windows normally, so
- # schedule a callback to center them on the parent.
- if {[tk windowingsystem] eq {win32}} {
+ if {$geometry ne ""} {
+ after idle [list wm geometry $window $geometry]
+ } elseif {[tk windowingsystem] eq {win32}} {
+ # Windows fails to place transient windows normally, so
+ # schedule a callback to center them on the parent.
after idle [list tk::PlaceWindow $window widget $origin]
}
}
@@ -2215,6 +2217,7 @@ proc setoptions {} {
}
proc setttkstyle {} {
+ global theme
eval font configure TkDefaultFont [fontflags mainfont]
eval font configure TkTextFont [fontflags textfont]
eval font configure TkHeadingFont [fontflags mainfont]
@@ -2224,6 +2227,10 @@ proc setttkstyle {} {
eval font configure TkIconFont [fontflags uifont]
eval font configure TkMenuFont [fontflags uifont]
eval font configure TkSmallCaptionFont [fontflags uifont]
+
+ if {[catch {ttk::style theme use $theme} err]} {
+ set theme [ttk::style theme use]
+ }
}
# Make a menu and submenus.
@@ -2301,6 +2308,11 @@ proc scrollval {D {koff 0}} {
return [expr int(-($D / $scroll_D0) * max(1, $kscroll-$koff))]
}
+proc precisescrollval {D {koff 0}} {
+ global kscroll
+ return [expr (-($D / 10.0) * max(1, $kscroll-$koff))]
+}
+
proc bind_mousewheel {} {
global canv cflist ctext
bindall <MouseWheel> {allcanvs yview scroll [scrollval %D] units}
@@ -2319,6 +2331,25 @@ proc bind_mousewheel {} {
bind $cflist <Alt-MouseWheel> {$cflist yview scroll [scrollval 5*%D 2] units}
bind $cflist <Alt-Shift-MouseWheel> break
bind $canv <Alt-Shift-MouseWheel> {$canv xview scroll [scrollval 5*%D] units}
+
+ bindall <TouchpadScroll> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ allcanvs yview scroll [precisescrollval $deltaY] units
+ }
+ bind $ctext <TouchpadScroll> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ $ctext yview scroll [precisescrollval $deltaY 2] units
+ $ctext xview scroll [precisescrollval $deltaX 2] units
+ }
+ bind $cflist <TouchpadScroll> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ $cflist yview scroll [precisescrollval $deltaY 2] units
+ }
+ bind $canv <TouchpadScroll> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ $canv xview scroll [precisescrollval $deltaX] units
+ allcanvs yview scroll [precisescrollval $deltaY] units
+ }
}
}
@@ -2352,7 +2383,6 @@ proc makewindow {} {
global highlight_files gdttype
global searchstring sstring
global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor
- global uifgcolor uifgdisabledcolor
global filesepbgcolor filesepfgcolor
global mergecolors foundbgcolor currentsearchhitbgcolor
global headctxmenu progresscanv progressitem progresscoords statusw
@@ -2471,40 +2501,18 @@ proc makewindow {} {
set sha1entry .tf.bar.sha1
set entries $sha1entry
set sha1but .tf.bar.sha1label
- button $sha1but -text "[mc "Commit ID:"] " -state disabled -relief flat \
+ ttk::button $sha1but -text "[mc "Commit ID:"] " -state disabled \
-command gotocommit -width 8
- $sha1but conf -disabledforeground [$sha1but cget -foreground]
pack .tf.bar.sha1label -side left
ttk::entry $sha1entry -width $hashlength -font textfont -textvariable sha1string
trace add variable sha1string write sha1change
pack $sha1entry -side left -pady 2
- set bm_left_data {
- #define left_width 16
- #define left_height 16
- static unsigned char left_bits[] = {
- 0x00, 0x00, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1c, 0x00,
- 0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,
- 0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};
- }
- set bm_right_data {
- #define right_width 16
- #define right_height 16
- static unsigned char right_bits[] = {
- 0x00, 0x00, 0xc0, 0x01, 0x80, 0x03, 0x00, 0x07, 0x00, 0x0e, 0x00, 0x1c,
- 0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
- 0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
- }
- image create bitmap bm-left -data $bm_left_data -foreground $uifgcolor
- image create bitmap bm-left-gray -data $bm_left_data -foreground $uifgdisabledcolor
- image create bitmap bm-right -data $bm_right_data -foreground $uifgcolor
- image create bitmap bm-right-gray -data $bm_right_data -foreground $uifgdisabledcolor
-
- ttk::button .tf.bar.leftbut -command goback -state disabled -width 26
- .tf.bar.leftbut configure -image [list bm-left disabled bm-left-gray]
+ ttk::button .tf.bar.leftbut -command goback -state disabled
+ .tf.bar.leftbut configure -text \u2190 -width 3
pack .tf.bar.leftbut -side left -fill y
- ttk::button .tf.bar.rightbut -command goforw -state disabled -width 26
- .tf.bar.rightbut configure -image [list bm-right disabled bm-right-gray]
+ ttk::button .tf.bar.rightbut -command goforw -state disabled
+ .tf.bar.rightbut configure -text \u2192 -width 3
pack .tf.bar.rightbut -side left -fill y
ttk::label .tf.bar.rowlabel -text [mc "Row"]
@@ -2535,31 +2543,8 @@ proc makewindow {} {
# build up the bottom bar of upper window
ttk::label .tf.lbar.flabel -text "[mc "Find"] "
- set bm_down_data {
- #define down_width 16
- #define down_height 16
- static unsigned char down_bits[] = {
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x87, 0xe1, 0x8e, 0x71, 0x9c, 0x39, 0xb8, 0x1d,
- 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01};
- }
- image create bitmap bm-down -data $bm_down_data -foreground $uifgcolor
- ttk::button .tf.lbar.fnext -width 26 -command {dofind 1 1}
- .tf.lbar.fnext configure -image bm-down
-
- set bm_up_data {
- #define up_width 16
- #define up_height 16
- static unsigned char up_bits[] = {
- 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
- 0xb8, 0x1d, 0x9c, 0x39, 0x8e, 0x71, 0x87, 0xe1,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
- }
- image create bitmap bm-up -data $bm_up_data -foreground $uifgcolor
- ttk::button .tf.lbar.fprev -width 26 -command {dofind -1 1}
- .tf.lbar.fprev configure -image bm-up
+ ttk::button .tf.lbar.fnext -command {dofind 1 1} -text \u2193 -width 3
+ ttk::button .tf.lbar.fprev -command {dofind -1 1} -text \u2191 -width 3
ttk::label .tf.lbar.flab2 -text " [mc "commit"] "
@@ -2632,7 +2617,7 @@ proc makewindow {} {
ttk::label .bleft.mid.labeldiffcontext -text " [mc "Lines of context"]: "
pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left -ipadx $wgap
- spinbox .bleft.mid.diffcontext -width 5 \
+ ttk::spinbox .bleft.mid.diffcontext -width 5 \
-from 0 -increment 1 -to 10000000 \
-validate all -validatecommand "diffcontextvalidate %P" \
-textvariable diffcontextstring
@@ -2740,17 +2725,9 @@ proc makewindow {} {
.pwbottom add .bright
.ctop add .pwbottom
- # restore window width & height if known
+ # restore window position if known
if {[info exists geometry(main)]} {
- if {[scan $geometry(main) "%dx%d" w h] >= 2} {
- if {$w > [winfo screenwidth .]} {
- set w [winfo screenwidth .]
- }
- if {$h > [winfo screenheight .]} {
- set h [winfo screenheight .]
- }
- wm geometry . "${w}x$h"
- }
+ wm geometry . "$geometry(main)"
}
if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
@@ -3090,6 +3067,11 @@ proc savestuff {w} {
puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
puts $f "set geometry(botwidth) [winfo width .bleft]"
puts $f "set geometry(botheight) [winfo height .bleft]"
+ unset -nocomplain geometry
+ global geometry
+ if {[info exists geometry(showrefs)]} {
+ puts $f "set geometry(showrefs) $geometry(showrefs)"
+ }
array set view_save {}
array set views {}
@@ -3805,6 +3787,34 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc check_for_renames_in_diff {filepath} { # renames
+ global difffilestart ctext
+
+ set filename [file tail $filepath]
+ set renames {}
+
+ foreach loc $difffilestart {
+ set loclineend [string map {.0 .end} $loc]
+ set fromlineloc "$loc + 2 lines"
+ set tolineloc "$loc + 3 lines"
+ set renfromline [$ctext get $fromlineloc [string map {.0 .end} $fromlineloc]]
+ set rentoline [$ctext get $tolineloc [string map {.0 .end} $tolineloc]]
+ if {[string equal -length 12 "rename from " $renfromline]
+ && [string equal -length 10 "rename to " $rentoline]} {
+ set renfrom [string range $renfromline 12 end]
+ set rento [string range $rentoline 10 end]
+ if {[string first $filename $renfrom] != -1
+ || [string first $filename $rento] != -1} {
+ lappend renames $renfrom
+ lappend renames $rento
+ break
+ }
+ }
+ }
+
+ return $renames
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
@@ -3835,8 +3845,16 @@ proc external_diff {} {
if {$diffdir eq {}} return
# gather files to diff
- set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
- set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
+ set renames [check_for_renames_in_diff $flist_menu_file]
+ set renamefrom [lindex $renames 0]
+ set renameto [lindex $renames 1]
+ if {$renamefrom ne {} && $renameto ne {}} {
+ set difffromfile [external_diff_get_one_file $diffidfrom $renamefrom $diffdir]
+ set difftofile [external_diff_get_one_file $diffidto $renameto $diffdir]
+ } else {
+ set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
+ set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
+ }
if {$difffromfile ne {} && $difftofile ne {}} {
set cmd [list [shellsplit $extdifftool] $difffromfile $difftofile]
@@ -6813,17 +6831,19 @@ proc drawtags {id x xt y1} {
} else {
# draw a head or other ref
if {[incr nheads -1] >= 0} {
- set col $headbgcolor
+ set refoutlinecol $headoutlinecolor
+ set reffillcol $headbgcolor
if {$tag eq $mainhead} {
set font mainfontbold
}
} else {
- set col "#ddddff"
+ set refoutlinecol black
+ set reffillcol "#ddddff"
}
set xl [expr {$xl - $delta/2}]
$canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
- -width 1 -outline black -fill $col -tags tag.$id
- if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
+ -width 1 -outline $refoutlinecol -fill $reffillcol -tags tag.$id
+ if {[regexp {^(remotes/[^/]*/|remotes/)} $tag match remoteprefix]} {
set rwid [font measure mainfont $remoteprefix]
set xi [expr {$x + 1}]
set yti [expr {$yt + 1}]
@@ -6832,7 +6852,8 @@ proc drawtags {id x xt y1} {
-width 0 -fill $remotebgcolor -tags tag.$id
}
}
- set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
+ set textfgcolor [expr {$ntags >= 0 ? $tagfgcolor : $headfgcolor}]
+ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $textfgcolor \
-font $font -tags [list tag.$id text]]
if {$ntags >= 0} {
$canv bind $t <1> $tagclick
@@ -8313,7 +8334,7 @@ proc parseblobdiffline {ids line} {
if {![regexp {^diff (--cc|--git) } $line m type]} {
set line [convertfrom utf-8 $line]
$ctext insert end "$line\n" hunksep
- continue
+ return
}
# start of a new file
set diffinhdr 1
@@ -8418,6 +8439,7 @@ proc parseblobdiffline {ids line} {
if {$i >= 0} {
setinlist difffilestart $i $curdiffstart
}
+ set line "rename from $fname"
} elseif {![string compare -length 10 $line "rename to "] ||
![string compare -length 8 $line "copy to "]} {
set fname [string range $line [expr 4 + [string first " to " $line] ] end]
@@ -8425,6 +8447,13 @@ proc parseblobdiffline {ids line} {
set fname [lindex $fname 0]
}
makediffhdr $fname $ids
+ set line "[lindex $line 0] to $fname"
+ } elseif {![string compare -length 10 $line "copy from "]} {
+ set fname [string range $line 10 end]
+ if {[string index $fname 0] eq "\""} {
+ set fname [lindex $fname 0]
+ }
+ set line "copy from $fname"
} elseif {[string compare -length 3 $line "---"] == 0} {
# do nothing
return
@@ -8886,9 +8915,9 @@ proc sha1change {n1 n2 op} {
}
if {[$sha1but cget -state] == $state} return
if {$state == "normal"} {
- $sha1but conf -state normal -relief raised -text "[mc "Goto:"] "
+ $sha1but conf -state normal -text "[mc "Goto:"] "
} else {
- $sha1but conf -state disabled -relief flat -text "[mc "Commit ID:"] "
+ $sha1but conf -state disabled -text "[mc "Commit ID:"] "
}
}
@@ -10177,6 +10206,7 @@ proc rmbranch {} {
proc showrefs {} {
global showrefstop bgcolor fgcolor selectbgcolor
global bglist fglist reflistfilter reflist maincursor
+ global geometry
set top .showrefs
set showrefstop $top
@@ -10187,7 +10217,11 @@ proc showrefs {} {
}
ttk_toplevel $top
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
- make_transient $top .
+ if {[info exists geometry(showrefs)]} {
+ make_transient $top . $geometry(showrefs)
+ } else {
+ make_transient $top .
+ }
text $top.list -background $bgcolor -foreground $fgcolor \
-selectbackground $selectbgcolor -font mainfont \
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10223,6 +10257,9 @@ proc showrefs {} {
bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
set reflist {}
refill_reflist
+ # avoid <Configure> being bound to child windows
+ bindtags $top [linsert [bindtags $top] 1 bind$top]
+ bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
}
proc sel_reflist {w x y} {
@@ -10270,7 +10307,9 @@ proc refill_reflist {} {
if {![string match "remotes/*" $n] && [string match $reflistfilter $n]} {
if {[commitinview $headids($n) $curview]} {
lappend localrefs [list $n H]
- if {[info exists upstreamofref($n)] && [commitinview $headids($upstreamofref($n)) $curview]} {
+ if {[info exists upstreamofref($n)] && \
+ [info exists headids($upstreamofref($n))] && \
+ [commitinview $headids($upstreamofref($n)) $curview]} {
lappend trackedremoterefs [list $upstreamofref($n) R]
}
} else {
@@ -11584,9 +11623,10 @@ proc mkfontdisp {font top which} {
set fontpref($font) [set $font]
ttk::button $top.${font}but -text $which \
-command [list choosefont $font $which]
- ttk::label $top.$font -relief flat -font $font \
- -text $fontattr($font,family) -justify left
+ ttk::label $top.$font -font $font \
+ -text $fontattr($font,family)
grid x $top.${font}but $top.$font -sticky w
+ grid configure $top.$font -sticky ew
}
proc centertext {w} {
@@ -11666,48 +11706,52 @@ proc prefspage_general {notebook} {
ttk::label $page.ldisp -text [mc "Commit list display options"] -font mainfontbold
grid $page.ldisp - -sticky w -pady 10
+
ttk::label $page.spacer -text " "
ttk::label $page.maxwidthl -text [mc "Maximum graph width (lines)"]
- spinbox $page.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth
+ ttk::spinbox $page.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth
grid $page.spacer $page.maxwidthl $page.maxwidth -sticky w
#xgettext:no-tcl-format
ttk::label $page.maxpctl -text [mc "Maximum graph width (% of pane)"]
- spinbox $page.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
+ ttk::spinbox $page.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
grid x $page.maxpctl $page.maxpct -sticky w
+
ttk::checkbutton $page.showlocal -text [mc "Show local changes"] \
-variable showlocalchanges
grid x $page.showlocal -sticky w
+
ttk::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
-variable hideremotes
grid x $page.hideremotes -sticky w
ttk::entry $page.refstohide -textvariable refstohide
- ttk::frame $page.refstohidef
- ttk::label $page.refstohidef.l -text [mc "Refs to hide (space-separated globs)" ]
- pack $page.refstohidef.l -side left
- pack configure $page.refstohidef.l -padx 10
- grid x $page.refstohidef $page.refstohide -sticky ew
+ ttk::label $page.refstohidel -text [mc "Refs to hide (space-separated globs)"]
+ grid x $page.refstohidel $page.refstohide -sticky ew
+ grid configure $page.refstohide -padx {0 5}
ttk::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
-variable autocopy
grid x $page.autocopy -sticky w
+
if {[haveselectionclipboard]} {
ttk::checkbutton $page.autoselect -text [mc "Copy commit ID to X11 selection"] \
-variable autoselect
grid x $page.autoselect -sticky w
}
- spinbox $page.autosellen -from 1 -to $hashlength -width 4 -textvariable autosellen
+ ttk::spinbox $page.autosellen -from 1 -to $hashlength -width 4 -textvariable autosellen
ttk::label $page.autosellenl -text [mc "Length of commit ID to copy"]
grid x $page.autosellenl $page.autosellen -sticky w
+
ttk::label $page.kscroll1 -text [mc "Wheel scrolling multiplier"]
- spinbox $page.kscroll -from 1 -to 20 -width 4 -textvariable kscroll
+ ttk::spinbox $page.kscroll -from 1 -to 20 -width 4 -textvariable kscroll
grid x $page.kscroll1 $page.kscroll -sticky w
ttk::label $page.ddisp -text [mc "Diff display options"] -font mainfontbold
grid $page.ddisp - -sticky w -pady 10
+
ttk::label $page.tabstopl -text [mc "Tab spacing"]
- spinbox $page.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
+ ttk::spinbox $page.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
grid x $page.tabstopl $page.tabstop -sticky w
ttk::label $page.wrapcommentl -text [mc "Wrap comment text"]
@@ -11721,12 +11765,15 @@ proc prefspage_general {notebook} {
ttk::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
-variable showneartags
grid x $page.ntag -sticky w
+
ttk::label $page.maxrefsl -text [mc "Maximum # tags/heads to show"]
- spinbox $page.maxrefs -from 1 -to 1000 -width 4 -textvariable maxrefs
+ ttk::spinbox $page.maxrefs -from 1 -to 1000 -width 4 -textvariable maxrefs
grid x $page.maxrefsl $page.maxrefs -sticky w
+
ttk::checkbutton $page.ldiff -text [mc "Limit diffs to listed paths"] \
-variable limitdiffs
grid x $page.ldiff -sticky w
+
ttk::checkbutton $page.lattr -text [mc "Support per-file encodings"] \
-variable perfile_attrs
grid x $page.lattr -sticky w
@@ -11735,76 +11782,114 @@ proc prefspage_general {notebook} {
ttk::frame $page.extdifff
ttk::label $page.extdifff.l -text [mc "External diff tool" ]
ttk::button $page.extdifff.b -text [mc "Choose..."] -command choose_extdiff
- pack $page.extdifff.l $page.extdifff.b -side left
- pack configure $page.extdifff.l -padx 10
+ pack $page.extdifff.l -side left
+ pack $page.extdifff.b -side right -padx {0 5}
grid x $page.extdifff $page.extdifft -sticky ew
+ grid configure $page.extdifft -padx {0 5}
ttk::entry $page.webbrowser -textvariable web_browser
- ttk::frame $page.webbrowserf
- ttk::label $page.webbrowserf.l -text [mc "Web browser" ]
- pack $page.webbrowserf.l -side left
- pack configure $page.webbrowserf.l -padx 10
- grid x $page.webbrowserf $page.webbrowser -sticky ew
+ ttk::label $page.webbrowserl -text [mc "Web browser" ]
+ grid x $page.webbrowserl $page.webbrowser -sticky ew
+ grid configure $page.webbrowser -padx {0 5}
+
+ grid columnconfigure $page 2 -weight 1
return $page
}
proc prefspage_colors {notebook} {
- global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
- global diffbgcolors
+ global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
+ global diffbgcolors linkfgcolor
+ global themeloader
set page [create_prefs_page $notebook.colors]
+ ttk::label $page.themesel -font mainfontbold \
+ -text [mc "Themes - change requires restart"]
+ grid $page.themesel - -sticky w -pady 10
+
+ ttk::label $page.themelabel -text [mc "Theme to use after restart"]
+ makedroplist $page.theme theme {*}[lsort [ttk::style theme names]]
+ grid x $page.themelabel $page.theme -sticky w
+
+ ttk::entry $page.tloadvar -textvariable themeloader
+ ttk::frame $page.tloadframe
+ ttk::label $page.tloadframe.l -text [mc "Theme definition file"]
+ ttk::button $page.tloadframe.b -text [mc "Choose..."] \
+ -command [list choose_themeloader $page]
+ pack $page.tloadframe.l -side left
+ pack $page.tloadframe.b -side right -padx {0 5}
+ pack configure $page.tloadframe.l -padx 0
+ grid x $page.tloadframe $page.tloadvar -sticky ew
+ grid configure $page.tloadvar -padx {0 5}
+
+ ttk::label $page.themelabel2 -text \
+ [mc "The theme definition file may affect all themes."]
+ ttk::button $page.themebut2 -text [mc "Apply theme"] \
+ -command [list updatetheme $page]
+ grid x $page.themebut2 $page.themelabel2 -sticky w
+
ttk::label $page.cdisp -text [mc "Colors: press to choose"] -font mainfontbold
grid $page.cdisp - -sticky w -pady 10
- label $page.ui -padx 40 -relief sunk -background $uicolor
- ttk::button $page.uibut -text [mc "Interface"] \
- -command [list choosecolor uicolor {} $page [mc "interface"]]
- grid x $page.uibut $page.ui -sticky w
label $page.bg -padx 40 -relief sunk -background $bgcolor
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
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]
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]
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]
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]
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]
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
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
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
+ 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
+
return $page
}
proc prefspage_set_colorswatches {page} {
- global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
- global diffbgcolors
+ global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
+ global diffbgcolors linkfgcolor
- $page.ui configure -background $uicolor
$page.bg configure -background $bgcolor
$page.fg configure -background $fgcolor
$page.diffold configure -background [lindex $diffcolors 0]
@@ -11814,6 +11899,7 @@ proc prefspage_set_colorswatches {page} {
$page.hunksep configure -background [lindex $diffcolors 2]
$page.markbgsep configure -background $markbgcolor
$page.selbgsep configure -background $selectbgcolor
+ $page.linkfg configure -background $linkfgcolor
}
proc prefspage_fonts {notebook} {
@@ -11823,6 +11909,7 @@ proc prefspage_fonts {notebook} {
mkfontdisp mainfont $page [mc "Main font"]
mkfontdisp textfont $page [mc "Diff display font"]
mkfontdisp uifont $page [mc "User interface font"]
+ grid columnconfigure $page 2 -weight 1
return $page
}
@@ -11857,7 +11944,7 @@ proc doprefs {} {
grid rowconfigure $notebook 1 -weight 1
raise [lindex $pages 0]
- grid $notebook -sticky news -padx 2 -pady 2
+ grid $notebook -sticky news -padx 3 -pady 3
grid rowconfigure $top 0 -weight 1
grid columnconfigure $top 0 -weight 1
@@ -11866,12 +11953,13 @@ proc doprefs {} {
ttk::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
bind $top <Key-Return> prefsok
bind $top <Key-Escape> prefscan
- grid $top.buts.ok $top.buts.can
- grid columnconfigure $top.buts 0 -weight 1 -uniform a
- grid columnconfigure $top.buts 1 -weight 1 -uniform a
- grid $top.buts - - -pady 10 -sticky ew
- grid columnconfigure $top 2 -weight 1
+ grid $top.buts.ok $top.buts.can -padx 20
+ grid $top.buts -sticky w -pady 10
bind $top <Visibility> [list focus $top.buts.ok]
+
+ # let geometry manager determine run, set minimum size
+ update idletasks
+ wm minsize $top [winfo reqwidth $top] [winfo reqheight $top]
}
proc choose_extdiff {} {
@@ -11883,6 +11971,51 @@ proc choose_extdiff {} {
}
}
+proc run_themeloader {f} {
+ if {![info exists ::_themefiles_seen]} {
+ set ::_themefiles_seen [dict create]
+ }
+
+ set fn [file normalize $f]
+ if {![dict exists $::_themefiles_seen $fn]} {
+ if {[catch {source $fn} err]} {
+ error_popup "could not interpret: $fn\n$err"
+ dict set ::_themefiles_seen $fn 0
+ } else {
+ dict set ::_themefiles_seen $fn 1
+ }
+ }
+ return [dict get $::_themefiles_seen $fn]
+}
+
+proc updatetheme {prefspage {dotheme 1}} {
+ global theme
+ global themeloader
+ if {$themeloader ne {}} {
+ if {![run_themeloader $themeloader]} {
+ set themeloader {}
+ return
+ } else {
+ $prefspage.theme configure -values \
+ [lsort [ttk::style theme names]]
+ }
+ }
+ if {$dotheme} {
+ ttk::style theme use $theme
+ set_gui_colors
+ prefspage_set_colorswatches $prefspage
+ }
+}
+
+proc choose_themeloader {prefspage} {
+ global themeloader
+ set tfile [tk_getOpenFile -title [mc "Gitk: select theme definition"] -multiple false]
+ if {$tfile ne {}} {
+ set themeloader $tfile
+ updatetheme $prefspage 0
+ }
+}
+
proc choosecolor {v vi prefspage x} {
global $v
@@ -11906,21 +12039,6 @@ proc setselbg {c} {
allcanvs itemconf secsel -fill $c
}
-# This sets the background color and the color scheme for the whole UI.
-# For some reason, tk_setPalette chooses a nasty dark red for selectColor
-# if we don't specify one ourselves, which makes the checkbuttons and
-# radiobuttons look bad. This chooses white for selectColor if the
-# background color is light, or black if it is dark.
-proc setui {c} {
- if {[tk windowingsystem] eq "win32"} { return }
- set bg [winfo rgb . $c]
- set selc black
- if {[lindex $bg 0] + 1.5 * [lindex $bg 1] + 0.5 * [lindex $bg 2] > 100000} {
- set selc white
- }
- tk_setPalette background $c selectColor $selc
-}
-
proc setbg {c} {
global bglist
@@ -11945,10 +12063,9 @@ proc setfg {c} {
}
proc set_gui_colors {} {
- global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
+ global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
global diffbgcolors
- setui $uicolor
setbg $bgcolor
setfg $fgcolor
$ctext tag conf d0 -foreground [lindex $diffcolors 0]
@@ -11970,6 +12087,7 @@ proc prefscan {} {
catch {destroy $prefstop}
unset prefstop
fontcan
+ setttkstyle
set_gui_colors
}
@@ -12436,11 +12554,13 @@ namespace import ::msgcat::mc
# on OSX bring the current Wish process window to front
if {[tk windowingsystem] eq "aqua"} {
- safe_exec [list osascript -e [format {
- tell application "System Events"
- set frontmost of processes whose unix id is %d to true
- end tell
- } [pid] ]]
+ catch {
+ safe_exec [list osascript -e [format {
+ tell application "System Events"
+ set frontmost of processes whose unix id is %d to true
+ end tell
+ } [pid] ]]
+ }
}
# Unset GIT_TRACE var if set
@@ -12545,17 +12665,11 @@ if {[tk windowingsystem] eq "aqua"} {
set colors {"#00ff00" red blue magenta darkgrey brown orange}
if {[tk windowingsystem] eq "win32"} {
- set uicolor SystemButtonFace
- set uifgcolor SystemButtonText
- set uifgdisabledcolor SystemDisabledText
set bgcolor SystemWindow
set fgcolor SystemWindowText
set selectbgcolor SystemHighlight
set web_browser "cmd /c start"
} else {
- set uicolor grey85
- set uifgcolor black
- set uifgdisabledcolor "#999"
set bgcolor white
set fgcolor black
set selectbgcolor gray85
@@ -12595,8 +12709,14 @@ set circleoutlinecolor $fgcolor
set foundbgcolor yellow
set currentsearchhitbgcolor orange
+set theme [ttk::style theme use]
+set themeloader {}
+set uicolor {}
+set uifgcolor {}
+set uifgdisabledcolor {}
+
# button for popping up context menus
-if {[tk windowingsystem] eq "aqua"} {
+if {[tk windowingsystem] eq "aqua" && [package vcompare $::tcl_version 8.7] < 0} {
set ctxbut <Button-2>
} else {
set ctxbut <Button-3>
@@ -12678,6 +12798,8 @@ set config_variables {
tagfgcolor
tagoutlinecolor
textfont
+ theme
+ themeloader
uicolor
uifgcolor
uifgdisabledcolor
@@ -12777,7 +12899,13 @@ set nullid "0000000000000000000000000000000000000000"
set nullid2 "0000000000000000000000000000000000000001"
set nullfile "/dev/null"
-setttkstyle
+if {[file exists $themeloader]} {
+ if {![run_themeloader $themeloader]} {
+ puts stderr "Could not interpret themeloader: $themeloader"
+ exit 1
+ }
+}
+
set appname "gitk"
set runq {}
@@ -12893,6 +13021,7 @@ if {[tk windowingsystem] eq "win32"} {
focus -force .
}
+setttkstyle
set_gui_colors
getcommits {}