1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
from enigma import *
from tools import *
import traceback
import Screens.InfoBar
import sys
import time
import ServiceReference
from Navigation import Navigation
from skin import readSkin, applyAllAttributes
# A screen is a function which instanciates all components of a screen into a temporary component.
# Thus, the global stuff is a screen, too.
# In a screen, components can either be instanciated from the class-tree, cloned (copied) or
# "linked" from the instance tree.
# A screen itself lives as the container of the components, so a screen is a component, too.
# we thus have one (static) hierarchy of screens (classes, not instances)
# and one with the instanciated components itself (both global and dynamic)
had = dict()
def dump(dir, p = ""):
if isinstance(dir, dict):
for (entry, val) in dir.items():
dump(val, p + "(dict)/" + entry)
if hasattr(dir, "__dict__"):
for name, value in dir.__dict__.items():
if not had.has_key(str(value)):
had[str(value)] = 1
dump(value, p + "/" + str(name))
else:
print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
else:
print p + ":" + str(dir)
# + ":" + str(dir.__class__)
# display
class OutputDevice:
def create(self, screen): pass
# display: HTML
class HTMLOutputDevice(OutputDevice):
def create(self, comp):
print comp.produceHTML()
html = HTMLOutputDevice()
class GUIOutputDevice(OutputDevice):
parent = None
def create(self, comp, desktop):
comp.createGUIScreen(self.parent, desktop)
class Session:
def __init__(self):
self.desktop = None
self.delayTimer = eTimer()
self.delayTimer.timeout.get().append(self.processDelay)
self.currentDialog = None
self.dialogStack = [ ]
def processDelay(self):
self.execEnd()
if self.currentDialog.isTmp:
self.currentDialog.doClose()
print sys.getrefcount(self.currentDialog)
del self.currentDialog.instance
# dump(self.currentDialog)
del self.currentDialog
self.popCurrent()
def execBegin(self):
self.currentDialog.execBegin()
self.currentDialog.instance.show()
def execEnd(self):
self.currentDialog.execEnd()
self.currentDialog.instance.hide()
def create(self, screen, arguments):
# creates an instance of 'screen' (which is a class)
return screen(self, *arguments)
def instantiateDialog(self, screen, *arguments):
# create dialog
try:
dlg = self.create(screen, arguments)
except:
print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
print '-'*60
traceback.print_exc(file=sys.stdout)
quitMainloop()
print '-'*60
# read skin data
readSkin(dlg, None, dlg.skinName, self.desktop)
# create GUI view of this dialog
assert self.desktop != None
dlg.instance = eWindow(self.desktop)
applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
gui = GUIOutputDevice()
gui.parent = dlg.instance
gui.create(dlg, self.desktop)
return dlg
def pushCurrent(self):
if self.currentDialog:
self.dialogStack.append(self.currentDialog)
self.execEnd()
def popCurrent(self):
if len(self.dialogStack):
self.currentDialog = self.dialogStack.pop()
self.execBegin()
def execDialog(self, dialog):
self.pushCurrent()
self.currentDialog = dialog
self.currentDialog.isTmp = False
self.execBegin()
def open(self, screen, *arguments):
self.pushCurrent()
self.currentDialog = self.instantiateDialog(screen, *arguments)
self.currentDialog.isTmp = True
self.execBegin()
def keyEvent(self, code):
print "code " + str(code)
def close(self):
self.delayTimer.start(0, 1)
def runScreenTest():
session = Session()
session.desktop = getDesktop()
session.nav = Navigation()
session.open(Screens.InfoBar.InfoBar)
CONNECT(keyPressedSignal(), session.keyEvent)
runMainloop()
session.nav.shutdown()
return 0
import keymapparser
keymapparser.readKeymap()
import skin
skin.loadSkin(getDesktop())
import Components.InputDevice
Components.InputDevice.InitInputDevices()
import Components.AVSwitch
Components.AVSwitch.InitAVSwitch()
import Components.SetupDevices
Components.SetupDevices.InitSetupDevices()
# first, setup a screen
try:
runScreenTest()
except:
print 'EXCEPTION IN PYTHON STARTUP CODE:'
print '-'*60
traceback.print_exc(file=sys.stdout)
quitMainloop()
print '-'*60
# now, run the mainloop
#pt = eDebugClassPtr()
#eDebugClass.getDebug(pt, 12)
#p = pt.__deref__()
#print pt.x
#print p.x
#print "removing ptr..."
#pt = 0
#print "now"
#print "p is " + str(p)
#print p.x
#p = 0
#
#bla = eDebugClass()
#bla = eDebugClass(2)
#
|