- fix serious problems in widget code. fixup buffered mode. add animation support...
[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         STATE_HIDDEN = 0
23         STATE_HIDING = 1
24         STATE_SHOWING = 2
25         STATE_SHOWN = 3
26         
27         def __init__(self, session):
28                 Screen.__init__(self, session)
29
30                 #instantiate forever
31                 self.servicelist = self.session.instantiateDialog(ChannelSelection)
32                 self.volumeBar = VolumeBar()            
33
34                 self["actions"] = ActionMap( [ "InfobarActions" ], 
35                         {
36                                 "switchChannelUp": self.switchChannelUp,
37                                 "switchChannelDown": self.switchChannelDown,
38                                 "mainMenu": self.mainMenu,
39                                 "zapUp": self.zapUp,
40                                 "zapDown": self.zapDown,
41                                 "volumeUp": self.volUp,
42                                 "volumeDown": self.volDown,
43                                 "volumeMute": self.volMute,
44                                 "instantRecord": self.instantRecord,
45                                 "hide": self.hide,
46                                 "toggleShow": self.toggleShow,
47                                 "showMovies": self.showMovies,
48                                 "quit": self.quit
49                         })
50 #               self["okbutton"] = Button("mainMenu", [self.mainMenu])
51                 
52                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
53                 # Clock()
54
55                 self["Volume"] = self.volumeBar
56                 
57                 self["ServiceName"] = ServiceName(self.session.nav)
58                 
59                 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
60                 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
61
62                 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
63                 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
64                 
65                 self.recording = None
66                 
67                 self.pos = 0
68         
69         def mainMenu(self):
70                 print "loading mainmenu XML..."
71                 menu = mdom.childNodes[0]
72                 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
73                 self.session.open(MainMenu, menu, menu.childNodes)
74
75         def switchChannelUp(self):      
76                 self.servicelist.moveUp()
77                 self.session.execDialog(self.servicelist)
78
79         def switchChannelDown(self):    
80                 self.servicelist.moveDown()
81                 self.session.execDialog(self.servicelist)
82
83         def hide(self): 
84                 self.instance.hide()
85
86         def toggleShow(self):
87                 if self.instance.isVisible():
88 #                       self.instance.hide()
89                         self.startHide()
90                 else:
91 #                       self.instance.show()
92                         self.startShow()
93
94         def     zapUp(self):
95                 self.servicelist.moveUp()
96                 self.servicelist.zap()
97
98         def     zapDown(self):
99                 self.servicelist.moveDown()
100                 self.servicelist.zap()
101
102         def     volUp(self):
103                 eDVBVolumecontrol.getInstance().volumeUp()
104                 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
105
106         def     volDown(self):
107                 eDVBVolumecontrol.getInstance().volumeDown()
108                 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
109                 
110         def startShow(self):
111                 self.instance.m_animation.startMoveAnimation(ePoint(0, 500), ePoint(0, 380), 100)
112         
113         def startHide(self):
114                 self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 500), 100)
115
116         def     volMute(self):
117                 eDVBVolumecontrol.getInstance().volumeToggleMute()
118                 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
119
120         def     quit(self):
121                 quitMainloop()
122                 
123         def instantRecord(self):
124                 #self.session.open(MessageBox, "this would be an instant recording! do you really know what you're doing?!")
125                 #return
126         
127                 if self.recording != None:
128                         print "remove entry"
129                         self.session.nav.RecordTimer.removeEntry(self.recording)
130                         self.recording = None
131                 else:
132                         serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
133                         
134                         # try to get event info
135                         epg = None
136                         service = self.session.nav.getCurrentService()
137                         if service != None:
138                                 info = iServiceInformationPtr()
139                                 if not service.info(info):
140                                         ev = eServiceEventPtr()
141                                         if info.getEvent(ev, 0) == 0:
142                                                 epg = ev
143                         # fix me, description. 
144                         self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg, "instant record")
145         
146         def showMovies(self):
147                 self.session.open(MovieSelection)
148