Changeset 775 for trunk/gsascmds.tcl


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

# on 2004/01/30 00:50:00, toby did:
Add code to set app/icon in OS X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 2004/01/30 00:41:47 to 2004/01/30 00:50:00
    • Property rcs:lines changed from +26 -19 to +42 -1
    • Property rcs:rev changed from 1.54 to 1.55
    r772 r775  
    12661266    # now save the file
    12671267    expwrite $expgui(expfile)
     1268    # change the icon and assign an app to this .EXP file
     1269    global tcl_platform
     1270    if {$tcl_platform(os) == "Darwin" && $expgui(MacAssignApp)} {
     1271        MacSetResourceFork $expgui(expfile)
     1272    }
    12681273    set expgui(changed) 0
    12691274    set expgui(expModifiedLast) [file mtime $expgui(expfile)]
     
    25352540    }
    25362541}
     2542
     2543# modify resource fork info for a .EXP file on the Mac
     2544proc MacSetResourceFork {expfile} {
     2545    global expgui tcl_platform
     2546    if {$tcl_platform(os) != "Darwin"} {return}
     2547    set expnative [file nativename $expfile]
     2548    #
     2549    # assign an app to the data file, if the app and the
     2550    # required tool (Rez) are installed
     2551    set app [file join $expgui(gsasdir) expgui.app]
     2552    if {[file exists $app] && [file exists /Developer/Tools/Rez]} {
     2553        # make a resource file
     2554        set l [string length $app]; incr l
     2555        set str "data 'usro' (0) {\n"
     2556        append str {  $"}
     2557        append str [format %.8X $l]
     2558        foreach char [split $app {}] {
     2559           append str [format %.2X [scan $char %c]]   
     2560        }
     2561        append str {00"}
     2562        append str " \t/* ....$app. */\n};"
     2563        set fp [open setapp.r w]
     2564        puts $fp $str
     2565        close $fp
     2566        exec /Developer/Tools/Rez setapp.r -o $expnative -a
     2567        file delete -force setapp.r
     2568    }
     2569
     2570    # assign an icon to the data file, if it and the required tools exist
     2571    set icon [file join $expgui(gsasdir) gsasicon.r]
     2572    if {[file exists $icon] && [file exists /Developer/Tools/Rez] && \
     2573            [file exists /Developer/Tools/SetFile]} {
     2574        exec /Developer/Tools/Rez [file nativename $icon] -o $expnative -a
     2575        exec /Developer/Tools/SetFile -a C $expnative
     2576    }
     2577}
Note: See TracChangeset for help on using the changeset viewer.