1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
from Screens.Screen import Screen
from Plugins.Plugin import PluginDescriptor
from enigma import eTimer
from Components.ActionMap import ActionMap
from Components.Label import Label
from Components.Pixmap import Pixmap
from Screens.MessageBox import MessageBox
from Screens.Setup import SetupSummary
from Components.ConfigList import ConfigListScreen
from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict
from VideoWizard import VideoWizard
from Components.config import config
from Tools.CList import CList
from VideoHardware import video_hw
class VideoSetup(Screen, ConfigListScreen):
def __init__(self, session, hw):
Screen.__init__(self, session)
self.skinName = "Setup"
self.setup_title = "Videomode Setup"
self.hw = hw
self.onChangedEntry = [ ]
# handle hotplug by re-creating setup
self.onShow.append(self.startHotplug)
self.onHide.append(self.stopHotplug)
self.list = [ ]
ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
self["actions"] = ActionMap(["SetupActions"],
{
"cancel": self.keyCancel,
"save": self.apply,
}, -2)
self["title"] = Label(_("Video-Setup"))
self["oktext"] = Label(_("OK"))
self["canceltext"] = Label(_("Cancel"))
self["ok"] = Pixmap()
self["cancel"] = Pixmap()
self.createSetup()
self.grabLastGoodMode()
def startHotplug(self):
self.hw.on_hotplug.append(self.createSetup)
def stopHotplug(self):
self.hw.on_hotplug.remove(self.createSetup)
def createSetup(self):
self.list = [ ]
self.list.append(getConfigListEntry(_("Output Type"), config.av.videoport))
# if we have modes for this port:
if config.av.videoport.value in config.av.videomode:
# add mode- and rate-selection:
self.list.append(getConfigListEntry(_("Mode"), config.av.videomode[config.av.videoport.value]))
self.list.append(getConfigListEntry(_("Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
self["config"].list = self.list
self["config"].l.setList(self.list)
def keyLeft(self):
ConfigListScreen.keyLeft(self)
self.createSetup()
def keyRight(self):
ConfigListScreen.keyRight(self)
self.createSetup()
def confirm(self, confirmed):
if not confirmed:
self.hw.setMode(*self.last_good)
else:
self.keySave()
def grabLastGoodMode(self):
port = config.av.videoport.value
mode = config.av.videomode[port].value
rate = config.av.videorate[mode].value
self.last_good = (port, mode, rate)
def apply(self):
port = config.av.videoport.value
mode = config.av.videomode[port].value
rate = config.av.videorate[mode].value
if (port, mode, rate) != self.last_good or True:
self.hw.setMode(port, mode, rate)
self.session.openWithCallback(self.confirm, MessageBox, "Is this videomode ok?", MessageBox.TYPE_YESNO, timeout = 5, default = False)
else:
self.keySave()
# for summary:
def changedEntry(self):
for x in self.onChangedEntry:
x()
def getCurrentEntry(self):
return self["config"].getCurrent()[0]
def getCurrentValue(self):
return str(self["config"].getCurrent()[1].getText())
def createSummary(self):
return SetupSummary
#class VideomodeHotplug:
# def __init__(self, hw):
# self.hw = hw
# self.hw.on_hotplug.append(self.hotplug)
#
# def hotplug(self, what):
# print "hotplug detected on port '%s'" % (what)
# ...
#
#hotplug = None
#
#def startHotplug(self):
# global hotplug
# hotplug = VideomodeHotplug()
# hotplug.start()
#
#def stopHotplug(self):
# global hotplug
# hotplug.stop()
#
#
#def autostart(reason, session = None, **kwargs):
# if session is not None:
# global my_global_session
# my_global_session = session
# return
#
# if reason == 0:
# startHotplug()
# elif reason == 1:
# stopHotplug()
def videoSetupMain(session, **kwargs):
session.open(VideoSetup, video_hw)
def startSetup(menuid):
if menuid != "system":
return [ ]
return [(_("Video Setup"), videoSetupMain, "video_setup", None)]
def Plugins(**kwargs):
list = []
list.append(PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))
if config.misc.firstrun.value:
list.append(PluginDescriptor(name=_("Video Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=VideoWizard))
return list
|