import gtk import thread from GuiObjects.menuItem import MenuItem from GuiObjects.libView import LibView from GuiObjects.plistView import PlistView from GuiObjects.controlPanel import ControlPanel from GuiObjects.infoView import InfoView from GuiObjects.scrobbler import Scrobbler class Window(gtk.Window): def __init__(self,onQuit,options,data): gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL) self.data = data self.options = options if self.options.verbose == True: print "Making window!" self.resize(self.data.size[0],self.data.size[1]) self.set_title("Ocarina") self.connect("delete_event",onQuit) self.set_icon_from_file("images/ocarina.png") self.mainLayout = gtk.VBox(False,0) self.add(self.mainLayout) self.makeMenuBar() self.makeContentPane() self.mainLayout.show() self.show() # Used to make the top row menu bar def makeMenuBar(self): # Make a menu bar bar = gtk.MenuBar() # This is the dropdown selections # Make a new library option newLib = MenuItem("New Library",self.selectDir,"ScanLib",self.data.library.scan,None) delete = MenuItem("Delete Library",self.deleteLib,"Delete",None,None) library = MenuItem("Library",None,None,None,[newLib,delete]) bar.append(library) clear = MenuItem("Clear Playlist",self.clearPlist,"Clear",None,None) plist = MenuItem("Playlist",None,None,None,[clear]) bar.append(plist) # Replace first 'None' with after track functions pafter = MenuItem("Pause After Current Track",self.setPlayStatus,"pafter",None,None) qafter = MenuItem("Quit After Current Track",None,"qafter",None,None) playback = MenuItem("Playback",None,None,None,[pafter,qafter]) bar.append(playback) bar.show() self.mainLayout.pack_start(bar,False,False,0) def deleteLib(self,widgit,data,other=None): self.data.library.reset() self.libview.update() self.clearPlist(None,None) def clearPlist(self,widgit,data,other=None): self.data.curList = [] #self.data.updateList = True self.plistview.clearList(self.plistview.plist,self.plistview.ptime) def setPlayStatus(self,widgit,status,other): self.plistview.setStatus(status) # Used to select a directory def selectDir(self,widgit,data,func): dirsel = gtk.FileChooserDialog(None,action=gtk.FILE_CHOOSER_ACTION_OPEN,buttons =(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) dirsel.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) response = None response = dirsel.run() file = "" if response == gtk.RESPONSE_OK: file = dirsel.get_filename() dirsel.hide() if response != gtk.RESPONSE_OK: return self.libview.updates() thread.start_new_thread(func,(data,file)) def makeContentPane(self): self.contentPane = gtk.HBox(False,0) self.divider = gtk.HPaned() self.divider.set_position(self.data.divider) self.contentPane.add(self.divider) self.divider.show() leftPane = gtk.Notebook() leftPane.show() leftPane.set_tab_pos(gtk.POS_LEFT) self.libview = LibView(self.data) self.libview.show() libLabel = gtk.Label("Library") libLabel.set_angle(90) leftPane.append_page(self.libview,libLabel) scrobbler = Scrobbler(self.data) scrobLabel = gtk.Label("Last.fm") scrobLabel.set_angle(90) leftPane.append_page(scrobbler,scrobLabel) self.divider.add1(leftPane) rightPane=gtk.VBox(False,0) topRight = gtk.HBox(False,0) topRight.show() infoview = InfoView(self.data) topRight.pack_start(infoview,False,False,0) rightPane.pack_start(topRight,False,False,0) self.plistview = PlistView(self.data,infoview) topRight.pack_end(self.plistview.searchBar,False,False,0) rightPane.add(self.plistview) self.makeBottomRow(rightPane) rightPane.show() self.libview.plist = self.plistview self.divider.add2(rightPane) self.contentPane.show() self.mainLayout.add(self.contentPane) def makeBottomRow(self,vbox): box = gtk.HBox(False,0) box.show() controls = ControlPanel(self.data,self.plistview) self.plistview.controls = controls vbox.pack_start(controls,False,False,0) box.pack_end(self.plistview.label) align = gtk.Alignment(1,1,0,0) align.add(box) align.show() vbox.pack_start(align,False,False,0)