-from Tools.Directories import resolveFilename, fileExists, SCOPE_FONTS, SCOPE_PLUGINS, SCOPE_SKIN
+
+from Tools.Directories import fileExists
+from Components.config import config, ConfigSubsection, ConfigInteger, ConfigYesNo, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence
+
+class ConfigColor(ConfigSequence):
+ def __init__(self):
+ ConfigSequence.__init__(self, seperator = "#", limits = [(0,255),(0,255),(0,255)])
+
+class ConfigPixelvals(ConfigSequence):
+ def __init__(self):
+ ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)])
+
+class ConfigPixelvals(ConfigSequence):
+ def __init__(self):
+ ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)])
+
+class ConfigFilename(ConfigText):
+ def __init__(self):
+ ConfigText.__init__(self, default = "", fixed_size = True, visible_width = False)
+
+ def getMulti(self, selected):
+ filename = (self.text.rstrip("/").rsplit("/",1))[1].encode("utf-8")[:40] + " "
+ if self.allmarked:
+ mark = range(0, len(filename))
+ else:
+ mark = [filename]
+ return ("mtext"[1-selected:], filename, mark)
+
class DVDProject:
def __init__(self):
self.titles = [ ]
self.target = None
- self.name = _("Dreambox DVD record")
- self.vmgm = resolveFilename(SCOPE_PLUGINS,"Extensions/DVDBurn/dreamvmgm.mpg")
- self.menuaudio = resolveFilename(SCOPE_PLUGINS,"Extensions/DVDBurn/silence.mp2")
- self.menubg = resolveFilename(SCOPE_SKIN, "dreamdvd_02.jpg")
- # tuples with R, G, B values
- self.color_button = ( 0x08, 0x00, 0x00 )
- self.color_highlight = ( 0x00, 0xC0, 0xC0 )
- self.color_headline = ( 0x00, 0x00, 0x80 )
- self.font_face = resolveFilename(SCOPE_FONTS, "nmsbd.ttf")
- # tuple with three pixel values ( headline, title, subtitle )
- self.font_size = ( 48, 28, 16 )
- # please supply even numbers for all dimensions
- self.space_left = 30
- self.space_top = 120
- self.space_rows = 36
+ self.settings = ConfigSubsection()
+ self.settings.name = ConfigText(fixed_size = False, visible_width = 40)
+ self.settings.authormode = ConfigSelection(choices = [("menu_linked", _("Linked titles with a DVD menu")), ("just_linked", _("Direct playback of linked titles without menu")), ("menu_seperate", _("Seperate titles with a main menu")), ("data_ts", _("Dreambox format data DVD (HDTV compatible)"))])
+ self.settings.menubg = ConfigFilename()
+ self.settings.menuaudio = ConfigFilename()
+ self.settings.titleformat = ConfigText(fixed_size = False, visible_width = 40)
+ self.settings.subtitleformat = ConfigText(fixed_size = False, visible_width = 40)
+ self.settings.color_headline = ConfigColor()
+ self.settings.color_highlight = ConfigColor()
+ self.settings.color_button = ConfigColor()
+ self.settings.font_face = ConfigFilename()
+ self.settings.font_size = ConfigPixelvals()
+ self.settings.space = ConfigPixelvals()
+ self.settings.vmgm = ConfigFilename()
+ self.settings.autochapter = ConfigInteger(default = 0, limits = (0, 99))
+ self.filekeys = ["vmgm", "menubg", "menuaudio", "font_face"]
def addService(self, service):
import DVDTitle
title.addService(service)
self.titles.append(title)
return title
-
+
def saveProject(self, path):
import xml.dom.minidom
from Tools.XMLTools import elementsWithTag, mergeText, stringToXML
list = []
list.append('<?xml version="1.0" encoding="utf-8" ?>\n')
list.append('<DreamDVDBurnerProject>\n')
- list.append('\t<config')
- list.append(' name="' + self.name + '"')
- list.append(' vmgm="' + self.vmgm + '"')
- list.append(' />\n')
- list.append('\t<menu')
- list.append(' bg="' + self.menubg + '"')
- list.append(' audio="' + self.menuaudio + '"')
- list.append(' color_button="' + str(self.color_button) + '"')
- list.append(' color_highlight="' + str(self.color_highlight) + '"')
- list.append(' color_headline="' + str(self.color_headline) + '"')
- list.append(' font_face="' + self.font_face + '"')
- list.append(' font_size="' + str(self.font_size) + '"')
- list.append(' space_left="' + str(self.space_left) + '"')
- list.append(' space_top="' + str(self.space_top) + '"')
- list.append(' space_rows="' + str(self.space_rows) + '"')
- list.append(' />\n')
+ list.append('\t<settings ')
+ for key, val in self.settings.dict().iteritems():
+ list.append( key + '="' + str(val.getValue()) + '" ' )
+ list.append(' />\n')
list.append('\t<titles>\n')
for title in self.titles:
list.append('\t\t<path>')
list.append('\t</titles>\n')
list.append('</DreamDVDBurnerProject>\n')
+ name = self.settings.name.getValue()
i = 0
- filename = path + "/" + self.name + ".ddvdp.xml"
+ filename = path + name + ".ddvdp.xml"
while fileExists(filename):
i = i+1
- filename = path + "/" + self.name + str(i).zfill(3) + ".ddvdp.xml"
-
- file = open(filename, "w")
- for x in list:
- file.write(x)
- file.close()
\ No newline at end of file
+ filename = path + name + str(i).zfill(3) + ".ddvdp.xml"
+ try:
+ file = open(filename, "w")
+ for x in list:
+ file.write(x)
+ file.close()
+ except:
+ return False
+ return filename
+
+ def loadProject(self, filename):
+ import xml.dom.minidom
+ try:
+ if not fileExists(filename):
+ self.error = "xml file not found!"
+ raise AttributeError
+ else:
+ self.error = ""
+ file = open(filename, "r")
+ data = file.read().decode("utf-8").replace('&',"&").encode("ascii",'xmlcharrefreplace')
+ file.close()
+ projectfiledom = xml.dom.minidom.parseString(data)
+ for project in projectfiledom.childNodes[0].childNodes:
+ if project.nodeType == xml.dom.minidom.Element.nodeType:
+ if project.tagName == 'settings':
+ i = 0
+ if project.attributes.length < 11:
+ self.error = "project attributes missing"
+ raise AttributeError
+ while i < project.attributes.length:
+ item = project.attributes.item(i)
+ key = item.name.encode("utf-8")
+ try:
+ val = eval(item.nodeValue)
+ except (NameError, SyntaxError):
+ val = item.nodeValue.encode("utf-8")
+ try:
+ self.settings.dict()[key].setValue(val)
+ except (KeyError):
+ self.error = "unknown attribute '%s'" % (key)
+ raise AttributeError
+ i += 1
+ for key in self.filekeys:
+ val = self.settings.dict()[key].getValue()
+ if not fileExists(val):
+ self.error += "\n%s '%s' not found" % (key, val)
+ if len(self.error):
+ raise AttributeError
+ except AttributeError:
+ self.error += (" in project '%s'") % (filename)
+ return False
+ return True