lots of improvements in the default wizard
[enigma2.git] / lib / python / Screens / DefaultWizard.py
1 from Wizard import wizardManager
2 from Screens.WizardLanguage import WizardLanguage
3 from Tools.Directories import crawlDirectory, resolveFilename, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTPARTITION
4
5 from Components.Pixmap import Pixmap, MovingPixmap
6 from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, getConfigListEntry
7 from Components.DreamInfoHandler import DreamInfoHandler, InfoHandler, InfoHandlerParseError
8 import os
9
10 config.misc.defaultchosen = ConfigBoolean(default = True)
11
12 import xml.sax
13
14 class DefaultWizard(WizardLanguage, DreamInfoHandler):
15         def __init__(self, session, silent = True):
16                 DreamInfoHandler.__init__(self, self.statusCallback)
17                 self.silent = silent
18                 os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
19                 self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
20                 self.xmlfile = "defaultwizard.xml"
21         
22                 WizardLanguage.__init__(self, session, showSteps = False)
23                 self["wizard"] = Pixmap()
24                 self["rc"] = MovingPixmap()
25                 self["arrowdown"] = MovingPixmap()
26                 self["arrowup"] = MovingPixmap()
27                 self["arrowup2"] = MovingPixmap()
28         
29         def markDone(self):
30                 config.misc.defaultchosen.value = 0
31                 config.misc.defaultchosen.save()
32                 configfile.save()
33                 
34         def statusCallback(self, status, progress):
35                 print "statusCallback:", status, progress
36                 if status == DreamInfoHandler.STATUS_DONE:
37                         self["text"].setText(_("The installation of the default settings is finished. You can now continue configuring your Dreambox by pressing the OK button on the remote control."))
38                         self.markDone()
39                         self.disableKeys = False
40
41         def getConfigList(self):
42                 self.packageslist = []
43                 configList = []
44                 self.fillPackagesList()
45                 self.packagesConfig = []
46                 for x in range(len(self.packageslist)):
47                         entry = ConfigYesNo()
48                         self.packagesConfig.append(entry)
49                         configList.append(getConfigListEntry(self.packageslist[x][0]["attributes"]["name"], entry))
50                 return configList
51
52         def selectionMade(self):
53                 print "selection made"
54                 #self.installPackage(int(index))
55                 indexList = []
56                 for x in range(len(self.packagesConfig)):
57                         if self.packagesConfig[x].value:
58                                 indexList.append(x)
59                 self.installPackages(indexList)
60                 
61 class ImageDefaultInstaller(DreamInfoHandler):
62         def __init__(self):
63                 DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
64                 self.directory = resolveFilename(SCOPE_DEFAULTDIR)
65                 self.fillPackagesList()
66                 self.installPackage(0)
67                 
68         def statusCallback(self, status, progress):
69                 pass
70                 
71 wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
72 if config.misc.defaultchosen.value:
73         print "Installing image defaults"
74         installer = ImageDefaultInstaller()
75         print "installing done!"