10 from skin import applyGUIskin
12 # A screen is a function which instanciates all components of a screen into a temporary component.
13 # Thus, the global stuff is a screen, too.
14 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
15 # "linked" from the instance tree.
16 # A screen itself lives as the container of the components, so a screen is a component, too.
18 # we thus have one (static) hierarchy of screens (classes, not instances)
19 # and one with the instanciated components itself (both global and dynamic)
23 def dump(dir, p = ""):
24 if isinstance(dir, dict):
25 for (entry, val) in dir.items():
26 dump(val, p + "(dict)/" + entry)
27 if hasattr(dir, "__dict__"):
28 for name, value in dir.__dict__.items():
29 if not had.has_key(str(value)):
31 dump(value, p + "/" + str(name))
33 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
35 print p + ":" + str(dir)
37 # + ":" + str(dir.__class__)
48 def create(self, screen): pass
52 class HTMLOutputDevice(OutputDevice):
53 def create(self, comp):
54 print comp.produceHTML()
56 html = HTMLOutputDevice()
58 class GUIOutputDevice(OutputDevice):
60 def create(self, comp):
61 comp.createGUIScreen(self.parent)
66 self.delayTimer = eTimer()
67 self.delayTimer.timeout.get().append(self.processDelay)
69 self.currentDialog = None
71 self.dialogStack = [ ]
73 def processDelay(self):
76 if self.currentDialog.isTmp:
77 self.currentDialog.doClose()
79 print sys.getrefcount(self.currentDialog)
80 del self.currentDialog.instance
81 dump(self.currentDialog)
82 del self.currentDialog
87 self.currentDialog.execBegin()
88 self.currentDialog.instance.show()
91 self.currentDialog.execEnd()
92 self.currentDialog.instance.hide()
94 def create(self, screen, arguments):
95 # creates an instance of 'screen' (which is a class)
96 return screen(self, *arguments)
98 def instantiateDialog(self, screen, *arguments):
99 dlg = self.create(screen, arguments)
100 assert self.desktop != None
101 dlg.instance = eWindow(self.desktop)
103 gui = GUIOutputDevice()
104 gui.parent = dlg.instance
107 applyGUIskin(dlg, None, dlg.skinName, self.desktop)
111 def pushCurrent(self):
112 if self.currentDialog:
113 self.dialogStack.append(self.currentDialog)
116 def popCurrent(self):
117 if len(self.dialogStack):
118 self.currentDialog = self.dialogStack.pop()
121 def execDialog(self, dialog):
123 self.currentDialog = dialog
124 self.currentDialog.isTmp = False
127 def open(self, screen, *arguments):
129 self.currentDialog = self.instantiateDialog(screen, *arguments)
130 self.currentDialog.isTmp = True
133 def keyEvent(self, code):
134 # print "code " + str(code)
136 self.currentDialog["okbutton"].instance.push()
139 self.currentDialog["channelSwitcher"].instance.push()
141 if code >= 0x30 and code <= 0x39:
143 self.currentDialog["menu"].instance.moveSelection(code - 0x31)
145 self.currentDialog["list"].instance.moveSelection(code - 0x31)
148 self.delayTimer.start(0, 1)
150 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
153 self.pnav = pNavigation()
154 self.pnav.m_event.get().append(self.callEvent)
156 self.currentlyPlayingService = None
158 self.RecordTimer = RecordTimer.RecordTimer()
160 def callEvent(self, i):
164 def playService(self, ref):
165 self.currentlyPlayingServiceReference = None
166 if not self.pnav.playService(ref):
167 self.currentlyPlayingServiceReference = ref
171 def getCurrentlyPlayingServiceReference(self):
172 return self.currentlyPlayingServiceReference
174 def recordService(self, ref):
175 service = iRecordableServicePtr()
176 print "recording service: %s" % (str(ref))
177 if self.pnav.recordService(ref, service):
178 print "record returned non-zero"
181 print "ok, recordService didn't fail"
184 def enqueueService(self, ref):
185 return self.pnav.enqueueService(ref)
187 def getCurrentService(self):
188 service = iPlayableServicePtr()
189 if self.pnav.getCurrentService(service):
193 def getPlaylist(self):
194 playlist = ePlaylistPtr()
195 if self.pnav.getPlaylist(playlist):
200 return self.pnav.pause(p)
202 def recordWithTimer(self, begin, end, ref, epg):
203 entry = RecordTimer.RecordTimerEntry(begin, end, self, ref, epg)
204 self.RecordTimer.record(entry)
209 session.desktop = getDesktop()
211 session.nav = Navigation()
213 session.open(infoBar)
215 CONNECT(keyPressedSignal(), session.keyEvent)
222 keymapparser.readKeymap()
226 # first, setup a screen
229 # now, run the mainloop
231 #pt = eDebugClassPtr()
232 #eDebugClass.getDebug(pt, 12)
236 #print "removing ptr..."
239 #print "p is " + str(p)
244 #bla = eDebugClass(2)