summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2002-05-08 05:13:03 (GMT)
committerdgp <dgp@users.sourceforge.net>2002-05-08 05:13:03 (GMT)
commit50a4cfe36baf76470123c8c9d24aee73d4e50fc4 (patch)
tree477a30f7a251e4a1243d7e255e01bf2197ef3d53
parente8abab9c4ff7f74bf91038224e4ce9f90b1e2cb8 (diff)
downloadtk-50a4cfe36baf76470123c8c9d24aee73d4e50fc4.zip
tk-50a4cfe36baf76470123c8c9d24aee73d4e50fc4.tar.gz
tk-50a4cfe36baf76470123c8c9d24aee73d4e50fc4.tar.bz2
* Cleaned up namespace usage of the bgerror
dialog. Completes soft dependence on msgcat. [FR 539309]
-rw-r--r--ChangeLog7
-rw-r--r--library/bgerror.tcl115
-rw-r--r--library/tclIndex6
3 files changed, 68 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 9b0ef02..108a399 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
-2002-05-07 David Gravereaux <davygrvy@pobox.com>
+2002-05-08 Don Porter <dgp@users.sourceforge.net>
+
+ * library/bgerror.tcl:
+ * library/tclIndex: Cleaned up namespace usage of the bgerror
+ dialog. Completes soft dependence on msgcat. [FR 539309]
+2002-05-07 David Gravereaux <davygrvy@pobox.com>
* win/makefile.vc: Problem with TCLDIR macro not accepting
forward slash path seperators resolved. Added the same logic
to INSTALLDIR, too. [Bug #553208]
diff --git a/library/bgerror.tcl b/library/bgerror.tcl
index 11b51ac..a379e75 100644
--- a/library/bgerror.tcl
+++ b/library/bgerror.tcl
@@ -9,17 +9,19 @@
# Copyright (c) 1998-2000 by Ajuba Solutions.
# All rights reserved.
#
-# RCS: @(#) $Id: bgerror.tcl,v 1.19 2002/05/03 07:46:41 bagnonm Exp $
-# $Id: bgerror.tcl,v 1.19 2002/05/03 07:46:41 bagnonm Exp $
-
-option add *ErrorDialog.function.text [namespace eval ::tk {mc "Save To Log"}] \
- widgetDefault
-option add *ErrorDialog.function.command "::tk::dialog::error::saveToLog"
-
-namespace eval ::tk {}
-namespace eval ::tk::dialog {}
-namespace eval ::tk::dialog::error {
- namespace import ::tk::msgcat::*
+# RCS: @(#) $Id: bgerror.tcl,v 1.20 2002/05/08 05:13:03 dgp Exp $
+# $Id: bgerror.tcl,v 1.20 2002/05/08 05:13:03 dgp Exp $
+
+namespace eval ::tk {
+ namespace eval dialog {
+ namespace eval error {
+ namespace import ::tk::msgcat::*
+ namespace export bgerror
+ option add *ErrorDialog.function.text [mc "Save To Log"] \
+ widgetDefault
+ option add *ErrorDialog.function.command [namespace code SaveToLog]
+ }
+ }
}
proc ::tk::dialog::error::Return {} {
@@ -31,27 +33,23 @@ proc ::tk::dialog::error::Return {} {
set button 0
}
-proc ::tk::dialog::error::details {} {
+proc ::tk::dialog::error::Details {} {
set w .bgerrorDialog
set caption [option get $w.function text {}]
set command [option get $w.function command {}]
- if { [string equal $caption ""] || [string equal $command ""] } {
+ if { ($caption eq "") || ($command eq "") } {
grid forget $w.function
}
- $w.function configure -text $caption \
- -command [list ::tk::dialog::error::evalFunction $command]
+ $w.function configure -text $caption -command \
+ "$command [list [.bgerrorDialog.top.info.text get 1.0 end]]"
grid $w.top.info - -sticky nsew -padx 3m -pady 3m
}
-proc ::tk::dialog::error::evalFunction {cmd} {
- uplevel \#0 [list $cmd [.bgerrorDialog.top.info.text get 1.0 end]]
-}
-
-proc ::tk::dialog::error::saveToLog {text} {
- if { [string equal $::tcl_platform(platform) "windows"] } {
- set allFiles "*.*"
+proc ::tk::dialog::error::SaveToLog {text} {
+ if { $::tcl_platform(platform) eq "windows" } {
+ set allFiles *.*
} else {
- set allFiles "*"
+ set allFiles *
}
set types [list \
[list [mc "Log Files"] .log] \
@@ -69,13 +67,13 @@ proc ::tk::dialog::error::saveToLog {text} {
}
proc ::tk::dialog::error::Destroy {w} {
- if {".bgerrorDialog" == "$w"} {
+ if {$w eq ".bgerrorDialog"} {
variable button
set button -1
}
}
-# ::bgerror --
+# ::tk::dialog::error::bgerror --
# This is the default version of bgerror.
# It tries to execute tkerror, if that fails it posts a dialog box containing
# the error message and gives the user a chance to ask to see a stack
@@ -83,26 +81,26 @@ proc ::tk::dialog::error::Destroy {w} {
# Arguments:
# err - The error message.
-proc ::bgerror err {
+proc ::tk::dialog::error::bgerror err {
global errorInfo tcl_platform
- set butvar ::tk::dialog::error::button
+ variable button
set info $errorInfo
- set ret [catch {tkerror $err} msg];
+ set ret [catch {::tkerror $err} msg];
if {$ret != 1} {return -code $ret $msg}
# Ok the application's tkerror either failed or was not found
# we use the default dialog then :
- if {$tcl_platform(platform) == "macintosh"} {
- set ok [namespace eval ::tk {mc "Ok"}]
+ if {$tcl_platform(platform) eq "macintosh"} {
+ set ok [mc Ok]
set messageFont system
- set textRelief "flat"
+ set textRelief flat
set textHilight 0
} else {
- set ok [namespace eval ::tk {mc "OK"}]
+ set ok [mc OK]
set messageFont {Times -18}
- set textRelief "sunken"
+ set textRelief sunken
set textHilight 1
}
@@ -112,7 +110,7 @@ proc ::bgerror err {
# which one of those conditions is met.
set displayedErr ""
set lines 0
- foreach line [split $err "\n"] {
+ foreach line [split $err \n] {
if { [string length $line] > 30 } {
append displayedErr "[string range $line 0 29]..."
break
@@ -127,10 +125,10 @@ proc ::bgerror err {
}
set w .bgerrorDialog
- set title [namespace eval ::tk {mc "Application Error"}]
- set text [namespace eval ::tk "mc {Error: %1\$s} {$err}"]
- set buttons [list ok $ok dismiss [namespace eval ::tk {mc "Skip Messages"}] \
- function [namespace eval ::tk {mc "Details >>"}]]
+ set title [mc "Application Error"]
+ set text [mc {Error: %1$s} $err]
+ set buttons [list ok $ok dismiss [mc "Skip Messages"] \
+ function [mc "Details >>"]]
# 1. Create the top-level window and divide it into top
# and bottom parts.
@@ -144,13 +142,13 @@ proc ::bgerror err {
# The following, though surprising, works.
wm transient .bgerrorDialog .bgerrorDialog
- if {$tcl_platform(platform) == "macintosh"} {
+ if {$tcl_platform(platform) eq "macintosh"} {
::tk::unsupported::MacWindowStyle style .bgerrorDialog dBoxProc
}
frame .bgerrorDialog.bot
frame .bgerrorDialog.top
- if {$tcl_platform(platform) == "unix"} {
+ if {$tcl_platform(platform) eq "unix"} {
.bgerrorDialog.bot configure -relief raised -bd 1
.bgerrorDialog.top configure -relief raised -bd 1
}
@@ -160,7 +158,7 @@ proc ::bgerror err {
set W [frame $w.top.info]
text $W.text \
-bd 2 \
- -yscrollcommand "$W.scroll set" \
+ -yscrollcommand [list $W.scroll set]\
-setgrid true \
-width 40 \
-height 10 \
@@ -169,7 +167,7 @@ proc ::bgerror err {
-highlightthickness $textHilight \
-wrap char
- scrollbar $W.scroll -relief sunken -command "$W.text yview"
+ scrollbar $W.scroll -relief sunken -command [list $W.text yview]
pack $W.scroll -side right -fill y
pack $W.text -side left -expand yes -fill both
$W.text insert 0.0 "$err\n$info"
@@ -180,7 +178,7 @@ proc ::bgerror err {
# 2. Fill the top part with bitmap and message
label .bgerrorDialog.msg -justify left -text $text -font $messageFont
- if { [string equal $tcl_platform(platform) "macintosh"] } {
+ if { $tcl_platform(platform) eq "macintosh" } {
# On the Macintosh, use the stop bitmap
label .bgerrorDialog.bitmap -bitmap stop
} else {
@@ -206,7 +204,7 @@ proc ::bgerror err {
button .bgerrorDialog.$name \
-text $caption \
-default normal \
- -command "set $butvar $i"
+ -command [namespace code "set button $i"]
grid .bgerrorDialog.$name \
-in .bgerrorDialog.bot \
-column $i \
@@ -215,8 +213,8 @@ proc ::bgerror err {
-padx 10
grid columnconfigure .bgerrorDialog.bot $i -weight 1
# We boost the size of some Mac buttons for l&f
- if {$tcl_platform(platform) == "macintosh"} {
- if {($name == "ok") || ($name == "dismiss")} {
+ if {$tcl_platform(platform) eq "macintosh"} {
+ if {($name eq "ok") || ($name eq "dismiss")} {
grid columnconfigure .bgerrorDialog.bot $i -minsize 79
}
}
@@ -225,11 +223,9 @@ proc ::bgerror err {
# The "OK" button is the default for this dialog.
.bgerrorDialog.ok configure -default active
- set ::tk::dialog::error::curh 0
- bind .bgerrorDialog <Return> {::tk::dialog::error::Return}
- bind .bgerrorDialog <Destroy> {::tk::dialog::error::Destroy %W}
- .bgerrorDialog.function configure \
- -command {::tk::dialog::error::details }
+ bind .bgerrorDialog <Return> [namespace code Return]
+ bind .bgerrorDialog <Destroy> [namespace code [list Destroy %W]]
+ .bgerrorDialog.function configure -command [namespace code Details]
# 6. Withdraw the window, then update all the geometry information
# so we know how big it wants to be, then center the window in the
@@ -264,19 +260,26 @@ proc ::bgerror err {
# may take the focus away so we can't redirect it. Finally,
# restore any grab that was in effect.
- vwait $butvar
- set button $::tk::dialog::error::button; # Save a copy...
+ vwait [namespace which -variable button]
+ set copy $button; # Save a copy...
catch {focus $oldFocus}
catch {destroy .bgerrorDialog}
- if {$oldGrab != ""} {
- if {$grabStatus == "global"} {
+ if {$oldGrab ne ""} {
+ if {$grabStatus eq "global"} {
grab -global $oldGrab
} else {
grab $oldGrab
}
}
- if {$button == 1} {
+ if {$copy == 1} {
return -code break
}
}
+
+namespace eval :: {
+ # Fool the indexer
+ proc bgerror err {}
+ rename bgerror {}
+ namespace import ::tk::dialog::error::bgerror
+}
diff --git a/library/tclIndex b/library/tclIndex
index 72ac96e..711fe32 100644
--- a/library/tclIndex
+++ b/library/tclIndex
@@ -7,10 +7,10 @@
# a script that loads the command.
set auto_index(::tk::dialog::error::Return) [list source [file join $dir bgerror.tcl]]
-set auto_index(::tk::dialog::error::details) [list source [file join $dir bgerror.tcl]]
-set auto_index(::tk::dialog::error::evalFunction) [list source [file join $dir bgerror.tcl]]
-set auto_index(::tk::dialog::error::saveToLog) [list source [file join $dir bgerror.tcl]]
+set auto_index(::tk::dialog::error::Details) [list source [file join $dir bgerror.tcl]]
+set auto_index(::tk::dialog::error::SaveToLog) [list source [file join $dir bgerror.tcl]]
set auto_index(::tk::dialog::error::Destroy) [list source [file join $dir bgerror.tcl]]
+set auto_index(::tk::dialog::error::bgerror) [list source [file join $dir bgerror.tcl]]
set auto_index(bgerror) [list source [file join $dir bgerror.tcl]]
set auto_index(::tk::ButtonInvoke) [list source [file join $dir button.tcl]]
set auto_index(::tk::ButtonAutoInvoke) [list source [file join $dir button.tcl]]