NeoLauncher Code

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:47, 19 September 2006 (edit)
( | contribs)
(page created, IT'S ALIVE!)
← Previous diff
Current revision (23:47, 19 September 2006) (edit) (undo)
( | contribs)
(page created, IT'S ALIVE!)
 

Current revision

xcode files: http://neo-downloads.sixthcrusade.com/neolauncher-xcode.zip


-- neolauncher.applescript
-- neolauncher

--  Created by Jacob  Haddon on 9/19/06.
--  Copyright (c) 2006. Released under LGPL

on clicked theObject
	set j to (name of theObject as string)
	--display dialog j
	if j is equal to "open" then
		display open panel
		set the pathNames to (path names of open panel)
		openFiles(pathNames)
	else if j is equal to "quit" then
		quit {}
	else
		openNeoOffice(j, "-")
	end if
end clicked


on run
	openNeoOffice("-")
end run

on open (theFiles)
	openFiles(theFiles)
end open

on idle
	-- close icon only if ooo has terminated
	if isOOoRunning() = 0 then
		tell me to quit
	end if
	-- check all x seconds if ok to quit
	return 3
end idle

on quit
	if isOOoRunning() = 0 then
		continue quit
	else
		display dialog "NeoOffice is still running, are you sure you want to quit NeoLauncher?"
		continue quit
	end if
end quit

-------------------------------------------------------------

on isOOoRunning()
	set soffice to getProgramPath() & "/soffice"
	set isRunning to do shell script "_FOUND_=`ps -wx -o command | grep \"" & soffice & "\" | grep -v grep`; echo $_FOUND_"
	if isRunning ≠ "" then
		return 1
	else
		return 0
	end if
end isOOoRunning

on openNeoOffice(progToOpen, aFile)
	set l to getProgramPath()
	--display dialog l
	--display dialog progToOpen
	do shell script ¬
	"alreadyRunning=`ps -auxww | grep soffice |grep -v grep | wc -l`;
	exec \"" & l & "/soffice.bin\" -" & progToOpen & " \"" & aFile & "\" &
	if [ $alreadyRunning -eq 1 ]
	then
	osascript -e 'tell app \"NeoOffice\" to activate';
	fi"
	
end openNeoOffice


on checkPath(aPath)
	set pathFound to do shell script "if [ -d \"" & aPath & "\" ]; then echo \"true\"; else echo \"false\"; fi"
	--display dialog quoted form of aPath
	if (pathFound = "true") then
		return 1
	else
		return 0
	end if
end checkPath

-- getInstallPath
-- finds the path to the oo.o installation
-- checks the path to make sure there is something there
-- returns true if so, or error message if not

on getNeoPath()
	set myPath to (path to me)
	--set oooInstallPath to "/Applications/OpenOffice.org 2.0.app/Contents/openoffice.org"
	tell application "Finder" to set j to POSIX path of (application file id "org.neooffice.neooffice" as string)
	set NeoInstallPath to j & "/Contents"
	if checkPath(NeoInstallPath) = 0 then
		display dialog "No valid installation found at: " & NeoInstallPath
		return ""
	else
		return NeoInstallPath
	end if
end getNeoPath

on getProgramPath()
	return getNeoPath() & "/MacOS"
end getProgramPath


on openFiles(fileList)
	-- open dialog sends posix 
	if (count of fileList) > 0 then
		repeat with i from 1 to the count of fileList
			set theDocument to (item i of fileList)
			--display dialog theDocument
			openNeoOffice("soffice", theDocument)
		end repeat
	end if
end openFiles



Personal tools