aboutsummaryrefslogtreecommitdiff
path: root/git-gui/lib/status_bar.tcl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-07-12 14:14:51 -0700
committerJunio C Hamano <gitster@pobox.com>2007-07-12 14:14:51 -0700
commitb9dcf846e20ed5287e239c9a0942c5d150081bab (patch)
treed6a6ae6c6240ac014f47c32e9ecf09b0c50c2dab /git-gui/lib/status_bar.tcl
parent237ce836e770e8ead12a14ee4a8170009fa4a40b (diff)
parentb215883de9322b8b475a04b4768d6ba5455373d1 (diff)
downloadgit-b9dcf846e20ed5287e239c9a0942c5d150081bab.tar.gz
git-b9dcf846e20ed5287e239c9a0942c5d150081bab.tar.xz
Merge commit 'git-gui/master'
* commit 'git-gui/master': (36 commits) git-gui: Change prior tree SHA-1 verification to use git_read git-gui: Include a space in Cygwin shortcut command lines git-gui: Use sh.exe in Cygwin shortcuts git-gui: Paper bag fix for Cygwin shortcut creation git-gui: Improve the Windows and Mac OS X shortcut creators git-gui: Teach console widget to use git_read git-gui: Perform our own magic shbang detection on Windows git-gui: Treat `git version` as `git --version` git-gui: Assume unfound commands are known by git wrapper git-gui: Correct gitk installation location git-gui: Always use absolute path to all git executables git-gui: Show a progress meter for checking out files git-gui: Change the main window progress bar to use status_bar git-gui: Extract blame viewer status bar into mega-widget git-gui: Allow double-click in checkout dialog to start checkout git-gui: Default selection to first matching ref git-gui: Unabbreviate commit SHA-1s prior to display git-gui: Refactor branch switch to support detached head git-gui: Refactor our ui_status_value update technique git-gui: Better handling of detached HEAD ...
Diffstat (limited to 'git-gui/lib/status_bar.tcl')
-rw-r--r--git-gui/lib/status_bar.tcl96
1 files changed, 96 insertions, 0 deletions
diff --git a/git-gui/lib/status_bar.tcl b/git-gui/lib/status_bar.tcl
new file mode 100644
index 000000000..72a8fe1fd
--- /dev/null
+++ b/git-gui/lib/status_bar.tcl
@@ -0,0 +1,96 @@
+# git-gui status bar mega-widget
+# Copyright (C) 2007 Shawn Pearce
+
+class status_bar {
+
+field w ; # our own window path
+field w_l ; # text widget we draw messages into
+field w_c ; # canvas we draw a progress bar into
+field status {}; # single line of text we show
+field prefix {}; # text we format into status
+field units {}; # unit of progress
+field meter {}; # current core git progress meter (if active)
+
+constructor new {path} {
+ set w $path
+ set w_l $w.l
+ set w_c $w.c
+
+ frame $w \
+ -borderwidth 1 \
+ -relief sunken
+ label $w_l \
+ -textvariable @status \
+ -anchor w \
+ -justify left
+ pack $w_l -side left
+
+ bind $w <Destroy> [cb _delete %W]
+ return $this
+}
+
+method start {msg uds} {
+ if {[winfo exists $w_c]} {
+ $w_c coords bar 0 0 0 20
+ } else {
+ canvas $w_c \
+ -width 100 \
+ -height [expr {int([winfo reqheight $w_l] * 0.6)}] \
+ -borderwidth 1 \
+ -relief groove \
+ -highlightt 0
+ $w_c create rectangle 0 0 0 20 -tags bar -fill navy
+ pack $w_c -side right
+ }
+
+ set status $msg
+ set prefix $msg
+ set units $uds
+ set meter {}
+}
+
+method update {have total} {
+ set pdone 0
+ if {$total > 0} {
+ set pdone [expr {100 * $have / $total}]
+ }
+
+ set status [format "%s ... %i of %i %s (%2i%%)" \
+ $prefix $have $total $units $pdone]
+ $w_c coords bar 0 0 $pdone 20
+}
+
+method update_meter {buf} {
+ append meter $buf
+ set r [string last "\r" $meter]
+ if {$r == -1} {
+ return
+ }
+
+ set prior [string range $meter 0 $r]
+ set meter [string range $meter [expr {$r + 1}] end]
+ if {[regexp "\\((\\d+)/(\\d+)\\)\\s+done\r\$" $prior _j a b]} {
+ update $this $a $b
+ }
+}
+
+method stop {{msg {}}} {
+ destroy $w_c
+ if {$msg ne {}} {
+ set status $msg
+ }
+}
+
+method show {msg {test {}}} {
+ if {$test eq {} || $status eq $test} {
+ set status $msg
+ }
+}
+
+method _delete {current} {
+ if {$current eq $w} {
+ delete_this
+ }
+}
+
+}