remove InfoBarEvent initialization, which is gone now
[enigma2.git] / lib / python / Screens / Menu.py
index 22aee7d926de6108022868c5c468281acbaaa8ec..ce7f2ea6fe68523aed1fa32994634e58629fefb6 100644 (file)
@@ -4,6 +4,8 @@ from Components.ActionMap import NumberActionMap
 from Components.Sources.StaticText import StaticText
 from Components.config import configfile
 from Components.PluginComponent import plugins
+from Components.config import config
+from Components.SystemInfo import SystemInfo
 
 from Tools.Directories import resolveFilename, SCOPE_SKIN
 
@@ -73,7 +75,8 @@ class Menu(Screen):
        def okbuttonClick(self):
                print "okbuttonClick"
                selection = self["menu"].getCurrent()
-               selection[1]()
+               if selection is not None:
+                       selection[1]()
 
        def execText(self, text):
                exec text
@@ -100,6 +103,9 @@ class Menu(Screen):
                self.session.openWithCallback(self.menuClosed, Setup, dialog)
 
        def addMenu(self, destList, node):
+               requires = node.getAttribute("requires")
+               if requires and not SystemInfo.get(requires, False):
+                       return
                MenuTitle = _(node.getAttribute("text").encode("UTF-8") or "??")
                entryID = node.getAttribute("entryID") or "undefined"
                weight = node.getAttribute("weight") or 50
@@ -120,6 +126,9 @@ class Menu(Screen):
                        self.close(True)
 
        def addItem(self, destList, node):
+               requires = node.getAttribute("requires")
+               if requires and not SystemInfo.get(requires, False):
+                       return
                item_text = node.getAttribute("text").encode("UTF-8")
                entryID = node.getAttribute("entryID") or "undefined"
                weight = node.getAttribute("weight") or 50
@@ -170,8 +179,11 @@ class Menu(Screen):
                        if x.nodeType != xml.dom.minidom.Element.nodeType:
                            continue
                        elif x.tagName == 'item':
-                               self.addItem(list, x)
-                               count += 1
+                               item_level = int(x.getAttribute("level") or "0")
+                               
+                               if item_level <= config.usage.setup_level.index:
+                                       self.addItem(list, x)
+                                       count += 1
                        elif x.tagName == 'menu':
                                self.addMenu(list, x)
                                count += 1
@@ -190,8 +202,13 @@ class Menu(Screen):
                if menuID is not None:
                        # plugins
                        for l in plugins.getPluginsForMenu(menuID):
+                               # check if a plugin overrides an existing menu
+                               plugin_menuid = l[2]
+                               for x in list:
+                                       if x[2] == plugin_menuid:
+                                               list.remove(x)
+                                               break
                                list.append((l[0], boundFunction(l[1], self.session), l[2], l[3] or 50))
-                                       
 
                # for the skin: first try a menu_<menuID>, then Menu
                self.skinName = [ ]