import gobject import os import sys import thread import pygtk pygtk.require('2.0') import gtk from song import Song from duration import Duration from library import Library from operations import Operations from playlist import Playlist from songInfo import SongInfo from window import Window #gtk.gdk.threads_init() gobject.threads_init() class main: def __init__(self,argv): self.ops = Operations(self.quit) self.library = Library() self.plist = Playlist() self.plist.insert(self.library.nonBanned()) self.ops.plist = self.plist self.ops.library = self.library window = Window(self.quit,self.ops) self.ops.setInfo = window.changeInfo self.ops.resetInfo = window.resetInfo song = None # If we were given a song as input, check that it exists and begin playback if len(argv) > 0: split = argv[0].split(self.library.data.path) if len(split) > 0: index = self.library.has(split[len(split)-1]) #if index != -1: #info = self.library.data.files[index] self.plist.queueSong(index) if index==-1: file = os.path.expanduser(argv[0]) if os.path.exists(file): info = SongInfo() info.filename = file song = Song(info,self.next)#,self.commands.printLines) self.ops.song = song self.ops.next("","") # Call gtk main gtk.main() # Eventually replace "delete_event" with this def quit(self,widget,event,data=None): print "Quitting..." self.library.dump() gtk.main_quit() return False if __name__=='__main__':main(sys.argv[1:])