9 import ServiceReference
11 from Navigation import Navigation
13 from skin import applyGUIskin
15 # A screen is a function which instanciates all components of a screen into a temporary component.
16 # Thus, the global stuff is a screen, too.
17 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
18 # "linked" from the instance tree.
19 # A screen itself lives as the container of the components, so a screen is a component, too.
21 # we thus have one (static) hierarchy of screens (classes, not instances)
22 # and one with the instanciated components itself (both global and dynamic)
26 def dump(dir, p = ""):
27 if isinstance(dir, dict):
28 for (entry, val) in dir.items():
29 dump(val, p + "(dict)/" + entry)
30 if hasattr(dir, "__dict__"):
31 for name, value in dir.__dict__.items():
32 if not had.has_key(str(value)):
34 dump(value, p + "/" + str(name))
36 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
38 print p + ":" + str(dir)
40 # + ":" + str(dir.__class__)
45 def create(self, screen): pass
49 class HTMLOutputDevice(OutputDevice):
50 def create(self, comp):
51 print comp.produceHTML()
53 html = HTMLOutputDevice()
55 class GUIOutputDevice(OutputDevice):
57 def create(self, comp):
58 comp.createGUIScreen(self.parent)
63 self.delayTimer = eTimer()
64 self.delayTimer.timeout.get().append(self.processDelay)
66 self.currentDialog = None
68 self.dialogStack = [ ]
70 def processDelay(self):
73 if self.currentDialog.isTmp:
74 self.currentDialog.doClose()
76 print sys.getrefcount(self.currentDialog)
77 del self.currentDialog.instance
78 dump(self.currentDialog)
79 del self.currentDialog
84 self.currentDialog.execBegin()
85 self.currentDialog.instance.show()
88 self.currentDialog.execEnd()
89 self.currentDialog.instance.hide()
91 def create(self, screen, arguments):
92 # creates an instance of 'screen' (which is a class)
93 return screen(self, *arguments)
95 def instantiateDialog(self, screen, *arguments):
96 dlg = self.create(screen, arguments)
97 assert self.desktop != None
98 dlg.instance = eWindow(self.desktop)
100 gui = GUIOutputDevice()
101 gui.parent = dlg.instance
104 applyGUIskin(dlg, None, dlg.skinName, self.desktop)
108 def pushCurrent(self):
109 if self.currentDialog:
110 self.dialogStack.append(self.currentDialog)
113 def popCurrent(self):
114 if len(self.dialogStack):
115 self.currentDialog = self.dialogStack.pop()
118 def execDialog(self, dialog):
120 self.currentDialog = dialog
121 self.currentDialog.isTmp = False
124 def open(self, screen, *arguments):
126 self.currentDialog = self.instantiateDialog(screen, *arguments)
127 self.currentDialog.isTmp = True
130 def keyEvent(self, code):
131 print "code " + str(code)
134 self.delayTimer.start(0, 1)
139 session.desktop = getDesktop()
141 session.nav = Navigation()
143 session.open(Screens.InfoBar.InfoBar)
145 CONNECT(keyPressedSignal(), session.keyEvent)
149 session.nav.shutdown()
154 keymapparser.readKeymap()
158 # first, setup a screen
161 # now, run the mainloop
163 #pt = eDebugClassPtr()
164 #eDebugClass.getDebug(pt, 12)
168 #print "removing ptr..."
171 #print "p is " + str(p)
176 #bla = eDebugClass(2)