1 from Tools.Directories import fileExists
2 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigYesNo, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence
4 class ConfigColor(ConfigSequence):
6 ConfigSequence.__init__(self, seperator = "#", limits = [(0,255),(0,255),(0,255)])
8 class ConfigPixelvals(ConfigSequence):
10 ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)])
16 self.settings = ConfigSubsection()
17 self.settings.name = ConfigText(visible_width = 40)
18 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")), ])
19 self.settings.menubg = ConfigText(visible_width = 40)
20 self.settings.menuaudio = ConfigText(visible_width = 40)
21 self.settings.titleformat = ConfigText(visible_width = 40)
22 self.settings.subtitleformat = ConfigText(visible_width = 40)
23 self.settings.color_headline = ConfigColor()
24 self.settings.color_highlight = ConfigColor()
25 self.settings.color_button = ConfigColor()
26 self.settings.font_face = ConfigText(visible_width = 40)
27 self.settings.font_size = ConfigPixelvals()
28 self.settings.space = ConfigPixelvals()
29 self.settings.vmgm = ConfigText(visible_width = 40)
31 def addService(self, service):
33 title = DVDTitle.DVDTitle()
34 title.addService(service)
35 self.titles.append(title)
38 def saveProject(self, path):
39 import xml.dom.minidom
40 from Tools.XMLTools import elementsWithTag, mergeText, stringToXML
42 list.append('<?xml version="1.0" encoding="utf-8" ?>\n')
43 list.append('<DreamDVDBurnerProject>\n')
44 list.append('\t<settings ')
45 for key, val in self.settings.dict().iteritems():
46 list.append( key + '="' + str(val.getValue()) + '" ' )
48 list.append('\t<titles>\n')
49 for title in self.titles:
50 list.append('\t\t<path>')
51 list.append(stringToXML(title.source.getPath()))
52 list.append('</path>\n')
53 list.append('\t</titles>\n')
54 list.append('</DreamDVDBurnerProject>\n')
56 name = self.settings.name.getValue()
58 filename = path + name + ".ddvdp.xml"
59 while fileExists(filename):
61 filename = path + name + str(i).zfill(3) + ".ddvdp.xml"
63 file = open(filename, "w")
71 def loadProject(self, filename):
72 import xml.dom.minidom
74 if not fileExists(filename):
75 self.error = "xml file not found!"
79 file = open(filename, "r")
80 data = file.read().decode("utf-8").replace('&',"&").encode("ascii",'xmlcharrefreplace')
82 projectfiledom = xml.dom.minidom.parseString(data)
83 for project in projectfiledom.childNodes[0].childNodes:
84 if project.nodeType == xml.dom.minidom.Element.nodeType:
85 if project.tagName == 'settings':
87 if project.attributes.length < 11:
88 self.error = "project attributes missing"
90 while i < project.attributes.length:
91 item = project.attributes.item(i)
92 key = item.name.encode("utf-8")
94 val = eval(item.nodeValue)
95 except (NameError, SyntaxError):
96 val = item.nodeValue.encode("utf-8")
98 self.settings.dict()[key].setValue(val)
100 self.error = "unknown attribute '%s'" % (key)
103 checkfiles = ["vmgm", "menubg", "menuaudio", "font_face"]
104 for key in checkfiles:
105 val = self.settings.dict()[key].getValue()
106 if not fileExists(val):
107 self.error += "\n%s '%s' not found" % (key, val)
110 except AttributeError:
111 self.error += (" in project '%s'") % (filename)