ocarina/trunk/src/GuiObjects/plistView.py

42 lines
1.1 KiB
Python

import gobject
import pygtk
pygtk.require('2.0')
import gtk
class PlistView(gtk.ScrolledWindow):
def __init__(self,data):
gtk.ScrolledWindow.__init__(self)
self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
self.data = data
self.tree = None
self.makeList()
gobject.timeout_add(1000,self.checkUpdate)
def checkUpdate(self):
if self.data.updateList == True:
self.data.updateList = False
self.makeList()
return True
def makeList(self):
trackList= gtk.ListStore(int,str,str,str,str)
if self.tree:
self.remove(self.tree)
for index in self.data.curList:
track = self.data.library.files[index]
trackList.append([track.id,track.title,track.artist,track.album,track.length])
self.tree = gtk.TreeView(trackList)
cell = gtk.CellRendererText()
cols = ["Id","Title","Artist","Album","Length"]
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)
self.tree.append_column(col)
self.tree.show()
self.add(self.tree)