Debian Codegraph @

packaging/macosx/support/template.applescript

raw
1 on run -- for testing in script editor
2 process_disk_image("Adium X 1.0b20", "/Users/evands/adium-1.0/Release/Artwork")
3 end run
4
5 on process_disk_image(volumeName)
6 tell application "Finder"
7 tell disk (volumeName as string)
8 open
9
10 set theXOrigin to WINX
11 set theYOrigin to WINY
12 set theWidth to WINW
13 set theHeight to WINH
14
15 set theBottomRightX to (theXOrigin + theWidth)
16 set theBottomRightY to (theYOrigin + theHeight)
17 set dsStore to "\"" & "/Volumes/" & volumeName & "/" & ".DS_STORE\""
18 -- do shell script "rm " & dsStore
19
20 tell container window
21 set current view to icon view
22 set toolbar visible to false
23 set statusbar visible to false
24 set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
25 set statusbar visible to false
26 end tell
27
28 set opts to the icon view options of container window
29 tell opts
30 set icon size to ICON_SIZE
31 set arrangement to not arranged
32 end tell
33 -- set background picture of opts to file ".background:background.png"
34 BACKGROUND_CLAUSE
35
36 -- Positioning
37 POSITION_CLAUSE
38 -- set position of item "Adium.app" to {196, 273}
39
40 -- Custom icons
41 -- my copyIconOfTo(artPath & "/ApplicationsIcon", "/Volumes/" & volumeName & "/Applications")
42
43 -- Label colors
44 -- set label index of item "Adium.app" to 6
45 -- set label index of item "License.txt" to 7
46 -- set label index of item "Changes.txt" to 7
47 -- set label index of item "Applications" to 4
48
49 update without registering applications
50 -- Force saving of the size
51 delay 1
52
53 tell container window
54 set statusbar visible to false
55 set the bounds to {theXOrigin, theYOrigin, theBottomRightX - 10, theBottomRightY - 10}
56 end tell
57
58 update without registering applications
59 end tell
60
61 delay 1
62
63 tell disk (volumeName as string)
64 tell container window
65 set statusbar visible to false
66 set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
67 end tell
68
69 update without registering applications
70 end tell
71
72 --give the finder some time to write the .DS_Store file
73 delay 3
74
75 set waitTime to 0
76 set ejectMe to false
77 repeat while ejectMe is false
78 delay 1
79 set waitTime to waitTime + 1
80
81 if (do shell script "[ -f " & dsStore & " ]; echo $?") = "0" then set ejectMe to true
82 end repeat
83 log "waited " & waitTime & " seconds for .DS_STORE to be created."
84 end tell
85 end process_disk_image
86
87 on copyIconOfTo(aFileOrFolderWithIcon, aFileOrFolder)
88 tell application "Finder" to set f to POSIX file aFileOrFolderWithIcon as alias
89 -- grab the file's icon
90 my CopyOrPaste(f, "c")
91 -- now the icon is in the clipboard
92 tell application "Finder" to set c to POSIX file aFileOrFolder as alias
93 my CopyOrPaste(result, "v")
94 end copyIconOfTo
95
96 on CopyOrPaste(i, cv)
97 tell application "Finder"
98 activate
99 open information window of i
100 end tell
101 tell application "System Events" to tell process "Finder" to tell window 1
102 keystroke tab -- select icon button
103 keystroke (cv & "w") using command down (* (copy or paste) + close window *)
104 end tell -- window 1 then process Finder then System Events
105 end CopyOrPaste