1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ActionMap import NumberActionMap
4 from Components.Label import Label
5 from Components.config import configfile
6 from ChannelSelection import ChannelSelection
8 from Components.ServiceName import ServiceName
9 from Components.EventInfo import EventInfo
11 from EpgSelection import EPGSelection
13 from Screens.MessageBox import MessageBox
14 from Screens.Volume import Volume
15 from Screens.Mute import Mute
16 from Screens.Standby import Standby
18 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
24 from Menu import MainMenu, mdom
26 class InfoBarVolumeControl:
27 """Volume control, handles volUp, volDown, volMute actions and display
28 a corresponding dialog"""
31 self["VolumeActions"] = ActionMap( ["InfobarVolumeActions"] ,
33 "volumeUp": self.volUp,
34 "volumeDown": self.volDown,
35 "volumeMute": self.volMute,
38 self.volumeDialog = self.session.instantiateDialog(Volume)
39 self.muteDialog = self.session.instantiateDialog(Mute)
41 self.hideVolTimer = eTimer()
42 self.hideVolTimer.timeout.get().append(self.volHide)
45 eDVBVolumecontrol.getInstance().volumeUp()
46 self.volumeDialog.instance.show()
47 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
48 self.hideVolTimer.start(3000)
51 eDVBVolumecontrol.getInstance().volumeDown()
52 self.volumeDialog.instance.show()
53 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
54 self.hideVolTimer.start(3000)
57 self.volumeDialog.instance.hide()
60 eDVBVolumecontrol.getInstance().volumeToggleMute()
61 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
63 if (eDVBVolumecontrol.getInstance().isMuted()):
64 self.muteDialog.instance.show()
66 self.muteDialog.instance.hide()
68 class InfoBarShowHide:
69 """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
77 self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
79 "toggleShow": self.toggleShow,
83 self.state = self.STATE_HIDDEN
85 self.hideTimer = eTimer()
86 self.hideTimer.timeout.get().append(self.doTimerHide)
87 #self.hideTimer.start(1000)
92 def doTimerHide(self):
93 if self.state == self.STATE_SHOWN:
95 self.state = self.STATE_HIDDEN
98 if self.state == self.STATE_SHOWN:
100 #pls check animation support, sorry
102 self.state = self.STATE_HIDDEN
106 self.state = self.STATE_SHOWN
107 #TODO: make it customizable
108 self.hideTimer.start(5000)
111 self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
112 self.state = self.STATE_SHOWN
115 self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
116 self.state = self.STATE_HIDDEN
118 class NumberZap(Screen):
125 print "do the action here"
128 def keyNumberGlobal(self, number):
129 self.Timer.start(3000) #reset timer
130 self.field = self.field + str(number)
131 self["number"].setText(self.field)
132 if len(self.field) >= 4:
135 def __init__(self, session, number):
136 Screen.__init__(self, session)
137 self.field = str(number)
139 self["number"] = Label(self.field)
141 self["actions"] = NumberActionMap( [ "SetupActions" ],
145 "1": self.keyNumberGlobal,
146 "2": self.keyNumberGlobal,
147 "3": self.keyNumberGlobal,
148 "4": self.keyNumberGlobal,
149 "5": self.keyNumberGlobal,
150 "6": self.keyNumberGlobal,
151 "7": self.keyNumberGlobal,
152 "8": self.keyNumberGlobal,
153 "9": self.keyNumberGlobal,
154 "0": self.keyNumberGlobal
157 self.Timer = eTimer()
158 self.Timer.timeout.get().append(self.keyOK)
159 self.Timer.start(3000)
161 class InfoBarPowerKey:
162 """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
165 self.powerKeyTimer = eTimer()
166 self.powerKeyTimer.timeout.get().append(self.powertimer)
167 self["PowerKeyActions"] = ActionMap( ["PowerKeyActions"],
169 "powerdown": self.powerdown,
170 "powerup": self.powerup,
173 def powertimer(self):
174 print "PowerOff - Now!"
178 self.standbyblocked = 0
179 self.powerKeyTimer.start(3000)
182 self.powerKeyTimer.stop()
183 if self.standbyblocked == 0:
184 self.standbyblocked = 1
185 self.session.open(Standby, self)
188 # self.session.open(Standby, self)
189 ref = self.session.nav.getCurrentlyPlayingServiceReference()
191 refstr = ref.toString()
199 class InfoBarNumberZap:
200 """ Handles an initial number for NumberZapping """
202 self["NumberZapActions"] = NumberActionMap( [ "NumberZapActions"],
204 "1": self.keyNumberGlobal,
205 "2": self.keyNumberGlobal,
206 "3": self.keyNumberGlobal,
207 "4": self.keyNumberGlobal,
208 "5": self.keyNumberGlobal,
209 "6": self.keyNumberGlobal,
210 "7": self.keyNumberGlobal,
211 "8": self.keyNumberGlobal,
212 "9": self.keyNumberGlobal,
213 "0": self.keyNumberGlobal,
216 def keyNumberGlobal(self, number):
217 print "You pressed number " + str(number)
218 self.session.open(NumberZap, number)
220 class InfoBarChannelSelection:
221 """ ChannelSelection - handles the channelSelection dialog and the initial
222 channelChange actions which open the channelSelection dialog """
225 self.servicelist = self.session.instantiateDialog(ChannelSelection)
227 self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
229 "switchChannelUp": self.switchChannelUp,
230 "switchChannelDown": self.switchChannelDown,
232 "zapDown": self.zapDown,
235 def switchChannelUp(self):
236 self.servicelist.moveUp()
237 self.session.execDialog(self.servicelist)
239 def switchChannelDown(self):
240 self.servicelist.moveDown()
241 self.session.execDialog(self.servicelist)
244 self.servicelist.moveUp()
245 self.servicelist.zap()
248 self.servicelist.moveDown()
249 self.servicelist.zap()
252 """ Handles a menu action, to open the (main) menu """
254 self["MenuActions"] = ActionMap( [ "InfobarMenuActions" ],
256 "mainMenu": self.mainMenu,
260 print "loading mainmenu XML..."
261 menu = mdom.childNodes[0]
262 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
263 self.session.open(MainMenu, menu, menu.childNodes)
266 """ EPG - Opens an EPG list when the showEPGList action fires """
268 self["EPGActions"] = ActionMap( [ "InfobarEPGActions" ],
270 "showEPGList": self.showEPGList,
273 def showEPGList(self):
274 ref=self.session.nav.getCurrentlyPlayingServiceReference()
275 ptr=eEPGCache.getInstance()
276 if ptr.startTimeQuery(ref) != -1:
277 self.session.open(EPGSelection, ref)
279 print 'no epg for service', ref.toString()
282 """provides a current/next event info display"""
284 self["Event_Now_StartTime"] = EventInfo(self.session.nav, EventInfo.Now_StartTime)
285 self["Event_Next_StartTime"] = EventInfo(self.session.nav, EventInfo.Next_StartTime)
287 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
288 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
290 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
291 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
293 class InfoBarServiceName:
295 self["ServiceName"] = ServiceName(self.session.nav)
298 """handles PVR specific actions like seeking, pause"""
300 self["PVRActions"] = ActionMap( [ "InfobarPVRActions" ],
302 "pauseService": self.pauseService,
303 "unPauseService": self.unPauseService,
305 "seekFwd": self.seekFwd,
306 "seekBack": self.seekBack,
309 def pauseService(self):
310 self.session.nav.pause(1)
312 def unPauseService(self):
313 self.session.nav.pause(0)
315 def doSeek(self, dir, seektime):
316 service = self.session.nav.getCurrentService()
320 seekable = service.seek()
323 seekable.seekRelative(dir, 90 * seektime)
326 self.doSeek(+1, 60000)
329 self.doSeek(-1, 60000)
331 class InfoBarInstantRecord:
332 """Instant Record - handles the instantRecord action in order to
333 start/stop instant records"""
335 self["InstnantRecordActions"] = ActionMap( [ "InfobarInstantRecord" ],
337 "instantRecord": self.instantRecord,
339 self.recording = None
341 def stopCurrentRecording(self):
342 self.session.nav.RecordTimer.removeEntry(self.recording)
343 self.recording = None
345 def startInstantRecording(self):
346 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
348 # try to get event info
351 service = self.session.nav.getCurrentService()
352 info = service.info()
353 ev = info.getEvent(0)
358 # fix me, description.
359 self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
361 def recordQuestionCallback(self, answer):
365 if self.recording != None:
366 self.stopCurrentRecording()
368 self.startInstantRecording()
370 def instantRecord(self):
371 if self.recording != None:
372 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Do you want to stop the current\n(instant) recording?")
374 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Start recording?")
376 from Screens.AudioSelection import AudioSelection
378 class InfoBarAudioSelection:
380 self["AudioSelectionAction"] = ActionMap( [ "InfobarAudioSelectionActions" ],
382 "audioSelection": self.audioSelection,
385 def audioSelection(self):
386 service = self.session.nav.getCurrentService()
387 audio = service.audioTracks()
388 n = audio.getNumberOfTracks()
390 self.session.open(AudioSelection, audio)