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):
74 self.currentDialog.doClose()
76 dump(self.currentDialog)
77 print sys.getrefcount(self.currentDialog)
78 del self.currentDialog
79 del self.currentWindow
81 if len(self.dialogStack):
82 (self.currentDialog, self.currentWindow) = self.dialogStack.pop()
86 self.currentDialog.execBegin()
87 self.currentWindow.show()
90 self.currentDialog.execEnd()
91 self.currentWindow.hide()
93 def create(self, screen, arguments):
94 return screen(self, *arguments)
96 def open(self, screen, *arguments):
97 if self.currentDialog:
98 self.dialogStack.append((self.currentDialog, self.currentWindow))
101 self.currentDialog = self.create(screen, arguments)
103 if self.desktop != None:
104 self.currentWindow = eWindow(self.desktop)
106 gui = GUIOutputDevice()
107 gui.parent = self.currentWindow
108 gui.create(self.currentDialog)
110 applyGUIskin(self.currentDialog, self.currentWindow, None, self.currentDialog.skinName)
114 self.currentWindow = None
116 def keyEvent(self, code):
117 # print "code " + str(code)
119 self.currentDialog["okbutton"].instance.push()
122 self.currentDialog["channelSwitcher"].instance.push()
124 if code >= 0x30 and code <= 0x39:
126 self.currentDialog["menu"].instance.moveSelection(code - 0x31)
128 self.currentDialog["list"].instance.moveSelection(code - 0x31)
131 self.delayTimer.start(0, 1)
135 session.desktop = getDesktop()
137 session.nav = pNavigation()
139 session.open(infoBar)
141 CONNECT(keyPressedSignal(), session.keyEvent)
148 keymapparser.readKeymap()
150 # first, setup a screen
153 # now, run the mainloop
155 #pt = eDebugClassPtr()
156 #eDebugClass.getDebug(pt, 12)
160 #print "removing ptr..."
163 #print "p is " + str(p)
168 #bla = eDebugClass(2)