84 lines
1.7 KiB
Python
84 lines
1.7 KiB
Python
|
#! /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)
|