9 import ServiceReference
11 from Navigation import Navigation
13 from skin import readSkin, applyAllAttributes
16 # A screen is a function which instanciates all components of a screen into a temporary component.
17 # Thus, the global stuff is a screen, too.
18 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
19 # "linked" from the instance tree.
20 # A screen itself lives as the container of the components, so a screen is a component, too.
22 # we thus have one (static) hierarchy of screens (classes, not instances)
23 # and one with the instanciated components itself (both global and dynamic)
27 def dump(dir, p = ""):
28 if isinstance(dir, dict):
29 for (entry, val) in dir.items():
30 dump(val, p + "(dict)/" + entry)
31 if hasattr(dir, "__dict__"):
32 for name, value in dir.__dict__.items():
33 if not had.has_key(str(value)):
35 dump(value, p + "/" + str(name))
37 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
39 print p + ":" + str(dir)
41 # + ":" + str(dir.__class__)
46 def create(self, screen): pass
50 class HTMLOutputDevice(OutputDevice):
51 def create(self, comp):
52 print comp.produceHTML()
54 html = HTMLOutputDevice()
56 class GUIOutputDevice(OutputDevice):
58 def create(self, comp, desktop):
59 comp.createGUIScreen(self.parent, desktop)
64 self.delayTimer = eTimer()
65 self.delayTimer.timeout.get().append(self.processDelay)
67 self.currentDialog = None
69 self.dialogStack = [ ]
71 def processDelay(self):
74 if self.currentDialog.isTmp:
75 self.currentDialog.doClose()
77 print sys.getrefcount(self.currentDialog)
78 del self.currentDialog.instance
79 # dump(self.currentDialog)
80 del self.currentDialog
85 self.currentDialog.execBegin()
86 self.currentDialog.instance.show()
89 self.currentDialog.execEnd()
90 self.currentDialog.instance.hide()
92 def create(self, screen, arguments):
93 # creates an instance of 'screen' (which is a class)
94 return screen(self, *arguments)
96 def instantiateDialog(self, screen, *arguments):
98 dlg = self.create(screen, arguments)
101 readSkin(dlg, None, dlg.skinName, self.desktop)
103 # create GUI view of this dialog
104 assert self.desktop != None
105 dlg.instance = eWindow(self.desktop)
106 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
107 gui = GUIOutputDevice()
108 gui.parent = dlg.instance
109 gui.create(dlg, self.desktop)
113 def pushCurrent(self):
114 if self.currentDialog:
115 self.dialogStack.append(self.currentDialog)
118 def popCurrent(self):
119 if len(self.dialogStack):
120 self.currentDialog = self.dialogStack.pop()
123 def execDialog(self, dialog):
125 self.currentDialog = dialog
126 self.currentDialog.isTmp = False
129 def open(self, screen, *arguments):
131 self.currentDialog = self.instantiateDialog(screen, *arguments)
132 self.currentDialog.isTmp = True
135 def keyEvent(self, code):
136 print "code " + str(code)
139 self.delayTimer.start(0, 1)
144 session.desktop = getDesktop()
146 session.nav = Navigation()
148 session.open(Screens.InfoBar.InfoBar)
150 CONNECT(keyPressedSignal(), session.keyEvent)
154 session.nav.shutdown()
159 keymapparser.readKeymap()
161 skin.loadSkin(getDesktop())
163 import Components.InputDevice
164 Components.InputDevice.InitInputDevices()
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)