/usr/share/cgnstools/tkdir.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 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | #########################################################
# Directory Selector TCL version 1.1
#
# Originally written by:
# Daniel Roche, <dan@lectra.com>
#
# Modified for xmktclapp (and for version of Tk prior to 8.0) by:
# D. Richard Hipp, <drh@hwaci.com>
# tk_getDirectory [option value ...]
#
# options are :
# [-parent window] parent window
# [-initialdir dir] display in dir
# [-title string] make string title of dialog window
# [-ok string] make string the label of OK button
# [-cancel string] make string the label of CANCEL button
# [-label string] make string the label of the directory message
# [-nofiles] don't show files
#
proc tk_getDirectory {args} {
global tcl_platform tk_getDirectory
set _titre "Directory Selector"
set _ldir Directory:
set _open Ok
set _cancel Cancel
set _parent {}
set tk_getDirectory(curdir) [pwd]
set tk_getDirectory(showfiles) 1
set ind 0
set max [llength $args]
while { $ind < $max } {
switch -exact -- [lindex $args $ind] {
"-parent" {
incr ind
set _parent [lindex $args $ind]
incr ind
}
"-initialdir" {
incr ind
if {![catch {cd [lindex $args $ind]}]} {
set dir [pwd]
catch {cd $tk_getDirectory(curdir)}
set tk_getDirectory(curdir) $dir
}
incr ind
}
"-title" {
incr ind
set _titre [lindex $args $ind]
incr ind
}
"-ok" {
incr ind
set _open [lindex $args $ind]
incr ind
}
"-cancel" {
incr ind
set _cancel [lindex $args $ind]
incr ind
}
"-label" {
incr ind
set _ldir [lindex $args $ind]
incr ind
}
"-nofiles" {
set tk_getDirectory(showfiles) 0
incr ind
}
default {
puts "unknown option [lindex $args $ind]"
return ""
}
}
}
set tk_getDirectory(fini) 0
if {![info exists tk_getDirectory:b_up]} {
image create photo tk_getDirectory:b_up -data {\
R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\
/wD//////yH5BAEAAAgALAAAAAAQABAAQwQ4EMlJKwJvZaB7fsD1eSQolmV4kaqFaUA8fuG7\
xTht7S7e9r4gTsKhzTo1mO+YNKKaqFFNSP3xKhEAOw==}
image create photo tk_getDirectory:b_new -data {\
R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\
/wD//////yH5BAEAAAgALAAAAAAQABAAQwQ1EMlJKwJv5a0BsNVHiZhmbiKohid5jVzsXl5t\
p+uE569lS5+g7vZ7BU9IIRDJ2QGYph2vEgEAOw==}
image create photo tk_getDirectory:b_dir -data {\
R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\
/wD//////yH5BAEAAA4ALAAAAAAQABAAQwQ+0MlJqzsPLc33PsD1jGQ5gtehruwaXh1yWBIW\
exxq47z80sAaK3i4yVq1R4+nUxo9zWUn+tSgHICsdrsNAiMAOw==}
image create photo tk_getDirectory:b_file -data {\
R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A\
/wD//////yH5BAEAAAgALAAAAAAQABAAQwQ3EMlJ6wTvkb0zqJjWfR+Ycd1TXkDrrqZIZF6M\
zir47rDlUyGaqicJ0l4x4TGpzAGbyyfU+atGAAA7}
image create bitmap tk_getDirectory:b_down -data "
#define down_width 13
#define down_height 10
static unsigned char down_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xfe, 0x0f, 0xfc, 0x07, 0xf8, 0x03, 0xf0, 0x01,
0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00};"
}
set w .dirsel
catch {destroy $w}
toplevel $w
wm geometry $w 420x220
wm title $w $_titre
if {$_parent == "" || ![winfo exists $_parent]} {
set _parent [winfo toplevel [winfo parent $w]]
} else {
set _parent [winfo toplevel $_parent]
}
wm transient $w $_parent
frame $w.f1 -relief flat -borderwidth 0
frame $w.f2 -relief sunken -borderwidth 1
frame $w.f3 -relief flat -borderwidth 0
pack $w.f1 -fill x -padx 6 -pady 5
pack $w.f2 -fill both -expand 1 -padx 6
pack $w.f3 -fill x -padx 6 -pady 3
label $w.f1.lab -text "Look In:"
frame $w.f1.dir -relief sunken -bd 2
entry $w.f1.dir.ent -relief flat -textvariable tk_getDirectory(curdir) \
-state disabled -cursor {}
menubutton $w.f1.dir.but -relief raised -image tk_getDirectory:b_down \
-menu $w.f1.dir.but.m -direction left
menu $w.f1.dir.but.m -tearoff 0
pack $w.f1.dir.ent -side left -fill x -expand 1
pack $w.f1.dir.but -side right -fill y
button $w.f1.up -image tk_getDirectory:b_up \
-command "tk_getDirectory:UpDir $w"
button $w.f1.new -image tk_getDirectory:b_new \
-command "tk_getDirectory:NewDir $w"
pack $w.f1.lab -side left
pack $w.f1.dir -side left -fill x -expand 1
pack $w.f1.new -side right
pack $w.f1.up -side right -padx 8
bind $w.f1.dir.but <1> "tk_getDirectory:Menu $w"
bind $w.f1.dir.ent <1> "tk_getDirectory:Menu $w;$w.f1.dir.but.m post %X %Y"
canvas $w.f2.cv -borderwidth 0 -xscrollcommand "$w.f2.sb set" \
-height 10 -bg white
scrollbar $w.f2.sb -command "$w.f2.cv xview" -orient horizontal
pack $w.f2.cv -side top -fill both -expand 1
pack $w.f2.sb -side top -fill x
$w.f2.cv bind TXT <Any-Button> "tk_getDirectory:HighlightItem $w"
$w.f2.cv bind IMG <Any-Button> "tk_getDirectory:HighlightItem $w"
$w.f2.cv bind TXT <Any-Double-Button> "tk_getDirectory:ClickItem $w"
$w.f2.cv bind IMG <Any-Double-Button> "tk_getDirectory:ClickItem $w"
label $w.f3.lab -text $_ldir
entry $w.f3.ent -relief sunken -textvariable tk_getDirectory(seldir) \
-state disabled -cursor {}
pack $w.f3.lab -side left
pack $w.f3.ent -side left -fill x -expand 1
set width [string length $_open]
if {$width < [string length $_cancel]} {
set width [string length $_cancel]
}
if {$tcl_platform(platform) == "windows"} {
button $w.f3.open -width $width -text $_open -pady 0 \
-default active -command {set tk_getDirectory(fini) 1}
button $w.f3.cancel -width $width -text $_cancel -pady 0 \
-command {set tk_getDirectory(fini) 0}
} else {
button $w.f3.open -width $width -text $_open \
-default active -command {set tk_getDirectory(fini) 1}
button $w.f3.cancel -width $width -text $_cancel \
-command {set tk_getDirectory(fini) 0}
}
pack $w.f3.cancel -side right
pack $w.f3.open -side right -padx 8
bind $w <Return> "$w.f3.open flash; set tk_getDirectory(fini) 1"
set oldFocus [focus]
set oldGrab [grab current $w]
if {$oldGrab != ""} {
set grabStatus [grab status $oldGrab]
}
catch {grab $w}
if {[winfo ismapped $_parent]} {
wm withdraw $w
wm geometry $w "+[winfo rootx $_parent]+[winfo rooty $_parent]"
update idletasks
wm deiconify $w
}
update
tk_getDirectory:ShowDir $w $tk_getDirectory(curdir)
focus -force $w
tkwait variable tk_getDirectory(fini)
if { $tk_getDirectory(fini) == 1 } {
set retval [eval file join [file split $tk_getDirectory(curdir)] \
$tk_getDirectory(seldir)]
} else {
set retval ""
}
catch {focus $oldFocus}
destroy $w
if {$oldGrab != ""} {
if {$grabStatus == "global"} {
grab -global $oldGrab
} else {
grab $oldGrab
}
}
return $retval
}
proc tk_getDirectory:ShowDir {w curdir} {
global tk_getDirectory
set tk_getDirectory(curdir) $curdir
$w.f1.dir.ent xview moveto 1.0
set wi [expr [image width tk_getDirectory:b_dir] + 3]
set hi [image height tk_getDirectory:b_dir]
set maxy [expr [winfo height $w.f2.cv]-$hi]
set lidir [list]
set lifile [list]
foreach file [glob -nocomplain $curdir/*] {
if [ file isdirectory $file ] {
lappend lidir [file tail $file]
} else {
lappend lifile [file tail $file]
}
}
set sldir [lsort $lidir]
$w.f2.cv delete all
set ind 0
set x 2
set y 2
foreach file $sldir {
$w.f2.cv create image $x $y -anchor nw \
-image tk_getDirectory:b_dir -tags IMG
$w.f2.cv create text [expr $x+$wi] $y -anchor nw -text $file -tags TXT
incr y $hi
if {$y >= $maxy} {
set bbox [$w.f2.cv bbox all]
set x [expr [lindex $bbox 2]+10]
set y 2
}
}
if {$tk_getDirectory(showfiles)} {
foreach file [lsort $lifile] {
$w.f2.cv create image $x $y -anchor nw -image tk_getDirectory:b_file
$w.f2.cv create text [expr $x+$wi] $y -anchor nw -text $file
incr y $hi
if {$y >= $maxy} {
set bbox [$w.f2.cv bbox all]
set x [expr [lindex $bbox 2]+10]
set y 2
}
}
}
$w.f2.cv configure -scrollregion [$w.f2.cv bbox all]
set tk_getDirectory(seldir) ""
}
proc tk_getDirectory:UpDir {w} {
global tk_getDirectory
set curdir $tk_getDirectory(curdir)
set curlst [file split $curdir]
set nbr [llength $curlst]
if {$nbr < 2} return
set tmp [expr $nbr - 2]
set newlst [ lrange $curlst 0 $tmp ]
set newdir [ eval file join $newlst ]
tk_getDirectory:ShowDir $w $newdir
}
proc tk_getDirectory:HighlightItem {w} {
global tk_getDirectory
catch {$w.f2.cv select clear}
set id [$w.f2.cv find withtag current]
if {[$w.f2.cv type $id] != "text"} {incr id}
$w.f2.cv select from $id 0
$w.f2.cv select to $id end
set tk_getDirectory(seldir) [$w.f2.cv itemcget $id -text]
}
proc tk_getDirectory:ClickItem {w} {
global tk_getDirectory
set id [$w.f2.cv find withtag current]
if {[$w.f2.cv type $id] != "text"} {incr id}
set dir [$w.f2.cv itemcget $id -text]
if {[string length $dir]==0} return
tk_getDirectory:ShowDir $w [file join $tk_getDirectory(curdir) $dir]
}
proc tk_getDirectory:Menu {w} {
global tk_getDirectory tcl_platform
if {![info exist tk_getDirectory(drives)]} {
if {$tcl_platform(platform) == "unix" ||
[catch {file volume} tk_getDirectory(drives)]} {
set tk_getDirectory(drives) {}
}
if {$tcl_platform(platform) == "windows"} {
set tk_getDirectory(drives) [string toupper $tk_getDirectory(drives)]
}
}
set curlst [file split $tk_getDirectory(curdir)]
set nbr [llength $curlst]
$w.f1.dir.but.m delete 0 last
incr nbr -2
set tmpdir {}
for {set ind $nbr} {$ind >= 0} {incr ind -1} {
set tmplst [ lrange $curlst 0 $ind]
set tmpdir [ eval file join $tmplst]
$w.f1.dir.but.m add command -label $tmpdir \
-command "tk_getDirectory:ShowDir $w [list $tmpdir]"
}
set rootdir [string toupper $tmpdir]
foreach drive $tk_getDirectory(drives) {
if {$drive != $rootdir} {
$w.f1.dir.but.m add command -label $drive \
-command "tk_getDirectory:ShowDir $w [list $drive]"
}
}
}
proc tk_getDirectory:NewDir {wref} {
global tcl_platform tk_getDirectory
set w .newdir
catch {destroy $w}
toplevel $w
wm title $w "New Folder"
wm transient $w $wref
set f [frame $w.name]
pack $f -side top -fill x -padx 5 -pady 5
label $f.lab -text "Name:"
pack $f.lab -side left
entry $f.ent -width 30
pack $f.ent -side left -fill x -expand 1
$f.ent insert 0 "New Folder"
set f [frame $w.but]
pack $f -side bottom -fill x -padx 5 -pady 5
button $f.accept -text Ok -width 6 -default active \
-command {set tk_getDirectory(newdir) 1}
bind $w <Return> "
$f.accept flash
set tk_getDirectory(newdir) 1
"
button $f.cancel -text Cancel -width 6 \
-command {set tk_getDirectory(newdir) 0}
pack $f.accept $f.cancel -side left -expand 1
if {$tcl_platform(platform) == "windows"} {
$f.accept configure -pady 0
$f.cancel configure -pady 0
}
wm withdraw $w
wm geometry $w \
"+[expr [winfo rootx $wref.f2.cv]+20]+[expr [winfo rooty $wref.f2.cv]+5]"
update idletasks
wm deiconify $w
set oldFocus [focus]
set oldGrab [grab current $w]
if {$oldGrab != ""} {
set grabStatus [grab status $oldGrab]
}
catch {grab $w}
tkwait visibility $w
$w.name.ent selection range 0 end
focus $w.name.ent
tkwait variable tk_getDirectory(newdir)
if {$tk_getDirectory(newdir)} {
set newdir "$tk_getDirectory(curdir)/[string trim [$w.name.ent get]]"
} else {
set newdir {}
}
catch {focus $oldFocus}
destroy $w
if {$oldGrab != ""} {
if {$grabStatus == "global"} {
grab -global $oldGrab
} else {
grab $oldGrab
}
}
if {$newdir != ""} {
if {[catch {file mkdir $newdir} msg]} {
tk_dialog .error Error $msg error 0 Ok
} else {
tk_getDirectory:ShowDir $wref $tk_getDirectory(curdir)
}
}
}
|