Added ocarina-extra
This commit is contained in:
parent
f058eda485
commit
9d27a0de0f
|
@ -0,0 +1,18 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 15, 2010 9:53:46 PM$"
|
||||
|
||||
from ct import path
|
||||
from ocarina import vars
|
||||
|
||||
|
||||
vars["$user"] = path.expand("~")
|
||||
vars["$ocarina"] = path.join(vars["$user"],".ocarina3")
|
||||
vars["$verbose"] = 0
|
||||
vars["$path"] = "coreplug"
|
||||
vars["$prompt"] = ">>>"
|
||||
vars["$playonload"] = True
|
|
@ -1,37 +1,36 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 5, 2010 7:53:19 PM$"
|
||||
__author__ = "bjschuma"
|
||||
__date__ = "$Feb 5, 2010 7:53:19 PM$"
|
||||
|
||||
import gst
|
||||
|
||||
import ocarina
|
||||
from ct.opts import args
|
||||
from ct.message import write
|
||||
from ct import path
|
||||
from ct.message import write
|
||||
from ct.opts import args
|
||||
import gst
|
||||
import ocarina
|
||||
|
||||
global player
|
||||
global time
|
||||
|
||||
player = gst.element_factory_make("playbin2","player")
|
||||
player = gst.element_factory_make("playbin2", "player")
|
||||
time = gst.Format(gst.FORMAT_TIME)
|
||||
bus = player.get_bus()
|
||||
volume = gst.element_factory_make("volume","vol")
|
||||
volume = gst.element_factory_make("volume", "vol")
|
||||
player.add(volume)
|
||||
|
||||
# Volume range goes from 0 to 1.0 (before sounding bad)
|
||||
volume.set_property("volume",1.0)
|
||||
volume.set_property("volume", 1.0)
|
||||
|
||||
|
||||
def load(song):
|
||||
song = path.expand(song)
|
||||
if path.exists(song) == False:
|
||||
write("Path does not exist: "+song)
|
||||
write("Path does not exist: " + song)
|
||||
return
|
||||
write("Loading file: "+song,1)
|
||||
write("Loading file: " + song, 1)
|
||||
global player
|
||||
player.set_state(gst.STATE_NULL)
|
||||
player.set_property("uri","file://"+song)
|
||||
player.set_property("uri", "file://" + song)
|
||||
if ocarina.vars["$playonload"] == True:
|
||||
player.set_state(gst.STATE_PLAYING)
|
||||
else:
|
||||
|
@ -54,18 +53,37 @@ def init():
|
|||
|
||||
def play():
|
||||
global player
|
||||
write("Gstreamer state: playing",1)
|
||||
write("Gstreamer state: playing", 1)
|
||||
player.set_state(gst.STATE_PLAYING)
|
||||
|
||||
|
||||
def pause():
|
||||
global player
|
||||
write("Gstreamer state: paused",1)
|
||||
write("Gstreamer state: paused", 1)
|
||||
player.set_state(gst.STATE_PAUSED)
|
||||
|
||||
|
||||
ocarina.events.invite("ocarina-start",init)
|
||||
ocarina.events.invite("ocarina-stop",uninit)
|
||||
def onMessage(bus, message):
|
||||
#print message.type
|
||||
if message.type == gst.MESSAGE_TAG:
|
||||
taglist = message.parse_tag()
|
||||
for tag in taglist.keys():
|
||||
write("Found tag: ("+tag+", "+str(taglist[tag])+")",1)
|
||||
if tag == "title":
|
||||
ocarina.vars["$title"] = taglist[tag]
|
||||
elif tag == "artist":
|
||||
ocarina.vars["$artist"]= taglist[tag]
|
||||
elif tag == "album":
|
||||
ocarina.vars["$album"] = taglist[tag]
|
||||
ocarina.events.start("tags-changed")
|
||||
|
||||
|
||||
bus.add_signal_watch()
|
||||
bus.connect("message", onMessage)
|
||||
ocarina.events.invite("ocarina-start", init, 60)
|
||||
ocarina.events.invite("ocarina-stop", uninit)
|
||||
ocarina.events.invite("ocarina-play", play)
|
||||
ocarina.events.invite("ocarina-pause", pause)
|
||||
|
||||
#
|
||||
#def setvol(value):
|
||||
|
|
|
@ -9,6 +9,7 @@ import scripting
|
|||
import manager
|
||||
import cli
|
||||
import gstreamer
|
||||
import coredefaults
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -26,12 +26,12 @@ 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
|
||||
#vars["$user"] = path.expand("~")
|
||||
#vars["$ocarina"] = path.join(vars["$user"],".ocarina3")
|
||||
#vars["$verbose"] = 0
|
||||
#vars["$path"] = "coreplug"
|
||||
#vars["$prompt"] = ">>>"
|
||||
#vars["$playonload"] = True
|
||||
|
||||
# Set verbose value
|
||||
if opts.opts.has("v") == True:
|
||||
|
|
|
@ -4,7 +4,8 @@ __author__="bjschuma"
|
|||
__date__ ="$Mar 14, 2010 5:16:51 PM$"
|
||||
|
||||
from ct import plugin
|
||||
import gstreamer
|
||||
import ocarina
|
||||
#import gstreamer
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
def __init__(self):
|
||||
|
@ -12,5 +13,6 @@ class Plugin(plugin.Plugin):
|
|||
|
||||
|
||||
def run(self,args):
|
||||
gstreamer.pause()
|
||||
ocarina.events.start("ocarina-pause")
|
||||
#gstreamer.pause()
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ __author__="bjschuma"
|
|||
__date__ ="$Mar 14, 2010 5:12:02 PM$"
|
||||
|
||||
from ct import plugin
|
||||
import gstreamer
|
||||
import ocarina
|
||||
#import gstreamer
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
|
@ -13,5 +14,6 @@ class Plugin(plugin.Plugin):
|
|||
|
||||
|
||||
def run(self,args):
|
||||
gstreamer.play()
|
||||
ocarina.events.start("ocarina-play")
|
||||
#gstreamer.play()
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 9:53:12 PM$"
|
||||
|
||||
__all__ = ["xm"]
|
|
@ -0,0 +1,84 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Jan 4, 2010 3:27:05 PM$"
|
||||
|
||||
|
||||
import xml
|
||||
import xml.dom.minidom as xml
|
||||
from ct.path import *
|
||||
|
||||
|
||||
def new():
|
||||
return xml.Document()
|
||||
|
||||
|
||||
def element(document,name):
|
||||
return document.createElement(name)
|
||||
|
||||
|
||||
def text(document,name):
|
||||
return document.createTextNode( str(name) )
|
||||
|
||||
|
||||
def append(document,child):#,root=None):
|
||||
document.appendChild(child)
|
||||
|
||||
|
||||
def child(document):#root=None):
|
||||
return document.firstChild
|
||||
|
||||
|
||||
def children(document):
|
||||
if document.hasChildNodes() == False:
|
||||
return []
|
||||
return document.childNodes
|
||||
|
||||
|
||||
def attributes(document):
|
||||
attrs = dict()
|
||||
if document.hasAttributes() == True:
|
||||
for i in range(document.attributes.length):
|
||||
item = document.attributes.item(i)
|
||||
attrs[item.name] = item.nodeValue
|
||||
return attrs
|
||||
|
||||
|
||||
def write(document,path):
|
||||
out = open(path,'w')
|
||||
out.write(document.toprettyxml(indent=" "))
|
||||
out.close()
|
||||
|
||||
|
||||
def load(path):
|
||||
fin = open(path)
|
||||
if fin == None:
|
||||
return
|
||||
document = xml.parse(fin)
|
||||
return document
|
||||
|
||||
|
||||
def isElm(node):
|
||||
return node.nodeType == 1
|
||||
|
||||
|
||||
def isText(node):
|
||||
return node.nodeType == 3
|
||||
|
||||
|
||||
def name(node):
|
||||
return node.nodeName
|
||||
|
||||
|
||||
def value(node):
|
||||
val = node.nodeValue.strip()
|
||||
if val == "False":
|
||||
return False
|
||||
elif val == "True":
|
||||
return True
|
||||
elif val.isdigit() == True:
|
||||
return int(val)
|
||||
return val
|
|
@ -0,0 +1,14 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 15, 2010 9:56:53 PM$"
|
||||
|
||||
|
||||
from ocarina import vars
|
||||
vars["$theme"] = "simple.xml"
|
||||
vars["$artist"] = ""
|
||||
vars["$album"] = ""
|
||||
vars["$title"] = ""
|
|
@ -0,0 +1,84 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 9:52:10 PM$"
|
||||
|
||||
|
||||
import ocarina
|
||||
from et import xm
|
||||
from ct.message import write
|
||||
#from oGtk import *
|
||||
|
||||
import gtk
|
||||
|
||||
global parts
|
||||
parts = dict()
|
||||
|
||||
global buildFunc
|
||||
buildFunc = 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 fill(node,container):
|
||||
global buildFunc
|
||||
pack = True
|
||||
packing = {"expand":False,"fill":False,"padding":0}
|
||||
|
||||
for child in xm.children(node):
|
||||
if child.nodeName == "add":
|
||||
write("We are adding to "+node.nodeName,2)
|
||||
pack = False
|
||||
for grandchild in xm.children(child):
|
||||
item = buildFunc(grandchild)
|
||||
if item != None:
|
||||
container.add(item)
|
||||
|
||||
elif child.nodeName == "pack":
|
||||
packing = setPacking( packing,xm.attributes(child) )
|
||||
write("Now using packing: "+str(packing), 2)
|
||||
|
||||
else:
|
||||
item = buildFunc(child)
|
||||
if item != None:
|
||||
if pack == False:
|
||||
container.add(item)
|
||||
else:
|
||||
container.pack_start(item,packing["expand"],packing["fill"],packing["padding"])
|
||||
|
||||
|
||||
def build(node):
|
||||
global parts
|
||||
tag = node.nodeName
|
||||
|
||||
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"):
|
||||
fill(node,part)
|
||||
return part
|
||||
|
||||
|
||||
def init():
|
||||
write("Building gui",1)
|
||||
doc = xm.load(ocarina.vars["$theme"])
|
||||
build( xm.child(doc) )
|
||||
|
||||
|
||||
buildFunc = build
|
||||
ocarina.events.invite("ocarina-start",init,50)
|
||||
ocarina.events.invite("ocarina-stop",gtk.main_quit)
|
|
@ -0,0 +1,5 @@
|
|||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 10:21:40 PM$"
|
||||
|
||||
|
||||
__all__ = ["box", "button", "label", "playButton", "songInfo", "window"]
|
|
@ -0,0 +1,43 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 10:59:25 PM$"
|
||||
|
||||
import gtk
|
||||
import guibuilder
|
||||
|
||||
|
||||
def getAttrs(attrs):
|
||||
homogeneous = False
|
||||
spacing = 0
|
||||
for a in attrs:
|
||||
if a == "homog" and attrs[a] == "True":
|
||||
homogeneous = True
|
||||
elif a == "spacing":
|
||||
spacing = int(attrs[a])
|
||||
return homogeneous, spacing
|
||||
|
||||
|
||||
|
||||
class HBox(gtk.HBox):
|
||||
def __init__(self,attrs):
|
||||
h,s = getAttrs(attrs)
|
||||
gtk.HBox.__init__(self,h,s)
|
||||
self.show()
|
||||
|
||||
|
||||
|
||||
class VBox(gtk.VBox):
|
||||
def __init__(self,attrs):
|
||||
h,s = getAttrs(attrs)
|
||||
gtk.VBox.__init__(self,h,s)
|
||||
self.show()
|
||||
|
||||
|
||||
def make_hbox(attrs):return HBox(attrs)
|
||||
def make_vbox(attrs):return VBox(attrs)
|
||||
guibuilder.parts["hbox"] = make_hbox
|
||||
guibuilder.parts["vbox"] = make_vbox
|
|
@ -0,0 +1,49 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 11:13:03 PM$"
|
||||
|
||||
import gtk
|
||||
import ocarina
|
||||
from ct import cmd
|
||||
|
||||
class Button(gtk.Button):
|
||||
def __init__(self,attrs):
|
||||
gtk.Button.__init__(self)
|
||||
self.command = ""
|
||||
hidden = False
|
||||
relief = gtk.RELIEF_NORMAL
|
||||
for a in attrs:
|
||||
if a == "cmd":
|
||||
self.command = attrs[a]
|
||||
elif a == "text":
|
||||
self.set_label(attrs[a])
|
||||
elif a == "show":
|
||||
ocarina.events.invite(attrs[a],self.show)
|
||||
elif a == "hide":
|
||||
ocarina.events.invite(attrs[a],self.hide)
|
||||
elif a=="hidden" and attrs[a].lower()=="true":
|
||||
hidden = True
|
||||
elif a=="relief":
|
||||
if attrs[a] == "none":
|
||||
relief = gtk.RELIEF_NONE
|
||||
elif attrs[a] == "half":
|
||||
relief = gtk.RELIEF_HALF
|
||||
elif a=="stock" and attrs[a]=="true":
|
||||
self.set_use_stock(True)
|
||||
|
||||
self.set_relief(relief)
|
||||
self.connect("clicked",self.clicked)
|
||||
if hidden==False:
|
||||
self.show()
|
||||
|
||||
|
||||
def clicked(self,button):
|
||||
cmd.run(self.command)
|
||||
|
||||
|
||||
def make_button(attrs):return Button(attrs)
|
||||
|
||||
|
||||
import guibuilder
|
||||
guibuilder.parts["button"] = make_button
|
|
@ -0,0 +1,50 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 15, 2010 9:46:07 AM$"
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
|
||||
class Label(gtk.Label):
|
||||
def __init__(self,attrs):
|
||||
gtk.Label.__init__(self)
|
||||
for a in attrs:
|
||||
if a == "text":
|
||||
self.set_text(attrs[a])
|
||||
self.show()
|
||||
|
||||
|
||||
def make_label(attrs):return Label(attrs)
|
||||
import guibuilder
|
||||
guibuilder.parts["label"] = make_label
|
||||
|
||||
|
||||
class Label2(gtk.Alignment):
|
||||
def __init__(self,size=None,weight=None,text=None):
|
||||
gtk.Alignment.__init__(self,0,1,0,0)
|
||||
self.show()
|
||||
|
||||
if text==None:
|
||||
self.label = gtk.Label()
|
||||
else:
|
||||
self.label = gtk.Label(text)
|
||||
|
||||
self.label.show()
|
||||
self.add(self.label)
|
||||
|
||||
if (size!=None) or (weight!=None):
|
||||
attr = pango.AttrList()
|
||||
if size != None:
|
||||
attr.insert(pango.AttrSize(size,0,-1))
|
||||
if weight != None:
|
||||
attr.insert(pango.AttrWeight(weight,0,-1))
|
||||
self.label.set_attributes(attr)
|
||||
|
||||
|
||||
def set_text(self,text):
|
||||
self.label.set_text(text)
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 15, 2010 11:47:24 PM$"
|
||||
|
||||
|
||||
import guibuilder
|
||||
import gtk
|
||||
|
||||
class PlayButton(gtk.HBox):
|
||||
def __init__(self,attrs):
|
||||
gtk.HBox.__init__(self,False,0)
|
||||
size = gtk.ICON_SIZE_BUTTON
|
||||
for a in attrs:
|
||||
if a=="size":
|
||||
if attrs[a] == "large":
|
||||
size = gtk.ICON_SIZE_LARGE_TOOLBAR
|
||||
|
||||
self.play = self.getButton(gtk.STOCK_MEDIA_PLAY, size)
|
||||
self.pause = self.getButton(gtk.STOCK_MEDIA_PAUSE, size)
|
||||
|
||||
self.pack_start(self.play, False)
|
||||
self.pack_start(self.pause, False)
|
||||
|
||||
self.pause.show()
|
||||
self.play.show()
|
||||
self.show()
|
||||
|
||||
|
||||
def getButton(self,stock,size):
|
||||
img = gtk.Image()
|
||||
img.show()
|
||||
img.set_from_stock(stock,size)
|
||||
button = gtk.Button()
|
||||
button.add(img)
|
||||
return button
|
||||
|
||||
|
||||
def make_playbutton(attrs=None):return PlayButton(attrs)
|
||||
guibuilder.parts["playbutton"] = make_playbutton
|
|
@ -0,0 +1,43 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 15, 2010 10:01:39 PM$"
|
||||
|
||||
|
||||
import gtk
|
||||
import ocarina
|
||||
from oGtk import label
|
||||
import guibuilder
|
||||
|
||||
|
||||
class SongInfo(gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER)
|
||||
box = gtk.VBox(False,0)
|
||||
|
||||
self.title = label.Label2(13000,700)
|
||||
self.artist = label.Label2(10000,400)
|
||||
self.album = label.Label2(10000,400)
|
||||
|
||||
box.pack_start(self.title,False,False,0)
|
||||
box.pack_start(self.album,False,False,0)
|
||||
box.pack_start(self.artist,False,False,0)
|
||||
self.add_with_viewport(box)
|
||||
|
||||
self.setLabels()
|
||||
ocarina.events.invite("tags-changed", self.setLabels)
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setLabels(self):
|
||||
self.title.set_text(ocarina.vars["$title"])
|
||||
self.album.set_text("from " + ocarina.vars["$album"])
|
||||
self.artist.set_text("by " + ocarina.vars["$artist"])
|
||||
|
||||
|
||||
def make_songinfo(attrs=None):return SongInfo()
|
||||
guibuilder.parts["songinfo"] = make_songinfo
|
|
@ -0,0 +1,40 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 10:23:17 PM$"
|
||||
|
||||
import gtk
|
||||
|
||||
import guibuilder
|
||||
import ocarina
|
||||
|
||||
class Window(gtk.Window):
|
||||
def __init__(self, attrs):
|
||||
gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)
|
||||
self.quitEvent = ""
|
||||
self.connect("delete_event", self.onQuit)
|
||||
size = [240,800]
|
||||
|
||||
for a in attrs:
|
||||
if a == "title":
|
||||
self.set_title(attrs[a])
|
||||
elif a == "width":
|
||||
size[0] = int(attrs[a])
|
||||
elif a == "height":
|
||||
size[1] = int(attrs[a])
|
||||
elif a == "close":
|
||||
self.quitEvent = attrs[a]
|
||||
|
||||
self.resize(size[0], size[1])
|
||||
self.show()
|
||||
|
||||
|
||||
def onQuit(self,a,b):
|
||||
ocarina.events.start(self.quitEvent)
|
||||
|
||||
|
||||
def make_window(attrs):return Window(attrs)
|
||||
guibuilder.parts["window"] = make_window
|
|
@ -0,0 +1,35 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Mar 14, 2010 9:50:09 PM$"
|
||||
|
||||
import sys
|
||||
sys.path.append("core")
|
||||
|
||||
|
||||
import ocarina
|
||||
from ct.message import write
|
||||
import scripting
|
||||
import manager
|
||||
#import cli
|
||||
import gstreamer
|
||||
import coredefaults
|
||||
import extradefaults
|
||||
|
||||
import guibuilder
|
||||
from oGtk import *
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
def main():
|
||||
ocarina.init()
|
||||
|
||||
# Potentially the first thing printed
|
||||
write("Welcome to Ocarina (extra)", 1)
|
||||
|
||||
ocarina.events.start("ocarina-start")
|
||||
gtk.main()
|
||||
|
||||
|
||||
if __name__ == "__main__":main()
|
|
@ -1,61 +0,0 @@
|
|||
# Basic plugin class
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 8, 2010 10:00:40 AM$"
|
||||
|
||||
|
||||
from bt import plugin
|
||||
from bt.message import write
|
||||
import settings
|
||||
from bt import signal
|
||||
import random
|
||||
random.seed()
|
||||
from ct import db
|
||||
import manager
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
def __init__(self):
|
||||
plugin.Plugin.__init__(self)
|
||||
self.help = ""
|
||||
|
||||
|
||||
def open(self):
|
||||
if settings.has("random") == False:
|
||||
settings.set("random",False)
|
||||
elif settings.get("random") == True:
|
||||
signal.register("next",self.randLib,90)
|
||||
pass
|
||||
|
||||
|
||||
def close(self):
|
||||
signal.remove("next",self.randLib)
|
||||
|
||||
|
||||
# Take a random song from the library
|
||||
def randLib(self):
|
||||
# Return if random is not enabled
|
||||
if settings.get("random") == False:
|
||||
return
|
||||
|
||||
count = db.countlib(str(settings.get("curlib")))
|
||||
curtrk = settings.get("curtrk")
|
||||
id = curtrk
|
||||
# Guarentee that we don't choose the same track twice
|
||||
while id==curtrk:
|
||||
id = random.randint(0,count)
|
||||
# Prevent infinite loop if library has size 1
|
||||
if count == 1:
|
||||
break
|
||||
manager.run("next",[id])
|
||||
signal.stop("next")
|
||||
|
||||
|
||||
def run(self, args=None):
|
||||
if args==None or len(args)==0:
|
||||
rand = not settings.get("random")
|
||||
settings.set("random",rand)
|
||||
|
||||
elif args[0] == "?":
|
||||
write(settings.get("random"))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
python extra/ocarina-extra.py $*
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" ?>
|
||||
<window width="400" height="300" close="ocarina-stop" title="Ocarina 3.0">
|
||||
<add>
|
||||
<vbox>
|
||||
<songinfo/>
|
||||
<playbutton size="large"/>
|
||||
<hbox>
|
||||
<button relief="none" text="gtk.STOCK_MEDIA_PLAY" cmd="play" show="ocarina-pause" hide="ocarina-play" stock="True"/>
|
||||
<button relief="none" text="Pause" cmd="pause" show="ocarina-play" hide="ocarina-pause" hidden="true"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</add>
|
||||
</window>
|
Loading…
Reference in New Issue