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

gitk: Integrate the reset progress bar in the main frame

This makes the reset function use a progress bar in the same location as the progress bars for reading in commits and for finding commits, instead of a progress bar in a separate detached window. The progress bar for resetting is red. This also puts "Resetting" in the status window while the reset is in progress. The setting of the status window is done through an extension of the interface used for setting the watch cursor. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Oct 23, 2007 at 21:12 UTC a137a90f49e30fdcb24da0f9ff5c21b28d9cb227
1 file changed +27 -21
gitk
+27 -21
@@ -626,6 +626,7 @@ proc makewindow {} {
626 global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
627 global headctxmenu progresscanv progressitem progresscoords statusw
628 global fprogitem fprogcoord lastprogupdate progupdatepending
629 + global rprogitem rprogcoord
630 global have_tk85
631
632 menu .bar
@@ -752,9 +753,11 @@ proc makewindow {} {
753 canvas $progresscanv -relief sunken -height $h -borderwidth 2
754 set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
755 set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
756 + set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
757 pack $progresscanv -side right -expand 1 -fill x
758 set progresscoords {0 0}
759 set fprogcoord 0
760 + set rprogcoord 0
761 bind $progresscanv <Configure> adjustprogress
762 set lastprogupdate [clock clicks -milliseconds]
763 set progupdatepending 0
@@ -1110,6 +1113,7 @@ proc click {w} {
1113 proc adjustprogress {} {
1114 global progresscanv progressitem progresscoords
1115 global fprogitem fprogcoord lastprogupdate progupdatepending
1116 + global rprogitem rprogcoord
1117
1118 set w [expr {[winfo width $progresscanv] - 4}]
1119 set x0 [expr {$w * [lindex $progresscoords 0]}]
@@ -1117,6 +1121,7 @@ proc adjustprogress {} {
1121 set h [winfo height $progresscanv]
1122 $progresscanv coords $progressitem $x0 0 $x1 $h
1123 $progresscanv coords $fprogitem 0 0 [expr {$w * $fprogcoord}] $h
1124 + $progresscanv coords $rprogitem 0 0 [expr {$w * $rprogcoord}] $h
1125 set now [clock clicks -milliseconds]
1126 if {$now >= $lastprogupdate + 100} {
1127 set progupdatepending 0
@@ -4195,20 +4200,30 @@ proc settextcursor {c} {
4200 set curtextcursor $c
4201 }
4202
4198 -proc nowbusy {what} {
4199 - global isbusy
4203 +proc nowbusy {what {name {}}} {
4204 + global isbusy busyname statusw
4205
4206 if {[array names isbusy] eq {}} {
4207 . config -cursor watch
4208 settextcursor watch
4209 }
4210 set isbusy($what) 1
4211 + set busyname($what) $name
4212 + if {$name ne {}} {
4213 + $statusw conf -text $name
4214 + }
4215 }
4216
4217 proc notbusy {what} {
4209 - global isbusy maincursor textcursor
4218 + global isbusy maincursor textcursor busyname statusw
4219
4211 - catch {unset isbusy($what)}
4220 + catch {
4221 + unset isbusy($what)
4222 + if {$busyname($what) ne {} &&
4223 + [$statusw cget -text] eq $busyname($what)} {
4224 + $statusw conf -text {}
4225 + }
4226 + }
4227 if {[array names isbusy] eq {}} {
4228 . config -cursor $maincursor
4229 settextcursor $textcursor
@@ -6432,32 +6447,23 @@ proc resethead {} {
6447 error_popup $err
6448 } else {
6449 dohidelocalchanges
6435 - set w ".resetprogress"
6436 - filerun $fd [list readresetstat $fd $w]
6437 - toplevel $w
6438 - wm transient $w
6439 - wm title $w "Reset progress"
6440 - message $w.m -text "Reset in progress, please wait..." \
6441 - -justify center -aspect 1000
6442 - pack $w.m -side top -fill x -padx 20 -pady 5
6443 - canvas $w.c -width 150 -height 20 -bg white
6444 - $w.c create rect 0 0 0 20 -fill green -tags rect
6445 - pack $w.c -side top -fill x -padx 20 -pady 5 -expand 1
6446 - nowbusy reset
6450 + filerun $fd [list readresetstat $fd]
6451 + nowbusy reset "Resetting"
6452 }
6453 }
6454
6450 -proc readresetstat {fd w} {
6451 - global mainhead mainheadid showlocalchanges
6455 +proc readresetstat {fd} {
6456 + global mainhead mainheadid showlocalchanges rprogcoord
6457
6458 if {[gets $fd line] >= 0} {
6459 if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
6455 - set x [expr {($m * 150) / $n}]
6456 - $w.c coords rect 0 0 $x 20
6460 + set rprogcoord [expr {1.0 * $m / $n}]
6461 + adjustprogress
6462 }
6463 return 1
6464 }
6460 - destroy $w
6465 + set rprogcoord 0
6466 + adjustprogress
6467 notbusy reset
6468 if {[catch {close $fd} err]} {
6469 error_popup $err