https://neowiki.neooffice.org/index.php?title=NeoLauncher_Code&action=history&feed=atomNeoLauncher Code - Revision history2024-03-29T06:34:26ZRevision history for this page on the wikiMediaWiki 1.10.1https://neowiki.neooffice.org/index.php?title=NeoLauncher_Code&diff=6780&oldid=prevJake: page created, IT'S ALIVE!2006-09-19T23:47:13Z<p>page created, IT'S ALIVE!</p>
<p><b>New page</b></p><div><br />
xcode files:<br />
http://neo-downloads.sixthcrusade.com/neolauncher-xcode.zip<br />
<br />
<pre><br />
<br />
-- neolauncher.applescript<br />
-- neolauncher<br />
<br />
-- Created by Jacob Haddon on 9/19/06.<br />
-- Copyright (c) 2006. Released under LGPL<br />
<br />
on clicked theObject<br />
set j to (name of theObject as string)<br />
--display dialog j<br />
if j is equal to "open" then<br />
display open panel<br />
set the pathNames to (path names of open panel)<br />
openFiles(pathNames)<br />
else if j is equal to "quit" then<br />
quit {}<br />
else<br />
openNeoOffice(j, "-")<br />
end if<br />
end clicked<br />
<br />
<br />
on run<br />
openNeoOffice("-")<br />
end run<br />
<br />
on open (theFiles)<br />
openFiles(theFiles)<br />
end open<br />
<br />
on idle<br />
-- close icon only if ooo has terminated<br />
if isOOoRunning() = 0 then<br />
tell me to quit<br />
end if<br />
-- check all x seconds if ok to quit<br />
return 3<br />
end idle<br />
<br />
on quit<br />
if isOOoRunning() = 0 then<br />
continue quit<br />
else<br />
display dialog "NeoOffice is still running, are you sure you want to quit NeoLauncher?"<br />
continue quit<br />
end if<br />
end quit<br />
<br />
-------------------------------------------------------------<br />
<br />
on isOOoRunning()<br />
set soffice to getProgramPath() & "/soffice"<br />
set isRunning to do shell script "_FOUND_=`ps -wx -o command | grep \"" & soffice & "\" | grep -v grep`; echo $_FOUND_"<br />
if isRunning ≠"" then<br />
return 1<br />
else<br />
return 0<br />
end if<br />
end isOOoRunning<br />
<br />
on openNeoOffice(progToOpen, aFile)<br />
set l to getProgramPath()<br />
--display dialog l<br />
--display dialog progToOpen<br />
do shell script ¬<br />
"alreadyRunning=`ps -auxww | grep soffice |grep -v grep | wc -l`;<br />
exec \"" & l & "/soffice.bin\" -" & progToOpen & " \"" & aFile & "\" &<br />
if [ $alreadyRunning -eq 1 ]<br />
then<br />
osascript -e 'tell app \"NeoOffice\" to activate';<br />
fi"<br />
<br />
end openNeoOffice<br />
<br />
<br />
on checkPath(aPath)<br />
set pathFound to do shell script "if [ -d \"" & aPath & "\" ]; then echo \"true\"; else echo \"false\"; fi"<br />
--display dialog quoted form of aPath<br />
if (pathFound = "true") then<br />
return 1<br />
else<br />
return 0<br />
end if<br />
end checkPath<br />
<br />
-- getInstallPath<br />
-- finds the path to the oo.o installation<br />
-- checks the path to make sure there is something there<br />
-- returns true if so, or error message if not<br />
<br />
on getNeoPath()<br />
set myPath to (path to me)<br />
--set oooInstallPath to "/Applications/OpenOffice.org 2.0.app/Contents/openoffice.org"<br />
tell application "Finder" to set j to POSIX path of (application file id "org.neooffice.neooffice" as string)<br />
set NeoInstallPath to j & "/Contents"<br />
if checkPath(NeoInstallPath) = 0 then<br />
display dialog "No valid installation found at: " & NeoInstallPath<br />
return ""<br />
else<br />
return NeoInstallPath<br />
end if<br />
end getNeoPath<br />
<br />
on getProgramPath()<br />
return getNeoPath() & "/MacOS"<br />
end getProgramPath<br />
<br />
<br />
on openFiles(fileList)<br />
-- open dialog sends posix <br />
if (count of fileList) > 0 then<br />
repeat with i from 1 to the count of fileList<br />
set theDocument to (item i of fileList)<br />
--display dialog theDocument<br />
openNeoOffice("soffice", theDocument)<br />
end repeat<br />
end if<br />
end openFiles<br />
<br />
<br />
<br />
</pre></div>Jake