summaryrefslogtreecommitdiff
path: root/gdb/gdbtk/library
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2004-12-08 22:31:45 +0000
committerKeith Seitz <keiths@redhat.com>2004-12-08 22:31:45 +0000
commit4288a7854574b164995a80e10c3d6ba90878ad69 (patch)
treedc1376ffe98c0343c0abcacbdaa59a8525e47ae8 /gdb/gdbtk/library
parent6b050e0b14dd79366ab5490b073aa7a6a3420127 (diff)
downloadgdb-4288a7854574b164995a80e10c3d6ba90878ad69.tar.gz
* library/download.ith (completed_steps): New variable.
* library/download.itb (Download::constructor): Remove "-fraction" option from iwidgets feedback widget. It's not a valid option! (update_download): Compute the step number and use that to update the feedback widget. (done): Use completed_steps to figure out how many steps the dumb feedback meter needs to show full.
Diffstat (limited to 'gdb/gdbtk/library')
-rw-r--r--gdb/gdbtk/library/download.itb30
-rw-r--r--gdb/gdbtk/library/download.ith3
2 files changed, 28 insertions, 5 deletions
diff --git a/gdb/gdbtk/library/download.itb b/gdb/gdbtk/library/download.itb
index afe3c1d599c..c2a5e3ae60b 100644
--- a/gdb/gdbtk/library/download.itb
+++ b/gdb/gdbtk/library/download.itb
@@ -31,7 +31,7 @@ itcl::body Download::constructor {args} {
set i 0
while {$i <$num_sections} {
- iwidgets::feedback $f.meter$i -steps $num_steps -fraction 0.0
+ iwidgets::feedback $f.meter$i -steps $num_steps
grid forget [$f.meter$i component percentage]
label $f.sec$i -text [lindex $section(names) $i] -anchor w
label $f.num$i -text $bytes($i) -anchor e
@@ -63,11 +63,26 @@ itcl::body Download::update_download { sec num tot } {
set i $section($s)
if {$s == $sec} {
- set f [expr {$num / $bytes($i)}]
- $itk_interior.f.meter$i configure -fraction $f
+ # Advance feedback meter. The iwidgets meter leaves a lot to
+ # be desired. No way to query the current setting. No way to
+ # set the state of the meter by percentage. It only understands
+ # steps, and we must be careful not to step the widget past the
+ # the configured number of steps, or else the meter will be
+ # set wrong. How lame.
+ set steps [expr {$num / $bytes($i) * $num_steps}]
+ if {[expr {$completed_steps($s) + $steps}] > $num_steps} {
+ set steps [expr {$num_steps - $completed_steps($s)}]
+ }
+ incr completed_steps($s) $steps
+ $itk_interior.f.meter$i step $steps
break
} else {
- $itk_interior.f.meter$i configure -fraction 1.0
+ # Section already loaded. Make sure meter is at 100%.
+ if {$completed_steps($s) < $num_steps} {
+ set steps [expr {$num_steps - $completed_steps($s)}]
+ set completed_steps($s) $num_steps
+ $itk_interior.f.meter$i step $steps
+ }
}
}
@@ -91,7 +106,11 @@ itcl::body Download::done { {msg ""} } {
# set all indicators to FULL
foreach sec $section(names) {
set i $section($sec)
- $itk_interior.f.meter$i configure -fraction 1.0
+ if {$completed_steps($sec) < $num_steps} {
+ set steps [expr {$num_steps - $completed_steps($sec)}]
+ set completed_steps($sec) $num_steps
+ $itk_interior.f.meter$i step $steps
+ }
}
} else {
# download failed
@@ -221,6 +240,7 @@ itcl::body Download::download_it { } {
set b [lindex $x 1]
set bytes($i) [expr {double($b)}]
incr total_bytes $b
+ set completed_steps($s) 0
incr i
}
set num_sections $i
diff --git a/gdb/gdbtk/library/download.ith b/gdb/gdbtk/library/download.ith
index f50c3fef3b5..daea4311727 100644
--- a/gdb/gdbtk/library/download.ith
+++ b/gdb/gdbtk/library/download.ith
@@ -22,6 +22,9 @@ itcl::class Download {
common num_sections
common num_steps 100
+ # completed steps in feedback meter (iwidget::feedback is lame)
+ common completed_steps
+
method _ignore_on_save {} { return 1 }
proc dont_remember_size {} { return 1}
}