- work on actions
[enigma2.git] / screens.py
1 from components import *
2 import sys
3 from enigma import quitMainloop
4
5 # some screens
6 def doGlobal(screen):
7         screen["clock"] = Clock()
8
9 class Screen(dict, HTMLSkin, GUISkin):
10         """ bla """
11
12         def __init__(self, session):
13                 self.skinName = self.__class__.__name__
14                 self.session = session
15                 GUISkin.__init__(self)
16                 
17         def execBegin(self):
18                 for (name, val) in self.items():
19                         val.execBegin()
20         
21         def execEnd(self):
22                 for (name, val) in self.items():
23                         val.execEnd()
24         
25         # never call this directly - it will be called from the session!
26         def doClose(self):
27                 GUISkin.close(self)
28         
29         def close(self, retval=None):
30                 self.session.close()
31
32 class mainMenu(Screen):
33         
34         def goEmu(self):
35                 self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!")
36         
37         def goTimeshift(self):
38                 self["title"].setText("JUST PRESS THE YELLOW BUTTON!")
39         
40         def goHDTV(self):
41                 self["title"].setText("HDTV GREEN FLASHES: ENABLED")
42         
43         def goScan(self):
44                 self.session.open(serviceScan)
45         
46         def goClock(self):
47                 self.session.open(clockDisplay, Clock())
48
49         def okbuttonClick(self):
50                 selection = self["menu"].getCurrent()
51                 selection[1]()
52         
53         def __init__(self, session):
54                 Screen.__init__(self, session)
55                 b = Button("ok")
56
57                 self["actions"] = ActionMap("MainMenuActions", 
58                         {
59                                 "selected": self.okbuttonClick
60                         })
61
62                 b.onClick = [ self.okbuttonClick ]
63                 self["okbutton"] = b
64                 self["title"] = Header("Main Menu! - press ok to leave!")
65                 self["menu"] = MenuList(
66                         [
67                                 ("Close Main Menu", self.close),
68                                 ("Service Scan", self.goScan),
69                                 ("Quit", quitMainloop),
70                                 ("EMU SETUP", self.goEmu),
71                                 ("TIMESHIFT SETUP", self.goTimeshift),
72                                 ("HDTV PIP CONFIG", self.goHDTV),
73                                 ("wie spaet ists?!", self.goClock)
74                         ])
75
76 #class mainMenu(Screen):
77 #       def __init__(self):
78 #               GUISkin.__init__(self)
79 #               
80 #               self["title"] = Header("this is the\nMAIN MENU !!!");
81 #               self["okbutton"] = Button("ok")
82 #               self["okbutton"].onClick = [ self.close ]
83
84 class channelSelection(Screen):
85         def __init__(self, session):
86                 Screen.__init__(self, session)
87                 
88                 self["list"] = ServiceList()
89                 self["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:PREMIERE"))
90                 
91                 self["okbutton"] = Button("ok", [self.channelSelected])
92
93                 self["actions"] = ActionMap("ChannelSelectActions", 
94                         {
95                                 "selectChannel": self.channelSelected,
96                         })
97
98         def channelSelected(self):
99                 self.session.nav.playService(self["list"].getCurrent())
100                 self.close()
101                 pass
102
103 class infoBar(Screen):
104         def __init__(self, session):
105                 Screen.__init__(self, session)
106                 
107                 self["actions"] = ActionMap("InfobarActions", 
108                         {
109                                 "switchChannel": self.switchChannel,
110                                 "mainMenu": self.mainMenu
111                         })
112                 self["channelSwitcher"] = Button("switch Channel", [self.switchChannel])
113                 self["okbutton"] = Button("mainMenu", [self.mainMenu])
114                 
115                 self["ServiceName"] = ServiceName(self.session.nav)
116                 
117                 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
118                 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
119         
120         def mainMenu(self):
121                 self.session.open(mainMenu)
122                 
123         def switchChannel(self):
124                 self.session.open(channelSelection)
125
126 # a clock display dialog
127 class clockDisplay(Screen):
128         def okbutton(self):
129                 self.session.close()
130         
131         def __init__(self, session, clock):
132                 Screen.__init__(self, session)
133                 self["theClock"] = clock
134                 b = Button("bye")
135                 b.onClick = [ self.okbutton ]
136                 self["okbutton"] = b
137                 self["title"] = Header("clock dialog: here you see the current uhrzeit!")
138
139
140 class serviceScan(Screen):
141         def ok(self):
142                 if self["scan"].isDone():
143                         self.close()
144         
145         def __init__(self, session):
146                 Screen.__init__(self, session)
147                 
148                 self["scan_progress"] = ProgressBar()
149                 self["scan_state"] = Label("scan state")
150                 self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
151
152                 self["okbutton"] = Button("ok", [self.ok])
153                 self["okbutton"].disable()