diff options
author | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
---|---|---|
committer | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
commit | 48c9fcb7281cc6aa076113db874c7ae0e105795d (patch) | |
tree | 7187940ff056462bfa41705a2ce04d0ed07d424e /library/msgbox.tcl | |
parent | 41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff) | |
download | tk-contrib_patrick_fradin_code_cleanup.zip tk-contrib_patrick_fradin_code_cleanup.tar.gz tk-contrib_patrick_fradin_code_cleanup.tar.bz2 |
Contribution by Patrick Fradin <patrick.fradin@planar.com>contrib_patrick_fradin_code_cleanup
Quoting his mail:
<pre>
==========================================================
Hi Jeff,
I spent some of my time to contribute to the TclTk community ! I'm in
late for Christmas gift but like we said in French : "Mieux vaut tard
que jamais". ;-)
I've use TclDevKit 5.3.0 tclchecker to analyse TclTk code in Tcl and
Tk library directories (library, tools and tests) to correct a lot of
warnings and few errors. (encapsulate some expr, use 'chan xxx'
instead of fconfigure, fileevent...)
I've made some improvements too :
Examples :
- Use 'lassign' instead of many 'lindex' of 'foreach/break' loop.
- Use 'in' or 'ni' operators instead of 'lsearch -exact' or to
factorise some eq/ne && / || tests.
- Use 'eq' or 'ne' to tests strings instead of '==' or '!='.
- Use 'unset -nocomplain' to avoid 'catch {unset...}'.
- Remove some useless catch around 'destroy' calls.
- Use expand {*} instead of 'eval'. Don't touch a lot of code because
I don't know all structs and lists. I think it could be a greater
improvement to reduce 'eval' calls.
Due to previous experience, I dot not change any indentation ! ;-)
==========================================================
</pre>
Diffstat (limited to 'library/msgbox.tcl')
-rw-r--r-- | library/msgbox.tcl | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/library/msgbox.tcl b/library/msgbox.tcl index 10e91f1..dd2756f 100644 --- a/library/msgbox.tcl +++ b/library/msgbox.tcl @@ -133,7 +133,7 @@ proc ::tk::MessageBox {args} { variable ::tk::Priv set w ::tk::PrivMsgBox - upvar $w data + upvar 1 $w data # # The default value of the title is space (" ") not the empty string @@ -163,6 +163,7 @@ proc ::tk::MessageBox {args} { "error" {set data(-icon) "stop"} "warning" {set data(-icon) "caution"} "info" {set data(-icon) "note"} + default {} } option add *Dialog*background systemDialogBackgroundActive widgetDefault option add *Dialog*Button.highlightBackground \ @@ -182,7 +183,7 @@ proc ::tk::MessageBox {args} { } ok { set names [list ok] - set labels {&OK} + set labels [list &OK] set cancel ok } okcancel { @@ -213,7 +214,7 @@ proc ::tk::MessageBox {args} { } } - set buttons {} + set buttons [list] foreach name $names lab $labels { lappend buttons [list $name -text [mc $lab]] } @@ -252,8 +253,8 @@ proc ::tk::MessageBox {args} { # 3. Create the top-level window and divide it into top # and bottom parts. - catch {destroy $w} - toplevel $w -class Dialog -bg $bg + destroy $w + toplevel $w -class Dialog -background $bg wm title $w $data(-title) wm iconname $w Dialog wm protocol $w WM_DELETE_WINDOW [list $w.$cancel invoke] @@ -270,7 +271,7 @@ proc ::tk::MessageBox {args} { } if {$windowingsystem eq "aqua"} { - ::tk::unsupported::MacWindowStyle style $w moveableModal {} + ::tk::unsupported::MacWindowStyle style $w moveableModal "" } elseif {$windowingsystem eq "x11"} { wm attributes $w -type dialog } @@ -299,7 +300,7 @@ proc ::tk::MessageBox {args} { # ttk::label has no -bitmap option label $w.bitmap -bitmap $data(-icon) -background $bg } else { - switch $data(-icon) { + switch -- $data(-icon) { error { ttk::label $w.bitmap -image ::tk::icons::error } @@ -350,9 +351,7 @@ proc ::tk::MessageBox {args} { # We boost the size of some Mac buttons for l&f if {$windowingsystem eq "aqua"} { set tmp [string tolower $name] - if {$tmp eq "ok" || $tmp eq "cancel" || $tmp eq "yes" || - $tmp eq "no" || $tmp eq "abort" || $tmp eq "retry" || - $tmp eq "ignore"} { + if {$tmp in "ok cancel yes no abort retry ignore"} { grid columnconfigure $w.bot $i -minsize 90 } grid configure $w.$name -pady 7 |