#!/usr/bin/env python

# example base.py

import pygtk
pygtk.require('2.0')
import gtk
import os
import thread

gtk.gdk.threads_init()

class ApertureScienceRadio:
    def play(self,lol,lol2):
	os.system("madplay /usr/share/aperturescienceradio/stillalive_radio.mp3 -r -q -o wave:- | aplay -q -");

    def delete_event(self, widget, event, data=None):
        print "shutting down!"
        return False

    def destroy(self, widget, data=None):
        print "nap time!"
	os.system("killall madplay; xrandr -o 0")
        gtk.main_quit()

    def __init__(self):
	print "Welcome to Aperture Science Enrichment Center!"
	os.system("xrandr -o 1")
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
	self.image=gtk.Image()
	self.image.set_from_file("/usr/share/aperturescienceradio/background.jpg")
	self.window.add(self.image)
	self.window.set_title("Aperture Science Radio")
        self.window.show_all()
	thread.start_new_thread(self.play, (0,0))

    def main(self):
        gtk.main()

#print __name__
if __name__ == "__main__":
    base = ApertureScienceRadio()
    base.main()

