#	tclgrowl - Tcl wrapper for Growl on MacOS X
#
#	based on Kevin Walzer's Macgrowl, but modified to work within Starkits 
#
#	Tclgrowl Copyright (c) 2009 Steve Landers
#	Macgrowl Copyright (c) 2008 WordTech Communications LLC
#	both licensed under the Tcl license
#		http://www.tcl.tk/software/tcltk/license.html
#
#	Growl available at http://growl.info
#
	
package provide tclgrowl 1.1

namespace eval growl {

    variable send {
	property theAppName : "$app"
	property theTitleString : "$title"
	property theGrowlString : "$msg"

	tell application "GrowlHelperApp"
	    set the theNotification to {theAppName & " Notification"}
	    register as application theAppName \
		all notifications theNotification \
		default notifications theNotification \
		icon of application theAppName
	    notify with name \
		(item 1 of theNotification) title theTitleString \
		description theGrowlString \
		application name theAppName
	end tell
    }

    variable check {
	tell application "System Events"
	set isRunning to (count of (every process whose name \
			    is "GrowlHelperApp")) > 0
	end tell
    }

    # check to see if growl is running 
    proc available {} {
	variable check
	return [expr {[exec osascript -e $check] eq "true"}]
    }

    proc message {app title msg} {
	variable send
	exec osascript -e [subst $send]
    }

    namespace export *

}
