9 from skin import applyGUIskin
11 # A screen is a function which instanciates all components of a screen into a temporary component.
12 # Thus, the global stuff is a screen, too.
13 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
14 # "linked" from the instance tree.
15 # A screen itself lives as the container of the components, so a screen is a component, too.
17 # we thus have one (static) hierarchy of screens (classes, not instances)
18 # and one with the instanciated components itself (both global and dynamic)
22 def dump(dir, p = ""):
23 if isinstance(dir, dict):
24 for (entry, val) in dir.items():
25 dump(val, p + "(dict)/" + entry)
26 if hasattr(dir, "__dict__"):
27 for name, value in dir.__dict__.items():
28 if not had.has_key(str(value)):
30 dump(value, p + "/" + str(name))
32 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
34 print p + ":" + str(dir)
36 # + ":" + str(dir.__class__)
47 def create(self, screen): pass
51 class HTMLOutputDevice(OutputDevice):
52 def create(self, comp):
53 print comp.produceHTML()
55 html = HTMLOutputDevice()
57 class GUIOutputDevice(OutputDevice):
59 def create(self, comp):
60 comp.createGUIScreen(self.parent)
65 self.delayTimer = eTimer()
66 self.delayTimer.timeout.get().append(self.processDelay)
68 self.currentDialog = None
70 self.dialogStack = [ ]
72 def processDelay(self):
75 if self.currentDialog.isTmp:
76 self.currentDialog.doClose()
78 print sys.getrefcount(self.currentDialog)
79 del self.currentDialog.instance
80 dump(self.currentDialog)
81 del self.currentDialog
86 self.currentDialog.execBegin()
87 self.currentDialog.instance.show()
90 self.currentDialog.execEnd()
91 self.currentDialog.instance.hide()
93 def create(self, screen, arguments):
94 # creates an instance of 'screen' (which is a class)
95 return screen(self, *arguments)
97 def instantiateDialog(self, screen, *arguments):
98 dlg = self.create(screen, arguments)
99 assert self.desktop != None
100 dlg.instance = eWindow(self.desktop)
102 gui = GUIOutputDevice()
103 gui.parent = dlg.instance
106 applyGUIskin(dlg, None, dlg.skinName)
110 def pushCurrent(self):
111 if self.currentDialog:
112 self.dialogStack.append(self.currentDialog)
115 def popCurrent(self):
116 if len(self.dialogStack):
117 self.currentDialog = self.dialogStack.pop()
120 def execDialog(self, dialog):
122 self.currentDialog = dialog
123 self.currentDialog.isTmp = False
126 def open(self, screen, *arguments):
128 self.currentDialog = self.instantiateDialog(screen, *arguments)
129 self.currentDialog.isTmp = True
132 def keyEvent(self, code):
133 # print "code " + str(code)
135 self.currentDialog["okbutton"].instance.push()
138 self.currentDialog["channelSwitcher"].instance.push()
140 if code >= 0x30 and code <= 0x39:
142 self.currentDialog["menu"].instance.moveSelection(code - 0x31)
144 self.currentDialog["list"].instance.moveSelection(code - 0x31)
147 self.delayTimer.start(0, 1)
151 session.desktop = getDesktop()
153 session.nav = pNavigation()
155 session.open(infoBar)
157 CONNECT(keyPressedSignal(), session.keyEvent)
164 keymapparser.readKeymap()
166 # first, setup a screen
169 # now, run the mainloop
171 #pt = eDebugClassPtr()
172 #eDebugClass.getDebug(pt, 12)
176 #print "removing ptr..."
179 #print "p is " + str(p)
184 #bla = eDebugClass(2)