4.2.5r2
[enigma2.git] / usr / lib / enigma2 / python / Screens / StartWizard.py
1 from Wizard import wizardManager
2 from Screens.WizardLanguage import WizardLanguage
3 from Screens.ScanSetup import DefaultSatLists
4 from Screens.DefaultWizard import DefaultWizard
5 from Screens.Rc import Rc
6 from Screens.LanguageSelection import LanguageSelection, _cached
7
8 from Components.config import config, ConfigBoolean, configfile, ConfigSubsection
9 from Components.Label import Label
10 from Components.NimManager import nimmanager
11 from Components.Pixmap import Pixmap
12 from Components.ResourceManager import resourcemanager
13 from Components.Sources.Boolean import Boolean
14
15 config.misc.firstrun = ConfigBoolean(default = True)
16 config.misc.startwizard = ConfigSubsection()
17 config.misc.startwizard.shownimconfig = ConfigBoolean(default = True)
18 config.misc.startwizard.doservicescan = ConfigBoolean(default = True)
19 config.misc.languageselected = ConfigBoolean(default = True)
20
21 emptyWizardList = []
22
23 # empty classes if the plugins are not present for not being forced to use dynamic inheritance
24 # we need a generator function here since multiple inheritance of the same class is not allowed in python
25 def makeEmptyWizard():
26         global emptyWizardList
27         class EmptyWizard(object):
28                 pass
29         emptyWizardList.append(EmptyWizard)
30         return EmptyWizard
31
32 NetworkWizardNew = resourcemanager.getResource("NetworkWizard.NetworkWizardNew", makeEmptyWizard())
33 VideoWizard = resourcemanager.getResource("videomode.videowizard", makeEmptyWizard())
34
35 class StartWizard(NetworkWizardNew, VideoWizard, DefaultSatLists, LanguageSelection, Rc):
36         def __init__(self, session, silent = True, showSteps = False, neededTag = None):
37                 self.xmlfile = ["startwizard.xml", "defaultsatlists.xml"]
38                 DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services", default = True)
39                 WizardLanguage.__init__(self, session, showSteps = False, showMulticontentList = True)
40                 Rc.__init__(self)
41
42                 self["wizard"] = Pixmap()
43
44                 # needed for LanguageSelection
45                 self.png_cache = { }
46
47                 self["button_green"] = Boolean(False)
48                 self["button_green_text"] = Label()
49                 self["button_green_text"].hide()
50                 self["button_yellow"] = Boolean(False)
51                 self["button_yellow_text"] = Label()
52                 self["button_yellow_text"].hide()
53                 self["button_blue"] = Boolean(False)
54                 self["button_blue_text"] = Label()
55                 self["button_blue_text"].hide()
56
57                 self["state_label"] = Label()
58                 self["state"] = Label()
59                 self.showState(False)
60
61                 NetworkWizardNew.__init__(self)
62                 self.networkWizardAvailable = NetworkWizardNew not in emptyWizardList
63
64                 self["portpic"] = Pixmap()
65                 VideoWizard.__init__(self)
66                 self.videoWizardAvailable = VideoWizard not in emptyWizardList
67
68         def _buildListEntry(self, *args, **kwargs):
69                 return (args[1], args[0])
70
71         def markDone(self):
72                 config.misc.firstrun.value = 0
73                 config.misc.firstrun.save()
74                 configfile.save()
75
76         def setLanguageList(self):
77                 LanguageSelection.updateList(self, listname = "multicontentlist")
78                 self["multicontentlist"].updateList(self.multicontentlist)
79                 LanguageSelection.selectActiveLanguage(self, listname = "multicontentlist")
80
81         def onLanguageSelect(self):
82                 LanguageSelection.updateList(self, listname = "multicontentlist")
83                 self.setTitle(_cached("T2", self["multicontentlist"].getCurrent()[0]))
84                 self["text"].setText(_cached("T1", self["multicontentlist"].getCurrent()[0]))
85
86         def languageSave(self, lang):
87                 LanguageSelection.setOSDLanguage(self, "multicontentlist")
88                 WizardLanguage.updateLanguageDescription(self)
89                 self.updateTexts()
90
91         def setTunerText(self, step):
92                 index = {"nima": 0, "nimb": 1, "nimc": 2, "nimd": 3}.get(step, None)
93                 text = ""
94                 if index == 0:
95                         text += _("Use the left and right buttons to change an option.") + "\n\n"
96                 text += _("Please set up tuner %s") % nimmanager.getNimSlotInputName(index)
97                 
98                 return text
99
100         def showHideButtons(self, green = False, yellow = False, blue = False):
101                 if green:
102                         self["button_green"].boolean = True
103                         self["button_green_text"].show()
104                 else:
105                         self["button_green"].boolean = False
106                         self["button_green_text"].hide()
107
108                 if yellow:
109                         self["button_yellow"].boolean = True
110                         self["button_yellow_text"].show()
111                 else:
112                         self["button_yellow"].boolean = False
113                         self["button_yellow_text"].hide()
114
115                 if blue:
116                         self["button_blue"].boolean = True
117                         self["button_blue_text"].show()
118                 else:
119                         self["button_blue"].boolean = False
120                         self["button_blue_text"].hide()
121
122         def showState(self, show = False):
123                 if show:
124                         self["state"].show()
125                         self["state_label"].show()
126                 else:
127                         self["state"].hide()
128                         self["state_label"].hide()
129
130 wizardManager.registerWizard(StartWizard, config.misc.firstrun.value, priority = 20)