import gtk import gobject from label import Label from playlist import Playlist from queue import Queue from liblist import LibList from button import Button from check import CheckButton from image import Image class RightPane(gtk.VBox): def __init__(self,data): gtk.VBox.__init__(self,False,0) self.show() self.data = data self.title = Label("",13000,700) self.album = Label("",10000,400) self.artist = Label("",10000,400) self.setLabels() self.pack_start(self.title,False,False,0) self.pack_start(self.album,False,False,0) self.searchBar = gtk.Entry() self.searchBar.connect("changed",self.textTyped) self.searchBar.show() artsearch = gtk.HBox(False,0) artsearch.show() artsearch.pack_start(self.artist,False,False,0) artsearch.pack_end(self.searchBar,False,False,0) self.pack_start(artsearch,False,False,0) self.makeTabs() self.makeControls() hbox = gtk.HBox(False,0) hbox.pack_start(self.library.pbaralign,False,False,0) hbox.pack_end(self.playlist.align,False,False,0) hbox.pack_end(self.queue.align,False,False,0) hbox.pack_end(self.library.align,False,False,0) self.pack_start(hbox,False,False,0) hbox.show() self.curTab = 0 self.changedTab(None,None,0) def setLabels(self): title = "a" album = "b" artist = "c" if self.data.song: title = self.data.song.info.title album = "from "+self.data.song.info.album artist = "by "+self.data.song.info.artist self.title.set_text(title) self.album.set_text(album) self.artist.set_text(artist) def makeTabs(self): self.tabs = gtk.Notebook() self.add(self.tabs) self.tabs.show() self.tabs.connect("switch-page",self.changedTab) self.playlist = Playlist(self.data) self.queue = Queue(self.data) self.library = LibList(self.data) self.data.library.libview = self.library self.tabs.append_page(self.playlist,self.playlist.label) self.tabs.append_page(self.queue,self.queue.label) self.tabs.append_page(self.library,self.library.label) def makeControls(self): box = gtk.HBox(False,0) box.show() self.pauseImg = Image(None,gtk.STOCK_MEDIA_PAUSE)#Image(os.path.join("images","pause")) box.pack_start(CheckButton("Random",self.toggleRand,self.data.random),False,False,0) hbox = gtk.VBox() hbox.show() pbar = gtk.ProgressBar() pbar.show() pbar.set_fraction(0) event = gtk.EventBox() event.show() event.add(pbar) hbox.pack_start(event,True,False,0) event.connect("button_release_event",self.pbarclick,pbar) box.pack_start(hbox,True,True,0) gobject.timeout_add(500,self.updatePBar,pbar) (self.playImg,self.plauseBtn) = self.makeButton("plause",gtk.STOCK_MEDIA_PLAY,self.plause,box) (self.stopImg,self.stopBtn) = self.makeButton("stop",gtk.STOCK_MEDIA_STOP,self.stop,box) (self.nextImg,self.nextBtn) = self.makeButton("next",gtk.STOCK_MEDIA_NEXT,self.next,box) self.pack_start(box,False,False,0) def makeButton(self,name,img,func,box): image = Image(None,img) button = Button(name,image,None,func) box.pack_start(button,False,False,0) return image,button def toggleRand(self,widgit): self.data.random = not self.data.random def pbarclick(self,widgit,data,pbar): if data.button==1: prcnt = float(data.x) / float(pbar.get_allocation()[2]) self.data.song.seek(int(prcnt * self.data.song.info.duration * 1000000000)) def updatePBar(self,pbar): time = 0 if not self.data.song: return True try: time = self.data.song.curTime() except: time = 0 if self.data.song.info.duration > 0: pbar.set_fraction(float(time)/self.data.song.info.duration) pbar.set_text(self.data.song.info.fixTime(time) + " / " + self.data.song.info.length) return True def plause(self,widgit,data): self.data.song.plause() self.changeImg() def stop(self,widgit,data): self.data.song.stop() self.changeImg() def next(self,widgit,data): print "next song" def changeImg(self): self.plauseBtn.set_image(self.playImg) if self.data.song.playing == True: self.plauseBtn.set_image(self.pauseImg) def changedTab(self,widgit,page,pagenum): self.playlist.align.hide() self.queue.align.hide() self.library.align.hide() self.curTab = pagenum if pagenum == 0: self.playlist.align.show() elif pagenum == 1: self.queue.align.show() else: self.library.align.show() self.filter(self.searchBar.get_text().lower()) def dumpLib(self): self.library.drop() self.playlist.drop() self.queue.drop() def textTyped(self,entry): search = entry.get_text().lower() self.filter(search) #print self.curTab def filter(self,search): if self.curTab == 0: self.playlist.filterRows(search) elif self.curTab == 1: self.queue.filterRows(search) else: self.library.filterRows(search)