From f3643e16acdb33f7a05ef3ce3faa45142a727e37 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Wed, 11 Jan 2006 20:03:06 +0000 Subject: 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 --- lib/python/Screens/Menu.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'lib/python/Screens/Menu.py') 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) -- cgit v1.2.3