Changeset 749 for trunk


Ignore:
Timestamp:
Dec 4, 2009 5:11:22 PM (13 years ago)
Author:
toby
Message:

# on 2003/11/13 17:21:17, toby did:
remove obsolete references to tkButtonInvoke
add code to support URL lookup in OSX & clean up for UNIX
don't allow archived files on initial open
fix parse of .EXP file for >999 LS cycles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 2003/11/05 22:16:55 to 2003/11/13 17:21:17
    • Property rcs:lines changed from +10 -4 to +75 -60
    • Property rcs:rev changed from 1.52 to 1.53
    r742 r749  
    227227
    228228    if {[string compare $data(-default) ""]} {
    229       bind $w <Return> [list tkButtonInvoke $w.[string tolower $data(-default)]]
     229      bind $w <Return> [list $w.[string tolower $data(-default)] invoke]
    230230    }
    231231
     
    858858proc urlOpen {url} {
    859859    global env tcl_platform
    860     switch $tcl_platform(platform) {
    861         "unix" {
    862             if {![info exists env(BROWSER)]} {
    863                 set progs [auto_execok netscape]
    864                 if {[llength $progs]} {
    865                     set env(BROWSER) [list $progs]
    866                 }
    867             }
    868             if {![info exists env(BROWSER)]} {
    869                 set progs [auto_execok mozilla]
    870                 if {[llength $progs]} {
    871                     set env(BROWSER) [list $progs]
    872                 }
    873             }
    874             if {[info exists env(BROWSER)]} {
    875                 if {[catch {exec $env(BROWSER) -remote openURL($url)}]} {
     860    if {$tcl_platform(os) == "Darwin"} {
     861        # if this is an external URL or does not contain an anchor, take the
     862        # easy approach
     863        if {[string range $url 0 4] == "http:" || \
     864                [string first "#" $url] == -1} {
     865            if {![catch {exec open $url}]} {
     866                return
     867            }
     868        }
     869        # so sorry, have to use Internet Explorer
     870        set url [file nativename $url]; # replace ~/ if present
     871        if {[file pathtype $url] == "relative"} {
     872            set url [file join [pwd] $url]
     873        }
     874        exec osascript -e "tell application \"Internet Explorer\"\rGetURL \"file://$url\"\rend tell"
     875    } elseif {$tcl_platform(platform) == "unix"} {
     876        set browserlist {}
     877        if {[info exists env(BROWSER)]} {
     878            set browserlist $env(BROWSER)
     879        }
     880        lappend browserlist netscape mozilla
     881        foreach p $browserlist {
     882            set progs [auto_execok $p]
     883            if {[llength $progs]} {
     884                if {[catch {exec $progs -remote openURL($url)}]} {
    876885                    # perhaps browser doesn't understand -remote flag
    877886                    if {[catch {exec $env(BROWSER) $url &} emsg]} {
     
    879888                    }
    880889                }
    881             } else {
    882                 MyMessageBox -parent . -title "No Browser" \
    883                         -message "Could not find a browser. Netscape is not in path. Define environment variable BROWSER to be full path name of browser." \
    884                         -icon warning
    885             }
    886         }
    887         "windows" {
    888             package require registry
    889             # Look for the application under
    890             # HKEY_CLASSES_ROOT
    891             set root HKEY_CLASSES_ROOT
    892 
    893             # Get the application key for HTML files
    894             set appKey [registry get $root\\.html ""]
    895 
    896             # Get the command for opening HTML files
    897             set appCmd [registry get \
    898                     $root\\$appKey\\shell\\open\\command ""]
    899 
    900             # Substitute the HTML filename into the command for %1
    901             # or stick it on the end
    902             if {[string first %1 $appCmd] != -1} {
    903                 regsub %1 $appCmd $url appCmd
    904             } else {
    905                 append appCmd " " $url
    906             }
    907            
    908             # Double up the backslashes for eval (below)
    909             regsub -all {\\} $appCmd  {\\\\} appCmd
    910            
    911             # Invoke the command
    912             eval exec $appCmd &
    913         }
    914         "macintosh" {
    915             if {0 == [info exists env(BROWSER)]} {
    916                 set env(BROWSER) "Browse the Internet"
    917             }
    918             if {[catch {
    919                 AppleScript execute\
    920                     "tell application \"$env(BROWSER)\"
     890                return
     891            }
     892        }
     893        MyMessageBox -parent . -title "No Browser" \
     894            -message "Could not find a browser. Netscape & Mozilla not found. Define environment variable BROWSER to be full path name of browser." \
     895            -icon warning
     896    } elseif {$tcl_platform(platform) == "windows"} {
     897        package require registry
     898        # Look for the application under
     899        # HKEY_CLASSES_ROOT
     900        set root HKEY_CLASSES_ROOT
     901       
     902        # Get the application key for HTML files
     903        set appKey [registry get $root\\.html ""]
     904       
     905        # Get the command for opening HTML files
     906        set appCmd [registry get \
     907                        $root\\$appKey\\shell\\open\\command ""]
     908
     909        # Substitute the HTML filename into the command for %1
     910        # or stick it on the end
     911        if {[string first %1 $appCmd] != -1} {
     912            regsub %1 $appCmd $url appCmd
     913        } else {
     914            append appCmd " " $url
     915        }
     916       
     917        # Double up the backslashes for eval (below)
     918        regsub -all {\\} $appCmd  {\\\\} appCmd
     919       
     920        # Invoke the command
     921        eval exec $appCmd &
     922    } elseif {$tcl_platform(platform) == "macintosh"} {
     923        # preOSX -- this is not used
     924        if {0 == [info exists env(BROWSER)]} {
     925            set env(BROWSER) "Browse the Internet"
     926        }
     927        if {[catch {
     928            AppleScript execute\
     929                "tell application \"$env(BROWSER)\"
    921930                         open url \"$url\"
    922931                     end tell
    923932                "} emsg]
    924             } then {
    925                 error "Error displaying $url in browser\n$emsg"
    926             }
    927         }
     933        } then {
     934            error "Error displaying $url in browser\n$emsg"
     935        }
    928936    }
    929937}
    930938
    931939proc NetHelp {file anchor localloc netloc} {
     940    # use the file on-line, if it exists
    932941    if {[file exists [file join $localloc $file]]} {
    933942        set url "[file join $localloc $file]"
     
    17731782                -class SmallFont] \
    17741783                -side top -fill both -expand yes -pady 5
     1784    } elseif {$mode != "new"} {
     1785        # for initial read, don't access archived files
     1786        pack [frame $expgui(FileInfoBox) -bd 4 -relief groove \
     1787                -class SmallFont] \
     1788                -side top -fill both -expand yes -pady 5
     1789        set mode "old"
    17751790    }
    17761791    pack [button $frmC.b -text Read \
     
    21692184            close $fp
    21702185            update
    2171             regexp {GNLS  RUN on (.*) +Total.*run +([0-9]+) } \
     2186            regexp {GNLS  RUN on (.*) +Total.*run *([0-9]+) } \
    21722187                    $testline a last cycles
    21732188            pack [label $expgui(FileInfoBox).2 -justify left \
Note: See TracChangeset for help on using the changeset viewer.