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