List.gotoCurSong() after sorting now works correctly
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@52 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
d41b443a9d
commit
860100f13a
|
@ -25,7 +25,6 @@ class Data:
|
|||
self.save(self.library,"library")
|
||||
self.library.libview = libview
|
||||
self.save([self.curList,self.curQ,self.curSong],"playlist")
|
||||
print self.colSizes
|
||||
self.save([self.size,self.divider,self.colSizes,self.sortedCol,self.random],"preferences")
|
||||
self.save([self.lfm,self.lfmuser,self.lfmpass],"last.fm")
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ class LibList(List):
|
|||
def filterRows(self,string):
|
||||
if self.updating == True:
|
||||
return
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
List.filterRows(self,string)
|
||||
|
||||
|
||||
|
@ -80,3 +78,9 @@ class LibList(List):
|
|||
|
||||
def filterQuick(self,string):
|
||||
List.filterQuick(self,self.data.library.files,string)
|
||||
|
||||
|
||||
def insert(self,file):
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
List.insert(self,file)
|
||||
|
|
|
@ -58,7 +58,9 @@ class Library:
|
|||
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)
|
||||
#self.add(self.hash(joined),self.count)
|
||||
#thread.start_new_thread(self.add,(self.count))
|
||||
self.add(self.count)
|
||||
self.count += 1
|
||||
|
||||
|
||||
|
@ -72,7 +74,7 @@ class Library:
|
|||
|
||||
|
||||
# Add song to library
|
||||
def add(self,words,index):
|
||||
def add(self,index):
|
||||
info = self.files[index]
|
||||
info.count = 0
|
||||
info.id = index
|
||||
|
|
|
@ -68,17 +68,21 @@ class List(gtk.ScrolledWindow):
|
|||
self.add(self.tree)
|
||||
|
||||
|
||||
# Select a song by double clicking on its row
|
||||
def selectSong(self,widgit,iter,path,data,list):
|
||||
self.loadSong(self.data.library.files[self.filter[iter][0]])
|
||||
#self.loadSong(self.data.library.files[self.filter[iter][0]])
|
||||
self.loadSong(self.data.library.files[self.sort[iter][0]])
|
||||
self.plause(None,None)
|
||||
self.data.scrobbler.nowPlaying(self.data.song.info)
|
||||
|
||||
|
||||
# Opens a menu on a right click
|
||||
def clicked(self,widgit,data):
|
||||
if data.button == 3:
|
||||
self.rcmenu.popup(None,None,None,data.button,data.time)
|
||||
|
||||
|
||||
# Add a row to the list
|
||||
def insert(self,file):
|
||||
self.list.insert(self.count,[file.id,file.title,file.length,file.artist,file.album,file.count])
|
||||
self.count+=1
|
||||
|
@ -202,20 +206,22 @@ class List(gtk.ScrolledWindow):
|
|||
self.data.song = Song(file,self.next)
|
||||
self.data.curSong = file.id
|
||||
self.labels()
|
||||
self.gotoCurSong()
|
||||
|
||||
|
||||
# Scroll the window and select the row
|
||||
def gotoCurSong(self):
|
||||
if len(self.filter) == 0:
|
||||
return
|
||||
for i in range(len(self.tree)):
|
||||
if self.tree[i][0] == self.data.curSong:
|
||||
print self.tree[i][0],self.data.curSong
|
||||
# self.sort will be filtered, and it will have rows in the correct order
|
||||
for i in range(len(self.sort)):
|
||||
if self.sort[i][0] == self.data.curSong:
|
||||
if i > 10:
|
||||
self.tree.scroll_to_cell(i-10,None,True,0,0)
|
||||
else:
|
||||
self.tree.scroll_to_cell(0,None,True,0,0)
|
||||
self.tree.set_cursor_on_cell(i,None,None,False)
|
||||
#return
|
||||
return
|
||||
|
||||
|
||||
def visible(self,func):
|
||||
|
@ -223,22 +229,24 @@ class List(gtk.ScrolledWindow):
|
|||
self.loadCols()
|
||||
self.align.show()
|
||||
self.tree.show()
|
||||
self.gotoCurSong()
|
||||
else:
|
||||
self.storeCols()
|
||||
self.align.hide()
|
||||
self.tree.hide()
|
||||
|
||||
|
||||
# Store the columns into an array in self.data
|
||||
def storeCols(self):
|
||||
#cols = self.tree.get_columns()
|
||||
for i in range(len(self.cols)):
|
||||
self.data.colSizes[i] = self.cols[i].get_width()
|
||||
|
||||
|
||||
# Load columns from self.data
|
||||
def loadCols(self):
|
||||
#cols = self.tree.get_columns()
|
||||
for i in range(len(self.cols)):
|
||||
width = self.data.colSizes[i]
|
||||
# Column widths are too small, set an initial width here
|
||||
if width <= 0:
|
||||
if i==0:
|
||||
width = 200
|
||||
|
|
|
@ -4,31 +4,45 @@ class Queue(List):
|
|||
def __init__(self,data,nextFunc,labelFunc,plause):
|
||||
List.__init__(self,data,"Queue",nextFunc,labelFunc,plause)
|
||||
self.data = data
|
||||
#for file in self.data.curQ:
|
||||
# List.insert(self,self.data.library.files[file])
|
||||
self.populated = False
|
||||
self.count = len(self.data.curQ)
|
||||
self.makeLabel()
|
||||
#self.filterRows("")
|
||||
|
||||
|
||||
# Returns true if we had a song to load, false otherwise
|
||||
def getNext(self):
|
||||
# Populate the queue
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
# No songs in queue, return false
|
||||
if len(self.list) == 0:
|
||||
return False
|
||||
# Queue ignores random settings and filtering
|
||||
# Queue ignores random settings and filtering, just takes next song
|
||||
self.data.curSong = self.list[0][0]
|
||||
self.data.curQ.pop(self.data.curQ.index(self.data.curSong))
|
||||
|
||||
# Remove file from queue and tree
|
||||
for i in range(len(self.data.curQ)):
|
||||
if self.data.curQ[i].id == self.data.curSong:
|
||||
self.data.curQ.pop(i)
|
||||
break
|
||||
self.remove(self.list.get_iter_root())
|
||||
self.filterRows(self.string)
|
||||
|
||||
# Removed 7/30/2009 (Do I really need to do this?)
|
||||
#self.filterRows(self.string)
|
||||
self.loadSong(self.data.library.files[self.data.curSong])
|
||||
return True
|
||||
|
||||
|
||||
# Inselt a song into the queue
|
||||
# Updates the visible treeview and the self.data.curQ array
|
||||
def insert(self,file):
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
List.insert(self,file)
|
||||
self.data.curQ += [file]
|
||||
|
||||
|
||||
# Shows and hides the treeview, populates if empty
|
||||
def visible(self,func):
|
||||
List.visible(self,func)
|
||||
if (func == "show") and (self.populated == False):
|
||||
|
@ -39,11 +53,7 @@ class Queue(List):
|
|||
self.timeText()
|
||||
|
||||
|
||||
def filterRows(self,string):
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
List.filterRows(self,string)
|
||||
|
||||
|
||||
# Filters things quicker because it does not have to show/hide rows
|
||||
# This is only called for offscreen tabs
|
||||
def filterQuick(self,string):
|
||||
List.filterQuick(self,self.data.curQ,string)
|
||||
|
|
|
@ -15,7 +15,7 @@ class RightPane(gtk.VBox):
|
|||
gtk.VBox.__init__(self,False,0)
|
||||
self.show()
|
||||
self.data = data
|
||||
print self.data.curSong
|
||||
#print self.data.curSong
|
||||
|
||||
self.title = Label("",13000,700)
|
||||
self.album = Label("",10000,400)
|
||||
|
@ -162,6 +162,7 @@ class RightPane(gtk.VBox):
|
|||
|
||||
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):
|
||||
|
@ -172,18 +173,25 @@ class RightPane(gtk.VBox):
|
|||
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
|
||||
|
@ -212,11 +220,15 @@ class RightPane(gtk.VBox):
|
|||
self.queue.drop()
|
||||
|
||||
|
||||
# text was typed, refilter rows
|
||||
# IDEA: refilter in half a second, if no additional text was typed
|
||||
def textTyped(self,entry):
|
||||
search = entry.get_text().lower()
|
||||
self.filter(search)
|
||||
|
||||
|
||||
# Filter the rows of the current tab
|
||||
# Do a quickFilter on nonvisible tabs
|
||||
def filter(self,search):
|
||||
if self.curTab == 0:
|
||||
self.playlist.filterRows(search)
|
||||
|
@ -237,6 +249,7 @@ class RightPane(gtk.VBox):
|
|||
self.library.filterQuick(search)
|
||||
|
||||
|
||||
# Coose to pause after the current song or not
|
||||
def setStatus(self,status):
|
||||
if status == "pafter":
|
||||
self.status = "pafter"
|
||||
|
@ -244,8 +257,8 @@ class RightPane(gtk.VBox):
|
|||
print status
|
||||
|
||||
|
||||
# Store the width of the current tabs columns
|
||||
def storeCols(self):
|
||||
print self.curTab
|
||||
if self.curTab == 0:
|
||||
self.playlist.storeCols()
|
||||
elif self.curTab == 1:
|
||||
|
|
Loading…
Reference in New Issue
Block a user