From 396631bc3d762b1531a652ea09fc97dae0577e4c Mon Sep 17 00:00:00 2001 From: bjschuma Date: Tue, 14 Jul 2009 03:17:53 +0000 Subject: [PATCH] Began redoing library view, removed GuiObjects directory git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@46 1daee41c-8060-4895-b1f0-2197c00d777a --- trunk/Makefile | 11 +- trunk/src/GuiObjects/__init__.py | 3 - trunk/src/GuiObjects/image.py | 8 - trunk/src/GuiObjects/infoView.py | 42 ----- trunk/src/{GuiObjects => }/button.py | 0 trunk/src/{GuiObjects => }/check.py | 0 trunk/src/contentPane.py | 33 ++++ trunk/src/{GuiObjects => }/controlPanel.py | 0 trunk/src/{saveddata.py => data.py} | 2 +- trunk/src/image.py | 11 ++ trunk/src/label.py | 18 ++ trunk/src/{GuiObjects => }/libView.py | 0 trunk/src/liblist.py | 36 ++++ trunk/src/library.py | 15 +- trunk/src/list.py | 166 ++++++++++++++++++ trunk/src/{GuiObjects => }/menuItem.py | 0 trunk/src/ocarina.py | 8 +- trunk/src/playlist.py | 7 + trunk/src/{GuiObjects => }/plistView.py | 4 +- trunk/src/queue.py | 6 + trunk/src/rightPane.py | 192 +++++++++++++++++++++ trunk/src/{GuiObjects => }/scrobbler.py | 4 +- trunk/src/window.py | 80 ++------- 23 files changed, 498 insertions(+), 148 deletions(-) delete mode 100644 trunk/src/GuiObjects/__init__.py delete mode 100644 trunk/src/GuiObjects/image.py delete mode 100644 trunk/src/GuiObjects/infoView.py rename trunk/src/{GuiObjects => }/button.py (100%) rename trunk/src/{GuiObjects => }/check.py (100%) create mode 100644 trunk/src/contentPane.py rename trunk/src/{GuiObjects => }/controlPanel.py (100%) rename trunk/src/{saveddata.py => data.py} (99%) create mode 100644 trunk/src/image.py create mode 100644 trunk/src/label.py rename trunk/src/{GuiObjects => }/libView.py (100%) create mode 100644 trunk/src/liblist.py create mode 100644 trunk/src/list.py rename trunk/src/{GuiObjects => }/menuItem.py (100%) create mode 100644 trunk/src/playlist.py rename trunk/src/{GuiObjects => }/plistView.py (98%) create mode 100644 trunk/src/queue.py create mode 100644 trunk/src/rightPane.py rename trunk/src/{GuiObjects => }/scrobbler.py (99%) diff --git a/trunk/Makefile b/trunk/Makefile index 33e8d7be..6e9152d8 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -1,25 +1,18 @@ open: - geany & - geany src/GuiObjects/*.py - geany src/*.py + geany src/*.py & clean: rm -rf src/*.pyo + rm -rf src/*.pyc rm -rf src/*~ rm -rf src/*.c rm -rf src/*.o rm -rf src/*.so - rm -rf src/GuiObjects/*.pyo - rm -rf src/GuiObjects/*~ - rm -rf src/GuiObjects/*.c - rm -rf src/GuiObjects/*.o - rm -rf src/GuiObjects/*.so rm *~ compile: cd src && ./cythonize - cd src/GuiObjects && ./cythonize install: # mkdir ~/bin/ocarina-bin diff --git a/trunk/src/GuiObjects/__init__.py b/trunk/src/GuiObjects/__init__.py deleted file mode 100644 index 2d9d7956..00000000 --- a/trunk/src/GuiObjects/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Used for initializing things in the GuiObjects directory - -__all__ = ['button','check','controlPanel','image','scrobbler','menuItem','libView','infoView','plistView'] diff --git a/trunk/src/GuiObjects/image.py b/trunk/src/GuiObjects/image.py deleted file mode 100644 index 4e38c74a..00000000 --- a/trunk/src/GuiObjects/image.py +++ /dev/null @@ -1,8 +0,0 @@ -import gtk - - -class Image(gtk.Image): - def __init__(self,path): - gtk.Image.__init__(self) - self.set_from_file(path) - self.show() diff --git a/trunk/src/GuiObjects/infoView.py b/trunk/src/GuiObjects/infoView.py deleted file mode 100644 index 060f5d80..00000000 --- a/trunk/src/GuiObjects/infoView.py +++ /dev/null @@ -1,42 +0,0 @@ -import pango -import gtk - - -class InfoView(gtk.VBox): - def __init__(self,data): - gtk.VBox.__init__(self,False,0) - self.data = data - self.title = self.makeLabel("",13000,700) - self.album = self.makeLabel("",10000,400) - self.artist = self.makeLabel("",10000,400) - self.changeLabels() - self.show() - - - # Called when the song changes - def changeLabels(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) - - - # Set the text, font, and weight of a label - def makeLabel(self,text,size,weight): - label = gtk.Label(text) - align = gtk.Alignment(0,1,0,0) - attr = pango.AttrList() - attr.insert(pango.AttrSize(size,0,-1)) - attr.insert(pango.AttrWeight(weight,0,-1)) - label.set_attributes(attr) - align.add(label) - self.pack_start(align,False,False,0) - label.show() - align.show() - return label diff --git a/trunk/src/GuiObjects/button.py b/trunk/src/button.py similarity index 100% rename from trunk/src/GuiObjects/button.py rename to trunk/src/button.py diff --git a/trunk/src/GuiObjects/check.py b/trunk/src/check.py similarity index 100% rename from trunk/src/GuiObjects/check.py rename to trunk/src/check.py diff --git a/trunk/src/contentPane.py b/trunk/src/contentPane.py new file mode 100644 index 00000000..94c569fd --- /dev/null +++ b/trunk/src/contentPane.py @@ -0,0 +1,33 @@ +import gtk + +from libView import LibView +from scrobbler import Scrobbler +from plistView import PlistView +from controlPanel import ControlPanel + +from rightPane import RightPane + +class ContentPane(gtk.HBox): + def __init__(self,data): + gtk.HBox.__init__(self,False,0) + self.data = data + + self.divider = gtk.HPaned() + self.divider.set_position(self.data.divider) + self.divider.show() + self.add(self.divider) + + self.makeLeftSide() + self.makeRightSide() + + self.show() + + + def makeLeftSide(self): + self.data.scrobbler = Scrobbler(self.data) + self.divider.add1(self.data.scrobbler) + + + def makeRightSide(self): + self.right = RightPane(self.data) + self.divider.add2(self.right) diff --git a/trunk/src/GuiObjects/controlPanel.py b/trunk/src/controlPanel.py similarity index 100% rename from trunk/src/GuiObjects/controlPanel.py rename to trunk/src/controlPanel.py diff --git a/trunk/src/saveddata.py b/trunk/src/data.py similarity index 99% rename from trunk/src/saveddata.py rename to trunk/src/data.py index 71bd4d00..ed230cdf 100644 --- a/trunk/src/saveddata.py +++ b/trunk/src/data.py @@ -3,7 +3,7 @@ import cPickle as pickle from library import Library -class SavedData: +class Data: def __init__(self,options): path = os.path.join(options.user,".ocarina") self.updateQ = False diff --git a/trunk/src/image.py b/trunk/src/image.py new file mode 100644 index 00000000..5bbeb58b --- /dev/null +++ b/trunk/src/image.py @@ -0,0 +1,11 @@ +import gtk + + +class Image(gtk.Image): + def __init__(self,path,stock): + gtk.Image.__init__(self) + if path: + self.set_from_file(path) + else: + self.set_from_stock(stock,gtk.ICON_SIZE_SMALL_TOOLBAR) + self.show() diff --git a/trunk/src/label.py b/trunk/src/label.py new file mode 100644 index 00000000..8cf5264d --- /dev/null +++ b/trunk/src/label.py @@ -0,0 +1,18 @@ +import gtk +import pango + +class Label(gtk.Alignment): + def __init__(self,text,size,weight): + gtk.Alignment.__init__(self,0,1,0,0) + self.show() + self.label = gtk.Label(text) + self.label.show() + attr = pango.AttrList() + attr.insert(pango.AttrSize(size,0,-1)) + attr.insert(pango.AttrWeight(weight,0,-1)) + self.label.set_attributes(attr) + self.add(self.label) + + + def set_text(self,text): + self.label.set_text(text) diff --git a/trunk/src/GuiObjects/libView.py b/trunk/src/libView.py similarity index 100% rename from trunk/src/GuiObjects/libView.py rename to trunk/src/libView.py diff --git a/trunk/src/liblist.py b/trunk/src/liblist.py new file mode 100644 index 00000000..c60cfcb5 --- /dev/null +++ b/trunk/src/liblist.py @@ -0,0 +1,36 @@ +import gtk +import gobject +from list import List + +class LibList(List): + def __init__(self,data): + List.__init__(self,data,"Library") + self.pbar = gtk.ProgressBar() + + self.pbaralign = gtk.Alignment(0,0,0,0) + self.pbaralign.add(self.pbar) + self.pbaralign.show() + + for file in self.data.library.files: + self.insert(file) + + self.filterRows("") + + + def updates(self): + self.pbar.show() + self.updating = True + gobject.timeout_add(500,self.updateLibview) + + + def stopUpdates(self): + self.updating = False + self.pbar.hide() + self.data.dump() + + + def updateLibview(self): + self.makeLabel() + self.pbar.pulse() + self.timeText() + return self.updating diff --git a/trunk/src/library.py b/trunk/src/library.py index 4dbc7a43..c1ec30e1 100644 --- a/trunk/src/library.py +++ b/trunk/src/library.py @@ -25,11 +25,8 @@ class Library: if os.path.exists(self.path) == False: #print "Directory not found: %s" % dir return - #print "Scanning: "+self.path self.traverse("") self.libview.stopUpdates() - #self.scanning = False - #print "Found %s files!" % str(self.count) def reset(self): @@ -59,12 +56,9 @@ class Library: song = SongInfo() song.filename = os.path.join(self.path,joined) self.files+=[song] - thread.start_new_thread(self.add,(self.hash(joined),self.count)) - #self.add(self.hash(joined),self.count) + #thread.start_new_thread(self.add,(self.hash(joined),self.count)) + self.add(self.hash(joined),self.count) self.count += 1 - #self.add(self.hash(joined),joined) - #else: - # self.notAdded.write(os.path.join(self.path,joined)+"\n") # Hash a file and return list of words @@ -109,9 +103,6 @@ class Library: print info.filename #print "here" - #info.title = info.title.lower() - #info.album = info.album.lower() - #info.artist = info.artist.lower() artist = info.artist.lower() info.artistl = artist album = info.album.lower() @@ -145,7 +136,7 @@ class Library: for i in range(len(album)-1): str = album[i]+album[i+1] info.double[str] = True - self.libview.insertSong(info) + self.libview.insert(info) # Return true if file is in the library diff --git a/trunk/src/list.py b/trunk/src/list.py new file mode 100644 index 00000000..2a15ae9e --- /dev/null +++ b/trunk/src/list.py @@ -0,0 +1,166 @@ +import gtk +import re + +class List(gtk.ScrolledWindow): + def __init__(self,data,text): + gtk.ScrolledWindow.__init__(self) + self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) + + self.text = text + self.count = 0 + self.seconds = 0 + + self.list = gtk.ListStore(int,str,str,str,str,int) + self.tree = gtk.TreeView(self.list) + self.data = data + cell = gtk.CellRendererText() + cols = ["Id","Title","Length","Artist","Album","#"] + for i in range(len(cols)): + col = gtk.TreeViewColumn(cols[i],cell) + col.add_attribute(cell,'text',i) + col.set_resizable(True) + col.set_sort_column_id(i) + col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) + col.set_min_width(2) + col.set_max_width(700) + col.set_sort_indicator(False) + if cols[i] != "Id": + self.tree.append_column(col) + col.set_fixed_width(self.data.colSizes[i-1]) + + self.tree.set_rules_hint(True) + self.tree.connect("row-activated",self.selectSong,"cliked",list) + self.sel = self.tree.get_selection() + self.sel.set_mode(gtk.SELECTION_MULTIPLE) + self.list.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING) + self.tree.show() + self.add(self.tree) + self.show() + self.resizeCols() + + self.label = gtk.Label() + self.makeLabel() + self.align = gtk.Alignment(1,0,0,0) + self.timeLabel = gtk.Label("") + self.timeLabel.show() + self.align.add(self.timeLabel) + self.timeText() + + self.string = "" + self.filter = self.list.filter_new() + self.filter.set_visible_func(self.hideRows,"") + self.sort = gtk.TreeModelSort(self.filter) + self.tree.set_model(self.sort) + + #self.align.show() + + + def selectSong(self): + print "song selected" + + + def resizeCols(self): + print "resize cols" + + + def insert(self,file): + self.list.insert(self.count,[file.id,file.title,file.length,file.artist,file.album,file.count]) + self.makeLabel() + self.timeText() + + + def makeLabel(self): + self.label.set_text(self.text+" ("+str(self.count)+")") + + + def timeText(self): + day = 0 + hour = 0 + min = 0 + sec = self.seconds + day = sec/86500 + sec = sec - (day*86500) + hour = sec/3600 + sec = sec - (hour*3600) + min = sec/60 + sec = sec - min*60 + string = "" + string = self.toStr(day,"day")+self.toStr(hour,"hour") + string += self.toStr(min,"minute")+self.toStr(sec,"second") + self.timeLabel.set_text(string) + + + def toStr(self,time,label): + if time > 0: + string = str(time) + " " + label + if time > 1: + string+="s" + string+=" " + return string + return "" + + + def drop(self): + if len(self.list) == 0: + return + iter = self.list.get_iter(0) + while iter: + if self.remove(iter) == False: + self.makeLabel() + self.timeText() + return + + + def remove(self,iter): + self.count -= 1 + self.seconds -= self.data.library.files[self.list[iter][0]].duration + return self.list.remove(iter) + + + def filterRows(self,string): + self.string = string + 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.makeLabel() + self.timeText() + + + def hideRows(self,list,iter,string): + file = self.data.library.files[list[iter][0]] + if self.string == "": + self.visibleSong(file) + return True + elif len(self.string) == 1: + try: + file.single[self.string] + self.visibleSong(file) + return True + except: + return False + elif len(self.string) == 2: + try: + file.double[self.string] + self.visibleSong(file) + return True + except: + return False + if re.search(self.string,file.titlel): + self.visibleSong(file) + return True + elif re.search(self.string,file.artistl): + self.visibleSong(file) + return True + elif re.search(self.string,file.albuml): + self.visibleSong(file) + return True + return False + + + def visibleSong(self,file): + self.seconds += file.duration + self.count+=1 diff --git a/trunk/src/GuiObjects/menuItem.py b/trunk/src/menuItem.py similarity index 100% rename from trunk/src/GuiObjects/menuItem.py rename to trunk/src/menuItem.py diff --git a/trunk/src/ocarina.py b/trunk/src/ocarina.py index a4519be3..37b71236 100644 --- a/trunk/src/ocarina.py +++ b/trunk/src/ocarina.py @@ -3,7 +3,7 @@ import gtk import gobject from options import Options -from saveddata import SavedData +from data import Data from window import Window @@ -17,7 +17,7 @@ class main: if ("-v" in argv) == True: self.options.verbose = True # Load saved data (or create new data) - self.data = SavedData(self.options) + self.data = Data(self.options) #self.data.song = Song(self.quit) self.data.quit = None @@ -31,8 +31,8 @@ class main: print "Quitting..." #print self.window.get_size() self.data.size = self.window.get_size() - self.data.divider = self.window.divider.get_position() - self.window.plistview.saveCols() + self.data.divider = self.window.contentPane.divider.get_position() + #self.window.contentPane.plistview.saveCols() #self.data.clearSong() self.data.dump() #self.library.dump() diff --git a/trunk/src/playlist.py b/trunk/src/playlist.py new file mode 100644 index 00000000..6ec213c7 --- /dev/null +++ b/trunk/src/playlist.py @@ -0,0 +1,7 @@ +from list import List + +class Playlist(List): + def __init__(self,data): + List.__init__(self,data,"Playlist") + print "playlist" + diff --git a/trunk/src/GuiObjects/plistView.py b/trunk/src/plistView.py similarity index 98% rename from trunk/src/GuiObjects/plistView.py rename to trunk/src/plistView.py index 22dfd3e2..1b7a80b7 100644 --- a/trunk/src/GuiObjects/plistView.py +++ b/trunk/src/plistView.py @@ -6,6 +6,8 @@ import re from menuItem import MenuItem from song import Song +from list import List + CONTINUE = 0 PAFTER = 1 @@ -345,8 +347,6 @@ class PlistView(gtk.Notebook): return True except: return False - #if self.search in self.data.library.files[list[iter][0]].letters == True: - # return True file = self.data.library.files[list[iter][0]] if re.search(self.search,file.titlel): return True diff --git a/trunk/src/queue.py b/trunk/src/queue.py new file mode 100644 index 00000000..c2ab2a88 --- /dev/null +++ b/trunk/src/queue.py @@ -0,0 +1,6 @@ +from list import List + +class Queue(List): + def __init__(self,data): + List.__init__(self,data,"Queue") + print "Making queue" diff --git a/trunk/src/rightPane.py b/trunk/src/rightPane.py new file mode 100644 index 00000000..43aed18e --- /dev/null +++ b/trunk/src/rightPane.py @@ -0,0 +1,192 @@ +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) diff --git a/trunk/src/GuiObjects/scrobbler.py b/trunk/src/scrobbler.py similarity index 99% rename from trunk/src/GuiObjects/scrobbler.py rename to trunk/src/scrobbler.py index 4c6bfafc..d7164d04 100644 --- a/trunk/src/GuiObjects/scrobbler.py +++ b/trunk/src/scrobbler.py @@ -57,7 +57,7 @@ class Scrobbler(gtk.VBox): self.pack_start(passwd,False,False,0) self.pack_start(password,False,False,0) else: - self.handshake() + #self.handshake() #self.labels = [gtk.Label("")]*10 self.similar = [] for i in range(10): @@ -113,6 +113,8 @@ class Scrobbler(gtk.VBox): # print line.strip() def nowPlaying(self,info): + if self.session == None: + self.handshake() vals = {"s":self.session, "a":info.artist.title(), "t":info.title.title(), diff --git a/trunk/src/window.py b/trunk/src/window.py index 0ad7327a..f3c7e2e2 100644 --- a/trunk/src/window.py +++ b/trunk/src/window.py @@ -1,12 +1,14 @@ 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 +from contentPane import ContentPane + +from menuItem import MenuItem +from libView import LibView +from plistView import PlistView +from controlPanel import ControlPanel +#from infoView import InfoView +from scrobbler import Scrobbler class Window(gtk.Window): @@ -57,9 +59,10 @@ class Window(gtk.Window): def deleteLib(self,widgit,data,other=None): + self.contentPane.right.dumpLib() self.data.library.reset() - self.libview.update() - self.clearPlist(None,None) + #self.libview.update() + #self.clearPlist(None,None) def clearPlist(self,widgit,data,other=None): @@ -75,9 +78,8 @@ class Window(gtk.Window): # Used to select a directory def selectDir(self,widgit,data,func): self.deleteLib(None,None) - dirsel = gtk.FileChooserDialog(None,action=gtk.FILE_CHOOSER_ACTION_OPEN,buttons =(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + dirsel = gtk.FileChooserDialog(None,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: @@ -85,64 +87,10 @@ class Window(gtk.Window): dirsel.hide() if response != gtk.RESPONSE_OK: return - self.libview.updates() + self.contentPane.right.library.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.data.scrobbler = scrobbler - - 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.contentPane = ContentPane(self.data) 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)