Began work on classic theme, finished simple theme
This commit is contained in:
parent
a9a9c3e642
commit
a9040d9481
|
@ -20,16 +20,27 @@ def join(a,b):
|
|||
|
||||
|
||||
def exists(path):
|
||||
return os.path.exists( path )
|
||||
return os.path.exists( expand(path) )
|
||||
|
||||
|
||||
def isdir(path):
|
||||
if exists(path) == True:
|
||||
return os.path.isdir( expand(path) )
|
||||
return False
|
||||
|
||||
|
||||
def ls(path):
|
||||
try:
|
||||
return os.listdir(path)
|
||||
return os.listdir( expand(path) )
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def mkdir(path):
|
||||
if exists(path) == False:
|
||||
os.mkdir(path)
|
||||
|
||||
|
||||
def addPyPath(path):
|
||||
mods = []
|
||||
if exists(path) == True:
|
||||
|
|
|
@ -4,17 +4,18 @@ __author__="bjschuma"
|
|||
__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
|
||||
import coredefaults
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
ocarina.init()
|
||||
|
||||
# Potentially the first thing printed
|
||||
write("Welcome to Ocarina (core)", 1)
|
||||
|
||||
|
|
|
@ -26,12 +26,7 @@ plugins = None
|
|||
# Set default values
|
||||
def init():
|
||||
opts.parse()
|
||||
#vars["$user"] = path.expand("~")
|
||||
#vars["$ocarina"] = path.join(vars["$user"],".ocarina3")
|
||||
#vars["$verbose"] = 0
|
||||
#vars["$path"] = "coreplug"
|
||||
#vars["$prompt"] = ">>>"
|
||||
#vars["$playonload"] = True
|
||||
path.mkdir(vars["$ocarina"])
|
||||
|
||||
# Set verbose value
|
||||
if opts.opts.has("v") == True:
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 7:33:16 PM$"
|
||||
|
||||
import re
|
||||
from ct import cmd
|
||||
import ocarina
|
||||
|
||||
def runScript(file):
|
||||
|
||||
def runOcaScript(file):
|
||||
fin = open(file)
|
||||
for line in fin:
|
||||
# Do some formatting for each line
|
||||
|
@ -17,6 +19,17 @@ def runScript(file):
|
|||
line = line.strip()
|
||||
if len(line) > 0:
|
||||
cmd.run(line)
|
||||
|
||||
|
||||
def runScript(file):
|
||||
if re.match("(.*?)\.py",file) == None:
|
||||
runOcaScript(file)
|
||||
else:
|
||||
try:
|
||||
execfile(file)
|
||||
except:
|
||||
print "Error in: " + file
|
||||
|
||||
|
||||
|
||||
def init():
|
||||
|
|
|
@ -7,10 +7,11 @@ __author__="bjschuma"
|
|||
__date__ ="$Jan 27, 2010 6:21:27 PM$"
|
||||
|
||||
|
||||
from bt.message import write
|
||||
from ct.message import write
|
||||
from sqlite3 import *
|
||||
from bt import sql
|
||||
import settings
|
||||
from et import sql
|
||||
from ct.path import expand
|
||||
#import settings
|
||||
|
||||
|
||||
def init():
|
||||
|
@ -52,10 +53,11 @@ def init():
|
|||
|
||||
def newlib(name,path):
|
||||
try:
|
||||
ins = sql.Insert('library',[None,name,path])
|
||||
ins = sql.Insert('library',[None,name,expand(path)])
|
||||
ins.execute()
|
||||
return 0
|
||||
except:
|
||||
pass
|
||||
return -1
|
||||
|
||||
|
||||
def rmtrk(trid):
|
||||
|
@ -128,15 +130,16 @@ def listlib():
|
|||
result = sel.execute().fetchall()
|
||||
id = settings.get("curlib")
|
||||
curname = ""
|
||||
write("Id Name Count Path")
|
||||
write("---------------------------")
|
||||
write("Id Name Count Path",2)
|
||||
write("---------------------------",2)
|
||||
for row in result:
|
||||
if row[0] == id:
|
||||
curname = row[1]
|
||||
count = str( countlib(row[0]) )
|
||||
write( str(row[0]) + " " +
|
||||
row[1] + " " + count + " " + row[2] )
|
||||
write("Current: "+curname)
|
||||
row[1] + " " + count + " " + row[2],2 )
|
||||
write("Current: "+curname,2)
|
||||
return result
|
||||
|
||||
|
||||
def getpath(dbid):
|
||||
|
@ -147,4 +150,7 @@ def getpath(dbid):
|
|||
|
||||
selt = sql.Select("path","track","id="+str(dbid))
|
||||
track = selt.execute().fetchone()[0]
|
||||
return root+track
|
||||
return root+track
|
||||
|
||||
|
||||
init()
|
|
@ -1,4 +1,4 @@
|
|||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 9:53:12 PM$"
|
||||
|
||||
__all__ = ["db", "sql", "times", "xm"]
|
||||
__all__ = ["needle", "scanlib", "sql", "times", "xm"]
|
|
@ -0,0 +1,24 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Dec 19, 2009 9:30:59 PM$"
|
||||
|
||||
|
||||
from threading import Thread
|
||||
|
||||
|
||||
class Needle(Thread):
|
||||
def __init__(self, func, args=None):
|
||||
Thread.__init__(self)
|
||||
self.func = func
|
||||
self.args = args
|
||||
|
||||
|
||||
def run(self):
|
||||
if self.args==None:
|
||||
self.func()
|
||||
else:
|
||||
self.func(self.args)
|
|
@ -0,0 +1,186 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Jan 30, 2010 3:57:53 PM$"
|
||||
|
||||
|
||||
from et import sql
|
||||
#from bt import needle
|
||||
from ct.path import *
|
||||
from ct.message import write
|
||||
import ocarina
|
||||
|
||||
import tagpy
|
||||
import re
|
||||
|
||||
global total
|
||||
global scanned
|
||||
global added
|
||||
global root
|
||||
global goodFiles
|
||||
global search
|
||||
|
||||
global libid
|
||||
|
||||
total = 0
|
||||
added = 0
|
||||
scanned = 0
|
||||
root = ""
|
||||
goodFiles = ["ogg", "mp3"]
|
||||
|
||||
|
||||
# Generate search string (allows adding to goodFiles later)
|
||||
def genSearch():
|
||||
global goodFiles
|
||||
global search
|
||||
search = ".*\.("
|
||||
for index,file in enumerate(goodFiles):
|
||||
if index > 0:
|
||||
search += "|"
|
||||
search += file
|
||||
search += ")"
|
||||
|
||||
genSearch()
|
||||
|
||||
|
||||
|
||||
# Test if the file extension is in goodFiles
|
||||
def testPath(path):
|
||||
global search
|
||||
match = re.search(search,path,re.IGNORECASE)
|
||||
if match == None:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def incr(path):
|
||||
global total
|
||||
total += 1
|
||||
|
||||
|
||||
# Call to insert either an artist or an album
|
||||
def insartalb(table,value):
|
||||
if value == "":
|
||||
value = "Unknown "+table.title()
|
||||
#value = value.replace("\'","\'\'")
|
||||
sel = sql.Select("id",table,'name="' + value + '"')
|
||||
result = sel.execute().fetchall()
|
||||
if result == []:
|
||||
ins = sql.Insert(table,[None,value])
|
||||
ins.execute()
|
||||
result = sel.execute().fetchall()
|
||||
return result[0][0]
|
||||
|
||||
|
||||
# Call to insert a new track
|
||||
def instrk(arid, alid, title, length, path):
|
||||
global root
|
||||
global libid
|
||||
if title == "":
|
||||
title = "Unknown Title"
|
||||
|
||||
path = path[len(root):]
|
||||
|
||||
sel = sql.Select("id","track",'path="'+path+'"')
|
||||
result = sel.execute().fetchall()
|
||||
|
||||
if result == []:
|
||||
ins = sql.Insert("track", [None, arid, alid, 0, length, title, path] )
|
||||
ins.execute()
|
||||
result = sel.execute().fetchall()
|
||||
|
||||
trid = str(result[0][0])
|
||||
|
||||
where = "library='"+libid+"' AND track='"+trid+"'"
|
||||
sel = sql.Select("*","libtrack",where)
|
||||
result = sel.execute().fetchall()
|
||||
if result == []:
|
||||
ins = sql.Insert("libtrack",[int(libid),int(trid)])
|
||||
ins.execute()
|
||||
|
||||
|
||||
|
||||
def addtrk(path):
|
||||
global added
|
||||
global scanned
|
||||
|
||||
scanned += 1
|
||||
try:
|
||||
f = tagpy.FileRef(path)
|
||||
t = f.tag()
|
||||
added += 1
|
||||
except:
|
||||
return
|
||||
|
||||
try:
|
||||
arid = insartalb("artist", t.artist)
|
||||
alid = insartalb("album", t.album)
|
||||
|
||||
a = f.audioProperties()
|
||||
instrk(arid, alid, t.title, a.length, path)
|
||||
except:
|
||||
write("Error adding: "+path)
|
||||
#pass
|
||||
|
||||
|
||||
|
||||
def scan(dir,func):
|
||||
files = ls(dir)
|
||||
for file in files:
|
||||
path = join(dir,file)
|
||||
if isdir(path) == True:
|
||||
scan(path,func)
|
||||
else:
|
||||
if testPath(path) == True:
|
||||
func(path)
|
||||
|
||||
|
||||
def go(name):
|
||||
global total
|
||||
global added
|
||||
global scanned
|
||||
global root
|
||||
global libid
|
||||
total = 0
|
||||
added = 0
|
||||
scanned = 0
|
||||
|
||||
sel = sql.Select("id,path","library","name='"+name+"'")
|
||||
result = sel.execute().fetchall()
|
||||
if result == []:
|
||||
return
|
||||
libid = str(result[0][0])
|
||||
path = result[0][1]
|
||||
root = path
|
||||
|
||||
ocarina.events.start("ocarina-scanlib-start")
|
||||
# Start a thread to count the total number of files to scan
|
||||
#totthr = needle.Needle(scan,(path,incr))
|
||||
#totthr.start()
|
||||
scan(path,incr)
|
||||
#print "Done scanning"
|
||||
#print total, added
|
||||
scan(path,addtrk)
|
||||
ocarina.events.start("ocarina-scanlib-stop")
|
||||
|
||||
# Start a thread to actually add tracks to the db
|
||||
#scthr = needle.Needle(scan,(path,addtrk))
|
||||
#scthr.start()
|
||||
|
||||
|
||||
def prcnt():
|
||||
global total
|
||||
global scanned
|
||||
global added
|
||||
write( str(scanned) + " / " + str(total) )
|
||||
write( "Added " + str(added) + " tracks." )
|
||||
|
||||
|
||||
def progress():
|
||||
global total
|
||||
global added
|
||||
return (added,total)
|
|
@ -8,13 +8,13 @@ __author__="bjschuma"
|
|||
__date__ ="$Jan 23, 2010 8:40:03 PM$"
|
||||
|
||||
import sqlite3
|
||||
import settings
|
||||
#import settings
|
||||
from ct.path import *
|
||||
import ocarina
|
||||
|
||||
|
||||
def getdb():
|
||||
return join(ocarina.vars["$ocarina"]+"ocarina.db")
|
||||
return join(ocarina.vars["$ocarina"],"ocarina.db")
|
||||
|
||||
|
||||
def dbexists():
|
||||
|
|
|
@ -8,7 +8,9 @@ __date__ ="$Mar 15, 2010 9:56:53 PM$"
|
|||
|
||||
|
||||
from ocarina import vars
|
||||
vars["$theme"] = "simple.xml"
|
||||
import coredefaults
|
||||
#vars["$theme"] = "themes/simple.xml"
|
||||
vars["$theme"] = "themes/classic.xml"
|
||||
vars["$artist"] = ""
|
||||
vars["$album"] = ""
|
||||
vars["$title"] = ""
|
|
@ -20,6 +20,32 @@ parts = dict()
|
|||
global buildFunc
|
||||
buildFunc = None
|
||||
|
||||
global window
|
||||
window = None
|
||||
|
||||
|
||||
def buildTabs(node,tabs):
|
||||
global buildFunc
|
||||
|
||||
for child in xm.children(node):
|
||||
if child.nodeName=="tab":
|
||||
label = None
|
||||
content = None
|
||||
for gchild in xm.children(child):
|
||||
if gchild.nodeName == "tablabel":
|
||||
for ggchild in xm.children(gchild):
|
||||
item = buildFunc(ggchild)
|
||||
if item != None:
|
||||
label = item
|
||||
elif gchild.nodeName == "tabcontent":
|
||||
for ggchild in xm.children(gchild):
|
||||
item = buildFunc(ggchild)
|
||||
if item != None:
|
||||
content = item
|
||||
|
||||
if content != None:
|
||||
tabs.append_page(content,label)
|
||||
|
||||
|
||||
def buildMenu(node,menu):
|
||||
global buildFunc
|
||||
|
@ -83,13 +109,18 @@ def build(node):
|
|||
fill(node,part)
|
||||
elif (tag=="menubar") or (tag=="menuitem"):
|
||||
buildMenu(node,part)
|
||||
elif (tag=="tabs"):
|
||||
buildTabs(node,part)
|
||||
return part
|
||||
|
||||
|
||||
def init():
|
||||
write("Building gui",1)
|
||||
global window
|
||||
if window != None:
|
||||
window.hide()
|
||||
write("Building gui from file: "+ocarina.vars["$theme"],1)
|
||||
doc = xm.load(ocarina.vars["$theme"])
|
||||
build( xm.child(doc) )
|
||||
window = build( xm.child(doc) )
|
||||
|
||||
|
||||
buildFunc = build
|
||||
|
|
|
@ -2,5 +2,5 @@ __author__="bjschuma"
|
|||
__date__ ="$Mar 14, 2010 10:21:40 PM$"
|
||||
|
||||
|
||||
__all__ = ["box", "button", "label", "label", "menu",
|
||||
"progbar", "songInfo", "window"]
|
||||
__all__ = ["box", "button", "dialog", "label", "label", "list", "menu",
|
||||
"progbar", "songInfo", "tabs", "window"]
|
|
@ -0,0 +1,73 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 18, 2010 11:48:15 AM$"
|
||||
|
||||
|
||||
import gtk
|
||||
import db
|
||||
import ocarina
|
||||
import scripting
|
||||
from oGtk import progbar
|
||||
|
||||
class FileChooser(gtk.FileChooserDialog):
|
||||
def __init__(self,title,seldir=False):
|
||||
buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN
|
||||
gtk.FileChooserDialog.__init__(self,title,None,action=action,buttons=buttons)
|
||||
if seldir == True:
|
||||
self.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
|
||||
def choose(self):
|
||||
response = self.run()
|
||||
self.hide()
|
||||
file = ""
|
||||
#print response
|
||||
if response == gtk.RESPONSE_OK:
|
||||
file = self.get_filename()
|
||||
if response != gtk.RESPONSE_OK:
|
||||
return None
|
||||
return file
|
||||
|
||||
|
||||
|
||||
class NewLibrary(gtk.Dialog):
|
||||
def __init__(self):
|
||||
buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,"Scan",gtk.RESPONSE_OK)
|
||||
gtk.Dialog.__init__(self,"New Library",None,gtk.DIALOG_NO_SEPARATOR,buttons=buttons)
|
||||
|
||||
self.table = gtk.Table(2,3,False)
|
||||
|
||||
name = gtk.Label("Name: ")
|
||||
dir = gtk.Label("Directory: ")
|
||||
self.libname = gtk.Entry()
|
||||
self.libname.set_text("New Library")
|
||||
self.dir = gtk.Entry()
|
||||
button = gtk.Button(None,gtk.STOCK_OPEN)
|
||||
button.connect("clicked",self.onclick)
|
||||
|
||||
self.table.attach(name,0,1,0,1)
|
||||
self.table.attach(self.libname,1,2,0,1)
|
||||
self.table.attach(dir,0,1,1,2)
|
||||
self.table.attach(self.dir,1,2,1,2)
|
||||
self.table.attach(button,2,3,1,2)
|
||||
|
||||
self.table.show_all()
|
||||
self.get_children()[0].pack_start(self.table,False,False,0)
|
||||
|
||||
|
||||
def choose(self):
|
||||
response = self.run()
|
||||
self.hide()
|
||||
if response == -5:
|
||||
return (self.libname.get_text(), self.dir.get_text())
|
||||
return (None,None)
|
||||
|
||||
|
||||
def onclick(self,button):
|
||||
dirresult = FileChooser("Select a directory",True).choose()
|
||||
if dirresult != "":
|
||||
self.dir.set_text(dirresult)
|
|
@ -0,0 +1,72 @@
|
|||
#! /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
|
|
@ -11,6 +11,11 @@ import gtk
|
|||
import ocarina
|
||||
import guibuilder
|
||||
from ct import cmd
|
||||
from oGtk import dialog
|
||||
from oGtk import window
|
||||
from et import scanlib
|
||||
from et import needle
|
||||
import db
|
||||
|
||||
|
||||
class MenuBar(gtk.MenuBar):
|
||||
|
@ -88,23 +93,45 @@ class MenuStop(gtk.ImageMenuItem):
|
|||
|
||||
class MenuSongSelect(gtk.MenuItem):
|
||||
def __init__(self):
|
||||
gtk.MenuItem.__init__(self,"Play File")
|
||||
gtk.MenuItem.__init__(self,"Select song")
|
||||
self.connect("activate",self.onclick)
|
||||
self.show()
|
||||
|
||||
def onclick(self,menu):
|
||||
buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)
|
||||
chooser = gtk.FileChooserDialog("Select a song",None,action=gtk.FILE_CHOOSER_ACTION_OPEN,buttons=buttons)
|
||||
response = chooser.run()
|
||||
chooser.hide()
|
||||
file = ""
|
||||
if response == gtk.RESPONSE_OK:
|
||||
file = chooser.get_filename()
|
||||
#chooser.hide()
|
||||
if response != gtk.RESPONSE_OK:
|
||||
return
|
||||
file = dialog.FileChooser("Select a song").choose()
|
||||
if file!=None:
|
||||
cmd.run("load " + file)
|
||||
|
||||
cmd.run("load "+file)
|
||||
|
||||
|
||||
class MenuLibNew(gtk.MenuItem):
|
||||
def __init__(self):
|
||||
gtk.MenuItem.__init__(self,"New Library")
|
||||
self.connect("activate",self.onclick)
|
||||
self.show()
|
||||
|
||||
def onclick(self,menu):
|
||||
choice = dialog.NewLibrary()
|
||||
(name,path) = choice.choose()
|
||||
del choice
|
||||
if name != None:
|
||||
db.newlib(name,path)
|
||||
thread = needle.Needle(scanlib.go,name)
|
||||
thread.start()
|
||||
|
||||
|
||||
class MenuTheme(gtk.MenuItem):
|
||||
def __init__(self):
|
||||
gtk.MenuItem.__init__(self,"Change Theme")
|
||||
self.connect("activate", self.onclick)
|
||||
self.show()
|
||||
|
||||
def onclick(self,menu):
|
||||
file = dialog.FileChooser("Select a theme file").choose()
|
||||
if file!=None:
|
||||
print file
|
||||
ocarina.vars["$theme"] = str(file)
|
||||
guibuilder.init()
|
||||
|
||||
|
||||
|
||||
|
@ -114,10 +141,14 @@ def make_menuplay(attrs=None):return MenuPlay()
|
|||
def make_menupause(attrs=None):return MenuPause()
|
||||
def make_menustop(attrs=None):return MenuStop()
|
||||
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["menuitem"] = make_menuitem
|
||||
guibuilder.parts["menuplay"] = make_menuplay
|
||||
guibuilder.parts["menupause"] = make_menupause
|
||||
guibuilder.parts["menustop"] = make_menustop
|
||||
guibuilder.parts["menusongsel"] = make_menusongsel
|
||||
guibuilder.parts["menusongsel"] = make_menusongsel
|
||||
guibuilder.parts["menulibnew"] = make_menulibnew
|
||||
guibuilder.parts["menutheme"] = make_menutheme
|
|
@ -12,7 +12,11 @@ import gobject
|
|||
|
||||
import guibuilder
|
||||
import gstreamer
|
||||
import ocarina
|
||||
|
||||
from et import times
|
||||
from et import scanlib
|
||||
|
||||
|
||||
class ProgressBar(gtk.EventBox):
|
||||
def __init__(self):
|
||||
|
@ -36,12 +40,37 @@ class ProgressBar(gtk.EventBox):
|
|||
|
||||
|
||||
def updatebar(self):
|
||||
self.bar.set_fraction(gstreamer.getProgress())
|
||||
current = times.ftime(gstreamer.currentpos())
|
||||
duration = times.ftime(gstreamer.duration())
|
||||
self.bar.set_text(current + " / " + duration)
|
||||
try:
|
||||
self.bar.set_fraction(gstreamer.getProgress())
|
||||
current = times.ftime(gstreamer.currentpos())
|
||||
duration = times.ftime(gstreamer.duration())
|
||||
self.bar.set_text(current + " / " + duration)
|
||||
except:
|
||||
pass
|
||||
return True
|
||||
|
||||
|
||||
|
||||
class LibScanBar(gtk.ProgressBar):
|
||||
def __init__(self):
|
||||
gtk.ProgressBar.__init__(self)
|
||||
gobject.timeout_add(500,self.updatebar)
|
||||
ocarina.events.invite("ocarina-scanlib-start",self.show)
|
||||
ocarina.events.invite("ocarina-scanlib-stop",self.hide)
|
||||
|
||||
|
||||
def updatebar(self):
|
||||
(cur,tot) = scanlib.progress()
|
||||
if cur > 0:
|
||||
self.set_text(str(cur) + " / " + str(tot))
|
||||
self.set_fraction(float(cur) / float(tot))
|
||||
else:
|
||||
self.set_text(str(tot))
|
||||
self.set_fraction(0)
|
||||
return True
|
||||
|
||||
|
||||
def make_progbar(attrs):return ProgressBar()
|
||||
guibuilder.parts["progbar"] = make_progbar
|
||||
def make_libscanbar(attrs):return LibScanBar()
|
||||
guibuilder.parts["progbar"] = make_progbar
|
||||
guibuilder.parts["scanlibbar"] = make_libscanbar
|
|
@ -0,0 +1,20 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 21, 2010 12:47:11 PM$"
|
||||
|
||||
|
||||
import gtk
|
||||
import guibuilder
|
||||
|
||||
class Tabs(gtk.Notebook):
|
||||
def __init__(self):
|
||||
gtk.Notebook.__init__(self)
|
||||
self.show()
|
||||
|
||||
|
||||
def make_tabs(attrs=None):return Tabs()
|
||||
guibuilder.parts["tabs"] = make_tabs
|
|
@ -10,6 +10,7 @@ import gtk
|
|||
|
||||
import guibuilder
|
||||
import ocarina
|
||||
from oGtk import progbar
|
||||
|
||||
class Window(gtk.Window):
|
||||
def __init__(self, attrs):
|
||||
|
@ -36,5 +37,14 @@ class Window(gtk.Window):
|
|||
ocarina.events.start(self.quitEvent)
|
||||
|
||||
|
||||
class LibScanWin(gtk.Window):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
self.bar = progbar.LibScanBar()
|
||||
self.add(self.bar)
|
||||
self.bar.show()
|
||||
self.show()
|
||||
|
||||
|
||||
def make_window(attrs):return Window(attrs)
|
||||
guibuilder.parts["window"] = make_window
|
|
@ -8,13 +8,15 @@ sys.path.append("core")
|
|||
|
||||
|
||||
import ocarina
|
||||
import extradefaults
|
||||
ocarina.init()
|
||||
|
||||
from ct.message import write
|
||||
import scripting
|
||||
import manager
|
||||
#import cli
|
||||
import gstreamer
|
||||
import coredefaults
|
||||
import extradefaults
|
||||
|
||||
|
||||
import guibuilder
|
||||
from oGtk import *
|
||||
|
@ -25,7 +27,7 @@ gobject.threads_init()
|
|||
|
||||
|
||||
def main():
|
||||
ocarina.init()
|
||||
#ocarina.init()
|
||||
|
||||
# Potentially the first thing printed
|
||||
write("Welcome to Ocarina (extra)", 1)
|
||||
|
|
136
src/extra/sql.py
136
src/extra/sql.py
|
@ -1,136 +0,0 @@
|
|||
import os.path
|
||||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Jan 23, 2010 8:40:03 PM$"
|
||||
|
||||
from bt.file import checkPath
|
||||
import sqlite3
|
||||
import settings
|
||||
from bt.file import *
|
||||
|
||||
|
||||
def getdb():
|
||||
return join(settings.get("appdir"), settings.get("appname")+".db")
|
||||
|
||||
|
||||
def dbexists():
|
||||
return checkPath(getdb())
|
||||
|
||||
|
||||
def connect():
|
||||
path = getdb()
|
||||
con = sqlite3.connect(path)
|
||||
con.text_factory = str
|
||||
return con
|
||||
|
||||
|
||||
def disconnect(con):
|
||||
con.commit()
|
||||
con.close()
|
||||
|
||||
|
||||
|
||||
|
||||
class Statement():
|
||||
def __init__(self):
|
||||
self.statement = ""
|
||||
self.con = connect()
|
||||
self.commit = True
|
||||
|
||||
def __del__(self):
|
||||
self.con.close()
|
||||
|
||||
def commitdb(self):
|
||||
self.con.commit()
|
||||
|
||||
def execute(self,vals=None):
|
||||
if self.statement == "":
|
||||
return
|
||||
if vals==None:
|
||||
result = self.con.execute(self.statement)
|
||||
else:
|
||||
result = self.con.execute(self.statement,vals)
|
||||
|
||||
if self.commit == True:
|
||||
self.commitdb()
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
||||
class CTable(Statement):
|
||||
def __init__(self,name):
|
||||
Statement.__init__(self)
|
||||
self.name = name
|
||||
self.cols = []
|
||||
|
||||
def addcol(self,name,type,params=""):
|
||||
self.cols += [(name,type,params)]
|
||||
|
||||
def execute(self):
|
||||
self.statement = "CREATE TABLE "+self.name + " ("
|
||||
for index,col in enumerate(self.cols):
|
||||
if not index == 0:
|
||||
self.statement += ", "
|
||||
self.statement += " " + col[0] + " " + col[1] + " " + col[2]
|
||||
self.statement += " );"
|
||||
return Statement.execute(self)
|
||||
|
||||
|
||||
|
||||
|
||||
class Select(Statement):
|
||||
def __init__(self,What,From,Where=None):
|
||||
Statement.__init__(self)
|
||||
self.commit = False
|
||||
self.What = What
|
||||
self.From = From
|
||||
self.Where = Where
|
||||
|
||||
def execute(self):
|
||||
self.statement = "SELECT " + self.What
|
||||
self.statement += " FROM " + self.From
|
||||
if not self.Where==None:
|
||||
self.statement += " WHERE " + self.Where
|
||||
return Statement.execute(self)
|
||||
|
||||
|
||||
|
||||
|
||||
class Insert(Statement):
|
||||
def __init__(self,table,values=[]):
|
||||
Statement.__init__(self)
|
||||
self.table = table
|
||||
self.values = values
|
||||
|
||||
def addval(self,val):
|
||||
self.values += [val]
|
||||
|
||||
def execute(self):
|
||||
self.statement = "INSERT INTO "+ self.table + " VALUES("
|
||||
qs = ""
|
||||
for i in range(len(self.values)):
|
||||
if not i == 0:
|
||||
qs+=","
|
||||
qs+="?"
|
||||
#self.values[i] = str(self.values[i])
|
||||
self.statement+=qs + ")"
|
||||
Statement.execute(self, self.values)
|
||||
|
||||
|
||||
|
||||
class Remove(Statement):
|
||||
def __init__(self,table,where=""):
|
||||
Statement.__init__(self)
|
||||
self.table = table
|
||||
self.where = where
|
||||
|
||||
def execute(self):
|
||||
self.statement = "DELETE FROM " + self.table
|
||||
if not self.where=="":
|
||||
self.statement += " WHERE "+self.where
|
||||
Statement.execute(self)
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" ?>
|
||||
<window width="900" height="600" close="ocarina-stop" title="Ocarina 3.0">
|
||||
<add>
|
||||
<vbox>
|
||||
<menubar>
|
||||
<menuitem name="Library">
|
||||
<menulibnew/>
|
||||
</menuitem>
|
||||
<menuitem name="Playback">
|
||||
<menuplay/>
|
||||
<menupause/>
|
||||
<menustop/>
|
||||
<menusongsel/>
|
||||
</menuitem>
|
||||
<menuitem name="Theme">
|
||||
<menutheme/>
|
||||
</menuitem>
|
||||
</menubar>
|
||||
<songinfo/>
|
||||
<tabs>
|
||||
<tab>
|
||||
<tablabel>
|
||||
<label text="Library"/>
|
||||
</tablabel>
|
||||
<tabcontent>
|
||||
<librarylist/>
|
||||
</tabcontent>
|
||||
</tab>
|
||||
</tabs>
|
||||
</vbox>
|
||||
</add>
|
||||
</window>
|
|
@ -3,18 +3,15 @@
|
|||
<add>
|
||||
<vbox>
|
||||
<menubar>
|
||||
<menuitem name="Library">
|
||||
<menuitem name="New Library"/>
|
||||
<!--<menuitem name="Select Library">
|
||||
<menuitem name="Library 1"/>
|
||||
</menuitem>-->
|
||||
</menuitem>
|
||||
<menuitem name="Playback">
|
||||
<menuplay/>
|
||||
<menupause/>
|
||||
<menustop/>
|
||||
<menusongsel/>
|
||||
</menuitem>
|
||||
<menuitem name="Theme">
|
||||
<menutheme/>
|
||||
</menuitem>
|
||||
</menubar>
|
||||
<songinfo/>
|
||||
<hbox>
|
Loading…
Reference in New Issue