9 import ServiceReference
11 from Navigation import Navigation
13 from skin import readSkin, applyAllAttributes
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, desktop):
58 comp.createGUIScreen(self.parent, desktop)
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):
97 dlg = self.create(screen, arguments)
100 readSkin(dlg, None, dlg.skinName, self.desktop)
102 # create GUI view of this dialog
103 assert self.desktop != None
104 dlg.instance = eWindow(self.desktop)
105 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
106 gui = GUIOutputDevice()
107 gui.parent = dlg.instance
108 gui.create(dlg, self.desktop)
112 def pushCurrent(self):
113 if self.currentDialog:
114 self.dialogStack.append(self.currentDialog)
117 def popCurrent(self):
118 if len(self.dialogStack):
119 self.currentDialog = self.dialogStack.pop()
122 def execDialog(self, dialog):
124 self.currentDialog = dialog
125 self.currentDialog.isTmp = False
128 def open(self, screen, *arguments):
130 self.currentDialog = self.instantiateDialog(screen, *arguments)
131 self.currentDialog.isTmp = True
134 def keyEvent(self, code):
135 print "code " + str(code)
138 self.delayTimer.start(0, 1)
143 session.desktop = getDesktop()
145 session.nav = Navigation()
147 session.open(Screens.InfoBar.InfoBar)
149 CONNECT(keyPressedSignal(), session.keyEvent)
153 session.nav.shutdown()
158 keymapparser.readKeymap()
160 skin.loadSkin(getDesktop())
162 # first, setup a screen
165 # now, run the mainloop
167 #pt = eDebugClassPtr()
168 #eDebugClass.getDebug(pt, 12)
172 #print "removing ptr..."
175 #print "p is " + str(p)
180 #bla = eDebugClass(2)