ocarina/ocarina/list.py

50 lines
1.3 KiB
Python

# Bryan Schumaker (8/15/2010)
import ocarina
gtk = ocarina.gtk
gobject = ocarina.gobject
#UNI = gobject.TYPE_UNICHAR
class List(gtk.TreeView):
def __init__(self):
gtk.TreeView.__init__(self)
self.list = gtk.ListStore(int, str, str, str, str, int, str)
self.append = self.list.append
cell = gtk.CellRendererText()
cell.set_fixed_height_from_font(1)
cols = ["Id", "Title", "Length", "Artist", "Album", "Year", "Played"]
colw = [ 2, 300, 60, 125, 125, 50, 70]
for index, label in enumerate(cols):
col = gtk.TreeViewColumn(label, cell)
col.add_attribute(cell, 'text', index)
col.set_resizable(True)
col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
col.set_min_width(2)
col.set_max_width(700)
col.set_fixed_width(colw[index])
if label!="Id" and label!="Played":
self.append_column(col)
self.set_rules_hint(True)
self.set_tooltip_column(len(cols)-1)
self.filter_model = self.list.filter_new()
self.filter_model.set_visible_func(self.set_visible)
self.set_model(self.filter_model)
self.show_all()
def freeze(self):
self.set_model(None)
self.freeze_child_notify()
def thaw(self):
self.set_model(self.filter_model)
self.thaw_child_notify()
def set_visible(self, a, b):
return True