Skip to content

Commit

Permalink
gitk: Integrate the reset progress bar in the main frame
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Mackerras committed Oct 23, 2007
1 parent eb33a67 commit a137a90
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ proc makewindow {} {
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
global headctxmenu progresscanv progressitem progresscoords statusw
global fprogitem fprogcoord lastprogupdate progupdatepending
global rprogitem rprogcoord
global have_tk85

menu .bar
Expand Down Expand Up @@ -752,9 +753,11 @@ proc makewindow {} {
canvas $progresscanv -relief sunken -height $h -borderwidth 2
set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
pack $progresscanv -side right -expand 1 -fill x
set progresscoords {0 0}
set fprogcoord 0
set rprogcoord 0
bind $progresscanv <Configure> adjustprogress
set lastprogupdate [clock clicks -milliseconds]
set progupdatepending 0
Expand Down Expand Up @@ -1110,13 +1113,15 @@ proc click {w} {
proc adjustprogress {} {
global progresscanv progressitem progresscoords
global fprogitem fprogcoord lastprogupdate progupdatepending
global rprogitem rprogcoord

set w [expr {[winfo width $progresscanv] - 4}]
set x0 [expr {$w * [lindex $progresscoords 0]}]
set x1 [expr {$w * [lindex $progresscoords 1]}]
set h [winfo height $progresscanv]
$progresscanv coords $progressitem $x0 0 $x1 $h
$progresscanv coords $fprogitem 0 0 [expr {$w * $fprogcoord}] $h
$progresscanv coords $rprogitem 0 0 [expr {$w * $rprogcoord}] $h
set now [clock clicks -milliseconds]
if {$now >= $lastprogupdate + 100} {
set progupdatepending 0
Expand Down Expand Up @@ -4195,20 +4200,30 @@ proc settextcursor {c} {
set curtextcursor $c
}

proc nowbusy {what} {
global isbusy
proc nowbusy {what {name {}}} {
global isbusy busyname statusw

if {[array names isbusy] eq {}} {
. config -cursor watch
settextcursor watch
}
set isbusy($what) 1
set busyname($what) $name
if {$name ne {}} {
$statusw conf -text $name
}
}

proc notbusy {what} {
global isbusy maincursor textcursor
global isbusy maincursor textcursor busyname statusw

catch {unset isbusy($what)}
catch {
unset isbusy($what)
if {$busyname($what) ne {} &&
[$statusw cget -text] eq $busyname($what)} {
$statusw conf -text {}
}
}
if {[array names isbusy] eq {}} {
. config -cursor $maincursor
settextcursor $textcursor
Expand Down Expand Up @@ -6432,32 +6447,23 @@ proc resethead {} {
error_popup $err
} else {
dohidelocalchanges
set w ".resetprogress"
filerun $fd [list readresetstat $fd $w]
toplevel $w
wm transient $w
wm title $w "Reset progress"
message $w.m -text "Reset in progress, please wait..." \
-justify center -aspect 1000
pack $w.m -side top -fill x -padx 20 -pady 5
canvas $w.c -width 150 -height 20 -bg white
$w.c create rect 0 0 0 20 -fill green -tags rect
pack $w.c -side top -fill x -padx 20 -pady 5 -expand 1
nowbusy reset
filerun $fd [list readresetstat $fd]
nowbusy reset "Resetting"
}
}

proc readresetstat {fd w} {
global mainhead mainheadid showlocalchanges
proc readresetstat {fd} {
global mainhead mainheadid showlocalchanges rprogcoord

if {[gets $fd line] >= 0} {
if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
set x [expr {($m * 150) / $n}]
$w.c coords rect 0 0 $x 20
set rprogcoord [expr {1.0 * $m / $n}]
adjustprogress
}
return 1
}
destroy $w
set rprogcoord 0
adjustprogress
notbusy reset
if {[catch {close $fd} err]} {
error_popup $err
Expand Down

0 comments on commit a137a90

Please sign in to comment.