More gui objects created, can filter a playlist, began implementing
system calls
This commit is contained in:
parent
a9040d9481
commit
e9561d5351
|
@ -9,35 +9,22 @@ __date__ ="$Mar 13, 2010 9:08:56 PM$"
|
|||
import readline
|
||||
import rlcompleter
|
||||
|
||||
from ct import cmd
|
||||
import ocarina
|
||||
|
||||
readline.parse_and_bind("tab:complete")
|
||||
|
||||
global quit
|
||||
quit = False
|
||||
from ct.call import *
|
||||
|
||||
|
||||
def loop():
|
||||
global quit
|
||||
while quit == False:
|
||||
while True:
|
||||
try:
|
||||
s = raw_input(ocarina.vars["$prompt"] + " ")
|
||||
cmd.run(s)
|
||||
except:
|
||||
ocarina.events.start("ocarina-stop")
|
||||
exec raw_input(ocarina.vars["$prompt"] + " ")
|
||||
|
||||
# Catch this so that we can use ctrl-d to exit
|
||||
except EOFError:
|
||||
print ""
|
||||
exit()
|
||||
except Exception,e:
|
||||
print e
|
||||
|
||||
|
||||
def uninit():
|
||||
global quit
|
||||
quit = True
|
||||
|
||||
|
||||
|
||||
#def init():
|
||||
# ocarina.events.invite("ocarina-start",loop)
|
||||
# ocarina.events.invite("ocarina-stop",uninit)
|
||||
|
||||
|
||||
ocarina.events.invite("ocarina-start",loop)
|
||||
ocarina.events.invite("ocarina-stop",uninit)
|
||||
ocarina.events.invite("ocarina-start",loop)
|
|
@ -6,6 +6,7 @@
|
|||
__author__="bjschuma"
|
||||
__date__ ="$Mar 15, 2010 9:53:46 PM$"
|
||||
|
||||
import ocarina
|
||||
from ct import path
|
||||
from ocarina import vars
|
||||
|
||||
|
@ -16,3 +17,10 @@ vars["$verbose"] = 0
|
|||
vars["$path"] = "coreplug"
|
||||
vars["$prompt"] = ">>>"
|
||||
vars["$playonload"] = True
|
||||
vars["$playing"] = False
|
||||
|
||||
|
||||
ocarina.init()
|
||||
import scripting
|
||||
import manager
|
||||
import gstreamer
|
||||
|
|
|
@ -2,4 +2,4 @@ __author__="bjschuma"
|
|||
__date__ ="$Mar 13, 2010 4:20:16 PM$"
|
||||
|
||||
|
||||
__all__ = ["cmd", "dict", "message", "opts", "path", "plugin","slist"]
|
||||
__all__ = ["call", "cmd", "dict", "message", "opts", "path", "plugin","slist"]
|
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 30, 2010 11:24:43 PM$"
|
||||
|
||||
|
||||
import ocarina
|
||||
|
||||
def load(path):
|
||||
import gstreamer
|
||||
gstreamer.load(path)
|
||||
|
||||
|
||||
def seek(prcnt):
|
||||
import gstreamer
|
||||
gstreamer.seek(prcnt)
|
||||
|
||||
|
||||
def play():
|
||||
ocarina.events.start("ocarina-play")
|
||||
|
||||
|
||||
def pause():
|
||||
ocarina.events.start("ocarina-pause")
|
||||
|
||||
|
||||
def stop():
|
||||
pause()
|
||||
seek(0)
|
||||
|
|
@ -35,6 +35,8 @@ def play():
|
|||
player.set_state(gst.STATE_PLAYING)
|
||||
if getstate() != gst.STATE_PLAYING:
|
||||
ocarina.events.stop("ocarina-play")
|
||||
else:
|
||||
ocarina.vars["$playing"] = True
|
||||
|
||||
|
||||
def pause():
|
||||
|
@ -42,6 +44,8 @@ def pause():
|
|||
player.set_state(gst.STATE_PAUSED)
|
||||
if getstate() != gst.STATE_PAUSED:
|
||||
ocarina.events.stop("ocarina-pause")
|
||||
else:
|
||||
ocarina.vars["$playing"] = False
|
||||
|
||||
|
||||
def load(song):
|
||||
|
@ -122,12 +126,26 @@ def getProgress():
|
|||
return 0
|
||||
total = duration()
|
||||
current = currentpos()
|
||||
return float(current) / float(total)
|
||||
fraction = float(current) / float(total)
|
||||
if fraction < 0.0:
|
||||
return 0.0
|
||||
elif fraction > 1.0:
|
||||
return 1.0
|
||||
return fraction
|
||||
|
||||
|
||||
def seek(prcnt):
|
||||
# Seek to the desired percent of the song.
|
||||
# Fraction is True if prcnt is already a fraction
|
||||
def seek(prcnt,fraction=False):
|
||||
global player
|
||||
global time
|
||||
if fraction == False:
|
||||
prcnt = float(prcnt)
|
||||
if prcnt < 0:
|
||||
return
|
||||
elif prcnt > 100:
|
||||
return
|
||||
prcnt = prcnt / 100.0
|
||||
newTime = duration() * prcnt
|
||||
player.seek_simple(time,gst.SEEK_FLAG_FLUSH,newTime)
|
||||
|
||||
|
|
|
@ -5,13 +5,10 @@ __date__ ="$Mar 13, 2010 4:19:31 PM$"
|
|||
|
||||
import ocarina
|
||||
import coredefaults
|
||||
ocarina.init()
|
||||
|
||||
from ct.message import write
|
||||
import scripting
|
||||
import manager
|
||||
import cli
|
||||
import gstreamer
|
||||
from ct.call import *
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ __date__ ="$Mar 13, 2010 4:19:39 PM$"
|
|||
from ct.dict import Dict
|
||||
from ct import opts
|
||||
from ct import path
|
||||
from ct import call
|
||||
import event
|
||||
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ def listlib():
|
|||
|
||||
|
||||
def getpath(dbid):
|
||||
curlib = str( settings.get("curlib") )
|
||||
curlib = str( libid("Music") )
|
||||
|
||||
selr = sql.Select("path","library","id="+curlib)
|
||||
root = selr.execute().fetchone()[0]
|
||||
|
@ -153,4 +153,16 @@ def getpath(dbid):
|
|||
return root+track
|
||||
|
||||
|
||||
def getsongs(libid):
|
||||
sel = sql.Select("*","libtrack","library="+str(libid))
|
||||
return sel.execute().fetchall()
|
||||
|
||||
|
||||
def gettrack(trid):
|
||||
select = "track.id,track.name,track.length,artist.name,album.name,track.count"
|
||||
where = "track.artist=artist.id AND track.album=album.id AND track.id="+str(trid)
|
||||
sel = sql.Select(select,"track,artist,album",where)
|
||||
return sel.execute().fetchone()
|
||||
|
||||
|
||||
init()
|
|
@ -12,6 +12,7 @@ from et import sql
|
|||
from ct.path import *
|
||||
from ct.message import write
|
||||
import ocarina
|
||||
import index
|
||||
|
||||
import tagpy
|
||||
import re
|
||||
|
@ -77,7 +78,7 @@ def insartalb(table,value):
|
|||
|
||||
|
||||
# Call to insert a new track
|
||||
def instrk(arid, alid, title, length, path):
|
||||
def instrk(arid, artist, alid, album, title, length, path):
|
||||
global root
|
||||
global libid
|
||||
if title == "":
|
||||
|
@ -93,6 +94,7 @@ def instrk(arid, alid, title, length, path):
|
|||
ins.execute()
|
||||
result = sel.execute().fetchall()
|
||||
|
||||
|
||||
trid = str(result[0][0])
|
||||
|
||||
where = "library='"+libid+"' AND track='"+trid+"'"
|
||||
|
@ -102,6 +104,10 @@ def instrk(arid, alid, title, length, path):
|
|||
ins = sql.Insert("libtrack",[int(libid),int(trid)])
|
||||
ins.execute()
|
||||
|
||||
index.add(title,trid)
|
||||
index.add(album,trid)
|
||||
index.add(artist,trid)
|
||||
|
||||
|
||||
|
||||
def addtrk(path):
|
||||
|
@ -121,7 +127,7 @@ def addtrk(path):
|
|||
alid = insartalb("album", t.album)
|
||||
|
||||
a = f.audioProperties()
|
||||
instrk(arid, alid, t.title, a.length, path)
|
||||
instrk(arid, t.artist, alid, t.album, t.title, a.length, path)
|
||||
except:
|
||||
write("Error adding: "+path)
|
||||
#pass
|
||||
|
@ -165,6 +171,7 @@ def go(name):
|
|||
#print "Done scanning"
|
||||
#print total, added
|
||||
scan(path,addtrk)
|
||||
index.save()
|
||||
ocarina.events.start("ocarina-scanlib-stop")
|
||||
|
||||
# Start a thread to actually add tracks to the db
|
||||
|
|
|
@ -7,8 +7,12 @@ __author__="bjschuma"
|
|||
__date__ ="$Mar 16, 2010 7:36:48 PM$"
|
||||
|
||||
|
||||
def ftime(time):
|
||||
time = time/1000000000
|
||||
def ftime(time,ms=True):
|
||||
time = int(time)
|
||||
# Convert to seconds if we were given milliseconds
|
||||
if ms==True:
|
||||
time = time/1000000000
|
||||
|
||||
#print time
|
||||
# Find hour
|
||||
length = ""
|
||||
|
|
|
@ -13,4 +13,5 @@ import coredefaults
|
|||
vars["$theme"] = "themes/classic.xml"
|
||||
vars["$artist"] = ""
|
||||
vars["$album"] = ""
|
||||
vars["$title"] = ""
|
||||
vars["$title"] = ""
|
||||
vars["$filterText"] = ""
|
|
@ -24,6 +24,20 @@ global window
|
|||
window = None
|
||||
|
||||
|
||||
def setPacking(old,newVals):
|
||||
for field in newVals:
|
||||
if (field=="expand") or (field=="fill"):
|
||||
if newVals[field]=="True":
|
||||
old[field] = True
|
||||
else:
|
||||
old[field] = False
|
||||
elif field=="padding":
|
||||
old[field] = int(newVals[field])
|
||||
|
||||
return old
|
||||
|
||||
|
||||
|
||||
def buildTabs(node,tabs):
|
||||
global buildFunc
|
||||
|
||||
|
@ -45,6 +59,8 @@ def buildTabs(node,tabs):
|
|||
|
||||
if content != None:
|
||||
tabs.append_page(content,label)
|
||||
attrs = setPacking({"expand":False,"fill":False}, xm.attributes(child) )
|
||||
tabs.set_tab_label_packing(content,attrs["expand"],attrs["fill"],gtk.PACK_START)
|
||||
|
||||
|
||||
def buildMenu(node,menu):
|
||||
|
@ -52,7 +68,7 @@ def buildMenu(node,menu):
|
|||
for child in xm.children(node):
|
||||
item = buildFunc(child)
|
||||
if item!=None:
|
||||
if node.nodeName == "menubar":
|
||||
if node.nodeName == "menu-bar":
|
||||
menu.append(item)
|
||||
elif node.nodeName == "menuitem":
|
||||
menu.addSubMenu(item)
|
||||
|
@ -105,9 +121,9 @@ def build(node):
|
|||
if (tag in parts.keys()) == True:
|
||||
write("Creating part from tag: "+tag,2)
|
||||
part = parts[tag](xm.attributes(node))
|
||||
if (tag=="hbox") or (tag=="vbox") or (tag=="window"):
|
||||
if (tag=="hbox") or (tag=="vbox") or (tag=="window") or (tag=="scrolled-window"):
|
||||
fill(node,part)
|
||||
elif (tag=="menubar") or (tag=="menuitem"):
|
||||
elif (tag=="menu-bar") or (tag=="menuitem"):
|
||||
buildMenu(node,part)
|
||||
elif (tag=="tabs"):
|
||||
buildTabs(node,part)
|
||||
|
@ -121,6 +137,8 @@ def init():
|
|||
write("Building gui from file: "+ocarina.vars["$theme"],1)
|
||||
doc = xm.load(ocarina.vars["$theme"])
|
||||
window = build( xm.child(doc) )
|
||||
ocarina.events.start("ocarina-gui-done")
|
||||
window.show()
|
||||
|
||||
|
||||
buildFunc = build
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 23, 2010 9:46:43 PM$"
|
||||
|
||||
import string
|
||||
import re
|
||||
|
||||
global index
|
||||
import ocarina
|
||||
from ct import path
|
||||
|
||||
from et import sql
|
||||
import cPickle as pickle
|
||||
|
||||
global index
|
||||
global alpha
|
||||
index = dict()
|
||||
alpha = dict()
|
||||
|
||||
|
||||
global filePath
|
||||
filePath = path.join( ocarina.vars["$ocarina"], "index.pickle" )
|
||||
|
||||
#if path.exists(filePath) == True:
|
||||
file = open( filePath )
|
||||
p = pickle.Unpickler( file )
|
||||
(index,alpha) = p.load()
|
||||
file.close()
|
||||
#filePath = "/home/bjschuma/.ocarina3/index.pickle"
|
||||
|
||||
|
||||
def format(word):
|
||||
strip = "!\"#$%&'()*+,.:;<=>?@[]^_`{|}~"
|
||||
split = " |-|\\|/"
|
||||
|
||||
word = word.lower()
|
||||
for l in strip:
|
||||
word = word.replace(l,'')
|
||||
|
||||
words = []
|
||||
for word in re.split(split,word):
|
||||
words += [word.strip()]
|
||||
|
||||
return words
|
||||
|
||||
|
||||
def add(tag,trid):
|
||||
global index
|
||||
global alpha
|
||||
#words = tag.lower().split()
|
||||
words = format(tag)
|
||||
id = int(trid)
|
||||
#print " ",words
|
||||
|
||||
for word in words:
|
||||
if (word in index.keys()) == False:
|
||||
index[word] = set()
|
||||
index[word].add(id)
|
||||
for l in word:
|
||||
if (l in alpha.keys()) == False:
|
||||
alpha[l] = set()
|
||||
alpha[l].add(trid)
|
||||
|
||||
|
||||
def reindex():
|
||||
select = "track.id,track.name,artist.name,album.name"
|
||||
frm = "track,artist,album"
|
||||
where = "track.artist=artist.id AND track.album=album.id"
|
||||
sel = sql.Select(select,frm,where)
|
||||
results = sel.execute().fetchall()
|
||||
|
||||
global index
|
||||
index = dict()
|
||||
for entry in results:
|
||||
#print entry
|
||||
words = entry[1] + " " + entry[2] + " " + entry[3]
|
||||
add(words,entry[0])
|
||||
|
||||
|
||||
|
||||
def save():
|
||||
global index
|
||||
global alpha
|
||||
global filePath
|
||||
file = open( filePath, 'w' )
|
||||
p = pickle.Pickler(file,pickle.HIGHEST_PROTOCOL)
|
||||
p.dump( (index,alpha) )
|
||||
file.close()
|
||||
|
||||
|
||||
def psearch(phrase,options):
|
||||
results = options[phrase[0]]
|
||||
for word in phrase[1:]:
|
||||
results.intersection_update(options[word])
|
||||
return results
|
||||
|
||||
|
||||
def search(text):
|
||||
global index
|
||||
global alpha
|
||||
|
||||
phrases = []
|
||||
|
||||
words = set()
|
||||
options = dict()
|
||||
# Break the search text into phrases and
|
||||
# gind a set of key terms for each search phrase
|
||||
for phrase in text.split(","):#phrases:
|
||||
split = format(phrase)
|
||||
# Weed out searches of length 0
|
||||
if len(split) == 0:
|
||||
continue
|
||||
phrases += [split]
|
||||
for word in split:
|
||||
if len(word) == 1:
|
||||
options[word] = alpha[word]
|
||||
else:
|
||||
words.add(word)
|
||||
|
||||
# Only do this if we are searching for words
|
||||
if len(words) > 0:
|
||||
regex = ""
|
||||
# Build up a regex and initialize possibilities to empty sets
|
||||
for i,word in enumerate(words):
|
||||
if i > 0:
|
||||
regex += "|"
|
||||
regex += word
|
||||
options[word] = set()
|
||||
|
||||
for key in index:
|
||||
# Check if the key matches any of the search terms
|
||||
if re.search(regex,key):
|
||||
# Find which search term the key matches
|
||||
for word in words:
|
||||
if re.search(word,key):
|
||||
# In place update > replacement update!
|
||||
options[word].update(index[key])
|
||||
|
||||
results = set()
|
||||
for phrase in phrases:
|
||||
results.update( psearch(phrase,options) )
|
||||
return results
|
||||
|
||||
|
||||
def show():
|
||||
global index
|
||||
print len(index)
|
||||
print "====="
|
||||
for key in index:
|
||||
try:
|
||||
print key
|
||||
except:
|
||||
pass
|
|
@ -0,0 +1,22 @@
|
|||
import sys
|
||||
sys.path.append("../core")
|
||||
|
||||
import ocarina
|
||||
import coredefaults
|
||||
ocarina.init()
|
||||
|
||||
import index
|
||||
|
||||
#search="eagles, a the, a, the, for you, why not, hello, world"
|
||||
#search = "eagles"
|
||||
#search = "a"
|
||||
#search="eagles, for you, why not, hello, world"
|
||||
#search = "hotel,eagles,blue,bunch of words,three,squirrel,muffin,pizza,linus"
|
||||
search = "e,a,t"
|
||||
index.search(search)
|
||||
#index.save()
|
||||
#print index.search(search)
|
||||
#print len( index.search(search) )
|
||||
#index.reindex()
|
||||
#index.save()
|
||||
#index.show()
|
|
@ -2,5 +2,5 @@ __author__="bjschuma"
|
|||
__date__ ="$Mar 14, 2010 10:21:40 PM$"
|
||||
|
||||
|
||||
__all__ = ["box", "button", "dialog", "label", "label", "list", "menu",
|
||||
__all__ = ["box", "button", "dialog","entry", "label", "label", "list", "menu",
|
||||
"progbar", "songInfo", "tabs", "window"]
|
|
@ -9,7 +9,7 @@ import guibuilder
|
|||
from ct import cmd
|
||||
|
||||
class Button(gtk.Button):
|
||||
def __init__(self,attrs):
|
||||
def __init__(self,attrs,cmd):
|
||||
gtk.Button.__init__(self)
|
||||
self.command = ""
|
||||
hidden = False
|
||||
|
@ -51,6 +51,7 @@ class ButtonImage(gtk.Button):
|
|||
show = None
|
||||
hide = None
|
||||
shownow = True
|
||||
relief = gtk.RELIEF_NORMAL
|
||||
self.cmd = ""
|
||||
for a in attrs:
|
||||
if a=="size":
|
||||
|
@ -64,6 +65,11 @@ class ButtonImage(gtk.Button):
|
|||
shownow = False
|
||||
elif a=="cmd":
|
||||
self.cmd = attrs[a]
|
||||
elif a=="relief":
|
||||
if attrs[a] == "none":
|
||||
relief = gtk.RELIEF_NONE
|
||||
elif attrs[a] == "half":
|
||||
relief = gtk.RELIEF_HALF
|
||||
|
||||
img = gtk.image_new_from_stock(stock,size)
|
||||
img.show()
|
||||
|
@ -76,6 +82,7 @@ class ButtonImage(gtk.Button):
|
|||
ocarina.events.invite(hide, self.hide)
|
||||
if show!=None:
|
||||
ocarina.events.invite(show, self.show)
|
||||
self.set_relief(relief)
|
||||
self.connect("clicked",self.onclick)
|
||||
|
||||
def onclick(self,button):
|
||||
|
@ -89,13 +96,14 @@ def make_buttonplay(attrs):
|
|||
attrs["show"] = "ocarina-pause"
|
||||
attrs["hide"] = "ocarina-play"
|
||||
attrs["cmd"] = "play"
|
||||
attrs["shownow"] = str( not ocarina.vars["$playing"] ).lower()
|
||||
return ButtonImage(attrs,gtk.STOCK_MEDIA_PLAY)
|
||||
|
||||
def make_buttonpause(attrs):
|
||||
attrs["show"] = "ocarina-play"
|
||||
attrs["hide"] = "ocarina-pause"
|
||||
attrs["cmd"] = "pause"
|
||||
attrs["shownow"] = "false"
|
||||
attrs["shownow"] = str( ocarina.vars["$playing"] ).lower()
|
||||
return ButtonImage(attrs,gtk.STOCK_MEDIA_PAUSE)
|
||||
|
||||
def make_buttonstop(attrs):
|
||||
|
@ -104,6 +112,6 @@ def make_buttonstop(attrs):
|
|||
|
||||
|
||||
guibuilder.parts["button"] = make_button
|
||||
guibuilder.parts["buttonplay"] = make_buttonplay
|
||||
guibuilder.parts["buttonpause"] = make_buttonpause
|
||||
guibuilder.parts["buttonstop"] = make_buttonstop
|
||||
guibuilder.parts["button-play"] = make_buttonplay
|
||||
guibuilder.parts["button-pause"] = make_buttonpause
|
||||
guibuilder.parts["button-stop"] = make_buttonstop
|
|
@ -0,0 +1,39 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 21, 2010 8:56:41 PM$"
|
||||
|
||||
import gtk
|
||||
import guibuilder
|
||||
import ocarina
|
||||
import gobject
|
||||
|
||||
|
||||
class EntryFilter(gtk.Entry):
|
||||
def __init__(self):
|
||||
gtk.Entry.__init__(self)
|
||||
self.modify_text(gtk.STATE_ACTIVE,gtk.gdk.Color(0,0,0))
|
||||
self.modify_base(gtk.STATE_ACTIVE,gtk.gdk.Color(65535,65535,65535))
|
||||
self.connect("changed",self.textTyped)
|
||||
self.filterCount = 0;
|
||||
self.show()
|
||||
|
||||
|
||||
def textTyped(self,entry):
|
||||
ocarina.vars["$filterText"] = entry.get_text().lower()
|
||||
self.filterCount += 1
|
||||
gobject.timeout_add(250,self.filter)
|
||||
|
||||
|
||||
def filter(self):
|
||||
self.filterCount -= 1
|
||||
if self.filterCount > 0:
|
||||
return
|
||||
ocarina.events.start("ocarina-filter-start")
|
||||
|
||||
|
||||
def make_entryfilter(attrs=None):return EntryFilter()
|
||||
guibuilder.parts["entryfilter"] = make_entryfilter
|
|
@ -8,6 +8,9 @@ __date__ ="$Mar 15, 2010 9:46:07 AM$"
|
|||
|
||||
import gtk
|
||||
import pango
|
||||
import guibuilder
|
||||
import ocarina
|
||||
import db
|
||||
|
||||
class Label(gtk.Label):
|
||||
def __init__(self,attrs):
|
||||
|
@ -18,9 +21,20 @@ class Label(gtk.Label):
|
|||
self.show()
|
||||
|
||||
|
||||
def make_label(attrs):return Label(attrs)
|
||||
import guibuilder
|
||||
guibuilder.parts["label"] = make_label
|
||||
|
||||
class LabelLibCount(gtk.Label):
|
||||
def __init__(self):
|
||||
gtk.Label.__init__(self)
|
||||
ocarina.events.invite("ocarina-filter-start",self.setcount,10000)
|
||||
#ocarina.events.invite("ocarina-gui-done",self.setcount,10000)
|
||||
|
||||
def setcount(self):
|
||||
#print "Here!", ocarina.vars["$libcount"]
|
||||
try:
|
||||
count = ocarina.vars["$libcount"]
|
||||
except:
|
||||
count = 0
|
||||
self.set_text("Library (" + str(count) + ")")
|
||||
|
||||
|
||||
class Label2(gtk.Alignment):
|
||||
|
@ -48,3 +62,8 @@ class Label2(gtk.Alignment):
|
|||
def set_text(self,text):
|
||||
self.label.set_text(text)
|
||||
|
||||
|
||||
def make_label(attrs):return Label(attrs)
|
||||
def make_libcountlabel(attrs):return LabelLibCount()
|
||||
guibuilder.parts["label"] = make_label
|
||||
guibuilder.parts["libcountlabel"] = make_libcountlabel
|
|
@ -9,16 +9,22 @@ __date__ ="$Mar 21, 2010 1:06:27 PM$"
|
|||
import gtk
|
||||
import guibuilder
|
||||
import db
|
||||
import ocarina
|
||||
from et import needle
|
||||
import re
|
||||
import index
|
||||
from ct import cmd
|
||||
from et import times
|
||||
|
||||
|
||||
class SongList(gtk.ScrolledWindow):
|
||||
class SongList(gtk.TreeView):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
|
||||
gtk.TreeView.__init__(self)
|
||||
self.countvar = None
|
||||
ocarina.events.invite("ocarina-filter-start",self.filter)
|
||||
self.list = gtk.ListStore(int,str,str,str,str,int)
|
||||
self.tree = gtk.TreeView(self.list)
|
||||
self.tree.set_reorderable(True)
|
||||
self.set_reorderable(True)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cols = ["Id","Title","Length","Artist","Album","Play Count"]
|
||||
for i in range(len(cols)):
|
||||
|
@ -32,34 +38,90 @@ class SongList(gtk.ScrolledWindow):
|
|||
col.set_fixed_width(150)
|
||||
col.set_sort_indicator(True)
|
||||
if cols[i] != "Id":
|
||||
self.tree.append_column(col)
|
||||
self.append_column(col)
|
||||
|
||||
self.tree.set_rules_hint(True)
|
||||
#self.tree.connect("row-activated",self.selectSong,"clicked",list)
|
||||
self.set_rules_hint(True)
|
||||
self.connect("row-activated",self.doubleClick)
|
||||
#self.tree.connect("button_release_event",self.clicked)
|
||||
self.sel = self.tree.get_selection()
|
||||
self.sel = self.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.cols = self.get_columns()
|
||||
#self.loadCols()
|
||||
#self.tree.show()
|
||||
self.add(self.tree)
|
||||
self.show_all()
|
||||
#self.add(self.tree)
|
||||
self.filter = self.list.filter_new()
|
||||
self.filter.set_visible_func(self.setvisible)
|
||||
self.sort = gtk.TreeModelSort(self.filter)
|
||||
self.set_model(self.sort)
|
||||
#self.set_model(self.filter)
|
||||
#self.set_model(self.list)
|
||||
#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
|
||||
def insert(self,trackid):
|
||||
file = list(db.gettrack(trackid))
|
||||
file[2] = times.ftime(file[2],False)
|
||||
self.list.append(file)
|
||||
#self.list.insert(len(self.list),file)
|
||||
if self.countvar != None:
|
||||
ocarina.vars[self.countvar] += 1
|
||||
|
||||
|
||||
def filter(self):
|
||||
text = ocarina.vars["$filterText"]
|
||||
self.results = index.search(ocarina.vars["$filterText"])
|
||||
if self.countvar != None:
|
||||
c = len(self.results)
|
||||
if c == 0:
|
||||
ocarina.vars[self.countvar] = len(self.list)
|
||||
else:
|
||||
ocarina.vars[self.countvar] = c
|
||||
self.filter.refilter()
|
||||
|
||||
|
||||
def setvisible(self,list,iter):
|
||||
if ocarina.vars["$filterText"] == "":
|
||||
return True
|
||||
if (list[iter][0] in self.results) == True:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def doubleClick(self,tree,index,col):
|
||||
trid = self.sort[index][0]
|
||||
path = db.getpath(trid)
|
||||
cmd.run("load "+path)
|
||||
cmd.run("play")
|
||||
#print self.sort[index][1],self.sort[index][0]
|
||||
|
||||
|
||||
|
||||
class LibraryList(SongList):
|
||||
def __init__(self):
|
||||
SongList.__init__(self)
|
||||
libid = db.libid("Music")
|
||||
#print db.listlib()
|
||||
self.countvar = "$libcount"
|
||||
ocarina.vars["$libcount"] = 0
|
||||
ocarina.events.invite("ocarina-gui-done",self.populate)
|
||||
|
||||
|
||||
def populate(self):
|
||||
thread = needle.Needle(self.insertLibrary)
|
||||
thread.start()
|
||||
#self.insertLibrary()
|
||||
|
||||
|
||||
def insertLibrary(self):
|
||||
try:
|
||||
libid = db.libid("Music")
|
||||
ocarina.events.start("ocarina-filter-start")
|
||||
for track in db.getsongs(libid):
|
||||
self.insert(track[1])
|
||||
except:
|
||||
pass
|
||||
self.show_all()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ class MenuLibNew(gtk.MenuItem):
|
|||
thread.start()
|
||||
|
||||
|
||||
|
||||
class MenuTheme(gtk.MenuItem):
|
||||
def __init__(self):
|
||||
gtk.MenuItem.__init__(self,"Change Theme")
|
||||
|
@ -129,7 +130,7 @@ class MenuTheme(gtk.MenuItem):
|
|||
def onclick(self,menu):
|
||||
file = dialog.FileChooser("Select a theme file").choose()
|
||||
if file!=None:
|
||||
print file
|
||||
#print file
|
||||
ocarina.vars["$theme"] = str(file)
|
||||
guibuilder.init()
|
||||
|
||||
|
@ -144,7 +145,7 @@ def make_menusongsel(attrs=None):return MenuSongSelect()
|
|||
def make_menulibnew(attrs=None):return MenuLibNew()
|
||||
def make_menutheme(attrs=None):return MenuTheme()
|
||||
|
||||
guibuilder.parts["menubar"] = make_menubar
|
||||
guibuilder.parts["menu-bar"] = make_menubar
|
||||
guibuilder.parts["menuitem"] = make_menuitem
|
||||
guibuilder.parts["menuplay"] = make_menuplay
|
||||
guibuilder.parts["menupause"] = make_menupause
|
||||
|
|
|
@ -36,7 +36,7 @@ class ProgressBar(gtk.EventBox):
|
|||
if data.button == 1:
|
||||
prcnt = float(data.x) / float(self.bar.get_allocation()[2])
|
||||
self.bar.set_fraction(prcnt)
|
||||
gstreamer.seek(prcnt)
|
||||
gstreamer.seek(prcnt,fraction=True)
|
||||
|
||||
|
||||
def updatebar(self):
|
||||
|
|
|
@ -30,7 +30,7 @@ class Window(gtk.Window):
|
|||
self.quitEvent = attrs[a]
|
||||
|
||||
self.resize(size[0], size[1])
|
||||
self.show()
|
||||
#self.show()
|
||||
|
||||
|
||||
def onQuit(self,a,b):
|
||||
|
@ -46,5 +46,27 @@ class LibScanWin(gtk.Window):
|
|||
self.show()
|
||||
|
||||
|
||||
class ScrolledWindow(gtk.ScrolledWindow):
|
||||
def __init__(self,attrs):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
hscroll = gtk.POLICY_AUTOMATIC
|
||||
vscroll = gtk.POLICY_AUTOMATIC
|
||||
for a in attrs:
|
||||
type = gtk.POLICY_AUTOMATIC
|
||||
if attrs[a] == "none":
|
||||
type = gtk.POLICY_NONE
|
||||
elif attrs[a] == "always":
|
||||
type = gtk.POLICY_ALWAYS
|
||||
if a=="hscroll":
|
||||
hscroll = type
|
||||
elif a=="vscroll":
|
||||
vscroll = type
|
||||
self.set_policy(hscroll,vscroll)
|
||||
self.show()
|
||||
|
||||
|
||||
|
||||
def make_window(attrs):return Window(attrs)
|
||||
guibuilder.parts["window"] = make_window
|
||||
def make_scrollwin(attrs):return ScrolledWindow(attrs)
|
||||
guibuilder.parts["window"] = make_window
|
||||
guibuilder.parts["scrolled-window"] = make_scrollwin
|
|
@ -9,14 +9,8 @@ sys.path.append("core")
|
|||
|
||||
import ocarina
|
||||
import extradefaults
|
||||
ocarina.init()
|
||||
|
||||
from ct.message import write
|
||||
import scripting
|
||||
import manager
|
||||
#import cli
|
||||
import gstreamer
|
||||
|
||||
|
||||
import guibuilder
|
||||
from oGtk import *
|
||||
|
@ -26,9 +20,10 @@ import gobject
|
|||
gobject.threads_init()
|
||||
|
||||
|
||||
def main():
|
||||
#ocarina.init()
|
||||
from et import needle
|
||||
|
||||
|
||||
def main():
|
||||
# Potentially the first thing printed
|
||||
write("Welcome to Ocarina (extra)", 1)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<window width="900" height="600" close="ocarina-stop" title="Ocarina 3.0">
|
||||
<add>
|
||||
<vbox>
|
||||
<menubar>
|
||||
<menu-bar>
|
||||
<menuitem name="Library">
|
||||
<menulibnew/>
|
||||
</menuitem>
|
||||
|
@ -15,18 +15,44 @@
|
|||
<menuitem name="Theme">
|
||||
<menutheme/>
|
||||
</menuitem>
|
||||
</menubar>
|
||||
</menu-bar>
|
||||
<songinfo/>
|
||||
<pack expand="True" fill="True"/>
|
||||
<tabs>
|
||||
<tab>
|
||||
<tablabel>
|
||||
<label text="Library"/>
|
||||
<libcountlabel/>
|
||||
</tablabel>
|
||||
<tabcontent>
|
||||
<librarylist/>
|
||||
<scrolled-window>
|
||||
<add>
|
||||
<librarylist/>
|
||||
</add>
|
||||
</scrolled-window>
|
||||
</tabcontent>
|
||||
</tab>
|
||||
<tab expand="True" fill="True" packing="End">
|
||||
<tablabel>
|
||||
<entryfilter/>
|
||||
</tablabel>
|
||||
<tabcontent>
|
||||
<vbox/>
|
||||
</tabcontent>
|
||||
</tab>
|
||||
</tabs>
|
||||
<pack expand="False"/>
|
||||
<hbox>
|
||||
<pack expand="True" fill="True"/>
|
||||
<vbox>
|
||||
<pack expand="True" fill="False"/>
|
||||
<progbar/>
|
||||
</vbox>
|
||||
<pack expand="False" fill="False"/>
|
||||
<button-play relief="none"/>
|
||||
<button-pause relief="none"/>
|
||||
<button-stop relief="none"/>
|
||||
</hbox>
|
||||
<scanlibbar/>
|
||||
</vbox>
|
||||
</add>
|
||||
</window>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<window width="400" height="150" close="ocarina-stop" title="Ocarina 3.0">
|
||||
<add>
|
||||
<vbox>
|
||||
<menubar>
|
||||
<menu-bar>
|
||||
<menuitem name="Playback">
|
||||
<menuplay/>
|
||||
<menupause/>
|
||||
|
@ -12,12 +12,12 @@
|
|||
<menuitem name="Theme">
|
||||
<menutheme/>
|
||||
</menuitem>
|
||||
</menubar>
|
||||
</menu-bar>
|
||||
<songinfo/>
|
||||
<hbox>
|
||||
<buttonplay size="large"/>
|
||||
<buttonpause size="large"/>
|
||||
<buttonstop size="large"/>
|
||||
<button-play size="large"/>
|
||||
<button-pause size="large"/>
|
||||
<button-stop size="large"/>
|
||||
</hbox>
|
||||
<progbar/>
|
||||
</vbox>
|
||||
|
|
Loading…
Reference in New Issue