@matheusbsbs / matheus-bagliano / commits / d93f1713b0
Fork 0

gitk: Use themed tk widgets

With Tk 8.5+, this uses the themed widgets to improve the appearance on Windows and MacOSX. On X11 less difference is apparent, but users can select alternate themes by setting *TkTheme in the resource database (eg: *TkTheme: clam). With Tk 8.6 there is a built-in font selection dialog. This will make use of that when available, as on Windows and MacOSX it calls the native font selection dialog. [paulus@samba.org - folded in subsequent patch to restore saved pane sizes for ttk widgets, and trimmed trailing whitespace.] Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Paul Mackerras <paulus@samba.org>

Pat Thoyts committed Apr 17, 2009 at 01:24 UTC d93f1713b0ba57b119f2ba2e2beda2ed9cc7349d
1 file changed +370 -237
gitk
+370 -237
@@ -7,6 +7,8 @@ exec wish "$0" -- "$@"
7 # and distributed under the terms of the GNU General Public Licence,
8 # either version 2, or (at your option) any later version.
9
10 +package require Tk
11 +
12 proc gitdir {} {
13 global env
14 if {[info exists env(GIT_DIR)]} {
@@ -264,7 +266,7 @@ proc parseviewrevs {view revs} {
266 }
267 lappend badrev $line
268 }
267 - }
269 + }
270 error_popup "[mc "Error parsing revisions:"] $err"
271 return {}
272 }
@@ -1767,6 +1769,15 @@ proc removehead {id name} {
1769 unset headids($name)
1770 }
1771
1772 +proc ttk_toplevel {w args} {
1773 + global use_ttk
1774 + eval [linsert $args 0 ::toplevel $w]
1775 + if {$use_ttk} {
1776 + place [ttk::frame $w._toplevel_background] -x 0 -y 0 -relwidth 1 -relheight 1
1777 + }
1778 + return $w
1779 +}
1780 +
1781 proc make_transient {window origin} {
1782 global have_tk85
1783
@@ -1786,9 +1797,11 @@ proc make_transient {window origin} {
1797 }
1798
1799 proc show_error {w top msg} {
1800 + global NS
1801 + if {[wm state $top] eq "withdrawn"} { wm deiconify $top }
1802 message $w.m -text $msg -justify center -aspect 400
1803 pack $w.m -side top -fill x -padx 20 -pady 20
1791 - button $w.ok -text [mc OK] -command "destroy $top"
1804 + ${NS}::button $w.ok -default active -text [mc OK] -command "destroy $top"
1805 pack $w.ok -side bottom -fill x
1806 bind $top <Visibility> "grab $top; focus $top"
1807 bind $top <Key-Return> "destroy $top"
@@ -1798,45 +1811,56 @@ proc show_error {w top msg} {
1811 }
1812
1813 proc error_popup {msg {owner .}} {
1801 - set w .error
1802 - toplevel $w
1803 - make_transient $w $owner
1804 - show_error $w $w $msg
1814 + if {[tk windowingsystem] eq "win32"} {
1815 + tk_messageBox -icon error -type ok -title [wm title .] \
1816 + -parent $owner -message $msg
1817 + } else {
1818 + set w .error
1819 + ttk_toplevel $w
1820 + make_transient $w $owner
1821 + show_error $w $w $msg
1822 + }
1823 }
1824
1825 proc confirm_popup {msg {owner .}} {
1808 - global confirm_ok
1826 + global confirm_ok NS
1827 set confirm_ok 0
1828 set w .confirm
1811 - toplevel $w
1829 + ttk_toplevel $w
1830 make_transient $w $owner
1831 message $w.m -text $msg -justify center -aspect 400
1832 pack $w.m -side top -fill x -padx 20 -pady 20
1815 - button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
1833 + ${NS}::button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
1834 pack $w.ok -side left -fill x
1817 - button $w.cancel -text [mc Cancel] -command "destroy $w"
1835 + ${NS}::button $w.cancel -text [mc Cancel] -command "destroy $w"
1836 pack $w.cancel -side right -fill x
1837 bind $w <Visibility> "grab $w; focus $w"
1838 bind $w <Key-Return> "set confirm_ok 1; destroy $w"
1839 bind $w <Key-space> "set confirm_ok 1; destroy $w"
1840 bind $w <Key-Escape> "destroy $w"
1841 + tk::PlaceWindow $w widget $owner
1842 tkwait window $w
1843 return $confirm_ok
1844 }
1845
1846 proc setoptions {} {
1828 - option add *Panedwindow.showHandle 1 startupFile
1829 - option add *Panedwindow.sashRelief raised startupFile
1847 + if {[tk windowingsystem] ne "win32"} {
1848 + option add *Panedwindow.showHandle 1 startupFile
1849 + option add *Panedwindow.sashRelief raised startupFile
1850 + if {[tk windowingsystem] ne "aqua"} {
1851 + option add *Menu.font uifont startupFile
1852 + }
1853 + } else {
1854 + option add *Menu.TearOff 0 startupFile
1855 + }
1856 option add *Button.font uifont startupFile
1857 option add *Checkbutton.font uifont startupFile
1858 option add *Radiobutton.font uifont startupFile
1833 - if {[tk windowingsystem] ne "aqua"} {
1834 - option add *Menu.font uifont startupFile
1835 - }
1859 option add *Menubutton.font uifont startupFile
1860 option add *Label.font uifont startupFile
1861 option add *Message.font uifont startupFile
1862 option add *Entry.font uifont startupFile
1863 + option add *Labelframe.font uifont startupFile
1864 }
1865
1866 # Make a menu and submenus.
@@ -1893,6 +1917,17 @@ proc mca {str} {
1917 return [string map {&& & & {}} [mc $str]]
1918 }
1919
1920 +proc makedroplist {w varname args} {
1921 + global use_ttk
1922 + if {$use_ttk} {
1923 + set gm [ttk::combobox $w -width 10 -state readonly\
1924 + -textvariable $varname -values $args]
1925 + } else {
1926 + set gm [eval [linsert $args 0 tk_optionMenu $w $varname]]
1927 + }
1928 + return $gm
1929 +}
1930 +
1931 proc makewindow {} {
1932 global canv canv2 canv3 linespc charspc ctext cflist cscroll
1933 global tabstop
@@ -1908,7 +1943,7 @@ proc makewindow {} {
1943 global headctxmenu progresscanv progressitem progresscoords statusw
1944 global fprogitem fprogcoord lastprogupdate progupdatepending
1945 global rprogitem rprogcoord rownumsel numcommits
1911 - global have_tk85
1946 + global have_tk85 use_ttk NS
1947
1948 # The "mc" arguments here are purely so that xgettext
1949 # sees the following string as needing to be translated
@@ -1960,8 +1995,13 @@ proc makewindow {} {
1995 makemenu .bar $bar
1996 . configure -menu .bar
1997
1998 + if {$use_ttk} {
1999 + # cover the non-themed toplevel with a themed frame.
2000 + place [ttk::frame ._main_background] -x 0 -y 0 -relwidth 1 -relheight 1
2001 + }
2002 +
2003 # the gui has upper and lower half, parts of a paned window.
1964 - panedwindow .ctop -orient vertical
2004 + ${NS}::panedwindow .ctop -orient vertical
2005
2006 # possibly use assumed geometry
2007 if {![info exists geometry(pwsash0)]} {
@@ -1969,14 +2009,17 @@ proc makewindow {} {
2009 set geometry(topwidth) [expr {80 * $charspc}]
2010 set geometry(botheight) [expr {15 * $linespc}]
2011 set geometry(botwidth) [expr {50 * $charspc}]
1972 - set geometry(pwsash0) "[expr {40 * $charspc}] 2"
1973 - set geometry(pwsash1) "[expr {60 * $charspc}] 2"
2012 + set geometry(pwsash0) [list [expr {40 * $charspc}] 2]
2013 + set geometry(pwsash1) [list [expr {60 * $charspc}] 2]
2014 }
2015
2016 # the upper half will have a paned window, a scroll bar to the right, and some stuff below
1977 - frame .tf -height $geometry(topheight) -width $geometry(topwidth)
1978 - frame .tf.histframe
1979 - panedwindow .tf.histframe.pwclist -orient horizontal -sashpad 0 -handlesize 4
2017 + ${NS}::frame .tf -height $geometry(topheight) -width $geometry(topwidth)
2018 + ${NS}::frame .tf.histframe
2019 + ${NS}::panedwindow .tf.histframe.pwclist -orient horizontal
2020 + if {!$use_ttk} {
2021 + .tf.histframe.pwclist configure -sashpad 0 -handlesize 4
2022 + }
2023
2024 # create three canvases
2025 set cscroll .tf.histframe.csb
@@ -1996,19 +2039,28 @@ proc makewindow {} {
2039 -selectbackground $selectbgcolor \
2040 -background $bgcolor -bd 0 -yscrollincr $linespc
2041 .tf.histframe.pwclist add $canv3
1999 - eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
2000 - eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
2042 + if {$use_ttk} {
2043 + bind .tf.histframe.pwclist <Map> {
2044 + bind %W <Map> {}
2045 + .tf.histframe.pwclist sashpos 1 [lindex $::geometry(pwsash1) 0]
2046 + .tf.histframe.pwclist sashpos 0 [lindex $::geometry(pwsash0) 0]
2047 + }
2048 + } else {
2049 + eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
2050 + eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
2051 + }
2052
2053 # a scroll bar to rule them
2003 - scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
2054 + ${NS}::scrollbar $cscroll -command {allcanvs yview}
2055 + if {!$use_ttk} {$cscroll configure -highlightthickness 0}
2056 pack $cscroll -side right -fill y
2057 bind .tf.histframe.pwclist <Configure> {resizeclistpanes %W %w}
2058 lappend bglist $canv $canv2 $canv3
2059 pack .tf.histframe.pwclist -fill both -expand 1 -side left
2060
2061 # we have two button bars at bottom of top frame. Bar 1
2010 - frame .tf.bar
2011 - frame .tf.lbar -height 15
2062 + ${NS}::frame .tf.bar
2063 + ${NS}::frame .tf.lbar -height 15
2064
2065 set sha1entry .tf.bar.sha1
2066 set entries $sha1entry
@@ -2017,7 +2069,7 @@ proc makewindow {} {
2069 -command gotocommit -width 8
2070 $sha1but conf -disabledforeground [$sha1but cget -foreground]
2071 pack .tf.bar.sha1label -side left
2020 - entry $sha1entry -width 40 -font textfont -textvariable sha1string
2072 + ${NS}::entry $sha1entry -width 40 -font textfont -textvariable sha1string
2073 trace add variable sha1string write sha1change
2074 pack $sha1entry -side left -pady 2
2075
@@ -2037,36 +2089,43 @@ proc makewindow {} {
2089 0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
2090 0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
2091 }
2040 - button .tf.bar.leftbut -image bm-left -command goback \
2092 + ${NS}::button .tf.bar.leftbut -image bm-left -command goback \
2093 -state disabled -width 26
2094 pack .tf.bar.leftbut -side left -fill y
2043 - button .tf.bar.rightbut -image bm-right -command goforw \
2095 + ${NS}::button .tf.bar.rightbut -image bm-right -command goforw \
2096 -state disabled -width 26
2097 pack .tf.bar.rightbut -side left -fill y
2098
2047 - label .tf.bar.rowlabel -text [mc "Row"]
2099 + ${NS}::label .tf.bar.rowlabel -text [mc "Row"]
2100 set rownumsel {}
2049 - label .tf.bar.rownum -width 7 -font textfont -textvariable rownumsel \
2101 + ${NS}::label .tf.bar.rownum -width 7 -textvariable rownumsel \
2102 -relief sunken -anchor e
2051 - label .tf.bar.rowlabel2 -text "/"
2052 - label .tf.bar.numcommits -width 7 -font textfont -textvariable numcommits \
2103 + ${NS}::label .tf.bar.rowlabel2 -text "/"
2104 + ${NS}::label .tf.bar.numcommits -width 7 -textvariable numcommits \
2105 -relief sunken -anchor e
2106 pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
2107 -side left
2108 + if {!$use_ttk} {
2109 + foreach w {rownum numcommits} {.tf.bar.$w configure -font textfont}
2110 + }
2111 global selectedline
2112 trace add variable selectedline write selectedline_change
2113
2114 # Status label and progress bar
2115 set statusw .tf.bar.status
2061 - label $statusw -width 15 -relief sunken
2116 + ${NS}::label $statusw -width 15 -relief sunken
2117 pack $statusw -side left -padx 5
2063 - set h [expr {[font metrics uifont -linespace] + 2}]
2064 - set progresscanv .tf.bar.progress
2065 - canvas $progresscanv -relief sunken -height $h -borderwidth 2
2066 - set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
2067 - set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
2068 - set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
2069 - pack $progresscanv -side right -expand 1 -fill x
2118 + if {$use_ttk} {
2119 + set progresscanv [ttk::progressbar .tf.bar.progress]
2120 + } else {
2121 + set h [expr {[font metrics uifont -linespace] + 2}]
2122 + set progresscanv .tf.bar.progress
2123 + canvas $progresscanv -relief sunken -height $h -borderwidth 2
2124 + set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
2125 + set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
2126 + set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
2127 + }
2128 + pack $progresscanv -side right -expand 1 -fill x -padx {0 2}
2129 set progresscoords {0 0}
2130 set fprogcoord 0
2131 set rprogcoord 0
@@ -2075,14 +2134,14 @@ proc makewindow {} {
2134 set progupdatepending 0
2135
2136 # build up the bottom bar of upper window
2078 - label .tf.lbar.flabel -text "[mc "Find"] "
2079 - button .tf.lbar.fnext -text [mc "next"] -command {dofind 1 1}
2080 - button .tf.lbar.fprev -text [mc "prev"] -command {dofind -1 1}
2081 - label .tf.lbar.flab2 -text " [mc "commit"] "
2137 + ${NS}::label .tf.lbar.flabel -text "[mc "Find"] "
2138 + ${NS}::button .tf.lbar.fnext -text [mc "next"] -command {dofind 1 1}
2139 + ${NS}::button .tf.lbar.fprev -text [mc "prev"] -command {dofind -1 1}
2140 + ${NS}::label .tf.lbar.flab2 -text " [mc "commit"] "
2141 pack .tf.lbar.flabel .tf.lbar.fnext .tf.lbar.fprev .tf.lbar.flab2 \
2142 -side left -fill y
2143 set gdttype [mc "containing:"]
2085 - set gm [tk_optionMenu .tf.lbar.gdttype gdttype \
2144 + set gm [makedroplist .tf.lbar.gdttype gdtype \
2145 [mc "containing:"] \
2146 [mc "touching paths:"] \
2147 [mc "adding/removing string:"]]
@@ -2092,14 +2151,14 @@ proc makewindow {} {
2151 set findstring {}
2152 set fstring .tf.lbar.findstring
2153 lappend entries $fstring
2095 - entry $fstring -width 30 -font textfont -textvariable findstring
2154 + ${NS}::entry $fstring -width 30 -font textfont -textvariable findstring
2155 trace add variable findstring write find_change
2156 set findtype [mc "Exact"]
2098 - set findtypemenu [tk_optionMenu .tf.lbar.findtype \
2099 - findtype [mc "Exact"] [mc "IgnCase"] [mc "Regexp"]]
2157 + set findtypemenu [makedroplist .tf.lbar.findtype \
2158 + findtype [mc "Exact"] [mc "IgnCase"] [mc "Regexp"]]
2159 trace add variable findtype write findcom_change
2160 set findloc [mc "All fields"]
2102 - tk_optionMenu .tf.lbar.findloc findloc [mc "All fields"] [mc "Headline"] \
2161 + makedroplist .tf.lbar.findloc findloc [mc "All fields"] [mc "Headline"] \
2162 [mc "Comments"] [mc "Author"] [mc "Committer"]
2163 trace add variable findloc write find_change
2164 pack .tf.lbar.findloc -side right
@@ -2111,38 +2170,41 @@ proc makewindow {} {
2170 pack .tf.bar -in .tf -side bottom -fill x
2171 pack .tf.histframe -fill both -side top -expand 1
2172 .ctop add .tf
2114 - .ctop paneconfigure .tf -height $geometry(topheight)
2115 - .ctop paneconfigure .tf -width $geometry(topwidth)
2173 + if {!$use_ttk} {
2174 + .ctop paneconfigure .tf -height $geometry(topheight)
2175 + .ctop paneconfigure .tf -width $geometry(topwidth)
2176 + }
2177
2178 # now build up the bottom
2118 - panedwindow .pwbottom -orient horizontal
2179 + ${NS}::panedwindow .pwbottom -orient horizontal
2180
2181 # lower left, a text box over search bar, scroll bar to the right
2182 # if we know window height, then that will set the lower text height, otherwise
2183 # we set lower text height which will drive window height
2184 if {[info exists geometry(main)]} {
2124 - frame .bleft -width $geometry(botwidth)
2185 + ${NS}::frame .bleft -width $geometry(botwidth)
2186 } else {
2126 - frame .bleft -width $geometry(botwidth) -height $geometry(botheight)
2187 + ${NS}::frame .bleft -width $geometry(botwidth) -height $geometry(botheight)
2188 }
2128 - frame .bleft.top
2129 - frame .bleft.mid
2130 - frame .bleft.bottom
2189 + ${NS}::frame .bleft.top
2190 + ${NS}::frame .bleft.mid
2191 + ${NS}::frame .bleft.bottom
2192
2132 - button .bleft.top.search -text [mc "Search"] -command dosearch
2193 + ${NS}::button .bleft.top.search -text [mc "Search"] -command dosearch
2194 pack .bleft.top.search -side left -padx 5
2195 set sstring .bleft.top.sstring
2135 - entry $sstring -width 20 -font textfont -textvariable searchstring
2196 + set searchstring ""
2197 + ${NS}::entry $sstring -width 20 -font textfont -textvariable searchstring
2198 lappend entries $sstring
2199 trace add variable searchstring write incrsearch
2200 pack $sstring -side left -expand 1 -fill x
2139 - radiobutton .bleft.mid.diff -text [mc "Diff"] \
2201 + ${NS}::radiobutton .bleft.mid.diff -text [mc "Diff"] \
2202 -command changediffdisp -variable diffelide -value {0 0}
2141 - radiobutton .bleft.mid.old -text [mc "Old version"] \
2203 + ${NS}::radiobutton .bleft.mid.old -text [mc "Old version"] \
2204 -command changediffdisp -variable diffelide -value {0 1}
2143 - radiobutton .bleft.mid.new -text [mc "New version"] \
2205 + ${NS}::radiobutton .bleft.mid.new -text [mc "New version"] \
2206 -command changediffdisp -variable diffelide -value {1 0}
2145 - label .bleft.mid.labeldiffcontext -text " [mc "Lines of context"]: "
2207 + ${NS}::label .bleft.mid.labeldiffcontext -text " [mc "Lines of context"]: "
2208 pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
2209 spinbox .bleft.mid.diffcontext -width 5 -font textfont \
2210 -from 1 -increment 1 -to 10000000 \
@@ -2152,7 +2214,7 @@ proc makewindow {} {
2214 trace add variable diffcontextstring write diffcontextchange
2215 lappend entries .bleft.mid.diffcontext
2216 pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
2155 - checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
2217 + ${NS}::checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
2218 -command changeignorespace -variable ignorespace
2219 pack .bleft.mid.ignspace -side left -padx 5
2220 set ctext .bleft.bottom.ctext
@@ -2163,9 +2225,8 @@ proc makewindow {} {
2225 if {$have_tk85} {
2226 $ctext conf -tabstyle wordprocessor
2227 }
2166 - scrollbar .bleft.bottom.sb -command "$ctext yview"
2167 - scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h \
2168 - -width 10
2228 + ${NS}::scrollbar .bleft.bottom.sb -command "$ctext yview"
2229 + ${NS}::scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h
2230 pack .bleft.top -side top -fill x
2231 pack .bleft.mid -side top -fill x
2232 grid $ctext .bleft.bottom.sb -sticky nsew
@@ -2205,14 +2266,16 @@ proc makewindow {} {
2266 $ctext tag conf found -back yellow
2267
2268 .pwbottom add .bleft
2208 - .pwbottom paneconfigure .bleft -width $geometry(botwidth)
2269 + if {!$use_ttk} {
2270 + .pwbottom paneconfigure .bleft -width $geometry(botwidth)
2271 + }
2272
2273 # lower right
2211 - frame .bright
2212 - frame .bright.mode
2213 - radiobutton .bright.mode.patch -text [mc "Patch"] \
2274 + ${NS}::frame .bright
2275 + ${NS}::frame .bright.mode
2276 + ${NS}::radiobutton .bright.mode.patch -text [mc "Patch"] \
2277 -command reselectline -variable cmitmode -value "patch"
2215 - radiobutton .bright.mode.tree -text [mc "Tree"] \
2278 + ${NS}::radiobutton .bright.mode.tree -text [mc "Tree"] \
2279 -command reselectline -variable cmitmode -value "tree"
2280 grid .bright.mode.patch .bright.mode.tree -sticky ew
2281 pack .bright.mode -side top -fill x
@@ -2228,7 +2291,7 @@ proc makewindow {} {
2291 -spacing1 1 -spacing3 1
2292 lappend bglist $cflist
2293 lappend fglist $cflist
2231 - scrollbar .bright.sb -command "$cflist yview"
2294 + ${NS}::scrollbar .bright.sb -command "$cflist yview"
2295 pack .bright.sb -side right -fill y
2296 pack $cflist -side left -fill both -expand 1
2297 $cflist tag configure highlight \
@@ -2263,6 +2326,17 @@ proc makewindow {} {
2326 set ::BM "2"
2327 }
2328
2329 + if {$use_ttk} {
2330 + bind .ctop <Map> {
2331 + bind %W <Map> {}
2332 + %W sashpos 0 $::geometry(topheight)
2333 + }
2334 + bind .pwbottom <Map> {
2335 + bind %W <Map> {}
2336 + %W sashpos 0 $::geometry(botwidth)
2337 + }
2338 + }
2339 +
2340 bind .pwbottom <Configure> {resizecdetpanes %W %w}
2341 pack .ctop -fill both -expand 1
2342 bindall <1> {selcanvline %W %x %y}
@@ -2482,7 +2556,12 @@ proc click {w} {
2556 proc adjustprogress {} {
2557 global progresscanv progressitem progresscoords
2558 global fprogitem fprogcoord lastprogupdate progupdatepending
2485 - global rprogitem rprogcoord
2559 + global rprogitem rprogcoord use_ttk
2560 +
2561 + if {$use_ttk} {
2562 + $progresscanv configure -value [expr {int($fprogcoord * 100)}]
2563 + return
2564 + }
2565
2566 set w [expr {[winfo width $progresscanv] - 4}]
2567 set x0 [expr {$w * [lindex $progresscoords 0]}]
@@ -2518,7 +2597,7 @@ proc savestuff {w} {
2597 global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
2598 global cmitmode wrapcomment datetimeformat limitdiffs
2599 global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
2521 - global autoselect extdifftool perfile_attrs markbgcolor
2600 + global autoselect extdifftool perfile_attrs markbgcolor use_ttk
2601
2602 if {$stuffsaved} return
2603 if {![winfo viewable .]} return
@@ -2555,8 +2634,13 @@ proc savestuff {w} {
2634 puts $f "set geometry(state) [wm state .]"
2635 puts $f "set geometry(topwidth) [winfo width .tf]"
2636 puts $f "set geometry(topheight) [winfo height .tf]"
2558 - puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
2559 - puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
2637 + if {$use_ttk} {
2638 + puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sashpos 0] 1\""
2639 + puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
2640 + } else {
2641 + puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
2642 + puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
2643 + }
2644 puts $f "set geometry(botwidth) [winfo width .bleft]"
2645 puts $f "set geometry(botheight) [winfo height .bleft]"
2646
@@ -2574,10 +2658,15 @@ proc savestuff {w} {
2658 }
2659
2660 proc resizeclistpanes {win w} {
2577 - global oldwidth
2661 + global oldwidth use_ttk
2662 if {[info exists oldwidth($win)]} {
2579 - set s0 [$win sash coord 0]
2580 - set s1 [$win sash coord 1]
2663 + if {$use_ttk} {
2664 + set s0 [$win sashpos 0]
2665 + set s1 [$win sashpos 1]
2666 + } else {
2667 + set s0 [$win sash coord 0]
2668 + set s1 [$win sash coord 1]
2669 + }
2670 if {$w < 60} {
2671 set sash0 [expr {int($w/2 - 2)}]
2672 set sash1 [expr {int($w*5/6 - 2)}]
@@ -2598,16 +2687,25 @@ proc resizeclistpanes {win w} {
2687 }
2688 }
2689 }
2601 - $win sash place 0 $sash0 [lindex $s0 1]
2602 - $win sash place 1 $sash1 [lindex $s1 1]
2690 + if {$use_ttk} {
2691 + $win sashpos 0 $sash0
2692 + $win sashpos 1 $sash1
2693 + } else {
2694 + $win sash place 0 $sash0 [lindex $s0 1]
2695 + $win sash place 1 $sash1 [lindex $s1 1]
2696 + }
2697 }
2698 set oldwidth($win) $w
2699 }
2700
2701 proc resizecdetpanes {win w} {
2608 - global oldwidth
2702 + global oldwidth use_ttk
2703 if {[info exists oldwidth($win)]} {
2610 - set s0 [$win sash coord 0]
2704 + if {$use_ttk} {
2705 + set s0 [$win sashpos 0]
2706 + } else {
2707 + set s0 [$win sash coord 0]
2708 + }
2709 if {$w < 60} {
2710 set sash0 [expr {int($w*3/4 - 2)}]
2711 } else {
@@ -2620,7 +2718,11 @@ proc resizecdetpanes {win w} {
2718 set sash0 [expr {$w - 15}]
2719 }
2720 }
2623 - $win sash place 0 $sash0 [lindex $s0 1]
2721 + if {$use_ttk} {
2722 + $win sashpos 0 $sash0
2723 + } else {
2724 + $win sash place 0 $sash0 [lindex $s0 1]
2725 + }
2726 }
2727 set oldwidth($win) $w
2728 }
@@ -2640,31 +2742,33 @@ proc bindall {event action} {
2742 }
2743
2744 proc about {} {
2643 - global uifont
2745 + global uifont NS
2746 set w .about
2747 if {[winfo exists $w]} {
2748 raise $w
2749 return
2750 }
2649 - toplevel $w
2751 + ttk_toplevel $w
2752 wm title $w [mc "About gitk"]
2753 make_transient $w .
2754 message $w.m -text [mc "
2755 Gitk - a commit viewer for git
2756
2655 -Copyright © 2005-2008 Paul Mackerras
2757 +Copyright \u00a9 2005-2009 Paul Mackerras
2758
2759 Use and redistribute under the terms of the GNU General Public License"] \
2760 -justify center -aspect 400 -border 2 -bg white -relief groove
2761 pack $w.m -side top -fill x -padx 2 -pady 2
2660 - button $w.ok -text [mc "Close"] -command "destroy $w" -default active
2762 + ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w" -default active
2763 pack $w.ok -side bottom
2764 bind $w <Visibility> "focus $w.ok"
2765 bind $w <Key-Escape> "destroy $w"
2766 bind $w <Key-Return> "destroy $w"
2767 + tk::PlaceWindow $w widget .
2768 }
2769
2770 proc keys {} {
2771 + global NS
2772 set w .keys
2773 if {[winfo exists $w]} {
2774 raise $w
@@ -2675,7 +2779,7 @@ proc keys {} {
2779 } else {
2780 set M1T Ctrl
2781 }
2678 - toplevel $w
2782 + ttk_toplevel $w
2783 wm title $w [mc "Gitk key bindings"]
2784 make_transient $w .
2785 message $w.m -text "
@@ -2719,7 +2823,7 @@ proc keys {} {
2823 " \
2824 -justify left -bg white -border 2 -relief groove
2825 pack $w.m -side top -fill both -padx 2 -pady 2
2722 - button $w.ok -text [mc "Close"] -command "destroy $w" -default active
2826 + ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w" -default active
2827 bind $w <Key-Escape> [list destroy $w]
2828 pack $w.ok -side bottom
2829 bind $w <Visibility> "focus $w.ok"
@@ -3694,7 +3798,7 @@ proc encode_view_opts {n} {
3798 set pattern [lindex $patterns 0]
3799
3800 set val $newviewopts($n,[lindex $opt 0])
3697 -
3801 +
3802 if {[lindex $opt 1] eq "b"} {
3803 if {$val} {
3804 lappend rargs $pattern
@@ -3782,16 +3886,16 @@ proc editview {} {
3886
3887 proc vieweditor {top n title} {
3888 global newviewname newviewopts viewfiles bgcolor
3785 - global known_view_options
3889 + global known_view_options NS
3890
3787 - toplevel $top
3891 + ttk_toplevel $top
3892 wm title $top $title
3893 make_transient $top .
3894
3895 # View name
3792 - frame $top.nfr
3793 - label $top.nl -text [mc "Name"]
3794 - entry $top.name -width 20 -textvariable newviewname($n)
3896 + ${NS}::frame $top.nfr
3897 + ${NS}::label $top.nl -text [mc "Name"]
3898 + ${NS}::entry $top.name -width 20 -textvariable newviewname($n)
3899 pack $top.nfr -in $top -fill x -pady 5 -padx 3
3900 pack $top.nl -in $top.nfr -side left -padx {0 30}
3901 pack $top.name -in $top.nfr -side left
@@ -3810,7 +3914,7 @@ proc vieweditor {top n title} {
3914 if {$flags eq "+" || $flags eq "*"} {
3915 set cframe $top.fr$cnt
3916 incr cnt
3813 - frame $cframe
3917 + ${NS}::frame $cframe
3918 pack $cframe -in $top -fill x -pady 3 -padx 3
3919 set cexpand [expr {$flags eq "*"}]
3920 } else {
@@ -3818,18 +3922,18 @@ proc vieweditor {top n title} {
3922 }
3923
3924 if {$type eq "b"} {
3821 - checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
3925 + ${NS}::checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
3926 pack $cframe.c_$id -in $cframe -side left \
3927 -padx [list $lxpad 0] -expand $cexpand -anchor w
3928 } elseif {[regexp {^t(\d+)$} $type type sz]} {
3825 - message $cframe.l_$id -aspect 1500 -text $title
3826 - entry $cframe.e_$id -width $sz -background $bgcolor \
3929 + ${NS}::label $cframe.l_$id -text $title
3930 + ${NS}::entry $cframe.e_$id -width $sz -background $bgcolor \
3931 -textvariable newviewopts($n,$id)
3932 pack $cframe.l_$id -in $cframe -side left -padx [list $lxpad 0]
3933 pack $cframe.e_$id -in $cframe -side left -expand 1 -fill x
3934 } elseif {[regexp {^t(\d+)=$} $type type sz]} {
3831 - message $cframe.l_$id -aspect 1500 -text $title
3832 - entry $cframe.e_$id -width $sz -background $bgcolor \
3935 + ${NS}::label $cframe.l_$id -text $title
3936 + ${NS}::entry $cframe.e_$id -width $sz -background $bgcolor \
3937 -textvariable newviewopts($n,$id)
3938 pack $cframe.l_$id -in $cframe -side top -pady [list 3 0] -anchor w
3939 pack $cframe.e_$id -in $cframe -side top -fill x
@@ -3837,7 +3941,7 @@ proc vieweditor {top n title} {
3941 }
3942
3943 # Path list
3840 - message $top.l -aspect 1500 \
3944 + ${NS}::label $top.l \
3945 -text [mc "Enter files and directories to include, one per line:"]
3946 pack $top.l -in $top -side top -pady [list 7 0] -anchor w -padx 3
3947 text $top.t -width 40 -height 5 -background $bgcolor -font uifont
@@ -3850,10 +3954,10 @@ proc vieweditor {top n title} {
3954 $top.t mark set insert 0.0
3955 }
3956 pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3
3853 - frame $top.buts
3854 - button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
3855 - button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]
3856 - button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
3957 + ${NS}::frame $top.buts
3958 + ${NS}::button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
3959 + ${NS}::button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]
3960 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
3961 bind $top <Control-Return> [list newviewok $top $n]
3962 bind $top <F5> [list newviewok $top $n 1]
3963 bind $top <Escape> [list destroy $top]
@@ -6723,8 +6827,7 @@ proc selectline {l isnew {desired_loc {}}} {
6827 $sha1entry delete 0 end
6828 $sha1entry insert 0 $id
6829 if {$autoselect} {
6726 - $sha1entry selection from 0
6727 - $sha1entry selection to end
6830 + $sha1entry selection range 0 end
6831 }
6832 rhighlight_sel $id
6833
@@ -8332,7 +8435,7 @@ proc doseldiff {oldid newid} {
8435 }
8436
8437 proc mkpatch {} {
8335 - global rowmenuid currentid commitinfo patchtop patchnum
8438 + global rowmenuid currentid commitinfo patchtop patchnum NS
8439
8440 if {![info exists currentid]} return
8441 set oldid $currentid
@@ -8342,38 +8445,38 @@ proc mkpatch {} {
8445 set top .patch
8446 set patchtop $top
8447 catch {destroy $top}
8345 - toplevel $top
8448 + ttk_toplevel $top
8449 make_transient $top .
8347 - label $top.title -text [mc "Generate patch"]
8450 + ${NS}::label $top.title -text [mc "Generate patch"]
8451 grid $top.title - -pady 10
8349 - label $top.from -text [mc "From:"]
8350 - entry $top.fromsha1 -width 40 -relief flat
8452 + ${NS}::label $top.from -text [mc "From:"]
8453 + ${NS}::entry $top.fromsha1 -width 40
8454 $top.fromsha1 insert 0 $oldid
8455 $top.fromsha1 conf -state readonly
8456 grid $top.from $top.fromsha1 -sticky w
8354 - entry $top.fromhead -width 60 -relief flat
8457 + ${NS}::entry $top.fromhead -width 60
8458 $top.fromhead insert 0 $oldhead
8459 $top.fromhead conf -state readonly
8460 grid x $top.fromhead -sticky w
8358 - label $top.to -text [mc "To:"]
8359 - entry $top.tosha1 -width 40 -relief flat
8461 + ${NS}::label $top.to -text [mc "To:"]
8462 + ${NS}::entry $top.tosha1 -width 40
8463 $top.tosha1 insert 0 $newid
8464 $top.tosha1 conf -state readonly
8465 grid $top.to $top.tosha1 -sticky w
8363 - entry $top.tohead -width 60 -relief flat
8466 + ${NS}::entry $top.tohead -width 60
8467 $top.tohead insert 0 $newhead
8468 $top.tohead conf -state readonly
8469 grid x $top.tohead -sticky w
8367 - button $top.rev -text [mc "Reverse"] -command mkpatchrev -padx 5
8368 - grid $top.rev x -pady 10
8369 - label $top.flab -text [mc "Output file:"]
8370 - entry $top.fname -width 60
8470 + ${NS}::button $top.rev -text [mc "Reverse"] -command mkpatchrev
8471 + grid $top.rev x -pady 10 -padx 5
8472 + ${NS}::label $top.flab -text [mc "Output file:"]
8473 + ${NS}::entry $top.fname -width 60
8474 $top.fname insert 0 [file normalize "patch$patchnum.patch"]
8475 incr patchnum
8476 grid $top.flab $top.fname -sticky w
8374 - frame $top.buts
8375 - button $top.buts.gen -text [mc "Generate"] -command mkpatchgo
8376 - button $top.buts.can -text [mc "Cancel"] -command mkpatchcan
8477 + ${NS}::frame $top.buts
8478 + ${NS}::button $top.buts.gen -text [mc "Generate"] -command mkpatchgo
8479 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command mkpatchcan
8480 bind $top <Key-Return> mkpatchgo
8481 bind $top <Key-Escape> mkpatchcan
8482 grid $top.buts.gen $top.buts.can
@@ -8424,30 +8527,30 @@ proc mkpatchcan {} {
8527 }
8528
8529 proc mktag {} {
8427 - global rowmenuid mktagtop commitinfo
8530 + global rowmenuid mktagtop commitinfo NS
8531
8532 set top .maketag
8533 set mktagtop $top
8534 catch {destroy $top}
8432 - toplevel $top
8535 + ttk_toplevel $top
8536 make_transient $top .
8434 - label $top.title -text [mc "Create tag"]
8537 + ${NS}::label $top.title -text [mc "Create tag"]
8538 grid $top.title - -pady 10
8436 - label $top.id -text [mc "ID:"]
8437 - entry $top.sha1 -width 40 -relief flat
8539 + ${NS}::label $top.id -text [mc "ID:"]
8540 + ${NS}::entry $top.sha1 -width 40
8541 $top.sha1 insert 0 $rowmenuid
8542 $top.sha1 conf -state readonly
8543 grid $top.id $top.sha1 -sticky w
8441 - entry $top.head -width 60 -relief flat
8544 + ${NS}::entry $top.head -width 60
8545 $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
8546 $top.head conf -state readonly
8547 grid x $top.head -sticky w
8445 - label $top.tlab -text [mc "Tag name:"]
8446 - entry $top.tag -width 60
8548 + ${NS}::label $top.tlab -text [mc "Tag name:"]
8549 + ${NS}::entry $top.tag -width 60
8550 grid $top.tlab $top.tag -sticky w
8448 - frame $top.buts
8449 - button $top.buts.gen -text [mc "Create"] -command mktaggo
8450 - button $top.buts.can -text [mc "Cancel"] -command mktagcan
8551 + ${NS}::frame $top.buts
8552 + ${NS}::button $top.buts.gen -text [mc "Create"] -command mktaggo
8553 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command mktagcan
8554 bind $top <Key-Return> mktaggo
8555 bind $top <Key-Escape> mktagcan
8556 grid $top.buts.gen $top.buts.can
@@ -8530,34 +8633,34 @@ proc mktaggo {} {
8633 }
8634
8635 proc writecommit {} {
8533 - global rowmenuid wrcomtop commitinfo wrcomcmd
8636 + global rowmenuid wrcomtop commitinfo wrcomcmd NS
8637
8638 set top .writecommit
8639 set wrcomtop $top
8640 catch {destroy $top}
8538 - toplevel $top
8641 + ttk_toplevel $top
8642 make_transient $top .
8540 - label $top.title -text [mc "Write commit to file"]
8643 + ${NS}::label $top.title -text [mc "Write commit to file"]
8644 grid $top.title - -pady 10
8542 - label $top.id -text [mc "ID:"]
8543 - entry $top.sha1 -width 40 -relief flat
8645 + ${NS}::label $top.id -text [mc "ID:"]
8646 + ${NS}::entry $top.sha1 -width 40
8647 $top.sha1 insert 0 $rowmenuid
8648 $top.sha1 conf -state readonly
8649 grid $top.id $top.sha1 -sticky w
8547 - entry $top.head -width 60 -relief flat
8650 + ${NS}::entry $top.head -width 60
8651 $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
8652 $top.head conf -state readonly
8653 grid x $top.head -sticky w
8551 - label $top.clab -text [mc "Command:"]
8552 - entry $top.cmd -width 60 -textvariable wrcomcmd
8654 + ${NS}::label $top.clab -text [mc "Command:"]
8655 + ${NS}::entry $top.cmd -width 60 -textvariable wrcomcmd
8656 grid $top.clab $top.cmd -sticky w -pady 10
8554 - label $top.flab -text [mc "Output file:"]
8555 - entry $top.fname -width 60
8657 + ${NS}::label $top.flab -text [mc "Output file:"]
8658 + ${NS}::entry $top.fname -width 60
8659 $top.fname insert 0 [file normalize "commit-[string range $rowmenuid 0 6]"]
8660 grid $top.flab $top.fname -sticky w
8558 - frame $top.buts
8559 - button $top.buts.gen -text [mc "Write"] -command wrcomgo
8560 - button $top.buts.can -text [mc "Cancel"] -command wrcomcan
8661 + ${NS}::frame $top.buts
8662 + ${NS}::button $top.buts.gen -text [mc "Write"] -command wrcomgo
8663 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command wrcomcan
8664 bind $top <Key-Return> wrcomgo
8665 bind $top <Key-Escape> wrcomcan
8666 grid $top.buts.gen $top.buts.can
@@ -8588,25 +8691,25 @@ proc wrcomcan {} {
8691 }
8692
8693 proc mkbranch {} {
8591 - global rowmenuid mkbrtop
8694 + global rowmenuid mkbrtop NS
8695
8696 set top .makebranch
8697 catch {destroy $top}
8595 - toplevel $top
8698 + ttk_toplevel $top
8699 make_transient $top .
8597 - label $top.title -text [mc "Create new branch"]
8700 + ${NS}::label $top.title -text [mc "Create new branch"]
8701 grid $top.title - -pady 10
8599 - label $top.id -text [mc "ID:"]
8600 - entry $top.sha1 -width 40 -relief flat
8702 + ${NS}::label $top.id -text [mc "ID:"]
8703 + ${NS}::entry $top.sha1 -width 40
8704 $top.sha1 insert 0 $rowmenuid
8705 $top.sha1 conf -state readonly
8706 grid $top.id $top.sha1 -sticky w
8604 - label $top.nlab -text [mc "Name:"]
8605 - entry $top.name -width 40
8707 + ${NS}::label $top.nlab -text [mc "Name:"]
8708 + ${NS}::entry $top.name -width 40
8709 grid $top.nlab $top.name -sticky w
8607 - frame $top.buts
8608 - button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
8609 - button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
8710 + ${NS}::frame $top.buts
8711 + ${NS}::button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
8712 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
8713 bind $top <Key-Return> [list mkbrgo $top]
8714 bind $top <Key-Escape> "catch {destroy $top}"
8715 grid $top.buts.go $top.buts.can
@@ -8751,34 +8854,31 @@ proc cherrypick {} {
8854 }
8855
8856 proc resethead {} {
8754 - global mainhead rowmenuid confirm_ok resettype
8857 + global mainhead rowmenuid confirm_ok resettype NS
8858
8859 set confirm_ok 0
8860 set w ".confirmreset"
8758 - toplevel $w
8861 + ttk_toplevel $w
8862 make_transient $w .
8863 wm title $w [mc "Confirm reset"]
8761 - message $w.m -text \
8762 - [mc "Reset branch %s to %s?" $mainhead [string range $rowmenuid 0 7]] \
8763 - -justify center -aspect 1000
8864 + ${NS}::label $w.m -text \
8865 + [mc "Reset branch %s to %s?" $mainhead [string range $rowmenuid 0 7]]
8866 pack $w.m -side top -fill x -padx 20 -pady 20
8765 - frame $w.f -relief sunken -border 2
8766 - message $w.f.rt -text [mc "Reset type:"] -aspect 1000
8767 - grid $w.f.rt -sticky w
8867 + ${NS}::labelframe $w.f -text [mc "Reset type:"]
8868 set resettype mixed
8769 - radiobutton $w.f.soft -value soft -variable resettype -justify left \
8869 + ${NS}::radiobutton $w.f.soft -value soft -variable resettype \
8870 -text [mc "Soft: Leave working tree and index untouched"]
8871 grid $w.f.soft -sticky w
8772 - radiobutton $w.f.mixed -value mixed -variable resettype -justify left \
8872 + ${NS}::radiobutton $w.f.mixed -value mixed -variable resettype \
8873 -text [mc "Mixed: Leave working tree untouched, reset index"]
8874 grid $w.f.mixed -sticky w
8775 - radiobutton $w.f.hard -value hard -variable resettype -justify left \
8875 + ${NS}::radiobutton $w.f.hard -value hard -variable resettype \
8876 -text [mc "Hard: Reset working tree and index\n(discard ALL local changes)"]
8877 grid $w.f.hard -sticky w
8778 - pack $w.f -side top -fill x
8779 - button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
8878 + pack $w.f -side top -fill x -padx 4
8879 + ${NS}::button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
8880 pack $w.ok -side left -fill x -padx 20 -pady 20
8781 - button $w.cancel -text [mc Cancel] -command "destroy $w"
8881 + ${NS}::button $w.cancel -text [mc Cancel] -command "destroy $w"
8882 bind $w <Key-Escape> [list destroy $w]
8883 pack $w.cancel -side right -fill x -padx 20 -pady 20
8884 bind $w <Visibility> "grab $w; focus $w"
@@ -8926,7 +9026,7 @@ proc rmbranch {} {
9026
9027 # Display a list of tags and heads
9028 proc showrefs {} {
8929 - global showrefstop bgcolor fgcolor selectbgcolor
9029 + global showrefstop bgcolor fgcolor selectbgcolor NS
9030 global bglist fglist reflistfilter reflist maincursor
9031
9032 set top .showrefs
@@ -8936,7 +9036,7 @@ proc showrefs {} {
9036 refill_reflist
9037 return
9038 }
8939 - toplevel $top
9039 + ttk_toplevel $top
9040 wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
9041 make_transient $top .
9042 text $top.list -background $bgcolor -foreground $fgcolor \
@@ -8947,19 +9047,19 @@ proc showrefs {} {
9047 $top.list tag configure highlight -background $selectbgcolor
9048 lappend bglist $top.list
9049 lappend fglist $top.list
8950 - scrollbar $top.ysb -command "$top.list yview" -orient vertical
8951 - scrollbar $top.xsb -command "$top.list xview" -orient horizontal
9050 + ${NS}::scrollbar $top.ysb -command "$top.list yview" -orient vertical
9051 + ${NS}::scrollbar $top.xsb -command "$top.list xview" -orient horizontal
9052 grid $top.list $top.ysb -sticky nsew
9053 grid $top.xsb x -sticky ew
8954 - frame $top.f
8955 - label $top.f.l -text "[mc "Filter"]: "
8956 - entry $top.f.e -width 20 -textvariable reflistfilter
9054 + ${NS}::frame $top.f
9055 + ${NS}::label $top.f.l -text "[mc "Filter"]: "
9056 + ${NS}::entry $top.f.e -width 20 -textvariable reflistfilter
9057 set reflistfilter "*"
9058 trace add variable reflistfilter write reflistfilter_change
9059 pack $top.f.e -side right -fill x -expand 1
9060 pack $top.f.l -side left
9061 grid $top.f - -sticky ew -pady 2
8962 - button $top.close -command [list destroy $top] -text [mc "Close"]
9062 + ${NS}::button $top.close -command [list destroy $top] -text [mc "Close"]
9063 bind $top <Key-Escape> [list destroy $top]
9064 grid $top.close -
9065 grid columnconfigure $top 0 -weight 1
@@ -9157,7 +9257,7 @@ proc getallclines {fd} {
9257 global allparents allchildren idtags idheads nextarc
9258 global arcnos arcids arctags arcout arcend arcstart archeads growing
9259 global seeds allcommits cachedarcs allcupdate
9160 -
9260 +
9261 set nid 0
9262 while {[incr nid] <= 1000 && [gets $fd line] >= 0} {
9263 set id [lindex $line 0]
@@ -10255,19 +10355,20 @@ proc doquit {} {
10355 }
10356
10357 proc mkfontdisp {font top which} {
10258 - global fontattr fontpref $font
10358 + global fontattr fontpref $font NS use_ttk
10359
10360 set fontpref($font) [set $font]
10261 - button $top.${font}but -text $which -font optionfont \
10361 + ${NS}::button $top.${font}but -text $which \
10362 -command [list choosefont $font $which]
10263 - label $top.$font -relief flat -font $font \
10363 + if {!$use_ttk} {$top.${font}but configure -font optionfont}
10364 + ${NS}::label $top.$font -relief flat -font $font \
10365 -text $fontattr($font,family) -justify left
10366 grid x $top.${font}but $top.$font -sticky w
10367 }
10368
10369 proc choosefont {font which} {
10370 global fontparam fontlist fonttop fontattr
10270 - global prefstop
10371 + global prefstop NS
10372
10373 set fontparam(which) $which
10374 set fontparam(font) $font
@@ -10280,21 +10381,21 @@ proc choosefont {font which} {
10381 if {![winfo exists $top]} {
10382 font create sample
10383 eval font config sample [font actual $font]
10283 - toplevel $top
10384 + ttk_toplevel $top
10385 make_transient $top $prefstop
10386 wm title $top [mc "Gitk font chooser"]
10286 - label $top.l -textvariable fontparam(which)
10387 + ${NS}::label $top.l -textvariable fontparam(which)
10388 pack $top.l -side top
10389 set fontlist [lsort [font families]]
10289 - frame $top.f
10390 + ${NS}::frame $top.f
10391 listbox $top.f.fam -listvariable fontlist \
10392 -yscrollcommand [list $top.f.sb set]
10393 bind $top.f.fam <<ListboxSelect>> selfontfam
10293 - scrollbar $top.f.sb -command [list $top.f.fam yview]
10394 + ${NS}::scrollbar $top.f.sb -command [list $top.f.fam yview]
10395 pack $top.f.sb -side right -fill y
10396 pack $top.f.fam -side left -fill both -expand 1
10397 pack $top.f -side top -fill both -expand 1
10297 - frame $top.g
10398 + ${NS}::frame $top.g
10399 spinbox $top.g.size -from 4 -to 40 -width 4 \
10400 -textvariable fontparam(size) \
10401 -validatecommand {string is integer -strict %s}
@@ -10312,9 +10413,9 @@ proc choosefont {font which} {
10413 -fill black -tags text
10414 bind $top.c <Configure> [list centertext $top.c]
10415 pack $top.c -side top -fill x
10315 - frame $top.buts
10316 - button $top.buts.ok -text [mc "OK"] -command fontok -default active
10317 - button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal
10416 + ${NS}::frame $top.buts
10417 + ${NS}::button $top.buts.ok -text [mc "OK"] -command fontok -default active
10418 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal
10419 bind $top <Key-Return> fontok
10420 bind $top <Key-Escape> fontcan
10421 grid $top.buts.ok $top.buts.can
@@ -10350,7 +10451,7 @@ proc fontok {} {
10451 }
10452 set w $prefstop.$f
10453 $w conf -text $fontparam(family) -font $fontpref($f)
10353 -
10454 +
10455 fontcan
10456 }
10457
@@ -10365,6 +10466,28 @@ proc fontcan {} {
10466 }
10467 }
10468
10469 +if {[package vsatisfies [package provide Tk] 8.6]} {
10470 + # In Tk 8.6 we have a native font chooser dialog. Overwrite the above
10471 + # function to make use of it.
10472 + proc choosefont {font which} {
10473 + tk fontchooser configure -title $which -font $font \
10474 + -command [list on_choosefont $font $which]
10475 + tk fontchooser show
10476 + }
10477 + proc on_choosefont {font which newfont} {
10478 + global fontparam
10479 + puts stderr "$font $newfont"
10480 + array set f [font actual $newfont]
10481 + set fontparam(which) $which
10482 + set fontparam(font) $font
10483 + set fontparam(family) $f(-family)
10484 + set fontparam(size) $f(-size)
10485 + set fontparam(weight) $f(-weight)
10486 + set fontparam(slant) $f(-slant)
10487 + fontok
10488 + }
10489 +}
10490 +
10491 proc selfontfam {} {
10492 global fonttop fontparam
10493
@@ -10381,7 +10504,7 @@ proc chg_fontparam {v sub op} {
10504 }
10505
10506 proc doprefs {} {
10384 - global maxwidth maxgraphpct
10507 + global maxwidth maxgraphpct use_ttk NS
10508 global oldprefs prefstop showneartags showlocalchanges
10509 global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
10510 global tabstop limitdiffs autoselect extdifftool perfile_attrs
@@ -10396,103 +10519,109 @@ proc doprefs {} {
10519 limitdiffs tabstop perfile_attrs} {
10520 set oldprefs($v) [set $v]
10521 }
10399 - toplevel $top
10522 + ttk_toplevel $top
10523 wm title $top [mc "Gitk preferences"]
10524 make_transient $top .
10402 - label $top.ldisp -text [mc "Commit list display options"]
10525 + ${NS}::label $top.ldisp -text [mc "Commit list display options"]
10526 grid $top.ldisp - -sticky w -pady 10
10404 - label $top.spacer -text " "
10405 - label $top.maxwidthl -text [mc "Maximum graph width (lines)"] \
10406 - -font optionfont
10527 + ${NS}::label $top.spacer -text " "
10528 + ${NS}::label $top.maxwidthl -text [mc "Maximum graph width (lines)"]
10529 spinbox $top.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth
10530 grid $top.spacer $top.maxwidthl $top.maxwidth -sticky w
10409 - label $top.maxpctl -text [mc "Maximum graph width (% of pane)"] \
10410 - -font optionfont
10531 + ${NS}::label $top.maxpctl -text [mc "Maximum graph width (% of pane)"]
10532 spinbox $top.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
10533 grid x $top.maxpctl $top.maxpct -sticky w
10413 - checkbutton $top.showlocal -text [mc "Show local changes"] \
10414 - -font optionfont -variable showlocalchanges
10534 + ${NS}::checkbutton $top.showlocal -text [mc "Show local changes"] \
10535 + -variable showlocalchanges
10536 grid x $top.showlocal -sticky w
10416 - checkbutton $top.autoselect -text [mc "Auto-select SHA1"] \
10417 - -font optionfont -variable autoselect
10537 + ${NS}::checkbutton $top.autoselect -text [mc "Auto-select SHA1"] \
10538 + -variable autoselect
10539 grid x $top.autoselect -sticky w
10540
10420 - label $top.ddisp -text [mc "Diff display options"]
10541 + ${NS}::label $top.ddisp -text [mc "Diff display options"]
10542 grid $top.ddisp - -sticky w -pady 10
10422 - label $top.tabstopl -text [mc "Tab spacing"] -font optionfont
10543 + ${NS}::label $top.tabstopl -text [mc "Tab spacing"]
10544 spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
10545 grid x $top.tabstopl $top.tabstop -sticky w
10425 - checkbutton $top.ntag -text [mc "Display nearby tags"] \
10426 - -font optionfont -variable showneartags
10546 + ${NS}::checkbutton $top.ntag -text [mc "Display nearby tags"] \
10547 + -variable showneartags
10548 grid x $top.ntag -sticky w
10428 - checkbutton $top.ldiff -text [mc "Limit diffs to listed paths"] \
10429 - -font optionfont -variable limitdiffs
10549 + ${NS}::checkbutton $top.ldiff -text [mc "Limit diffs to listed paths"] \
10550 + -variable limitdiffs
10551 grid x $top.ldiff -sticky w
10431 - checkbutton $top.lattr -text [mc "Support per-file encodings"] \
10432 - -font optionfont -variable perfile_attrs
10552 + ${NS}::checkbutton $top.lattr -text [mc "Support per-file encodings"] \
10553 + -variable perfile_attrs
10554 grid x $top.lattr -sticky w
10555
10435 - entry $top.extdifft -textvariable extdifftool
10436 - frame $top.extdifff
10437 - label $top.extdifff.l -text [mc "External diff tool" ] -font optionfont \
10438 - -padx 10
10439 - button $top.extdifff.b -text [mc "Choose..."] -font optionfont \
10440 - -command choose_extdiff
10556 + ${NS}::entry $top.extdifft -textvariable extdifftool
10557 + ${NS}::frame $top.extdifff
10558 + ${NS}::label $top.extdifff.l -text [mc "External diff tool" ]
10559 + ${NS}::button $top.extdifff.b -text [mc "Choose..."] -command choose_extdiff
10560 pack $top.extdifff.l $top.extdifff.b -side left
10442 - grid x $top.extdifff $top.extdifft -sticky w
10561 + pack configure $top.extdifff.l -padx 10
10562 + grid x $top.extdifff $top.extdifft -sticky ew
10563
10444 - label $top.cdisp -text [mc "Colors: press to choose"]
10564 + ${NS}::label $top.cdisp -text [mc "Colors: press to choose"]
10565 grid $top.cdisp - -sticky w -pady 10
10566 label $top.bg -padx 40 -relief sunk -background $bgcolor
10447 - button $top.bgbut -text [mc "Background"] -font optionfont \
10567 + ${NS}::button $top.bgbut -text [mc "Background"] \
10568 -command [list choosecolor bgcolor {} $top.bg [mc "background"] setbg]
10569 grid x $top.bgbut $top.bg -sticky w
10570 label $top.fg -padx 40 -relief sunk -background $fgcolor
10451 - button $top.fgbut -text [mc "Foreground"] -font optionfont \
10571 + ${NS}::button $top.fgbut -text [mc "Foreground"] \
10572 -command [list choosecolor fgcolor {} $top.fg [mc "foreground"] setfg]
10573 grid x $top.fgbut $top.fg -sticky w
10574 label $top.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
10455 - button $top.diffoldbut -text [mc "Diff: old lines"] -font optionfont \
10575 + ${NS}::button $top.diffoldbut -text [mc "Diff: old lines"] \
10576 -command [list choosecolor diffcolors 0 $top.diffold [mc "diff old lines"] \
10577 [list $ctext tag conf d0 -foreground]]
10578 grid x $top.diffoldbut $top.diffold -sticky w
10579 label $top.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
10460 - button $top.diffnewbut -text [mc "Diff: new lines"] -font optionfont \
10580 + ${NS}::button $top.diffnewbut -text [mc "Diff: new lines"] \
10581 -command [list choosecolor diffcolors 1 $top.diffnew [mc "diff new lines"] \
10582 [list $ctext tag conf dresult -foreground]]
10583 grid x $top.diffnewbut $top.diffnew -sticky w
10584 label $top.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
10465 - button $top.hunksepbut -text [mc "Diff: hunk header"] -font optionfont \
10585 + ${NS}::button $top.hunksepbut -text [mc "Diff: hunk header"] \
10586 -command [list choosecolor diffcolors 2 $top.hunksep \
10587 [mc "diff hunk header"] \
10588 [list $ctext tag conf hunksep -foreground]]
10589 grid x $top.hunksepbut $top.hunksep -sticky w
10590 label $top.markbgsep -padx 40 -relief sunk -background $markbgcolor
10471 - button $top.markbgbut -text [mc "Marked line bg"] -font optionfont \
10591 + ${NS}::button $top.markbgbut -text [mc "Marked line bg"] \
10592 -command [list choosecolor markbgcolor {} $top.markbgsep \
10593 [mc "marked line background"] \
10594 [list $ctext tag conf omark -background]]
10595 grid x $top.markbgbut $top.markbgsep -sticky w
10596 label $top.selbgsep -padx 40 -relief sunk -background $selectbgcolor
10477 - button $top.selbgbut -text [mc "Select bg"] -font optionfont \
10597 + ${NS}::button $top.selbgbut -text [mc "Select bg"] \
10598 -command [list choosecolor selectbgcolor {} $top.selbgsep [mc "background"] setselbg]
10599 grid x $top.selbgbut $top.selbgsep -sticky w
10600
10481 - label $top.cfont -text [mc "Fonts: press to choose"]
10601 + ${NS}::label $top.cfont -text [mc "Fonts: press to choose"]
10602 grid $top.cfont - -sticky w -pady 10
10603 mkfontdisp mainfont $top [mc "Main font"]
10604 mkfontdisp textfont $top [mc "Diff display font"]
10605 mkfontdisp uifont $top [mc "User interface font"]
10606
10487 - frame $top.buts
10488 - button $top.buts.ok -text [mc "OK"] -command prefsok -default active
10489 - button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
10607 + if {!$use_ttk} {
10608 + foreach w {maxpctl maxwidthl showlocal autoselect tabstopl ntag
10609 + ldiff lattr extdifff.l extdifff.b bgbut fgbut
10610 + diffoldbut diffnewbut hunksepbut markbgbut selbgbut} {
10611 + $top.$w configure -font optionfont
10612 + }
10613 + }
10614 +
10615 + ${NS}::frame $top.buts
10616 + ${NS}::button $top.buts.ok -text [mc "OK"] -command prefsok -default active
10617 + ${NS}::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
10618 bind $top <Key-Return> prefsok
10619 bind $top <Key-Escape> prefscan
10620 grid $top.buts.ok $top.buts.can
10621 grid columnconfigure $top.buts 0 -weight 1 -uniform a
10622 grid columnconfigure $top.buts 1 -weight 1 -uniform a
10623 grid $top.buts - - -pady 10 -sticky ew
10624 + grid columnconfigure $top 2 -weight 1
10625 bind $top <Visibility> "focus $top.buts.ok"
10626 }
10627
@@ -11156,6 +11285,10 @@ set nullid2 "0000000000000000000000000000000000000001"
11285 set nullfile "/dev/null"
11286
11287 set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
11288 +if {![info exists use_ttk]} {
11289 + set use_ttk [llength [info commands ::ttk::style]]
11290 +}
11291 +set NS [expr {$use_ttk ? "ttk" : ""}]
11292
11293 set runq {}
11294 set history {}