diff --git a/trunk/library.py b/trunk/library.py index 73f1fcfc..4414ce0c 100644 --- a/trunk/library.py +++ b/trunk/library.py @@ -73,10 +73,11 @@ class Library(): index = len(self.data.files) info = SongInfo() info.filename = os.path.join(self.data.path,file) + info.count = 0 #use later for length - # a = f.audioProperties() - # info.length = a.length + #a = f.audioProperties() + #info.length = a.length #print file split = file.rsplit(os.sep) @@ -101,9 +102,13 @@ class Library(): info.album = t.album if t.artist != "": info.artist = t.artist + + a = f.audioProperties() + info.length = a.length + info.id = len(self.data.files) self.data.files+=[info] - print len(self.data.files) + print info.id for word in words: if (word in self.data.map.keys()) == True: self.data.map[word]+=[index] @@ -144,7 +149,8 @@ class Library(): def translate(self,sid): - file = self.data.files[sid] + #file = self.data.files[sid] + return self.data.files[sid] #print file.title, file.artist, file.album return (sid,file.title,file.artist,file.album,file.playCount) #return (file.artist,file.album) diff --git a/trunk/operations.py b/trunk/operations.py index 2cca760f..76e4cc8c 100644 --- a/trunk/operations.py +++ b/trunk/operations.py @@ -56,7 +56,7 @@ class Operations: def next(self,widget,data): # Close open songs if self.song != None: - self.song.info.playCount+=1 + self.song.info.count+=1 self.song.close() # Are we exiting? if self.after == QUIT: diff --git a/trunk/songInfo.py b/trunk/songInfo.py index a0dfd591..2f0f6e58 100644 --- a/trunk/songInfo.py +++ b/trunk/songInfo.py @@ -2,9 +2,10 @@ from duration import Duration class SongInfo: def __init__(self): + self.id = 0 self.filename = "" self.tags = dict() - self.playCount = 0 + self.count = 0 self.banned = False self.length = None self.title = "" diff --git a/trunk/window.py b/trunk/window.py index d1a83eae..1574080f 100644 --- a/trunk/window.py +++ b/trunk/window.py @@ -4,6 +4,7 @@ import pygtk pygtk.require('2.0') import gtk import thread +from kiwi.ui.objectlist import Column, ObjectList class Window(gtk.Window): @@ -90,6 +91,31 @@ class Window(gtk.Window): def makeList(self): + title = Column('title') + title.expand = True + title.searchable = True + artist = Column('artist') + artist.expand = True + artist.searchable = True + album = Column('album') + album.expand = True + album.searchable = True + count = Column('count') + count.expand = True + #count.searchable = True + length = Column('length') + length.expand = True + #length.searchable = True + self.list = ObjectList([title,artist,album,count,length]) + for num in self.ops.plist.list: + #print self.ops.plist.translate(num) + self.list.append(self.ops.plist.translate(num)) + #self.list.append(num) + self.list.sort_by_attribute('artist') + self.list.connect("row-activated",self.ops.plist.selectSong,"clicked",self.list) + self.list.show() + self.mainLayout.add(self.list) + ''' # Make scrolled window, add to window scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) @@ -119,9 +145,11 @@ class Window(gtk.Window): self.tree.show() scroll.show() #self.gotoCurSong() + ''' def gotoCurSong(self): + #return if len(self.list) == 0: return #print self.list[0][0] @@ -130,18 +158,19 @@ class Window(gtk.Window): row = 0 for i in range(len(self.list)): #print i - if self.list[i][0] == self.ops.plist.curSong: + if self.list[i].id == self.ops.plist.curSong: if i > 10: selrow = i - 10 row = i break + self.list.select(self.list[row],True) #selrow = self.ops.plist.curSong - 10 #if selrow < 0: # selrow = 0 #print selrow,row - self.tree.scroll_to_cell(selrow,None,True,0,0) - treesel = self.tree.get_selection() - treesel.select_path(row) + #self.tree.scroll_to_cell(selrow,None,True,0,0) + #treesel = self.tree.get_selection() + #treesel.select_path(row) # Use to make play/pause/next/etc buttons