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