11 from skin import applyGUIskin
13 # A screen is a function which instanciates all components of a screen into a temporary component.
14 # Thus, the global stuff is a screen, too.
15 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
16 # "linked" from the instance tree.
17 # A screen itself lives as the container of the components, so a screen is a component, too.
19 # we thus have one (static) hierarchy of screens (classes, not instances)
20 # and one with the instanciated components itself (both global and dynamic)
24 def dump(dir, p = ""):
25 if isinstance(dir, dict):
26 for (entry, val) in dir.items():
27 dump(val, p + "(dict)/" + entry)
28 if hasattr(dir, "__dict__"):
29 for name, value in dir.__dict__.items():
30 if not had.has_key(str(value)):
32 dump(value, p + "/" + str(name))
34 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
36 print p + ":" + str(dir)
38 # + ":" + str(dir.__class__)
43 def create(self, screen): pass
47 class HTMLOutputDevice(OutputDevice):
48 def create(self, comp):
49 print comp.produceHTML()
51 html = HTMLOutputDevice()
53 class GUIOutputDevice(OutputDevice):
55 def create(self, comp):
56 comp.createGUIScreen(self.parent)
61 self.delayTimer = eTimer()
62 self.delayTimer.timeout.get().append(self.processDelay)
64 self.currentDialog = None
66 self.dialogStack = [ ]
68 def processDelay(self):
71 if self.currentDialog.isTmp:
72 self.currentDialog.doClose()
74 print sys.getrefcount(self.currentDialog)
75 del self.currentDialog.instance
76 dump(self.currentDialog)
77 del self.currentDialog
82 self.currentDialog.execBegin()
83 self.currentDialog.instance.show()
86 self.currentDialog.execEnd()
87 self.currentDialog.instance.hide()
89 def create(self, screen, arguments):
90 # creates an instance of 'screen' (which is a class)
91 return screen(self, *arguments)
93 def instantiateDialog(self, screen, *arguments):
94 dlg = self.create(screen, arguments)
95 assert self.desktop != None
96 dlg.instance = eWindow(self.desktop)
98 gui = GUIOutputDevice()
99 gui.parent = dlg.instance
102 applyGUIskin(dlg, None, dlg.skinName, self.desktop)
106 def pushCurrent(self):
107 if self.currentDialog:
108 self.dialogStack.append(self.currentDialog)
111 def popCurrent(self):
112 if len(self.dialogStack):
113 self.currentDialog = self.dialogStack.pop()
116 def execDialog(self, dialog):
118 self.currentDialog = dialog
119 self.currentDialog.isTmp = False
122 def open(self, screen, *arguments):
124 self.currentDialog = self.instantiateDialog(screen, *arguments)
125 self.currentDialog.isTmp = True
128 def keyEvent(self, code):
129 # print "code " + str(code)
131 self.currentDialog["okbutton"].instance.push()
134 self.currentDialog["channelSwitcher"].instance.push()
136 if code >= 0x30 and code <= 0x39:
138 self.currentDialog["menu"].instance.moveSelection(code - 0x31)
140 self.currentDialog["list"].instance.moveSelection(code - 0x31)
143 self.delayTimer.start(0, 1)
145 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
148 self.pnav = pNavigation()
149 self.pnav.m_event.get().append(self.callEvent)
151 self.currentlyPlayingService = None
153 self.RecordTimer = RecordTimer.RecordTimer()
155 def callEvent(self, i):
159 def playService(self, ref):
160 self.currentlyPlayingServiceReference = None
161 if not self.pnav.playService(ref):
162 self.currentlyPlayingServiceReference = ref
166 def getCurrentlyPlayingServiceReference(self):
167 return self.currentlyPlayingServiceReference
169 def recordService(self, ref):
170 service = iRecordableServicePtr()
171 print "recording service: %s" % (str(ref))
172 if self.pnav.recordService(ref, service):
173 print "record returned non-zero"
176 print "ok, recordService didn't fail"
179 def enqueueService(self, ref):
180 return self.pnav.enqueueService(ref)
182 def getCurrentService(self):
183 service = iPlayableServicePtr()
184 if self.pnav.getCurrentService(service):
188 def getPlaylist(self):
189 playlist = ePlaylistPtr()
190 if self.pnav.getPlaylist(playlist):
195 return self.pnav.pause(p)
197 def recordWithTimer(self, begin, end, ref, epg):
198 entry = RecordTimer.RecordTimerEntry(begin, end, self, ref, epg)
199 self.RecordTimer.record(entry)
204 session.desktop = getDesktop()
206 session.nav = Navigation()
208 session.open(Screens.InfoBar.InfoBar)
210 CONNECT(keyPressedSignal(), session.keyEvent)
217 keymapparser.readKeymap()
221 # first, setup a screen
224 # now, run the mainloop
226 #pt = eDebugClassPtr()
227 #eDebugClass.getDebug(pt, 12)
231 #print "removing ptr..."
234 #print "p is " + str(p)
239 #bla = eDebugClass(2)