Changeset 760


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

# on 2003/12/05 13:00:13, toby did:
add file menu command to create applescript shortcut (OSX only)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expgui

    • Property rcs:date changed from 2003/11/22 00:50:56 to 2003/12/05 13:00:13
    • Property rcs:lines changed from +3 -3 to +39 -2
    • Property rcs:rev changed from 1.65 to 1.66
    r757 r760  
    608608}
    609609
     610proc MakeAppleScript {} {
     611    global wishshell expgui
     612    # create a local script directory, if it does not exist
     613    if {![file exists ~/Library/Scripts]} {file mkdir  ~/Library/Scripts}
     614    set dir [file nativename  ~/Library/Scripts]
     615    set file [tk_getSaveFile -initialdir $dir -initialfile EXPGUI.scpt]
     616    set tmpfile [file nativename ~/tmpscriptfile]
     617    set fp [open $tmpfile w]
     618    # the applescript starts here
     619    puts $fp {on run}
     620    puts $fp {  tell application "Finder"}
     621    puts $fp {     launch application "X11"}
     622    puts $fp {   end tell}
     623    puts $fp "  set results to do shell script \"cd ~; DISPLAY=:0.0; export DISPLAY; $wishshell $expgui(script)  > /dev/null 2>&1 &\""
     624    puts $fp {end run}
     625    # someday, perhaps we can get drag & drop to work
     626    #puts $fp {on open}
     627    #puts $fp {  -- need to get file name and incorporate into command line}
     628    #puts $fp {end open}
     629    close $fp
     630    if {[catch {
     631        exec osacompile -l AppleScript -o $file  $tmpfile
     632        file delete -force $tmpfile
     633        MyMessageBox -parent . -title "AppleScript created" \
     634            -message "Script $file created & compiled. You may wish to use the Script Editor to save this as an application" \
     635            -icon "info" -type OK -default ok
     636#           -helplink "expguierr.html Customizewarning"
     637    } errmsg]} {
     638        MyMessageBox -parent . -title "AppleScript warning" \
     639        -message "An error occurred while atempting to create the script. Details:\n$errmsg"\
     640            -icon warning -type Ignore -default ignore
     641#       -helplink "expguierr.html Customizewarning"
     642    }
     643}
    610644# this proc gets called when the export coordinate button is pressed
    611645# it loads export
     
    42224256}
    42234257
     4258if {$tcl_platform(os) == "Darwin"} {
     4259    $expgui(fm).file.menu add command -label "Create AppleScript" -command MakeAppleScript
     4260}
    42244261$expgui(fm).file.menu add command -label "Exit"  -underline 1 -command catchQuit
    42254262foreach c {X x} {bind . <Alt-$c> [list catchQuit]}
Note: See TracChangeset for help on using the changeset viewer.