/usr/share/cgnstools/dialog.tcl is in cgns-convert 3.3.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | if {![info exists UseNativeDialogs] || $UseNativeDialogs == ""} {
if {$tcl_platform(platform) == "windows"} {
set UseNativeDialogs 1
} else {
set UseNativeDialogs 0
}
}
#----- pop-up dialog window - borrowed from tk_dialog
proc dialog {w x y title text bitmap default args} {
global _DialogDone
catch {destroy $w}
toplevel $w -class Dialog
wm title $w $title
if {$x != {} && [winfo exists $x] && [winfo ismapped $x]} {
wm transient $w [winfo toplevel $x]
} else {
wm transient $w [winfo toplevel [winfo parent $w]]
}
frame $w.top -relief raised -bd 1
pack $w.top -side top -fill both
message $w.msg -width 10c -text $text
pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 5 -pady 5
if {$bitmap != ""} {
if {![catch {image type $bitmap} type] && $type == "photo"} {
label $w.bitmap -image $bitmap
} else {
label $w.bitmap -bitmap $bitmap
}
pack $w.bitmap -in $w.top -side left -padx 5 -pady 5
}
set nbut 0
set wbut 0
set fbut $w
foreach but $args {
if {$but != ""} {
incr nbut
if {$wbut < [string length $but]} {
set wbut [string length $but]
}
}
}
if {$nbut} {
if {$wbut < 4} {set wbut 4}
frame $w.bot -relief raised -bd 1
pack $w.bot -side bottom -fill both
set i 0
foreach but $args {
if {$but != ""} {
button $w.button$i -text $but -width $wbut -command "set _DialogDone $i"
pack $w.button$i -in $w.bot -side left -expand 1 -padx 3 -pady 5
if {$i == $default} {
set fbut $w.button$i
$fbut configure -default active
bind $w <Return> "$fbut flash; set _DialogDone $i"
}
}
incr i
}
}
center_window $w $x $y
if {!$nbut} {
update idletasks
return 0
}
set oldFocus [focus]
set oldGrab [grab current $w]
if {$oldGrab != ""} {
set grabStatus [grab status $oldGrab]
}
catch {grab $w}
tkwait visibility $w
focus $fbut
tkwait variable _DialogDone
catch {focus $oldFocus}
destroy $w
if {$oldGrab != ""} {
if {$grabStatus == "global"} {
grab -global $oldGrab
} else {
grab $oldGrab
}
}
return $_DialogDone
}
proc MessageBox {title msg {icon ""} {type ""} {default ""}} {
global UseNativeDialogs
if {$UseNativeDialogs} {
set cmd "tk_messageBox -title {$title} -message {$msg}"
if {$icon != ""} {
append cmd " -icon $icon"
}
if {$type != ""} {
append cmd " -type $type"
}
if {$default != ""} {
append cmd " -default $default"
}
return [eval $cmd]
}
set buttons OK
case $type {
abortretryignore {set buttons "Abort Retry Ignore"}
okcancel {set buttons "OK Cancel"}
retrycancel {set buttons "Retry Cancel"}
yesno {set buttons "Yes No"}
yesnocancel {set buttons "Yes No Cancel"}
}
set defbut 0
if {$default != ""} {
set n 0
foreach b [split $buttons] {
if {$default == [string tolower $b]} {
set defbut $n
break
}
incr n
}
}
set cmd "dialog .messagewin {} {} {$title} {$msg} \
{$icon} $defbut $buttons"
set n [eval $cmd]
if [catch {lindex $buttons $n} result] {
return ""
}
return [string tolower $result]
}
proc DialogBox {w x y title text bitmap args} {
global _DialogDone
# get button width
set width 0
foreach btn $args {
if {[string length [lindex $btn 0]] > $width} {
set width [string length [lindex $btn 0]]
}
}
if !$width {
return [dialog $w $x $y $title $text $bitmap {} {}]
}
incr width 2
catch {destroy $w}
toplevel $w -class Dialog
wm title $w $title
if {$x != {} && [winfo exists $x] && [winfo ismapped $x]} {
wm transient $w [winfo toplevel $x]
} else {
wm transient $w [winfo toplevel [winfo parent $w]]
}
# top message
frame $w.msg -relief raised -bd 1
pack $w.msg -side top -fill both -expand 1
if {$bitmap != ""} {
if {![catch {image type $bitmap} type] && $type == "photo"} {
label $w.msg.icon -image $bitmap
} else {
label $w.msg.icon -bitmap $bitmap
}
pack $w.msg.icon -side left -padx 10 -pady 3
}
message $w.msg.msg -text $text -width 8c
pack $w.msg.msg -pady 3 -anchor w
# button selections
set cnt -1
foreach btn $args {
incr cnt
set f [frame $w.f$cnt -relief raised -bd 1]
pack $f -side top -fill x
button $f.btn -width $width -text [lindex $btn 0] \
-padx 3 -pady 2 -command "set _DialogDone $cnt"
pack $f.btn -side left -padx 3 -pady 3
pack $f.btn -side left
message $f.msg -text [lindex $btn 1] -width 10c
pack $f.msg -anchor w -padx 3 -pady 3
}
center_window $w $x $y
set oldFocus [focus]
set oldGrab [grab current $w]
if {$oldGrab != ""} {
set grabStatus [grab status $oldGrab]
}
catch {grab $w}
focus $w
tkwait variable _DialogDone
catch {focus $oldFocus}
destroy $w
if {$oldGrab != ""} {
if {$grabStatus == "global"} {
grab -global $oldGrab
} else {
grab $oldGrab
}
}
return $_DialogDone
}
#----- error message popup window
proc errormsg {msg {x -1} {y -1}} {
if {$msg != ""} {
dialog .errorwin $x $y Error $msg error 0 Dismiss
}
}
proc ErrorMessage {msg} {
MessageBox Error "$msg" error
}
#----- center a window
proc center_window {w xref {yref -1}} {
wm withdraw $w
update idletasks
set ww [winfo reqwidth $w]
set wh [winfo reqheight $w]
if {$xref == ""} {
set x [expr ([winfo screenwidth $w] - $ww) / 2]
set y [expr ([winfo screenheight $w] - $wh) / 2]
} elseif {[winfo exists $xref] && [winfo ismapped $xref]} {
set x [expr [winfo rootx $xref] + ([winfo width $xref] - $ww) / 2]
set y [expr [winfo rooty $xref] + ([winfo height $xref] - $wh) / 2]
} else {
if [catch {expr $xref < 0} x] {
set x 1
}
if {$x} {
if [winfo ismapped .] {
set x [expr [winfo rootx .] + ([winfo width .] - $ww) / 2]
} else {
set x [expr ([winfo screenwidth $w] - $ww) / 2]
}
} else {
set x [expr $xref - $ww / 2]
}
if [catch {expr $yref < 0} y] {
set y 1
}
if {$y} {
if [winfo ismapped .] {
set y [expr [winfo rooty .] + ([winfo height .] - $wh) / 2]
} else {
set y [expr ([winfo screenheight $w] - $wh) / 2]
}
} else {
set y [expr $yref - $wh / 2]
}
}
if {$x < 0} {
set pos +0
} elseif {[expr $x + $ww] > [winfo screenwidth $w]} {
set pos -0
} else {
set pos +$x
}
if {$y < 0} {
set pos $pos+0
} elseif {[expr $y + $wh] > [winfo screenheight $w]} {
set pos $pos-0
} else {
set pos $pos+$y
}
wm geometry $w $pos
update idletasks
wm deiconify $w
}
#----- about message window
proc about {title text {bitmap ""}} {
dialog .about -1 -1 $title $text $bitmap 0 Close
}
#----- popup message
proc popup_message {msg args} {
global Font
set font $Font(normal)
set bg #ffffcc
set fg black
set parent .
set pos ""
set width 5c
set wrap 1
foreach {opt val} $args {
switch -glob -- $opt {
-fon* {set font $val}
-par* {set parent $val}
-pos* {set pos $val}
-for* - -fg {set fg $val}
-bac* - -bg {set bg $val}
-wid* {set width $val}
-wra* {set wrap $val}
}
}
if {$pos == ""} {set pos $parent}
set w .popup
catch {destroy $w}
toplevel $w -bg black
wm overrideredirect $w 1
wm transient $w [winfo toplevel $parent]
if {$wrap} {
message $w.l -text $msg -font $font -relief flat -bg $bg -fg $fg \
-padx 2 -pady 0 -anchor w -width $width
} else {
label $w.l -text $msg -font $font -relief flat -bg $bg -fg $fg \
-padx 2 -pady 0 -anchor w -justify left -wraplength 0
}
pack $w.l -side left -padx 1 -pady 1
eval center_window $w $pos
bind $w <ButtonRelease> {catch {destroy .popup};break}
bind $w <KeyRelease> {catch {destroy .popup};break}
bind $w <FocusOut> {catch {destroy .popup}}
set oldFocus [focus]
set oldGrab [grab current $w]
if {$oldGrab != ""} {
set grabStatus [grab status $oldGrab]
}
catch {grab $w}
focus $w
tkwait window $w
catch {focus $oldFocus}
if {$oldGrab != ""} {
if {$grabStatus == "global"} {
grab -global $oldGrab
} else {
grab $oldGrab
}
}
}
|