Changeset 72


Ignore:
Timestamp:
Dec 4, 2009 4:59:56 PM (13 years ago)
Author:
toby
Message:

# on 1999/03/19 17:07:59, toby did:
rename file directory routines
make file menus smarter w/r to windows usage
fix bug with spaces in filenames

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 1999/02/19 18:18:23 to 1999/03/19 17:07:59
    • Property rcs:lines changed from +3 -4 to +53 -35
    • Property rcs:rev changed from 1.9 to 1.10
    r62 r72  
    696696    pack [frame [set frmA $frm.1] -bd 2 -relief groove] -padx 3 -pady 3 -side left
    697697    pack [frame [set frmC $frm.3] ] -padx 3 -pady 3 -side left
    698     pack [button $frmC.b -text Convert -command "valid_conv_win $frm"] \
     698    pack [button $frmC.b -text Convert -command "ValidWinCnv $frm"] \
    699699            -side top
    700700    pack [button $frmC.q -text Quit -command "destroy $frm"] -side top
    701701    pack [label $frmA.0 -text "Select a file to convert"] -side top -anchor center
    702     winfilebox $frmA
     702    winfilebox $frm
    703703    # force the window to stay on top
    704704    wm transient $frm [winfo toplevel [winfo parent $frm]]
    705705
    706     bind $frm <Return> "valid_conv_win $frm"
     706    bind $frm <Return> "ValidWinCnv $frm"
    707707    wm withdraw $frm
    708708    update idletasks
     
    734734
    735735# validate the files and make the conversion
    736 proc valid_conv_win {frm} {
     736proc ValidWinCnv {frm} {
    737737    global expgui
     738    # change backslashes to something sensible
     739    regsub -all {\\} $expgui(FileMenuCnvName) / expgui(FileMenuCnvName)
     740    # allow entry of D: for D:/ and D:TEST for d:/TEST
     741    if {[string first : $expgui(FileMenuCnvName)] != -1 && \
     742            [string first :/ $expgui(FileMenuCnvName)] == -1} {
     743        regsub : $expgui(FileMenuCnvName) :/ expgui(FileMenuCnvName)
     744    }
    738745    if {$expgui(FileMenuCnvName) == "<Parent>"} {
    739746        set expgui(FileMenuDir) [file dirname [set expgui(FileMenuDir)] ]
    740         ChooseCnvFil $frm
     747        ChooseWinCnv $frm
    741748        return
    742749    } elseif [file isdirectory \
     
    746753                [file join $expgui(FileMenuDir) $expgui(FileMenuCnvName)]
    747754        }
    748         ChooseCnvFil $frm
     755        ChooseWinCnv $frm
    749756        return
    750757    }
     
    803810
    804811# create a file box
    805 proc winfilebox {bx} {
     812proc winfilebox {frm} {
    806813    global expgui
     814    set bx $frm.1
    807815    pack [frame $bx.top] -side top
    808816    pack [label $bx.top.a -text "Directory" ] -side left
     
    823831
    824832    pack [button $bx.top.b -image $upfolder \
    825             -command "updir; ChooseCnvFil $bx" ]
     833            -command "updir; ChooseWinCnv $frm" ]
    826834    pack [frame $bx.a -width 200 -height 75] -side top -expand yes -fill both
    827835    listbox $bx.a.files -relief raised -bd 2 \
     
    832840            -height 15 -width 0 -takefocus 0
    833841    scrollbar $bx.a.scroll -command "move2boxesY \" $bx.a.files $bx.a.dates \" "
    834     ChooseCnvFil $bx
    835     bind $bx.a.files <ButtonRelease-1> "ReleaseCnvFil $bx"
    836     bind $bx.a.dates <ButtonRelease-1> "ReleaseCnvFil $bx"
    837     bind $bx.a.files <Double-1> "SelectCnvFil $bx"
    838     bind $bx.a.dates <Double-1> "SelectCnvFil $bx"
     842    ChooseWinCnv $frm
     843    bind $bx.a.files <ButtonRelease-1> "ReleaseWinCnv $frm"
     844    bind $bx.a.dates <ButtonRelease-1> "ReleaseWinCnv $frm"
     845    bind $bx.a.files <Double-1> "SelectWinCnv $frm"
     846    bind $bx.a.dates <Double-1> "SelectWinCnv $frm"
    839847    pack $bx.a.scroll -side left -fill y
    840848    pack $bx.a.files $bx.a.dates -side left -fill both -expand yes
     
    843851
    844852# set the box or file in the selection window
    845 proc ReleaseCnvFil {frm} {
     853proc ReleaseWinCnv {frm} {
    846854    global expgui
    847     set files $frm.a.files
    848     set dates $frm.a.dates
     855    set files $frm.1.a.files
     856    set dates $frm.1.a.dates
    849857    set select [$files curselection]
    850858    if {$select == ""} {
     
    858866    if {$expgui(FileMenuCnvName) == "<Parent>"} {
    859867        set expgui(FileMenuDir) [file dirname $expgui(FileMenuDir)]
    860         ChooseCnvFil $frm
     868        ChooseWinCnv $frm
    861869    } elseif [file isdirectory \
    862870            [file join [set expgui(FileMenuDir)] $expgui(FileMenuCnvName)]] {
    863871        if {$expgui(FileMenuCnvName) != "."} {
    864872            set expgui(FileMenuDir) [file join $expgui(FileMenuDir) $expgui(FileMenuCnvName)]
    865             ChooseCnvFil $frm
     873            ChooseWinCnv $frm
    866874        }
    867875    }
     
    870878
    871879# select a file or directory -- called on double click
    872 proc SelectCnvFil {frm} {
     880proc SelectWinCnv {frm} {
    873881    global expgui
    874     set files $frm.a.files
    875     set dates $frm.a.dates
     882    set files $frm.1.a.files
     883    set dates $frm.1.a.dates
    876884    set select [$files curselection]
    877885    if {$select == ""} {
     
    885893    if {$file == "<Parent>"} {
    886894        set expgui(FileMenuDir) [file dirname [set expgui(FileMenuDir)] ]
    887         ChooseCnvFil $frm
     895        ChooseWinCnv $frm
    888896    } elseif [file isdirectory [file join [set expgui(FileMenuDir)] $file]] {
    889897        if {$file != "."} {
    890898            set expgui(FileMenuDir) [file join [set expgui(FileMenuDir)] $file]
    891             ChooseCnvFil $frm
     899            ChooseWinCnv $frm
    892900        }
    893901    } else {
    894902        set expgui(FileMenuCnvName) [file tail $file]
    895         valid_conv_win $frm
     903        ValidWinCnv $frm
    896904    }
    897905}
     
    899907# fill the files & dates & Directory selection box with current directory,
    900908# also called when box is created to fill it
    901 proc ChooseCnvFil {frm} {
     909proc ChooseWinCnv {frm} {
    902910    global expgui
    903     set files $frm.a.files
    904     set dates $frm.a.dates
     911    set files $frm.1.a.files
     912    set dates $frm.1.a.dates
    905913    set expgui(FileMenuCnvName) {}
    906914    $files delete 0 end
     
    917925    }
    918926    foreach file [lsort $filelist] {
    919         set modified [file mtime $file]
    920         set modified [clock format [file mtime $file] -format "%T %D"]
    921         $files insert end [file tail $file]
    922         $dates insert end $modified
     927        if {![file isdirectory $file]} {
     928            set modified [clock format [file mtime $file] -format "%T %D"]
     929            $files insert end [file tail $file]
     930            $dates insert end $modified
     931        }
    923932    }
    924933    $expgui(FileDirButtonMenu)  delete 0 end
     
    932941        $expgui(FileDirButtonMenu) add command -label $path \
    933942                -command "[list set expgui(FileMenuDir) $path]; \
    934                 ChooseCnvFil $frm"
     943                ChooseWinCnv $frm"
    935944    }
    936945    return
     
    10511060# validation routine
    10521061proc valid_exp_file {frm mode} {
    1053     global expgui
     1062    global expgui tcl_platform
     1063    # windows fixes
     1064    if {$tcl_platform(platform) == "windows"} {
     1065        # change backslashes to something sensible
     1066        regsub -all {\\} $expgui(FileMenuEXPNAM) / expgui(FileMenuEXPNAM)
     1067        # allow entry of D: for D:/ and D:TEST for d:/TEST
     1068        if {[string first : $expgui(FileMenuEXPNAM)] != -1 && \
     1069                [string first :/ $expgui(FileMenuEXPNAM)] == -1} {
     1070            regsub : $expgui(FileMenuEXPNAM) :/ expgui(FileMenuEXPNAM)
     1071        }
     1072    }
    10541073    if {$expgui(FileMenuEXPNAM) == "<Parent>"} {
    10551074        set expgui(FileMenuDir) [file dirname [set expgui(FileMenuDir)] ]
     
    12261245                [string toupper [file extension $file]] == ".EXP"} {
    12271246            set modified [file mtime $file]
    1228             lappend pairlist "$file $modified"
     1247            lappend pairlist [list $file $modified]
    12291248        }
    12301249    }
     
    12651284    return
    12661285}
    1267 
Note: See TracChangeset for help on using the changeset viewer.