fill configlist with correct entries
[enigma2.git] / lib / python / Screens / InfoBar.py
1 from Screen import Screen
2 from ChannelSelection import ChannelSelection
3 from Components.Clock import Clock
4 from Components.VolumeBar import VolumeBar
5 from Components.ActionMap import ActionMap
6 from Components.Button import Button
7 from Components.ServiceName import ServiceName
8 from Components.EventInfo import EventInfo
9
10 from Screens.MessageBox import MessageBox
11 from Screens.MovieSelection import MovieSelection
12
13 from enigma import *
14
15 import time
16
17 # hack alert!
18 from Menu import MainMenu, mdom
19
20 class InfoBar(Screen):
21         def __init__(self, session):
22                 Screen.__init__(self, session)
23
24                 #instantiate forever
25                 self.servicelist = self.session.instantiateDialog(ChannelSelection)
26                 self.volumeBar = VolumeBar()            
27
28                 self["actions"] = ActionMap( [ "InfobarActions" ], 
29                         {
30                                 "switchChannelUp": self.switchChannelUp,
31                                 "switchChannelDown": self.switchChannelDown,
32                                 "mainMenu": self.mainMenu,
33                                 "zapUp": self.zapUp,
34                                 "zapDown": self.zapDown,
35                                 "volumeUp": self.volUp,
36                                 "volumeDown": self.volDown,
37                                 "volumeMute": self.volMute,
38                                 "instantRecord": self.instantRecord,
39                                 "hide": self.hide,
40                                 "toggleShow": self.toggleShow,
41                                 "showMovies": self.showMovies,
42                                 "quit": self.quit
43                         })
44 #               self["okbutton"] = Button("mainMenu", [self.mainMenu])
45                 
46                 self["CurrentTime"] = Clock()
47
48                 self["Volume"] = self.volumeBar
49                 
50                 self["ServiceName"] = ServiceName(self.session.nav)
51                 
52                 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
53                 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
54
55                 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
56                 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
57                 
58                 self.recording = None
59         
60         def mainMenu(self):
61                 print "loading mainmenu XML..."
62                 menu = mdom.childNodes[0]
63                 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
64                 self.session.open(MainMenu, menu, menu.childNodes)
65
66         def switchChannelUp(self):      
67                 self.servicelist.moveUp()
68                 self.session.execDialog(self.servicelist)
69
70         def switchChannelDown(self):    
71                 self.servicelist.moveDown()
72                 self.session.execDialog(self.servicelist)
73
74         def hide(self): 
75                 self.instance.hide()
76
77         def toggleShow(self):
78                 if self.instance.isVisible():
79                         self.instance.hide()
80                 else:
81                         self.instance.show()
82
83         def     zapUp(self):
84                 self.servicelist.moveUp()
85                 self.servicelist.zap()
86
87         def     zapDown(self):
88                 self.servicelist.moveDown()
89                 self.servicelist.zap()
90
91         def     volUp(self):
92                 eDVBVolumecontrol.getInstance().volumeUp()
93                 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
94
95         def     volDown(self):
96                 eDVBVolumecontrol.getInstance().volumeDown()
97                 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
98
99         def     volMute(self):
100                 eDVBVolumecontrol.getInstance().volumeToggleMute()
101                 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
102
103         def     quit(self):
104                 quitMainloop()
105                 
106         def instantRecord(self):
107                 self.session.open(MessageBox, "this would be an instant recording! do you really know what you're doing?!")
108                 return
109         
110                 if self.recording != None:
111                         print "remove entry"
112                         self.session.nav.RecordTimer.removeEntry(self.recording)
113                         self.recording = None
114                 else:
115                         serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
116                         
117                         # try to get event info
118                         epg = None
119                         service = self.session.nav.getCurrentService()
120                         if service != None:
121                                 info = iServiceInformationPtr()
122                                 if not service.info(info):
123                                         ev = eServiceEventPtr()
124                                         if info.getEvent(ev, 0) == 0:
125                                                 epg = ev
126                         # fix me, description. 
127                         self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg, "instant record")
128         
129         def showMovies(self):
130                 self.session.open(MovieSelection)
131