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