Pass a tuple of functions to playlist,queue,liblist instead of individual functions

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@56 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-08-02 20:04:33 +00:00
parent c338c740a8
commit bb0dbd0c27
7 changed files with 55 additions and 50 deletions

View File

@ -1,5 +1,3 @@
# Eventually this and rightPane should probably be merged...
import gtk
import gobject
@ -10,13 +8,11 @@ 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
# This is the main content area
class ContentPane(gtk.HBox):
def __init__(self,data):
gtk.HBox.__init__(self,False,0)
@ -32,43 +28,19 @@ class ContentPane(gtk.HBox):
self.show()
# Left side is scrobbler, album art, maybe others at some point?
def makeLeftSide(self):
self.data.scrobbler = Scrobbler(self.data)
self.divider.add1(self.data.scrobbler)
# Right side has tabs, current song info, controls, and more
def makeRightSide(self):
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.makeInfoArea(vbox)
self.makeTabs(vbox)
self.makeControls(vbox)
@ -100,15 +72,52 @@ class ContentPane(gtk.HBox):
self.artist.set_text(artist)
# This is the upper end of the right side of the divider
# Current song labels, and the filter entry
def makeInfoArea(self,box):
# Make the labels
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)
# Pack the labels into a vbox
infolabels.pack_start(self.title,False,False,0)
infolabels.pack_start(self.album,False,False,0)
infolabels.pack_start(self.artist,False,False,0)
# Make the filter bar
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)
# Pack it all in
box.pack_start(infobox,False,False,0)
# Makes the playlist/queue/library tabs
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)
# Ann array of function pointers that gets passed to List
funcs = [self.next,self.setLabels,self.plause]
self.queue = Queue(self.data,funcs)
self.playlist = Playlist(self.data,self.queue,funcs)
self.playlist.visible("show")
self.library = LibList(self.data,self.playlist,self.queue,self.next,self.setLabels,self.plause)
self.library = LibList(self.data,self.playlist,self.queue,funcs)
self.data.library.libview = self.library
self.tabs.append_page(self.playlist,self.playlist.label)
@ -120,6 +129,7 @@ class ContentPane(gtk.HBox):
#self.filter("")
# Makes buttons and progress bar
def makeControls(self,vbox):
box = gtk.HBox(False,0)
box.show()

View File

@ -5,8 +5,8 @@ from list import List
from menuItem import MenuItem
class LibList(List):
def __init__(self,data,playlist,queue,nextFunc,labelFunc,plause):
List.__init__(self,data,"Library",nextFunc,labelFunc,plause)
def __init__(self,data,playlist,queue,funcs):
List.__init__(self,data,"Library",funcs)
self.plist = playlist
self.queue = queue
self.pbar = gtk.ProgressBar()

View File

@ -5,7 +5,7 @@ from menuItem import MenuItem
from song import Song
class List(gtk.ScrolledWindow):
def __init__(self,data,text,nextFunc,labelFunc,plauseFunc):
def __init__(self,data,text,(nextFunc,labelFunc,plauseFunc)):
gtk.ScrolledWindow.__init__(self)
self.show()
self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
@ -150,10 +150,6 @@ class List(gtk.ScrolledWindow):
self.seconds = 0
self.count = 0
self.filter.refilter()
#for row in self.filter:
#file = self.data.library.files[row[0]]
# self.seconds+=self.data.library.files[row[0]].duration
# self.count+=1
self.count = len(self.filter)
for i in range(self.count):
self.seconds+=self.data.library.files[self.filter[i][0]].duration

View File

@ -29,14 +29,12 @@ class main:
def quit(self,widgit,data):
if self.options.verbose == True:
print "Quitting..."
#print self.window.get_size()
if self.data.song:
self.data.song.close()
self.data.size = self.window.get_size()
self.data.divider = self.window.contentPane.divider.get_position()
self.window.contentPane.storeCols()
#self.window.contentPane.plistview.saveCols()
#self.data.clearSong()
self.data.dump()
#self.library.dump()
gtk.main_quit()
return False

View File

@ -3,8 +3,8 @@ import random
from menuItem import MenuItem
class Playlist(List):
def __init__(self,data,queue,nextFunc,labelFunc,plause):
List.__init__(self,data,"Playlist",nextFunc,labelFunc,plause)
def __init__(self,data,queue,funcs):
List.__init__(self,data,"Playlist",funcs)
self.queue = queue
#for file in self.data.curList:
# List.insert(self,file)

View File

@ -1,8 +1,8 @@
from list import List
class Queue(List):
def __init__(self,data,nextFunc,labelFunc,plause):
List.__init__(self,data,"Queue",nextFunc,labelFunc,plause)
def __init__(self,data,funcs):
List.__init__(self,data,"Queue",funcs)
self.data = data
self.populated = False
self.count = len(self.data.curQ)

View File

@ -94,6 +94,7 @@ class Window(gtk.Window):
thread.start_new_thread(func,(data,file))
# This is the "main area" where all info is shown
def makeContentPane(self):
self.contentPane = ContentPane(self.data)
self.mainLayout.add(self.contentPane)