# Bryan Schumaker (12/12/2010)

import pynotify
import ocarina
libsaria  = ocarina.libsaria
get_attrs = libsaria.sources.get_attrs
image = ocarina.components.image.Image()

__NAME__ = "Notify"

def notify(*args):
	title, artist, art = get_attrs("title", "artist", "art")

	try:
		image.set_from_file(art)
		image.set_height(64)
		n = pynotify.Notification(title, "by %s" % artist)
		n.set_icon_from_pixbuf(image.get_pixbuf())
		n.set_timeout(10)
		n.show()
	except Exception, e:
		pass

def start():
	if pynotify.init(ocarina.__vers__):
		libsaria.event.invite("POSTLOAD", notify)

def stop():
	pass

def check_version():
	if libsaria.__major__ != 4:
		return False
	if libsaria.__minor__ == 4:
		return True
	return True
