from Components.Button import Button
from Components.Label import Label
from Components.ProgressBar import ProgressBar
+from Components.config import configfile
+from Components.Clock import Clock
from Tools.Directories import resolveFilename, SCOPE_SKIN
return self.updatedMenuItems[id]
menuupdater = MenuUpdater()
-
+
+class MenuSummary(Screen):
+ skin = """
+ <screen position="0,0" size="132,64">
+ <widget name="MenuTitle" position="0,4" size="132,21" font="Regular;18" />
+ <widget name="MenuEntry" position="0,25" size="132,21" font="Regular;16" />
+ <widget name="Clock" position="50,46" size="82,18" font="Regular;16" />
+ </screen>"""
+
+ def __init__(self, session, parent):
+ Screen.__init__(self, session)
+ self["MenuTitle"] = Label(parent.menu_title)
+ self["MenuEntry"] = Label("")
+ self["Clock"] = Clock()
+ self.parent = parent
+ self.onShow.append(self.addWatcher)
+ self.onHide.append(self.removeWatcher)
+
+ def addWatcher(self):
+ self.parent["menu"].onSelectionChanged.append(self.selectionChanged)
+ self.selectionChanged()
+
+ def removeWatcher(self):
+ self.parent["menu"].onSelectionChanged.remove(self.selectionChanged)
+
+ def selectionChanged(self):
+ self["MenuEntry"].setText(self.parent["menu"].getCurrent()[0])
+
class Menu(Screen):
def okbuttonClick(self):
print "okbuttonClick"
def execText(self, text):
exec text
-
+
def runScreen(self, arg):
# arg[0] is the module (as string)
# arg[1] is Screen inside this module
# string (as we want to reference
# stuff which is just imported)
# FIXME. somehow
- print arg
if arg[0] != "":
exec "from " + arg[0] + " import *"
self.session.open(*dialog)
def openSetup(self, dialog):
- self.session.open(Setup, dialog)
+ self.session.openWithCallback(self.menuClosed, Setup, dialog)
def addMenu(self, destList, node):
MenuTitle = _(getValbyAttr(node, "text"))
if MenuTitle != "": #check for title
- a = boundFunction(self.session.open, Menu, node, node.childNodes)
+ x = getValbyAttr(node, "flushConfigOnClose")
+ if x == "1":
+ a = boundFunction(self.session.openWithCallback, self.menuClosedWithConfigFlush, Menu, node, node.childNodes)
+ else:
+ a = boundFunction(self.session.openWithCallback, self.menuClosed, Menu, node, node.childNodes)
#TODO add check if !empty(node.childNodes)
destList.append((MenuTitle, a))
-
+
+ def menuClosedWithConfigFlush(self, *res):
+ configfile.save()
+ self.menuClosed(*res)
+
+ def menuClosed(self, *res):
+ if len(res) and res[0]:
+ self.close(True)
+
def addItem(self, destList, node):
ItemText = _(getValbyAttr(node, "text"))
if ItemText != "": #check for name
self["actions"] = ActionMap(["OkCancelActions", "MenuActions"],
{
"ok": self.okbuttonClick,
- "cancel": self.close,
- "menu": self.close
+ "cancel": self.closeNonRecursive,
+ "menu": self.closeRecursive
})
a = getValbyAttr(parent, "title")
if a == "": #if empty use name
a = _(getValbyAttr(parent, "text"))
self["title"] = Header(a)
+ self.menu_title = a
+
+ def closeNonRecursive(self):
+ self.close(False)
+
+ def closeRecursive(self):
+ self.close(True)
+
+ def createSummary(self):
+ return MenuSummary
class MainMenu(Menu):
#add file load functions for the xml-file