config entries must be defined globally
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / Videomode / VideoWizard.py
1 from Screens.Wizard import Wizard, wizardManager
2 import sys
3 from VideoHardware import video_hw
4
5 from Components.Pixmap import Pixmap, MovingPixmap
6 from Components.config import config, ConfigBoolean, configfile
7
8 config.misc.showtestcard = ConfigBoolean(default = False)
9
10 class VideoWizard(Wizard):
11         skin = """
12                 <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
13                         <widget name="text" position="153,50" size="340,270" font="Regular;23" />
14                         <widget source="list" render="Listbox" position="50,300" size="440,200" scrollbarMode="showOnDemand" >
15                                 <convert type="StringList" />
16                         </widget>
17                         <widget name="config" position="50,300" zPosition="1" size="440,200" transparent="1" scrollbarMode="showOnDemand" />                    
18                         <widget name="stepslider" position="50,500" zPosition="1" borderWidth="2" size="440,20" backgroundColor="dark" />
19                         <widget name="wizard" pixmap="wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
20                         <widget name="rc" pixmap="rc.png" position="500,600" zPosition="10" size="154,475" transparent="1" alphatest="on"/>
21                         <widget name="arrowdown" pixmap="arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
22                         <widget name="arrowup" pixmap="arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
23                         <widget name="arrowup2" pixmap="arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
24                 </screen>"""
25         
26         def __init__(self, session):
27                 # FIXME anyone knows how to use relative paths from the plugin's directory?
28                 self.xmlfile = sys.path[0] + "/Plugins/SystemPlugins/Videomode/videowizard.xml"
29                 self.hw = video_hw
30                 
31                 Wizard.__init__(self, session, showSteps = False)
32                 self["wizard"] = Pixmap()
33                 self["rc"] = MovingPixmap()
34                 self["arrowdown"] = MovingPixmap()
35                 self["arrowup"] = MovingPixmap()
36                 self["arrowup2"] = MovingPixmap()
37                 
38                 self.port = None
39                 self.mode = None
40                 
41                 
42         def createSummary(self):
43                 print "++++++++++++***++**** VideoWizard-createSummary"
44                 from Screens.Wizard import WizardSummary
45                 return WizardSummary
46                 
47         def markDone(self):
48                 pass
49         
50         def listInputChannels(self):
51                 list = []
52
53                 for port in self.hw.getPortList():
54                         if self.hw.isPortUsed(port):
55                                 list.append((port, port))
56                 return list
57
58         def inputSelectionMade(self, index):
59                 print "inputSelectionMade:", index
60                 self.port = index
61                 self.inputSelect(index)
62                 
63         def inputSelectionMoved(self):
64                 print "input selection moved:", self.selection
65                 self.inputSelect(self.selection)
66                 
67         def inputSelect(self, port):
68                 print "inputSelect:", port
69                 modeList = self.hw.getModeList(self.selection)
70                 print "modeList:", modeList
71                 self.hw.setMode(port = port, mode = modeList[0][0], rate = modeList[0][1][0])
72                 
73         def listModes(self):
74                 list = []
75                 print "modes for port", self.port
76                 for mode in self.hw.getModeList(self.port):
77                         if mode[0] != "PC":
78                                 list.append((mode[0], mode[0]))
79                 return list
80         
81         def modeSelectionMade(self, index):
82                 print "modeSelectionMade:", index
83                 self.mode = index
84                 self.modeSelect(index)
85                 
86         def modeSelectionMoved(self):
87                 print "mode selection moved:", self.selection
88                 self.modeSelect(self.selection)
89                 
90         def modeSelect(self, mode):
91                 ratesList = self.listRates(mode)
92                 print "ratesList:", ratesList
93                 self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0])
94                 
95         def listRates(self, querymode = None):
96                 if querymode is None:
97                         querymode = self.mode
98                 list = []
99                 print "modes for port", self.port, "and mode", querymode
100                 for mode in self.hw.getModeList(self.port):
101                         print mode
102                         if mode[0] == querymode:
103                                 for rate in mode[1]:
104                                         list.append((rate, rate))
105                 return list
106         
107         def rateSelectionMade(self, index):
108                 print "rateSelectionMade:", index
109                 self.rateSelect(index)
110                 
111         def rateSelectionMoved(self):
112                 print "rate selection moved:", self.selection
113                 self.rateSelect(self.selection)
114
115         def rateSelect(self, rate):
116                 self.hw.setMode(port = self.port, mode = self.mode, rate = rate)
117
118         def showTestCard(self, selection = None):
119                 if selection is None:
120                         selection = self.selection
121                 print "set config.misc.showtestcard to", {'yes': True, 'no': False}[selection]
122                 if selection == "yes":
123                         config.misc.showtestcard.value = True
124                 else:
125                         config.misc.showtestcard.value = False