Merged contentPane with rightPane
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@55 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
8586fa1f47
commit
c338c740a8
|
@ -1,11 +1,21 @@
|
|||
import gtk
|
||||
# Eventually this and rightPane should probably be merged...
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
from label import Label
|
||||
from queue import Queue
|
||||
from playlist import Playlist
|
||||
from liblist import LibList
|
||||
from image import Image
|
||||
from check import CheckButton
|
||||
from button import Button
|
||||
#from libView import LibView
|
||||
from scrobbler import Scrobbler
|
||||
#from plistView import PlistView
|
||||
from controlPanel import ControlPanel
|
||||
|
||||
from rightPane import RightPane
|
||||
#from rightPane import RightPane
|
||||
|
||||
class ContentPane(gtk.HBox):
|
||||
def __init__(self,data):
|
||||
|
@ -29,5 +39,264 @@ class ContentPane(gtk.HBox):
|
|||
|
||||
|
||||
def makeRightSide(self):
|
||||
self.right = RightPane(self.data)
|
||||
self.divider.add2(self.right)
|
||||
vbox = gtk.VBox(False,0)
|
||||
vbox.show()
|
||||
#self.right = RightPane(self.data)
|
||||
self.divider.add2(vbox)
|
||||
|
||||
self.title = Label("",13000,700)
|
||||
self.album = Label("",10000,400)
|
||||
self.artist = Label("",10000,400)
|
||||
self.setLabels()
|
||||
|
||||
infobox = gtk.HBox(False,0)
|
||||
infobox.show()
|
||||
infolabels = gtk.VBox(False,0)
|
||||
infolabels.show()
|
||||
infobox.pack_start(infolabels,False,False,0)
|
||||
|
||||
infolabels.pack_start(self.title,False,False,0)
|
||||
infolabels.pack_start(self.album,False,False,0)
|
||||
infolabels.pack_start(self.artist,False,False,0)
|
||||
|
||||
self.searchBar = gtk.Entry()
|
||||
self.searchBar.show()
|
||||
self.searchBar.connect("changed",self.textTyped)
|
||||
searchalign = gtk.Alignment(1,1,0,0)
|
||||
searchalign.show()
|
||||
searchalign.add(self.searchBar)
|
||||
infobox.pack_end(searchalign,False,False,0)
|
||||
|
||||
vbox.pack_start(infobox,False,False,0)
|
||||
|
||||
self.makeTabs(vbox)
|
||||
self.makeControls(vbox)
|
||||
|
||||
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)
|
||||
|
||||
vbox.pack_start(hbox,False,False,0)
|
||||
hbox.show()
|
||||
|
||||
#self.changedTab(None,None,0)
|
||||
self.status = ""
|
||||
self.filterCount = 0
|
||||
|
||||
|
||||
def setLabels(self):
|
||||
title = ""
|
||||
album = ""
|
||||
artist = ""
|
||||
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,box):
|
||||
self.tabs = gtk.Notebook()
|
||||
box.add(self.tabs)
|
||||
self.tabs.show()
|
||||
|
||||
self.queue = Queue(self.data,self.next,self.setLabels,self.plause)
|
||||
self.playlist = Playlist(self.data,self.queue,self.next,self.setLabels,self.plause)
|
||||
self.playlist.visible("show")
|
||||
self.library = LibList(self.data,self.playlist,self.queue,self.next,self.setLabels,self.plause)
|
||||
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)
|
||||
|
||||
self.curTab = 0
|
||||
self.tabs.connect("switch-page",self.changedTab)
|
||||
#self.filter("")
|
||||
|
||||
|
||||
def makeControls(self,vbox):
|
||||
box = gtk.HBox(False,0)
|
||||
box.show()
|
||||
self.pauseImg = Image(None,gtk.STOCK_MEDIA_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)
|
||||
|
||||
vbox.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):
|
||||
loaded = self.queue.getNext()
|
||||
#print loaded
|
||||
if loaded == False:
|
||||
loaded = self.playlist.getNext()
|
||||
if not (self.status == "pafter") and (loaded==True):
|
||||
self.plause(None,None)
|
||||
self.data.scrobbler.nowPlaying(self.data.song.info)
|
||||
self.gotoCurSong()
|
||||
self.status = ""
|
||||
self.data.dump()
|
||||
|
||||
|
||||
# Scroll to the current song
|
||||
def gotoCurSong(self):
|
||||
print "here!"
|
||||
self.playlist.gotoCurSong()
|
||||
self.queue.gotoCurSong()
|
||||
self.library.gotoCurSong()
|
||||
|
||||
|
||||
# Change the state of the play/pause button
|
||||
def changeImg(self):
|
||||
self.plauseBtn.set_image(self.playImg)
|
||||
if self.data.song.playing == True:
|
||||
self.plauseBtn.set_image(self.pauseImg)
|
||||
|
||||
|
||||
# This is called when a user changes tabs
|
||||
# Do nothing if the user selects the same tab
|
||||
# Otherwise, hide objects on the old visible tab and show the new visible tab
|
||||
# Also updates self.curTab
|
||||
def changedTab(self,widgit,page,pagenum):
|
||||
if self.curTab == pagenum:
|
||||
return
|
||||
|
||||
if self.curTab == 0:
|
||||
self.playlist.visible("hide")
|
||||
elif self.curTab == 1:
|
||||
self.queue.visible("hide")
|
||||
else:
|
||||
self.library.visible("hide")
|
||||
|
||||
self.curTab = pagenum
|
||||
|
||||
if pagenum == 0:
|
||||
self.playlist.visible("show")
|
||||
elif pagenum == 1:
|
||||
self.queue.visible("show")
|
||||
else:
|
||||
self.library.visible("show")
|
||||
self.textTyped(self.searchBar)
|
||||
|
||||
|
||||
def dumpLib(self):
|
||||
self.library.drop()
|
||||
self.playlist.drop()
|
||||
self.queue.drop()
|
||||
|
||||
|
||||
# text was typed, refilter rows
|
||||
# Arrange to filter rows in 250ms, as long as no additional text has been typed
|
||||
def textTyped(self,entry):
|
||||
search = entry.get_text().lower()
|
||||
self.filterCount+=1
|
||||
gobject.timeout_add(250,self.filter,search)
|
||||
|
||||
|
||||
# Filter the rows of the current tab
|
||||
# Do a quickFilter on nonvisible tabs
|
||||
# Decrements self.filterCount
|
||||
def filter(self,search):
|
||||
# If filterCount is 0, no additional text has been typed
|
||||
self.filterCount -= 1
|
||||
if self.filterCount > 0:
|
||||
return
|
||||
# It is ok to filter rows
|
||||
if self.curTab == 0:
|
||||
self.playlist.filterRows(search)
|
||||
tabs = [1,2]
|
||||
elif self.curTab == 1:
|
||||
self.queue.filterRows(search)
|
||||
tabs = [0,2]
|
||||
else:
|
||||
self.library.filterRows(search)
|
||||
tabs = [0,1]
|
||||
|
||||
for tab in tabs:
|
||||
if tab == 0:
|
||||
self.playlist.filterQuick(search)
|
||||
elif tab == 1:
|
||||
self.queue.filterQuick(search)
|
||||
else:
|
||||
self.library.filterQuick(search)
|
||||
|
||||
|
||||
# Coose to pause after the current song or not
|
||||
def setStatus(self,status):
|
||||
if status == "pafter":
|
||||
self.status = "pafter"
|
||||
else:
|
||||
print status
|
||||
|
||||
|
||||
# Store the width of the current tabs columns
|
||||
def storeCols(self):
|
||||
if self.curTab == 0:
|
||||
self.playlist.storeCols()
|
||||
elif self.curTab == 1:
|
||||
self.queue.storeCols()
|
||||
else:
|
||||
self.library.storeCols()
|
||||
|
|
|
@ -20,10 +20,12 @@ class Data:
|
|||
|
||||
# Dump user data to a file
|
||||
def dump(self):
|
||||
# Have to clear library.libview before saving, otherwise there are problems
|
||||
libview = self.library.libview
|
||||
self.library.libview = None
|
||||
self.save(self.library,"library")
|
||||
self.library.libview = libview
|
||||
|
||||
self.save([self.curList,self.curSong],"playlist")
|
||||
self.save([self.curQ],"queue")
|
||||
self.save([self.size,self.divider,self.colSizes,self.sortedCol,self.random],"preferences")
|
||||
|
|
|
@ -32,7 +32,7 @@ class main:
|
|||
#print self.window.get_size()
|
||||
self.data.size = self.window.get_size()
|
||||
self.data.divider = self.window.contentPane.divider.get_position()
|
||||
self.window.contentPane.right.storeCols()
|
||||
self.window.contentPane.storeCols()
|
||||
#self.window.contentPane.plistview.saveCols()
|
||||
#self.data.clearSong()
|
||||
self.data.dump()
|
||||
|
|
|
@ -1,275 +0,0 @@
|
|||
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
|
||||
#print self.data.curSong
|
||||
|
||||
self.title = Label("",13000,700)
|
||||
self.album = Label("",10000,400)
|
||||
self.artist = Label("",10000,400)
|
||||
self.setLabels()
|
||||
|
||||
infobox = gtk.HBox(False,0)
|
||||
infobox.show()
|
||||
infolabels = gtk.VBox(False,0)
|
||||
infolabels.show()
|
||||
infobox.pack_start(infolabels,False,False,0)
|
||||
|
||||
infolabels.pack_start(self.title,False,False,0)
|
||||
infolabels.pack_start(self.album,False,False,0)
|
||||
infolabels.pack_start(self.artist,False,False,0)
|
||||
|
||||
self.searchBar = gtk.Entry()
|
||||
self.searchBar.show()
|
||||
self.searchBar.connect("changed",self.textTyped)
|
||||
searchalign = gtk.Alignment(1,1,0,0)
|
||||
searchalign.show()
|
||||
searchalign.add(self.searchBar)
|
||||
infobox.pack_end(searchalign,False,False,0)
|
||||
|
||||
self.pack_start(infobox,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.changedTab(None,None,0)
|
||||
self.status = ""
|
||||
self.filterCount = 0
|
||||
|
||||
|
||||
def setLabels(self):
|
||||
title = ""
|
||||
album = ""
|
||||
artist = ""
|
||||
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.queue = Queue(self.data,self.next,self.setLabels,self.plause)
|
||||
self.playlist = Playlist(self.data,self.queue,self.next,self.setLabels,self.plause)
|
||||
self.playlist.visible("show")
|
||||
self.library = LibList(self.data,self.playlist,self.queue,self.next,self.setLabels,self.plause)
|
||||
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)
|
||||
|
||||
self.curTab = 0
|
||||
self.tabs.connect("switch-page",self.changedTab)
|
||||
#self.filter("")
|
||||
|
||||
|
||||
def makeControls(self):
|
||||
box = gtk.HBox(False,0)
|
||||
box.show()
|
||||
self.pauseImg = Image(None,gtk.STOCK_MEDIA_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):
|
||||
loaded = self.queue.getNext()
|
||||
#print loaded
|
||||
if loaded == False:
|
||||
loaded = self.playlist.getNext()
|
||||
if not (self.status == "pafter") and (loaded==True):
|
||||
self.plause(None,None)
|
||||
self.data.scrobbler.nowPlaying(self.data.song.info)
|
||||
self.gotoCurSong()
|
||||
self.status = ""
|
||||
self.data.dump()
|
||||
|
||||
|
||||
# Scroll to the current song
|
||||
def gotoCurSong(self):
|
||||
print "here!"
|
||||
self.playlist.gotoCurSong()
|
||||
self.queue.gotoCurSong()
|
||||
self.library.gotoCurSong()
|
||||
|
||||
|
||||
# Change the state of the play/pause button
|
||||
def changeImg(self):
|
||||
self.plauseBtn.set_image(self.playImg)
|
||||
if self.data.song.playing == True:
|
||||
self.plauseBtn.set_image(self.pauseImg)
|
||||
|
||||
|
||||
# This is called when a user changes tabs
|
||||
# Do nothing if the user selects the same tab
|
||||
# Otherwise, hide objects on the old visible tab and show the new visible tab
|
||||
# Also updates self.curTab
|
||||
def changedTab(self,widgit,page,pagenum):
|
||||
if self.curTab == pagenum:
|
||||
return
|
||||
|
||||
if self.curTab == 0:
|
||||
self.playlist.visible("hide")
|
||||
elif self.curTab == 1:
|
||||
self.queue.visible("hide")
|
||||
else:
|
||||
self.library.visible("hide")
|
||||
|
||||
self.curTab = pagenum
|
||||
|
||||
if pagenum == 0:
|
||||
self.playlist.visible("show")
|
||||
elif pagenum == 1:
|
||||
self.queue.visible("show")
|
||||
else:
|
||||
self.library.visible("show")
|
||||
self.textTyped(self.searchBar)
|
||||
|
||||
|
||||
def dumpLib(self):
|
||||
self.library.drop()
|
||||
self.playlist.drop()
|
||||
self.queue.drop()
|
||||
|
||||
|
||||
# text was typed, refilter rows
|
||||
# Arrange to filter rows in 250ms, as long as no additional text has been typed
|
||||
def textTyped(self,entry):
|
||||
search = entry.get_text().lower()
|
||||
self.filterCount+=1
|
||||
gobject.timeout_add(250,self.filter,search)
|
||||
|
||||
|
||||
# Filter the rows of the current tab
|
||||
# Do a quickFilter on nonvisible tabs
|
||||
# Decrements self.filterCount
|
||||
def filter(self,search):
|
||||
# If filterCount is 0, no additional text has been typed
|
||||
self.filterCount -= 1
|
||||
if self.filterCount > 0:
|
||||
return
|
||||
# It is ok to filter rows
|
||||
if self.curTab == 0:
|
||||
self.playlist.filterRows(search)
|
||||
tabs = [1,2]
|
||||
elif self.curTab == 1:
|
||||
self.queue.filterRows(search)
|
||||
tabs = [0,2]
|
||||
else:
|
||||
self.library.filterRows(search)
|
||||
tabs = [0,1]
|
||||
|
||||
for tab in tabs:
|
||||
if tab == 0:
|
||||
self.playlist.filterQuick(search)
|
||||
elif tab == 1:
|
||||
self.queue.filterQuick(search)
|
||||
else:
|
||||
self.library.filterQuick(search)
|
||||
|
||||
|
||||
# Coose to pause after the current song or not
|
||||
def setStatus(self,status):
|
||||
if status == "pafter":
|
||||
self.status = "pafter"
|
||||
else:
|
||||
print status
|
||||
|
||||
|
||||
# Store the width of the current tabs columns
|
||||
def storeCols(self):
|
||||
if self.curTab == 0:
|
||||
self.playlist.storeCols()
|
||||
elif self.curTab == 1:
|
||||
self.queue.storeCols()
|
||||
else:
|
||||
self.library.storeCols()
|
|
@ -60,22 +60,22 @@ class Window(gtk.Window):
|
|||
|
||||
|
||||
def deleteLib(self,widgit,data,other=None):
|
||||
self.contentPane.right.dumpLib()
|
||||
self.contentPane.dumpLib()
|
||||
self.data.library.reset()
|
||||
#self.libview.update()
|
||||
#self.clearPlist(None,None)
|
||||
|
||||
|
||||
def clearPlist(self,widgit,data,other=None):
|
||||
self.contentPane.right.playlist.drop()
|
||||
self.contentPane.playlist.drop()
|
||||
|
||||
|
||||
def setPlayStatus(self,widgit,status,other):
|
||||
self.contentPane.right.setStatus(status)
|
||||
self.contentPane.setStatus(status)
|
||||
|
||||
|
||||
def gotoCurSong(self,widgit,status,other):
|
||||
self.contentPane.right.gotoCurSong()
|
||||
self.contentPane.gotoCurSong()
|
||||
|
||||
|
||||
# Used to select a directory
|
||||
|
@ -90,7 +90,7 @@ class Window(gtk.Window):
|
|||
dirsel.hide()
|
||||
if response != gtk.RESPONSE_OK:
|
||||
return
|
||||
self.contentPane.right.library.updates()
|
||||
self.contentPane.library.updates()
|
||||
thread.start_new_thread(func,(data,file))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue