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) index = len(self.data.files)
info = SongInfo() info = SongInfo()
info.filename = os.path.join(self.data.path,file) info.filename = os.path.join(self.data.path,file)
info.count = 0
#use later for length #use later for length
# a = f.audioProperties() #a = f.audioProperties()
# info.length = a.length #info.length = a.length
#print file #print file
split = file.rsplit(os.sep) split = file.rsplit(os.sep)
@ -101,9 +102,13 @@ class Library():
info.album = t.album info.album = t.album
if t.artist != "": if t.artist != "":
info.artist = t.artist info.artist = t.artist
a = f.audioProperties()
info.length = a.length
info.id = len(self.data.files)
self.data.files+=[info] self.data.files+=[info]
print len(self.data.files) print info.id
for word in words: for word in words:
if (word in self.data.map.keys()) == True: if (word in self.data.map.keys()) == True:
self.data.map[word]+=[index] self.data.map[word]+=[index]
@ -144,7 +149,8 @@ class Library():
def translate(self,sid): 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 #print file.title, file.artist, file.album
return (sid,file.title,file.artist,file.album,file.playCount) return (sid,file.title,file.artist,file.album,file.playCount)
#return (file.artist,file.album) #return (file.artist,file.album)

View File

@ -56,7 +56,7 @@ class Operations:
def next(self,widget,data): def next(self,widget,data):
# Close open songs # Close open songs
if self.song != None: if self.song != None:
self.song.info.playCount+=1 self.song.info.count+=1
self.song.close() self.song.close()
# Are we exiting? # Are we exiting?
if self.after == QUIT: if self.after == QUIT:

View File

@ -2,9 +2,10 @@ from duration import Duration
class SongInfo: class SongInfo:
def __init__(self): def __init__(self):
self.id = 0
self.filename = "" self.filename = ""
self.tags = dict() self.tags = dict()
self.playCount = 0 self.count = 0
self.banned = False self.banned = False
self.length = None self.length = None
self.title = "" self.title = ""

View File

@ -4,6 +4,7 @@ import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import thread import thread
from kiwi.ui.objectlist import Column, ObjectList
class Window(gtk.Window): class Window(gtk.Window):
@ -90,6 +91,31 @@ class Window(gtk.Window):
def makeList(self): 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 # Make scrolled window, add to window
scroll = gtk.ScrolledWindow() scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
@ -119,9 +145,11 @@ class Window(gtk.Window):
self.tree.show() self.tree.show()
scroll.show() scroll.show()
#self.gotoCurSong() #self.gotoCurSong()
'''
def gotoCurSong(self): def gotoCurSong(self):
#return
if len(self.list) == 0: if len(self.list) == 0:
return return
#print self.list[0][0] #print self.list[0][0]
@ -130,18 +158,19 @@ class Window(gtk.Window):
row = 0 row = 0
for i in range(len(self.list)): for i in range(len(self.list)):
#print i #print i
if self.list[i][0] == self.ops.plist.curSong: if self.list[i].id == self.ops.plist.curSong:
if i > 10: if i > 10:
selrow = i - 10 selrow = i - 10
row = i row = i
break break
self.list.select(self.list[row],True)
#selrow = self.ops.plist.curSong - 10 #selrow = self.ops.plist.curSong - 10
#if selrow < 0: #if selrow < 0:
# selrow = 0 # selrow = 0
#print selrow,row #print selrow,row
self.tree.scroll_to_cell(selrow,None,True,0,0) #self.tree.scroll_to_cell(selrow,None,True,0,0)
treesel = self.tree.get_selection() #treesel = self.tree.get_selection()
treesel.select_path(row) #treesel.select_path(row)
# Use to make play/pause/next/etc buttons # Use to make play/pause/next/etc buttons