gitk: remove non-ttk support code

gitk has code and variables to use the earlier non-themed widget set, but this code is now irrelevant as gitk now always uses ttk. Clean this up. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>

Mark Levedahl committed Jun 8, 2025 at 08:53 UTC 51bb2ab69feeee88815be0a118e1950eae70c441
1 file changed +60 -187
gitk
+60 -187
@@ -2089,11 +2089,8 @@ proc removehead {id name} {
2089 }
2090
2091 proc ttk_toplevel {w args} {
2092 - global use_ttk
2092 eval [linsert $args 0 ::toplevel $w]
2094 - if {$use_ttk} {
2095 - place [ttk::frame $w._toplevel_background] -x 0 -y 0 -relwidth 1 -relheight 1
2096 - }
2093 + place [ttk::frame $w._toplevel_background] -x 0 -y 0 -relwidth 1 -relheight 1
2094 return $w
2095 }
2096
@@ -2108,8 +2105,6 @@ proc make_transient {window origin} {
2105 }
2106
2107 proc show_error {w top msg} {
2111 - global NS
2112 - if {![info exists NS]} {set NS ""}
2108 if {[wm state $top] eq "withdrawn"} { wm deiconify $top }
2109 message $w.m -text $msg -justify center -aspect 400
2110 pack $w.m -side top -fill x -padx 20 -pady 20
@@ -2135,7 +2130,7 @@ proc error_popup {msg {owner .}} {
2130 }
2131
2132 proc confirm_popup {msg {owner .}} {
2138 - global confirm_ok NS
2133 + global confirm_ok
2134 set confirm_ok 0
2135 set w .confirm
2136 ttk_toplevel $w
@@ -2160,8 +2155,6 @@ proc haveselectionclipboard {} {
2155 }
2156
2157 proc setoptions {} {
2163 - global use_ttk
2164 -
2158 if {[tk windowingsystem] ne "win32"} {
2159 option add *Panedwindow.showHandle 1 startupFile
2160 option add *Panedwindow.sashRelief raised startupFile
@@ -2254,20 +2247,15 @@ proc cleardropsel {w} {
2247 $w selection clear
2248 }
2249 proc makedroplist {w varname args} {
2257 - global use_ttk
2258 - if {$use_ttk} {
2259 - set width 0
2260 - foreach label $args {
2261 - set cx [string length $label]
2262 - if {$cx > $width} {set width $cx}
2263 - }
2264 - set gm [ttk::combobox $w -width $width -state readonly\
2265 - -textvariable $varname -values $args \
2266 - -exportselection false]
2267 - bind $gm <<ComboboxSelected>> [list $gm selection clear]
2268 - } else {
2269 - set gm [eval [linsert $args 0 tk_optionMenu $w $varname]]
2270 - }
2250 + set width 0
2251 + foreach label $args {
2252 + set cx [string length $label]
2253 + if {$cx > $width} {set width $cx}
2254 + }
2255 + set gm [ttk::combobox $w -width $width -state readonly\
2256 + -textvariable $varname -values $args \
2257 + -exportselection false]
2258 + bind $gm <<ComboboxSelected>> [list $gm selection clear]
2259 return $gm
2260 }
2261
@@ -2289,7 +2277,6 @@ proc makewindow {} {
2277 global headctxmenu progresscanv progressitem progresscoords statusw
2278 global fprogitem fprogcoord lastprogupdate progupdatepending
2279 global rprogitem rprogcoord rownumsel numcommits
2292 - global use_ttk NS
2280 global worddiff
2281
2282 # The "mc" arguments here are purely so that xgettext
@@ -2342,10 +2329,8 @@ proc makewindow {} {
2329 makemenu .bar $bar
2330 . configure -menu .bar
2331
2345 - if {$use_ttk} {
2346 - # cover the non-themed toplevel with a themed frame.
2347 - place [ttk::frame ._main_background] -x 0 -y 0 -relwidth 1 -relheight 1
2348 - }
2332 + # cover the non-themed toplevel with a themed frame.
2333 + place [ttk::frame ._main_background] -x 0 -y 0 -relwidth 1 -relheight 1
2334
2335 # the gui has upper and lower half, parts of a paned window.
2336 ttk::panedwindow .ctop -orient vertical
@@ -2364,9 +2349,6 @@ proc makewindow {} {
2349 ttk::frame .tf -height $geometry(topheight) -width $geometry(topwidth)
2350 ttk::frame .tf.histframe
2351 ttk::panedwindow .tf.histframe.pwclist -orient horizontal
2367 - if {!$use_ttk} {
2368 - .tf.histframe.pwclist configure -sashpad 0 -handlesize 4
2369 - }
2352
2353 # create three canvases
2354 set cscroll .tf.histframe.csb
@@ -2386,20 +2368,14 @@ proc makewindow {} {
2368 -selectbackground $selectbgcolor \
2369 -background $bgcolor -bd 0 -yscrollincr $linespc
2370 .tf.histframe.pwclist add $canv3
2389 - if {$use_ttk} {
2390 - bind .tf.histframe.pwclist <Map> {
2391 - bind %W <Map> {}
2392 - .tf.histframe.pwclist sashpos 1 [lindex $::geometry(pwsash1) 0]
2393 - .tf.histframe.pwclist sashpos 0 [lindex $::geometry(pwsash0) 0]
2394 - }
2395 - } else {
2396 - eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
2397 - eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
2371 + bind .tf.histframe.pwclist <Map> {
2372 + bind %W <Map> {}
2373 + .tf.histframe.pwclist sashpos 1 [lindex $::geometry(pwsash1) 0]
2374 + .tf.histframe.pwclist sashpos 0 [lindex $::geometry(pwsash0) 0]
2375 }
2376
2377 # a scroll bar to rule them
2378 ttk::scrollbar $cscroll -command {allcanvs yview}
2402 - if {!$use_ttk} {$cscroll configure -highlightthickness 0}
2379 pack $cscroll -side right -fill y
2380 bind .tf.histframe.pwclist <Configure> {resizeclistpanes %W %w}
2381 lappend bglist $canv $canv2 $canv3
@@ -2442,18 +2418,10 @@ proc makewindow {} {
2418 image create bitmap bm-right-gray -data $bm_right_data -foreground $uifgdisabledcolor
2419
2420 ttk::button .tf.bar.leftbut -command goback -state disabled -width 26
2445 - if {$use_ttk} {
2446 - .tf.bar.leftbut configure -image [list bm-left disabled bm-left-gray]
2447 - } else {
2448 - .tf.bar.leftbut configure -image bm-left
2449 - }
2421 + .tf.bar.leftbut configure -image [list bm-left disabled bm-left-gray]
2422 pack .tf.bar.leftbut -side left -fill y
2423 ttk::button .tf.bar.rightbut -command goforw -state disabled -width 26
2452 - if {$use_ttk} {
2453 - .tf.bar.rightbut configure -image [list bm-right disabled bm-right-gray]
2454 - } else {
2455 - .tf.bar.rightbut configure -image bm-right
2456 - }
2424 + .tf.bar.rightbut configure -image [list bm-right disabled bm-right-gray]
2425 pack .tf.bar.rightbut -side left -fill y
2426
2427 ttk::label .tf.bar.rowlabel -text [mc "Row"]
@@ -2465,9 +2433,6 @@ proc makewindow {} {
2433 -relief sunken -anchor e
2434 pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
2435 -side left
2468 - if {!$use_ttk} {
2469 - foreach w {rownum numcommits} {.tf.bar.$w configure -font textfont}
2470 - }
2436 global selectedline
2437 trace add variable selectedline write selectedline_change
2438
@@ -2475,16 +2440,7 @@ proc makewindow {} {
2440 set statusw .tf.bar.status
2441 ttk::label $statusw -width 15 -relief sunken
2442 pack $statusw -side left -padx 5
2478 - if {$use_ttk} {
2479 - set progresscanv [ttk::progressbar .tf.bar.progress]
2480 - } else {
2481 - set h [expr {[font metrics uifont -linespace] + 2}]
2482 - set progresscanv .tf.bar.progress
2483 - canvas $progresscanv -relief sunken -height $h -borderwidth 2
2484 - set progressitem [$progresscanv create rect -1 0 0 $h -fill "#00ff00"]
2485 - set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
2486 - set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
2487 - }
2443 + set progresscanv [ttk::progressbar .tf.bar.progress]
2444 pack $progresscanv -side right -expand 1 -fill x -padx {0 2}
2445 set progresscoords {0 0}
2446 set fprogcoord 0
@@ -2557,10 +2513,6 @@ proc makewindow {} {
2513 pack .tf.bar -in .tf -side bottom -fill x
2514 pack .tf.histframe -fill both -side top -expand 1
2515 .ctop add .tf
2560 - if {!$use_ttk} {
2561 - .ctop paneconfigure .tf -height $geometry(topheight)
2562 - .ctop paneconfigure .tf -width $geometry(topwidth)
2563 - }
2516
2517 # now build up the bottom
2518 ttk::panedwindow .pwbottom -orient horizontal
@@ -2673,9 +2625,6 @@ proc makewindow {} {
2625 $ctext tag lower d0
2626
2627 .pwbottom add .bleft
2676 - if {!$use_ttk} {
2677 - .pwbottom paneconfigure .bleft -width $geometry(botwidth)
2678 - }
2628
2629 # lower right
2630 ttk::frame .bright
@@ -2733,17 +2682,15 @@ proc makewindow {} {
2682 set ::BM "2"
2683 }
2684
2736 - if {$use_ttk} {
2737 - bind .ctop <Map> {
2738 - bind %W <Map> {}
2739 - %W sashpos 0 $::geometry(topheight)
2740 - }
2741 - bind .pwbottom <Map> {
2742 - bind %W <Map> {}
2743 - %W sashpos 0 $::geometry(botwidth)
2744 - }
2745 - bind .pwbottom <Configure> {resizecdetpanes %W %w}
2685 + bind .ctop <Map> {
2686 + bind %W <Map> {}
2687 + %W sashpos 0 $::geometry(topheight)
2688 }
2689 + bind .pwbottom <Map> {
2690 + bind %W <Map> {}
2691 + %W sashpos 0 $::geometry(botwidth)
2692 + }
2693 + bind .pwbottom <Configure> {resizecdetpanes %W %w}
2694
2695 pack .ctop -fill both -expand 1
2696 bindall <1> {selcanvline %W %x %y}
@@ -2990,30 +2937,10 @@ proc click {w} {
2937
2938 # Adjust the progress bar for a change in requested extent or canvas size
2939 proc adjustprogress {} {
2993 - global progresscanv progressitem progresscoords
2994 - global fprogitem fprogcoord lastprogupdate progupdatepending
2995 - global rprogitem rprogcoord use_ttk
2996 -
2997 - if {$use_ttk} {
2998 - $progresscanv configure -value [expr {int($fprogcoord * 100)}]
2999 - return
3000 - }
2940 + global progresscanv
2941 + global fprogcoord
2942
3002 - set w [expr {[winfo width $progresscanv] - 4}]
3003 - set x0 [expr {$w * [lindex $progresscoords 0]}]
3004 - set x1 [expr {$w * [lindex $progresscoords 1]}]
3005 - set h [winfo height $progresscanv]
3006 - $progresscanv coords $progressitem $x0 0 $x1 $h
3007 - $progresscanv coords $fprogitem 0 0 [expr {$w * $fprogcoord}] $h
3008 - $progresscanv coords $rprogitem 0 0 [expr {$w * $rprogcoord}] $h
3009 - set now [clock clicks -milliseconds]
3010 - if {$now >= $lastprogupdate + 100} {
3011 - set progupdatepending 0
3012 - update
3013 - } elseif {!$progupdatepending} {
3014 - set progupdatepending 1
3015 - after [expr {$lastprogupdate + 100 - $now}] doprogupdate
3016 - }
2943 + $progresscanv configure -value [expr {int($fprogcoord * 100)}]
2944 }
2945
2946 proc doprogupdate {} {
@@ -3072,7 +2999,6 @@ proc savestuff {w} {
2999 upvar #0 viewargscmd current_viewargscmd
3000 upvar #0 viewperm current_viewperm
3001 upvar #0 nextviewnum current_nextviewnum
3075 - upvar #0 use_ttk current_use_ttk
3002
3003 if {$stuffsaved} return
3004 if {![winfo viewable .]} return
@@ -3106,13 +3032,8 @@ proc savestuff {w} {
3032 puts $f "set geometry(state) [wm state .]"
3033 puts $f "set geometry(topwidth) [winfo width .tf]"
3034 puts $f "set geometry(topheight) [winfo height .tf]"
3109 - if {$current_use_ttk} {
3110 - puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sashpos 0] 1\""
3111 - puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
3112 - } else {
3113 - puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
3114 - puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
3115 - }
3035 + puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sashpos 0] 1\""
3036 + puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
3037 puts $f "set geometry(botwidth) [winfo width .bleft]"
3038 puts $f "set geometry(botheight) [winfo height .bleft]"
3039
@@ -3158,17 +3079,14 @@ proc savestuff {w} {
3079 }
3080
3081 proc resizeclistpanes {win w} {
3161 - global oldwidth oldsash use_ttk
3082 + global oldwidth oldsash
3083 if {[info exists oldwidth($win)]} {
3084 if {[info exists oldsash($win)]} {
3085 set s0 [lindex $oldsash($win) 0]
3086 set s1 [lindex $oldsash($win) 1]
3166 - } elseif {$use_ttk} {
3087 + } else {
3088 set s0 [$win sashpos 0]
3089 set s1 [$win sashpos 1]
3169 - } else {
3170 - set s0 [$win sash coord 0]
3171 - set s1 [$win sash coord 1]
3090 }
3091 if {$w < 60} {
3092 set sash0 [expr {int($w/2 - 2)}]
@@ -3190,29 +3108,20 @@ proc resizeclistpanes {win w} {
3108 }
3109 }
3110 }
3193 - if {$use_ttk} {
3194 - $win sashpos 0 $sash0
3195 - $win sashpos 1 $sash1
3196 - } else {
3197 - $win sash place 0 $sash0 [lindex $s0 1]
3198 - $win sash place 1 $sash1 [lindex $s1 1]
3199 - set sash0 [list $sash0 [lindex $s0 1]]
3200 - set sash1 [list $sash1 [lindex $s1 1]]
3201 - }
3111 + $win sashpos 0 $sash0
3112 + $win sashpos 1 $sash1
3113 set oldsash($win) [list $sash0 $sash1]
3114 }
3115 set oldwidth($win) $w
3116 }
3117
3118 proc resizecdetpanes {win w} {
3208 - global oldwidth oldsash use_ttk
3119 + global oldwidth oldsash
3120 if {[info exists oldwidth($win)]} {
3121 if {[info exists oldsash($win)]} {
3122 set s0 $oldsash($win)
3212 - } elseif {$use_ttk} {
3213 - set s0 [$win sashpos 0]
3123 } else {
3215 - set s0 [$win sash coord 0]
3124 + set s0 [$win sashpos 0]
3125 }
3126 if {$w < 60} {
3127 set sash0 [expr {int($w*3/4 - 2)}]
@@ -3226,12 +3135,7 @@ proc resizecdetpanes {win w} {
3135 set sash0 [expr {$w - 15}]
3136 }
3137 }
3229 - if {$use_ttk} {
3230 - $win sashpos 0 $sash0
3231 - } else {
3232 - $win sash place 0 $sash0 [lindex $s0 1]
3233 - set sash0 [list $sash0 [lindex $s0 1]]
3234 - }
3138 + $win sashpos 0 $sash0
3139 set oldsash($win) $sash0
3140 }
3141 set oldwidth($win) $w
@@ -3252,7 +3156,7 @@ proc bindall {event action} {
3156 }
3157
3158 proc about {} {
3255 - global bgcolor NS
3159 + global bgcolor
3160 set w .about
3161 if {[winfo exists $w]} {
3162 raise $w
@@ -3278,7 +3182,7 @@ Use and redistribute under the terms of the GNU General Public License"] \
3182 }
3183
3184 proc keys {} {
3281 - global bgcolor NS
3185 + global bgcolor
3186 set w .keys
3187 if {[winfo exists $w]} {
3188 raise $w
@@ -4480,7 +4384,7 @@ proc editview {} {
4384
4385 proc vieweditor {top n title} {
4386 global newviewname newviewopts viewfiles bgcolor
4483 - global known_view_options NS
4387 + global known_view_options
4388
4389 ttk_toplevel $top
4390 wm title $top [concat $title [mc "-- criteria for selecting revisions"]]
@@ -6755,13 +6659,7 @@ proc bindline {t id} {
6659 }
6660
6661 proc graph_pane_width {} {
6758 - global use_ttk
6759 -
6760 - if {$use_ttk} {
6761 - set g [.tf.histframe.pwclist sashpos 0]
6762 - } else {
6763 - set g [.tf.histframe.pwclist sash coord 0]
6764 - }
6662 + set g [.tf.histframe.pwclist sashpos 0]
6663 return [lindex $g 0]
6664 }
6665
@@ -9428,7 +9326,7 @@ proc doseldiff {oldid newid} {
9326 }
9327
9328 proc mkpatch {} {
9431 - global rowmenuid currentid commitinfo patchtop patchnum NS
9329 + global rowmenuid currentid commitinfo patchtop patchnum
9330
9331 if {![info exists currentid]} return
9332 set oldid $currentid
@@ -9517,7 +9415,7 @@ proc mkpatchcan {} {
9415 }
9416
9417 proc mktag {} {
9520 - global rowmenuid mktagtop commitinfo NS
9418 + global rowmenuid mktagtop commitinfo
9419
9420 set top .maketag
9421 set mktagtop $top
@@ -9648,7 +9546,7 @@ proc copyreference {} {
9546 }
9547
9548 proc writecommit {} {
9651 - global rowmenuid wrcomtop commitinfo wrcomcmd NS
9549 + global rowmenuid wrcomtop commitinfo wrcomcmd
9550
9551 set top .writecommit
9552 set wrcomtop $top
@@ -9706,7 +9604,7 @@ proc wrcomcan {} {
9604 }
9605
9606 proc mkbranch {} {
9709 - global NS rowmenuid
9607 + global rowmenuid
9608
9609 set top .branchdialog
9610
@@ -9721,7 +9619,6 @@ proc mkbranch {} {
9619 }
9620
9621 proc mvbranch {} {
9724 - global NS
9622 global headmenuid headmenuhead
9623
9624 set top .branchdialog
@@ -9737,7 +9634,7 @@ proc mvbranch {} {
9634 }
9635
9636 proc branchdia {top valvar uivar} {
9740 - global NS commitinfo
9637 + global commitinfo
9638 upvar $valvar val $uivar ui
9639
9640 catch {destroy $top}
@@ -10008,7 +9905,7 @@ proc revert {} {
9905 }
9906
9907 proc resethead {} {
10011 - global mainhead rowmenuid confirm_ok resettype NS
9908 + global mainhead rowmenuid confirm_ok resettype
9909
9910 set confirm_ok 0
9911 set w ".confirmreset"
@@ -10209,7 +10106,7 @@ proc rmbranch {} {
10106
10107 # Display a list of tags and heads
10108 proc showrefs {} {
10212 - global showrefstop bgcolor fgcolor selectbgcolor NS
10109 + global showrefstop bgcolor fgcolor selectbgcolor
10110 global bglist fglist reflistfilter reflist maincursor
10111
10112 set top .showrefs
@@ -11582,7 +11479,7 @@ proc doquit {} {
11479 }
11480
11481 proc mkfontdisp {font top which} {
11585 - global fontattr fontpref $font NS use_ttk
11482 + global fontattr fontpref $font
11483
11484 set fontpref($font) [set $font]
11485 ttk::button $top.${font}but -text $which \
@@ -11659,17 +11556,10 @@ proc chg_fontparam {v sub op} {
11556
11557 # Create a property sheet tab page
11558 proc create_prefs_page {w} {
11662 - global NS
11663 - set parent [join [lrange [split $w .] 0 end-1] .]
11664 - if {[winfo class $parent] eq "TNotebook"} {
11665 - ttk::frame $w
11666 - } else {
11667 - ttk::labelframe $w
11668 - }
11559 + ttk::frame $w
11560 }
11561
11562 proc prefspage_general {notebook} {
11672 - global NS
11563 global {*}$::config_variables
11564
11565 set page [create_prefs_page $notebook.general]
@@ -11751,7 +11641,7 @@ proc prefspage_general {notebook} {
11641 }
11642
11643 proc prefspage_colors {notebook} {
11754 - global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11644 + global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11645 global diffbgcolors
11646
11647 set page [create_prefs_page $notebook.colors]
@@ -11812,7 +11702,6 @@ proc prefspage_colors {notebook} {
11702 }
11703
11704 proc prefspage_fonts {notebook} {
11815 - global NS
11705 set page [create_prefs_page $notebook.fonts]
11706 ttk::label $page.cfont -text [mc "Fonts: press to choose"] -font mainfontbold
11707 grid $page.cfont - -sticky w -pady 10
@@ -11823,7 +11712,7 @@ proc prefspage_fonts {notebook} {
11712 }
11713
11714 proc doprefs {} {
11826 - global use_ttk NS oldprefs prefstop
11715 + global oldprefs prefstop
11716 global {*}$::config_variables
11717
11718 set top .gitkprefs
@@ -11839,33 +11728,19 @@ proc doprefs {} {
11728 wm title $top [mc "Gitk preferences"]
11729 make_transient $top .
11730
11842 - if {[set use_notebook [expr {$use_ttk && [info command ::ttk::notebook] ne ""}]]} {
11843 - set notebook [ttk::notebook $top.notebook]
11844 - } else {
11845 - set notebook [ttk::frame $top.notebook -borderwidth 0 -relief flat]
11846 - }
11731 + set notebook [ttk::notebook $top.notebook]
11732
11733 lappend pages [prefspage_general $notebook] [mc "General"]
11734 lappend pages [prefspage_colors $notebook] [mc "Colors"]
11735 lappend pages [prefspage_fonts $notebook] [mc "Fonts"]
11736 set col 0
11737 foreach {page title} $pages {
11853 - if {$use_notebook} {
11854 - $notebook add $page -text $title
11855 - } else {
11856 - set btn [ttk::button $notebook.b_[string map {. X} $page] \
11857 - -text $title -command [list raise $page]]
11858 - $page configure -text $title
11859 - grid $btn -row 0 -column [incr col] -sticky w
11860 - grid $page -row 1 -column 0 -sticky news -columnspan 100
11861 - }
11738 + $notebook add $page -text $title
11739 }
11740
11864 - if {!$use_notebook} {
11865 - grid columnconfigure $notebook 0 -weight 1
11866 - grid rowconfigure $notebook 1 -weight 1
11867 - raise [lindex $pages 0]
11868 - }
11741 + grid columnconfigure $notebook 0 -weight 1
11742 + grid rowconfigure $notebook 1 -weight 1
11743 + raise [lindex $pages 0]
11744
11745 grid $notebook -sticky news -padx 2 -pady 2
11746 grid rowconfigure $top 0 -weight 1
@@ -12739,8 +12614,6 @@ set nullid2 "0000000000000000000000000000000000000001"
12614 set nullfile "/dev/null"
12615
12616 setttkstyle
12742 -set use_ttk 1
12743 -set NS ttk
12617 set appname "gitk"
12618
12619 set runq {}