summaryrefslogtreecommitdiff
path: root/gdb/gdbtk/library/download.itb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbtk/library/download.itb')
-rw-r--r--gdb/gdbtk/library/download.itb102
1 files changed, 38 insertions, 64 deletions
diff --git a/gdb/gdbtk/library/download.itb b/gdb/gdbtk/library/download.itb
index f20aecf07f3..c4de6d4723e 100644
--- a/gdb/gdbtk/library/download.itb
+++ b/gdb/gdbtk/library/download.itb
@@ -1,5 +1,5 @@
-# Download class implementation for Insight.
-# Copyright (C) 1999, 2001 Red Hat, Inc.
+# Download class implementation for GDBtk.
+# Copyright 1999 Cygnus Solutions
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
@@ -17,7 +17,7 @@
#
# ----------------------------------------------------------------------
-itcl::body Download::constructor {args} {
+body Download::constructor {args} {
global gdb_pretty_name
debug $args
eval itk_initialize $args
@@ -31,30 +31,28 @@ itcl::body Download::constructor {args} {
set i 0
while {$i <$num_sections} {
- iwidgets::feedback $f.meter$i -steps $num_steps
- grid forget [$f.meter$i component percentage]
+ tixMeter $f.meter$i -value 0 -text 0
label $f.sec$i -text [lindex $section(names) $i] -anchor w
label $f.num$i -text $bytes($i) -anchor e
grid $f.sec$i $f.meter$i $f.num$i -padx 4 -pady 4 -sticky news
incr i
}
- grid columnconfigure $f 1 -weight 1
+
+ grid $itk_interior.dload -padx 5 -pady 5
+ grid $itk_interior.stat -padx 5 -pady 5
+ grid $itk_interior.f -padx 5 -pady 5
button $itk_interior.cancel -text Cancel -command "$this cancel" \
-state active -width 10
-
- pack $itk_interior.dload -padx 5 -pady 5 -side top -fill x -expand yes
- pack $itk_interior.stat -padx 5 -pady 5 -expand yes
- pack $itk_interior.f -padx 5 -pady 5 -fill x -expand yes
-
- pack $itk_interior.cancel -padx 5 -pady 5 -side bottom
- ::update idletasks
+ grid $itk_interior.cancel -padx 5 -pady 5
+# grid $itk_interior
+
}
# ------------------------------------------------------------------
# METHOD: update_download - update the download meters
# ------------------------------------------------------------------
-itcl::body Download::update_download { sec num tot } {
+body Download::update_download { sec num tot } {
# Loop through all the sections, marking each as either done or
# updating its meter. This will mark all previous sections prior to
@@ -63,36 +61,21 @@ itcl::body Download::update_download { sec num tot } {
set i $section($s)
if {$s == $sec} {
- # 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
+ $itk_interior.f.meter$i config -value [expr {$num / $bytes($i)}] -text $num
break
} else {
- # 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
+ if {[expr {double([$itk_interior.f.meter$i cget -value])}] != 1.0} {
+ $itk_interior.f.meter$i config -value 1.0 -text [expr {int($bytes($i))}]
}
}
}
-
::update
}
# ------------------------------------------------------------------
# METHOD: done - notification that the download is really complete
# ------------------------------------------------------------------
-itcl::body Download::done { {msg ""} } {
+body Download::done { {msg ""} } {
bell
if {$msg == ""} {
@@ -106,11 +89,7 @@ itcl::body Download::done { {msg ""} } {
# set all indicators to FULL
foreach sec $section(names) {
set i $section($sec)
- 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
- }
+ $itk_interior.f.meter$i config -value 1.0 -text "DONE"
}
} else {
# download failed
@@ -127,7 +106,7 @@ itcl::body Download::done { {msg ""} } {
# ------------------------------------------------------------------
# METHOD: cancel - cancel the download
# ------------------------------------------------------------------
-itcl::body Download::cancel {} {
+body Download::cancel {} {
debug "canceling the download"
set ::download_cancel_ok 1
}
@@ -135,15 +114,15 @@ itcl::body Download::cancel {} {
# ------------------------------------------------------------------
# DESTRUCTOR - destroy window containing widget
# ------------------------------------------------------------------
-itcl::body Download::destructor {} {
+body Download::destructor {} {
remove_hook download_progress_hook "$this update_download"
}
-itcl::body Download::do_download_hooks {} {
+body Download::do_download_hooks {} {
set ::download_timer(ok) 1
}
-itcl::body Download::download_hash { section num } {
+body Download::download_hash { section num } {
global download_timer
debug "sec=$section num=$num tot=$total_bytes ok=$::download_cancel_ok"
::update
@@ -152,7 +131,7 @@ itcl::body Download::download_hash { section num } {
after cancel $download_timer(timer)
}
- set download_timer(timer) [after 100 Download::do_download_hooks]
+ set download_timer(timer) [after 333 Download::do_download_hooks]
if {![info exists download_timer(ok)] || $download_timer(ok)} {
run_hooks download_progress_hook $section $num $total_bytes
::update
@@ -164,25 +143,25 @@ itcl::body Download::download_hash { section num } {
}
# Download the executable. Return zero for success, and non-zero for error.
-itcl::body Download::download_it { } {
+body Download::download_it { } {
global gdb_exe_name gdb_downloading gdb_loaded
global gdb_target_name gdb_pretty_name
- global gdb_running gdbtk_platform
-
+ global gdb_running
+
debug "exe=$gdb_exe_name downloading=$gdb_downloading"
debug " loaded=$gdb_loaded target=$gdb_target_name running=$gdb_running"
-
+
if {$gdb_downloading || $gdb_exe_name == ""} {
return 0
}
-
+
set gdb_downloading 1
set gdb_loaded 0
# Make sure the source window has had time to be created
::update
-
+
gdbtk_busy
-
+
# Only places that load files should do set_exe
#set_exe
switch [set_target] {
@@ -205,22 +184,17 @@ itcl::body Download::download_it { } {
return 1
}
}
-
- if {[string compare $gdbtk_platform(os) "cygwin"] == 0} {
- set f [ide_cygwin_path to_win32 $gdb_exe_name]
- } else {
- set f $gdb_exe_name
- }
- if {! [file exists $f]} {
- tk_messageBox -icon error -title GDB -type ok \
+
+ if {! [file exists $gdb_exe_name]} {
+ tk_messageBox -icon error -title GDB -type ok -modal task\
-message "Request to download non-existent executable $gdb_exe_name"
set gdb_downloading 0
gdbtk_idle
return 0
}
-
+
debug "downloading $gdb_exe_name"
-
+
set target $gdb_target_name
# get load info and total up number of bytes
@@ -239,13 +213,13 @@ 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
set ::download_cancel_ok 0
set ::download_start_time [clock seconds]
+
if {[pref getd gdb/load/$target-verbose] == "1"} {
# open a detailed download dialog window
@@ -258,7 +232,7 @@ itcl::body Download::download_it { } {
}
set download_dialog ""
}
-
+
set download_error ""
debug "starting load"
::update idletasks
@@ -271,7 +245,7 @@ itcl::body Download::download_it { } {
}
set ::download_cancel_ok 1
}
-
+
debug "Done loading"
set gdb_downloading 0
@@ -286,7 +260,7 @@ itcl::body Download::download_it { } {
catch {$download_dialog done}
}
}
-
+
foreach src [ManagedWin::find SrcWin] {
if {$download_error == "CANCEL"} {
$src download_progress CANCEL 1 1