Some big rewrites and changes to themes
This commit is contained in:
parent
9efb3255bc
commit
38689d5826
|
@ -136,6 +136,12 @@ def voldown():
|
|||
volume.voldown()
|
||||
|
||||
|
||||
def volset(vol):
|
||||
'''Set the volume'''
|
||||
from gstreamer import volume
|
||||
volume.setvol(vol)
|
||||
|
||||
|
||||
def pyfile(file):
|
||||
'''If file exists, try to execute it as a python script'''
|
||||
if path.exists(file) == True:
|
||||
|
|
|
@ -7,19 +7,21 @@ __date__ ="$Mar 13, 2010 4:37:46 PM$"
|
|||
import sys
|
||||
import re
|
||||
|
||||
from ct.dict import Dict
|
||||
|
||||
# option -> number of times passed
|
||||
global opts
|
||||
opts = Dict()
|
||||
opts = dict()
|
||||
|
||||
global args
|
||||
args = []
|
||||
|
||||
|
||||
def parseOpt(opt):
|
||||
def has(opt):
|
||||
global opts
|
||||
if opts.has(opt) == False:
|
||||
return (opt in opts)
|
||||
|
||||
|
||||
def parseOpt(opt):
|
||||
if has(opt) == False:
|
||||
opts[opt] = 1
|
||||
else:
|
||||
opts[opt] += 1
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
__author__ = "bjschuma"
|
||||
__date__ = "$Feb 5, 2010 7:53:19 PM$"
|
||||
|
||||
|
||||
|
||||
def uninit():
|
||||
global player
|
||||
player.set_state(gst.STATE_NULL)
|
||||
|
||||
|
||||
|
||||
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)
|
||||
events.invite(events.OCARINA_QUIT, uninit)
|
||||
|
|
@ -17,9 +17,9 @@ from ct import opts
|
|||
path.mkdir(vars.OCARINA)
|
||||
opts.parse()
|
||||
# Set verbose value
|
||||
if opts.opts.has("v") == True:
|
||||
if opts.has("v") == True:
|
||||
vars.VERBOSE += opts.opts["v"]
|
||||
if opts.opts.has("verbose") == True:
|
||||
if opts.has("verbose") == True:
|
||||
vars.VERBOSE += opts.opts["verbose"]
|
||||
|
||||
|
||||
|
|
|
@ -2,17 +2,15 @@ __author__="bjschuma"
|
|||
__date__ ="$May 13, 2010 10:37:20 AM$"
|
||||
|
||||
|
||||
__all__ = ["box", "importnode", "menu", "node", "window"]
|
||||
__all__ = ["box", "button", "image", "importnode",
|
||||
"label", "menu", "node", "window"]
|
||||
|
||||
|
||||
from ct.call import write
|
||||
|
||||
|
||||
global parts
|
||||
parts = dict()
|
||||
|
||||
|
||||
|
||||
def make(child):
|
||||
global parts
|
||||
name = str(child.nodeName).lower()
|
||||
|
@ -29,10 +27,23 @@ parts["vbox"] = VBox
|
|||
parts["hbox"] = HBox
|
||||
|
||||
|
||||
from gtknodes.button import *
|
||||
parts["button"] = Button
|
||||
parts["volume"] = VolumeButton
|
||||
|
||||
|
||||
from gtknodes.image import *
|
||||
parts["image"] = Image
|
||||
|
||||
|
||||
from gtknodes.importnode import *
|
||||
parts["import"] = Import
|
||||
|
||||
|
||||
from gtknodes.label import *
|
||||
parts["label"] = Label
|
||||
|
||||
|
||||
from gtknodes.menu import *
|
||||
parts["menubar"] = bar.MenuBar
|
||||
parts["menuitem"] = item.MenuItem
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$May 18, 2010 3:29:19 PM$"
|
||||
|
||||
import gtk
|
||||
from ocarina import vars
|
||||
from ct import call
|
||||
from gtknodes import Node
|
||||
|
||||
class Button(Node):
|
||||
def __init__(self,elm):
|
||||
Node.__init__(self,elm)
|
||||
self["relief"] = "normal"
|
||||
self.part = gtk.Button()
|
||||
self.setattrs()
|
||||
|
||||
relief = gtk.RELIEF_NORMAL
|
||||
if self["relief"] == "none":
|
||||
relief = gtk.RELIEF_NONE
|
||||
elif self["relief"] == "half":
|
||||
relief = gtk.RELIEF_HALF
|
||||
self.part.set_relief(relief)
|
||||
|
||||
self.add()
|
||||
|
||||
|
||||
def add(self):
|
||||
if len(self.children) == 0:
|
||||
return
|
||||
self.part.add(self.children[0].part)
|
||||
|
||||
|
||||
def clear(self):
|
||||
self.part.remove(self.children[0].part)
|
||||
|
||||
|
||||
|
||||
class VolumeButton(Node):
|
||||
def __init__(self,elm):
|
||||
Node.__init__(self,elm)
|
||||
self["relief"] = "normal"
|
||||
self.part = gtk.VolumeButton()
|
||||
self.setattrs()
|
||||
|
||||
relief = gtk.RELIEF_NORMAL
|
||||
if self["relief"] == "none":
|
||||
relief = gtk.RELIEF_NONE
|
||||
elif self["relief"] == "half":
|
||||
relief = gtk.RELIEF_HALF
|
||||
self.part.set_relief(relief)
|
||||
adj = self.part.get_adjustment()
|
||||
adj.set_page_increment(vars.VOLUMEINCR)
|
||||
self.part.set_value(vars.VOLUME)
|
||||
self.part.connect("value-changed", self.changed)
|
||||
|
||||
|
||||
def changed(self, widget, value):
|
||||
call.volset(value)
|
|
@ -0,0 +1,30 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$May 18, 2010 5:05:58 PM$"
|
||||
|
||||
import gtk
|
||||
from ct import path
|
||||
from gtknodes import Node
|
||||
|
||||
class Image(Node):
|
||||
def __init__(self,elm):
|
||||
Node.__init__(self,elm)
|
||||
self["src"] = "none"
|
||||
self["size"] = "button"
|
||||
self.part = gtk.Image()
|
||||
self.setattrs()
|
||||
|
||||
if self["src"] != "none":
|
||||
file = path.expand(self["src"])
|
||||
if path.exists(file) == True:
|
||||
self.part.set_from_file( file )
|
||||
else:
|
||||
func = "self.part.set_from_stock("
|
||||
func += "gtk.STOCK_"+self["src"].upper()
|
||||
func += ", gtk.ICON_SIZE_" + self["size"].upper() + ")"
|
||||
exec func
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$May 18, 2010 3:44:12 PM$"
|
||||
|
||||
|
||||
import gtk
|
||||
from gtknodes import Node
|
||||
|
||||
class Label(Node):
|
||||
def __init__(self, elm):
|
||||
Node.__init__(self, elm)
|
||||
self["text"] = ""
|
||||
self.part = gtk.Label()
|
||||
self.setattrs()
|
||||
self.part.set_text(self["text"].title())
|
|
@ -14,7 +14,7 @@ class MenuNode(Node):
|
|||
Node.__init__(self,elm)
|
||||
self.part = gtk.MenuItem(title)
|
||||
self.setattrs()
|
||||
self.part.connect("activate", self.onclick)
|
||||
self.part.connect("activate", self.onactivate)
|
||||
|
||||
def onclick(self, menu):
|
||||
def onactivate(self, menu):
|
||||
pass
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -16,7 +16,7 @@ class MenuSelectSong(MenuNode):
|
|||
self.file = None
|
||||
|
||||
|
||||
def onclick(self, menu):
|
||||
def onactivate(self, menu):
|
||||
from gtkextras import dialog
|
||||
song = dialog.FileChooser("Select a song", self.file).choose()
|
||||
if song != None:
|
||||
|
|
Binary file not shown.
|
@ -13,7 +13,7 @@ class MenuReloadTheme(MenuNode):
|
|||
MenuNode.__init__(self, elm, "Reload Theme")
|
||||
|
||||
|
||||
def onclick(self,menu):
|
||||
def onactivate(self,menu):
|
||||
gui.build()
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ class MenuChangeTheme(MenuNode):
|
|||
MenuNode.__init__(self, elm, "Change Theme")
|
||||
|
||||
|
||||
def onclick(self,menu):
|
||||
def onactivate(self,menu):
|
||||
from gtkextras import dialog
|
||||
file = dialog.FileChooser("Select a theme file",vars.THEME).choose()
|
||||
if file != None:
|
||||
|
|
Binary file not shown.
|
@ -7,43 +7,55 @@ __author__="bjschuma"
|
|||
__date__ ="$May 16, 2010 10:27:25 PM$"
|
||||
|
||||
|
||||
from ct.call import write
|
||||
from ct import call
|
||||
#from ct.call import *
|
||||
from gtknodes import make
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self,elm):
|
||||
write("Creating node: "+elm.nodeName, 2)
|
||||
call.write("Creating node: "+elm.nodeName, 2)
|
||||
self.elm = elm
|
||||
self.part = None
|
||||
self.function = None
|
||||
self.init2()
|
||||
|
||||
|
||||
def __del__(self):
|
||||
write("Deleting node: "+self.elm.nodeName, 2)
|
||||
call.write("Deleting node: "+self.elm.nodeName, 2)
|
||||
|
||||
|
||||
def init2(self):
|
||||
self.name = self.elm.nodeName.lower()
|
||||
self.attrs = dict()
|
||||
self.children = self.getchildren()
|
||||
|
||||
|
||||
def __setitem__(self,key,value):
|
||||
self.attrs[str(key).lower()] = str(value).lower()
|
||||
|
||||
|
||||
def __getitem__(self,key):
|
||||
return self.attrs[str(key).lower()]
|
||||
|
||||
|
||||
def keys(self):
|
||||
return self.attrs.keys()
|
||||
|
||||
|
||||
def show(self):
|
||||
self.part.show()
|
||||
|
||||
|
||||
def hide(self):
|
||||
self.part.hide()
|
||||
|
||||
|
||||
def setattrs(self):
|
||||
if ("show" in self.keys()) == False:
|
||||
self["show"] = "true"
|
||||
if ("click" in self.keys()) == False:
|
||||
self["click"] = "none"
|
||||
self["viewport"] = "false"
|
||||
|
||||
if self.elm.hasAttributes() == True:
|
||||
|
@ -51,9 +63,21 @@ class Node:
|
|||
item = self.elm.attributes.item(i)
|
||||
self[item.name.lower()] = item.nodeValue.lower()
|
||||
|
||||
self.function = self["click"]
|
||||
if self.part != None:
|
||||
try:
|
||||
self.part.connect("clicked", self.onclick)
|
||||
except:
|
||||
pass
|
||||
if self["show"] == "true":
|
||||
self.part.show()
|
||||
|
||||
|
||||
def onclick(self,item):
|
||||
if self.function!="none":
|
||||
exec "call."+self.function+"()"
|
||||
|
||||
|
||||
def getchildren(self):
|
||||
if self.elm.hasChildNodes() == False:
|
||||
return []
|
||||
|
@ -66,5 +90,6 @@ class Node:
|
|||
children += [child]
|
||||
return children
|
||||
|
||||
|
||||
def make(self,child):
|
||||
return make(child)
|
|
@ -0,0 +1,151 @@
|
|||
#! /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.call import write
|
||||
#from oGtk import *
|
||||
|
||||
import gtk
|
||||
|
||||
global parts
|
||||
parts = dict()
|
||||
|
||||
global buildFunc
|
||||
buildFunc = None
|
||||
|
||||
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])
|
||||
elif field=="pack":
|
||||
if newVals[field] == "Start":
|
||||
old[field] = gtk.PACK_START
|
||||
else:
|
||||
old[field] = gtk.PACK_END
|
||||
|
||||
return old
|
||||
|
||||
|
||||
|
||||
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.addpage(content,label)
|
||||
attrs = setPacking({"expand":False,"fill":False,"pack":gtk.PACK_START}, xm.attributes(child) )
|
||||
tabs.set_tab_label_packing(content,attrs["expand"],attrs["fill"],attrs["pack"])
|
||||
|
||||
|
||||
def buildMenu(node,menu):
|
||||
global buildFunc
|
||||
for child in xm.children(node):
|
||||
item = buildFunc(child)
|
||||
if item!=None:
|
||||
if node.nodeName == "menu-bar":
|
||||
menu.append(item)
|
||||
elif node.nodeName == "menuitem":
|
||||
menu.addSubMenu(item)
|
||||
|
||||
|
||||
def fill(node,container):
|
||||
global buildFunc
|
||||
pack = True
|
||||
packing = {"expand":False,"fill":False,"padding":0,"pack":gtk.PACK_START}
|
||||
|
||||
for child in xm.children(node):
|
||||
viewport = False
|
||||
if child.nodeName == "add" or child.nodeName == "add-viewport":
|
||||
if child.nodeName == "add-viewport":
|
||||
write("We are adding to "+node.nodeName+" with a viewport",2)
|
||||
viewport = True
|
||||
else:
|
||||
write("We are adding to "+node.nodeName,2)
|
||||
pack = False
|
||||
for grandchild in xm.children(child):
|
||||
item = buildFunc(grandchild)
|
||||
if item != None:
|
||||
if viewport == False:
|
||||
container.add(item)
|
||||
else:
|
||||
container.add_with_viewport(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:
|
||||
if packing["pack"] == gtk.PACK_START:
|
||||
container.pack_start(item,packing["expand"],packing["fill"],packing["padding"])
|
||||
else:
|
||||
container.pack_end(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") or (tag=="scrolled-window") or (tag=="align"):
|
||||
fill(node,part)
|
||||
elif (tag=="menu-bar") or (tag=="menuitem"):
|
||||
buildMenu(node,part)
|
||||
elif (tag=="tabs"):
|
||||
buildTabs(node,part)
|
||||
return part
|
||||
else:
|
||||
write("Cannot make part: "+tag,3)
|
||||
|
||||
|
||||
def init():
|
||||
global window
|
||||
if window != None:
|
||||
window.hide()
|
||||
write("Building gui from file: "+ocarina.vars.THEME,1)
|
||||
doc = xm.load(ocarina.vars.THEME)
|
||||
window = build( xm.child(doc) )
|
||||
ocarina.events.start(ocarina.events.GUI_DONE)
|
||||
window.show()
|
||||
|
||||
|
||||
buildFunc = build
|
||||
ocarina.events.invite(ocarina.events.OCARINA_START,init,50)
|
||||
ocarina.events.invite(ocarina.events.OCARINA_QUIT,gtk.main_quit)
|
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Apr 25, 2010 7:14:31 PM$"
|
||||
|
||||
|
||||
import gtk
|
||||
import guibuilder
|
||||
|
||||
class Align(gtk.Alignment):
|
||||
def __init__(self,attrs):
|
||||
xalign = 0.0
|
||||
yalign = 0.0
|
||||
xscale = 0.0
|
||||
yscale = 0.0
|
||||
for a in attrs:
|
||||
if a == "xalign":
|
||||
xalign = float( attrs[a] )
|
||||
elif a == "yalign":
|
||||
yalign = float( attrs[a] )
|
||||
elif a == "xscale":
|
||||
xscale = float( attrs[a] )
|
||||
elif a == "yscale":
|
||||
yscale = float( attrs[a] )
|
||||
gtk.Alignment.__init__(self,xalign,yalign,xscale,yscale)
|
||||
self.show()
|
||||
|
||||
|
||||
def make_align(attrs):return Align(attrs)
|
||||
guibuilder.parts["align"] = make_align
|
|
@ -11,10 +11,16 @@
|
|||
</vbox>
|
||||
</scrollwindow>
|
||||
<hbox>
|
||||
<!--<button-play size="large"/>
|
||||
<button-pause size="large"/>
|
||||
<button-stop size="large"/>
|
||||
<volume/>-->
|
||||
<button click="play">
|
||||
<image src="media_play" size="dialog"/>
|
||||
</button>
|
||||
<button click="pause">
|
||||
<image src="media_pause" size="dialog"/>
|
||||
</button>
|
||||
<button click="stop">
|
||||
<image src="media_stop" size="dialog"/>
|
||||
</button>
|
||||
<volume/>
|
||||
</hbox>
|
||||
<!--<progbar/>-->
|
||||
</vbox>
|
||||
|
|
Loading…
Reference in New Issue