From: Stefan Pluecken Date: Wed, 11 Jan 2006 20:03:06 +0000 (+0000) Subject: menu positioning for the plugins works now X-Git-Tag: 2.6.0~4471 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/f3643e16acdb33f7a05ef3ce3faa45142a727e37 menu positioning for the plugins works now example: def getMenuRegistrationList(): list = [] list.append(("setup", 2, "Softwareupdate", "Example")) list.append(("mainmenu", 0, "Foo", "Bar")) return list this means, that we have 2 menu entries: a menu entry "Softwareupdate" is added to the setup menu on position 2 which calls the Example screen of the plugin and a menu entry Foo is added to the main menu on the first position which calls the screen Bar --- diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index e0cc90a4..adfc98a0 100644 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -57,11 +57,11 @@ class PluginComponent: def menuDelete(self): for menuEntry in self.menuEntries: - menuupdater.delMenuItem(menuEntry[0][0], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) + menuupdater.delMenuItem(menuEntry[0][0], menuEntry[0][1], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) def menuUpdate(self): for menuEntry in self.menuEntries: - menuupdater.addMenuItem(menuEntry[0][0], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) + menuupdater.addMenuItem(menuEntry[0][0], menuEntry[0][1], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) def runPlugin(self, plugin, session): try: diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py index 68a8ef98..9c41c165 100644 --- a/lib/python/Screens/Menu.py +++ b/lib/python/Screens/Menu.py @@ -57,13 +57,13 @@ class MenuUpdater: def __init__(self): self.updatedMenuItems = {} - def addMenuItem(self, id, text, module, screen): + def addMenuItem(self, id, pos, text, module, screen): if not self.updatedMenuAvailable(id): self.updatedMenuItems[id] = [] - self.updatedMenuItems[id].append([text, module, screen]) + self.updatedMenuItems[id].append([text, pos, module, screen]) - def delMenuItem(self, id, text, module, screen): - self.updatedMenuItems[id].remove([text, module, screen]) + def delMenuItem(self, id, pos, text, module, screen): + self.updatedMenuItems[id].remove([text, pos, module, screen]) def updatedMenuAvailable(self, id): return self.updatedMenuItems.has_key(id) @@ -151,19 +151,26 @@ class Menu(Screen): list = [] menuID = "" - for x in childNode: #walk through the actual nodelist + menuID = -1 + for x in childNode: #walk through the actual nodelist if x.nodeType != xml.dom.minidom.Element.nodeType: continue elif x.tagName == 'item': self.addItem(list, x) + count += 1 elif x.tagName == 'menu': self.addMenu(list, x) + count += 1 elif x.tagName == "id": menuID = getValbyAttr(x, "val") + count = 0 + if menuID != -1: + if menuupdater.updatedMenuAvailable(menuID): + for x in menuupdater.getUpdatedMenu(menuID): + if x[1] == count: + list.append((x[0], boundFunction(self.runScreen, (x[2], x[3] + ", ")))) + count += 1 - if menuupdater.updatedMenuAvailable(menuID): - for x in menuupdater.getUpdatedMenu(menuID): - list.append((x[0], boundFunction(self.runScreen, (x[1], x[2] + ", ")))) self["menu"] = MenuList(list)