- add "getCurrent" to service listbox
[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         # never call this directly - it will be called from the session!
13         def doClose(self):
14                 GUISkin.close(self)
15         
16         def close(self, retval=None):
17                 self.session.close()
18         
19 class mainMenu(Screen):
20         
21         def goEmu(self):
22                 self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!")
23         
24         def goTimeshift(self):
25                 self["title"].setText("JUST PRESS THE YELLOW BUTTON!")
26         
27         def goHDTV(self):
28                 self["title"].setText("HDTV GREEN FLASHES: ENABLED")
29         
30         def goScan(self):
31                 self.session.open(serviceScan())
32         
33         def goClock(self):
34                 self.session.open(clockDisplay(Clock()))
35
36         def okbuttonClick(self):
37                 selection = self["menu"].getCurrent()
38                 selection[1]()
39
40         def __init__(self):
41                 GUISkin.__init__(self)
42                 b = Button("ok")
43
44                 b.onClick = [ self.okbuttonClick ]
45                 self["okbutton"] = b
46                 self["title"] = Header("Main Menu! - press ok to leave!")
47                 self["menu"] = MenuList(
48                         [
49                                 ("Close Main Menu", self.close),
50                                 ("Service Scan", self.goScan),
51                                 ("Quit", quitMainloop),
52                                 ("EMU SETUP", self.goEmu),
53                                 ("TIMESHIFT SETUP", self.goTimeshift),
54                                 ("HDTV PIP CONFIG", self.goHDTV),
55                                 ("wie spaet ists?!", self.goClock)
56                         ])
57
58 #class mainMenu(Screen):
59 #       def __init__(self):
60 #               GUISkin.__init__(self)
61 #               
62 #               self["title"] = Header("this is the\nMAIN MENU !!!");
63 #               self["okbutton"] = Button("ok")
64 #               self["okbutton"].onClick = [ self.close ]
65
66 class channelSelection(Screen):
67         def __init__(self):
68                 GUISkin.__init__(self)
69                 
70                 self["list"] = ServiceList()
71                 self["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:PREMIERE"))
72                 
73                 self["okbutton"] = Button("ok", [self.channelSelected, self.close])
74
75         def channelSelected(self):
76                 self.session.nav.playService(self["list"].getCurrent())
77                 pass
78
79 class infoBar(Screen):
80         def __init__(self):
81                 GUISkin.__init__(self)
82                 
83                 self["channelSwitcher"] = Button("switch Channel", [self.switchChannel])
84                 self["okbutton"] = Button("mainMenu", [self.mainMenu])
85         
86         def mainMenu(self):
87                 self.session.open(mainMenu())
88                 
89         def switchChannel(self):
90                 self.session.open(channelSelection())
91
92 # a clock display dialog
93 class clockDisplay(Screen):
94         def okbutton(self):
95                 self.session.close()
96         
97         def __init__(self, clock):
98                 GUISkin.__init__(self)
99                 self["theClock"] = clock
100                 b = Button("bye")
101                 b.onClick = [ self.okbutton ]
102                 self["okbutton"] = b
103                 self["title"] = Header("clock dialog: here you see the current uhrzeit!")
104
105
106 class serviceScan(Screen):
107         def ok(self):
108                 if self["scan"].isDone():
109                         self.close()
110         
111         def __init__(self):
112                 GUISkin.__init__(self)
113                 
114                 self["scan_progress"] = ProgressBar()
115                 self["scan_state"] = Label("scan state")
116                 self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
117
118                 self["okbutton"] = Button("ok", [self.ok])
119                 self["okbutton"].disable()