From 96225dbe966fdbf00ef1a3a1dd801534953c9919 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 26 Sep 2007 15:31:42 -0400 Subject: [PATCH] git-gui: Make the status bar easier to read in the setup wizard The setup wizard looks better if we layout the progress bar as two lines: the first line holds the message text and our text formatting of the progress while the second line holds the bar itself. Both extend the full width of the window and we try to pad out the message text so the window doesn't expand when the completed progress number jumps to the next order of magnitude. This change required updating the progress meter format string to allow the application to supply the precision. So we also are updating all of the translations at once to use the newer formatting string. Signed-off-by: Shawn O. Pearce --- lib/choose_repository.tcl | 4 ++-- lib/status_bar.tcl | 38 +++++++++++++++++++++++++++++++++----- po/de.po | 4 ++-- po/git-gui.pot | 2 +- po/hu.po | 4 ++-- po/it.po | 4 ++-- po/ja.po | 4 ++-- po/ru.po | 4 ++-- po/zh_cn.po | 2 +- 9 files changed, 47 insertions(+), 19 deletions(-) diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl index 8d3c81e7c..16bf67c34 100644 --- a/lib/choose_repository.tcl +++ b/lib/choose_repository.tcl @@ -481,7 +481,7 @@ method _do_clone2 {} { switch -exact -- $clone_type { hardlink { - set o_cons [status_bar::new $w_body] + set o_cons [status_bar::two_line $w_body] pack $w_body -fill x -padx 10 -pady 10 $o_cons start \ @@ -780,7 +780,7 @@ method _do_clone_checkout {HEAD} { return } - set o_cons [status_bar::new $w_body] + set o_cons [status_bar::two_line $w_body] pack $w_body -fill x -padx 10 -pady 10 $o_cons start \ [mc "Creating working directory"] \ diff --git a/lib/status_bar.tcl b/lib/status_bar.tcl index 769ef81c4..5c5bf7c73 100644 --- a/lib/status_bar.tcl +++ b/lib/status_bar.tcl @@ -6,6 +6,7 @@ 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 c_pack ; # script to pack the canvas with field status {}; # single line of text we show field prefix {}; # text we format into status field units {}; # unit of progress @@ -24,6 +25,29 @@ constructor new {path} { -anchor w \ -justify left pack $w_l -side left + set c_pack [cb _oneline_pack] + + bind $w [cb _delete %W] + return $this +} + +method _oneline_pack {} { + $w_c conf -width 100 + pack $w_c -side right +} + +constructor two_line {path} { + set w $path + set w_l $w.l + set w_c $w.c + + frame $w + label $w_l \ + -textvariable @status \ + -anchor w \ + -justify left + pack $w_l -anchor w -fill x + set c_pack [list pack $w_c -fill x] bind $w [cb _delete %W] return $this @@ -34,13 +58,12 @@ method start {msg uds} { $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 + eval $c_pack } set status $msg @@ -53,11 +76,16 @@ method update {have total} { set pdone 0 if {$total > 0} { set pdone [expr {100 * $have / $total}] + set cdone [expr {[winfo width $w_c] * $have / $total}] } - set status [mc "%s ... %i of %i %s (%2i%%)" \ - $prefix $have $total $units $pdone] - $w_c coords bar 0 0 $pdone 20 + set prec [string length [format %i $total]] + set status [mc "%s ... %*i of %*i %s (%3i%%)" \ + $prefix \ + $prec $have \ + $prec $total \ + $units $pdone] + $w_c coords bar 0 0 $cdone 20 } method update_meter {buf} { diff --git a/po/de.po b/po/de.po index 7d57dd15f..94b7463ca 100644 --- a/po/de.po +++ b/po/de.po @@ -1350,8 +1350,8 @@ msgstr "Fehler beim Erstellen des Icons:" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" -msgstr "%s ... %i von %i %s (%2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" +msgstr "%s ... %*i von %*i %s (%3i%%)" #: lib/transport.tcl:7 #, tcl-format diff --git a/po/git-gui.pot b/po/git-gui.pot index 991efea5f..b35230257 100644 --- a/po/git-gui.pot +++ b/po/git-gui.pot @@ -1216,7 +1216,7 @@ msgstr "" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" msgstr "" #: lib/transport.tcl:7 diff --git a/po/hu.po b/po/hu.po index faac58f81..1e189b608 100644 --- a/po/hu.po +++ b/po/hu.po @@ -1344,8 +1344,8 @@ msgstr "Nem sikerült írni az ikont:" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" -msgstr "%s ... %i / %i %s (%2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" +msgstr "%s ... %*i / %*i %s (%3i%%)" #: lib/transport.tcl:7 #, tcl-format diff --git a/po/it.po b/po/it.po index 17a5c2188..ad5cd9e5d 100644 --- a/po/it.po +++ b/po/it.po @@ -1344,8 +1344,8 @@ msgstr "Impossibile scrivere icona:" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" -msgstr "%s ... %i di %i %s (%2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" +msgstr "%s ... %*i di %*i %s (%3i%%)" #: lib/transport.tcl:7 #, tcl-format diff --git a/po/ja.po b/po/ja.po index 17139080e..cdbc981ca 100644 --- a/po/ja.po +++ b/po/ja.po @@ -1333,8 +1333,8 @@ msgstr "アイコンが書けません:" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" -msgstr "%1$s ... %3$i %4$s 中の %$2i (%5$2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" +msgstr "%1$s ... %3$*i %4$s 中の %$2*i (%5$3i%%)" #: lib/transport.tcl:7 #, tcl-format diff --git a/po/ru.po b/po/ru.po index c44d30af0..20080338c 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1434,8 +1434,8 @@ msgstr "Невозможно записать значок:" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" -msgstr "%s ... %i из %i %s (%2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" +msgstr "%s ... %*i из %*i %s (%3i%%)" #: lib/transport.tcl:7 #, tcl-format diff --git a/po/zh_cn.po b/po/zh_cn.po index 45eb5b5f9..d1ed94f8a 100644 --- a/po/zh_cn.po +++ b/po/zh_cn.po @@ -1238,7 +1238,7 @@ msgstr "" #: lib/status_bar.tcl:58 #, tcl-format -msgid "%s ... %i of %i %s (%2i%%)" +msgid "%s ... %*i of %*i %s (%3i%%)" msgstr "" #: lib/transport.tcl:7 -- 2.30.2