Used kiwi instead of gtk.treeview

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@26 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-06-27 00:05:50 +00:00
parent 6966d928b6
commit 9b9fe546ed
4 changed files with 46 additions and 10 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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 = ""

View File

@ -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