ocarina/src/extra/oGtk/list.py

73 lines
1.9 KiB
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Mar 21, 2010 1:06:27 PM$"
import gtk
import guibuilder
import db
class SongList(gtk.ScrolledWindow):
def __init__(self):
gtk.ScrolledWindow.__init__(self)
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.list = gtk.ListStore(int,str,str,str,str,int)
self.tree = gtk.TreeView(self.list)
self.tree.set_reorderable(True)
cell = gtk.CellRendererText()
cols = ["Id","Title","Length","Artist","Album","Play Count"]
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_fixed_width(150)
col.set_sort_indicator(True)
if cols[i] != "Id":
self.tree.append_column(col)
self.tree.set_rules_hint(True)
#self.tree.connect("row-activated",self.selectSong,"clicked",list)
#self.tree.connect("button_release_event",self.clicked)
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.cols = self.tree.get_columns()
#self.loadCols()
#self.tree.show()
self.add(self.tree)
self.show_all()
# 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
self.seconds+=file.duration
class LibraryList(SongList):
def __init__(self):
SongList.__init__(self)
libid = db.libid("Music")
#print db.listlib()
def make_songlist(attrs=None):return SongList()
def make_librarylist(attrs=None):return LibraryList()
guibuilder.parts["songlist"] = make_songlist
guibuilder.parts["librarylist"] = make_librarylist