|
ClipArt Code
From NeoWiki
(Difference between revisions)
Revision as of 02:41, 4 August 2006 (edit) ( | contribs) (added quoted forms) ← Previous diff |
Revision as of 05:24, 4 August 2006 (edit) (undo) Sardisson (Talk | contribs) m (categories) Next diff → |
||
Line 152: | Line 152: | ||
</pre> | </pre> | ||
+ | [[Category:NeoOffice]][[Category:Contributing]] |
Revision as of 05:24, 4 August 2006
(will make this pretty later - the white rabbit)
-- clipart.applescript -- clipart -- Created by Jacob Haddon on 7/31/06. -- this will install a folder into the 'gallery' of OO.o on run writePref(userPref()) --display dialog readPref() end run on idle (* Add any idle time processing here. *) end idle on open names checkPref() openFiles(names) display dialog "You have installed " & names & "!" quit end open ---- subroutines ---- -- unzipFile -- this unzips the .zip file into the gallery -- input f is name of .zip file on unzipFile(f) set gallery to pathToGallery() display dialog gallery display dialog f set thisscript to "unzip " & f & " -d " & gallery --set rmscript to "rm -r" & gallery & "/__MACOSX" do shell script thisscript with administrator privileges end unzipFile -- pathToGallery -- gets the path to the gallery -- this is where the output of the unzip will go on pathToGallery() -- path to neo -- set gallery to "/Applications/NeoOffice.app/Contents/share/gallery" -- path to oo.ox11 -- set gallery to "/Applications/OpenOffice.org\\ 2.0.app/Contents/openoffice.org2.0/share/gallery" --tell application "Finder" to set j to POSIX path of (application file id "org.neooffice.neooffice" as string) set k to "/Contents/share/gallery" set l to "/Contents/openoffice.org2.0/share/gallery" set qq to readPref() if qq = "NeoOffice" then -- if statement to decide Neo or OO.o tell application "Finder" to set j to POSIX path of (application file id "org.neooffice.neooffice" as string) set m to quoted form of j & k -- for neo else if qq = "OpenOffice.org" then tell application "Finder" to set j to POSIX path of (application file id "org.openoffice.script" as string) set m to quoted form of j & l -- for oo.o else display dialog "Your Preferences are not set" end if return m end pathToGallery -- openFiles -- taken from openoffice.org.app applescript LPGL -- goes through any dropped files and addes them to the gallery on openFiles(fileList) if (count of fileList) > 0 then repeat with i from 1 to the count of fileList set theDocument to (item i of fileList) set theFilePath to " \"" & (POSIX path of theDocument) & "\"" set theFileInfo to (info for theDocument) unzipFile(theFilePath) end repeat end if end openFiles -- getZipNames -- this gets the names of the zip files in the app on getZipNames() set a to POSIX path of (path to me) as string --display dialog a set next to "Contents/Resources/zipfiles" set test to (do shell script "ls " & a & next as string) tell application "Finder" to set gallery to POSIX path of (application file id "org.neooffice.neooffice" as string) --display dialog gallery end getZipNames -- userPref -- takes user input and returns it as a string -- asks which office suite (Neo or OO.o) they want to use on userPref() set whichOffice to {"NeoOffice", "OpenOffice.org"} set thisOffice to (choose from list whichOffice with prompt "Select Office Suite" without multiple selections allowed) as text --display dialog thisOffice return thisOffice as text end userPref -- readPref -- read the preference stored in /contents/resources/pref.txt -- default "none" -- "NeoOffice" or "OpenOffice.org" after run on readPref() --set officePref to (choose file with prompt "Select a file to read:" of type {"TEXT"}) set officePref to (((path to me) as text) & "Contents:Resources:pref.txt") set officePref to officePref as alias open for access officePref set xx to (read officePref) close access officePref return xx end readPref -- writePref -- writes the preference to /contents/resources/pref.txt -- input is value to be written on writePref(t) display dialog t set officePref2 to (((path to me) as text) & "Contents:Resources:pref.txt") set officePref2 to officePref2 as alias set prefFile to open for access officePref2 with write permission set eof of prefFile to 0 write t to prefFile close access officePref2 return true end writePref -- checkPref -- this checks to see if preferences have been set -- does file say "NeoOffice" or "OpenOffice.org"? -- yes, end, no, go to pref dialog on checkPref() set y to readPref() if y = "NeoOffice" or y = "OpenOffice.org" then --display dialog "Yo!" return true else writePref(userPref()) end if end checkPref