def singleItemMenu(self): self.onExecBegin.remove(self.singleItemMenu) if config.usage.menuType.value == "horzanim" and findSkinScreen( "Animmain"): return elif config.usage.menuType.value == "horzicon" and findSkinScreen( "Iconmain"): return else: self.okbuttonClick()
def __onExecBegin(self): self.onExecBegin.remove(self.__onExecBegin) if config.usage.menutype.value == "horzanim" and findSkinScreen( "Animmain"): return elif config.usage.menutype.value == "horzicon" and findSkinScreen( "Iconmain"): return else: self.okbuttonClick()
def __init__(self, session, parent): self.parentmenu = parent Screen.__init__(self, session) self["key_blue"] = StaticText("") self["menu"] = List([]) self["menu"].enableWrapAround = True self.showNumericHelp = False self.createMenuList() # for the skin: first try a menu_<menuID>, then Menu self.skinName = [] if self.menuID is not None: if config.usage.menutype.value == 'horzanim' and findSkinScreen( "Animmain"): self.skinName.append('Animmain') elif config.usage.menutype.value == 'horzicon' and findSkinScreen( "Iconmain"): self.skinName.append('Iconmain') else: self.skinName.append('menu_' + self.menuID) self.skinName.append("Menu") ProtectedScreen.__init__(self) self["actions"] = NumberActionMap( [ "OkCancelActions", "MenuActions", "NumberActions", "HelpActions", "ColorActions" ], { "ok": self.okbuttonClick, "cancel": self.closeNonRecursive, "menu": self.closeRecursive, "0": self.keyNumberGlobal, "1": self.keyNumberGlobal, "2": self.keyNumberGlobal, "3": self.keyNumberGlobal, "4": self.keyNumberGlobal, "5": self.keyNumberGlobal, "6": self.keyNumberGlobal, "7": self.keyNumberGlobal, "8": self.keyNumberGlobal, "9": self.keyNumberGlobal, "displayHelp": self.showHelp, "blue": self.keyBlue, }) title = parent.get("title", "").encode("UTF-8") or None title = title and _(title) or _(parent.get("text", "").encode("UTF-8")) title = self.__class__.__name__ == "MenuSort" and _( "Menusort (%s)") % title or title if title is None: title = _(parent.get('text', '').encode('UTF-8')) else: t_history.reset() self["title"] = StaticText(title) self.setTitle(title) self.menu_title = title self['thistory'] = StaticText(t_history.thistory) history_len = len(t_history.thistory) self['title0'] = StaticText('') self['title1'] = StaticText('') self['title2'] = StaticText('') if history_len < 13: self['title0'] = StaticText(title) elif history_len < 21: self['title0'] = StaticText('') self['title1'] = StaticText(title) else: self['title0'] = StaticText('') self['title1'] = StaticText('') self['title2'] = StaticText(title) if t_history.thistory == '': t_history.thistory = str(title) + ' > ' else: t_history.thistory = t_history.thistory + str(title) + ' > ' if config.usage.menutype.value == 'horzanim' and findSkinScreen( "Animmain"): self['label1'] = StaticText() self['label2'] = StaticText() self['label3'] = StaticText() self['label4'] = StaticText() self['label5'] = StaticText() self.onShown.append(self.openTestA) elif config.usage.menutype.value == 'horzicon' and findSkinScreen( "Iconmain"): self['label1'] = StaticText() self['label2'] = StaticText() self['label3'] = StaticText() self['label4'] = StaticText() self['label5'] = StaticText() self['label6'] = StaticText() self['label1s'] = StaticText() self['label2s'] = StaticText() self['label3s'] = StaticText() self['label4s'] = StaticText() self['label5s'] = StaticText() self['label6s'] = StaticText() self['pointer'] = Pixmap() self['pixmap1'] = Pixmap() self['pixmap2'] = Pixmap() self['pixmap3'] = Pixmap() self['pixmap4'] = Pixmap() self['pixmap5'] = Pixmap() self['pixmap6'] = Pixmap() self.onShown.append(self.openTestB) self.number = 0 self.nextNumberTimer = eTimer() self.nextNumberTimer.callback.append(self.okbuttonClick) if len(self.list) == 1: self.onExecBegin.append(self.__onExecBegin)
def __init__(self, session, parentMenu): self.session = session self.parentMenu = parentMenu Screen.__init__(self, session) HelpableScreen.__init__(self) self.menuList = [] self["menu"] = List(self.menuList) self["menu"].onSelectionChanged.append(self.selectionChanged) self["menuimage"] = Pixmap() self["description"] = StaticText() self["key_menu"] = StaticText(_("MENU")) self["key_red"] = StaticText(_("Exit")) self["key_green"] = StaticText() self["key_yellow"] = StaticText() self["key_blue"] = StaticText() menuImageLibrary = resolveFilename(SCOPE_GUISKIN, "mainmenu") self.menuImageLibrary = menuImageLibrary if isdir( menuImageLibrary) else None self.showNumericHelp = False self.sortMode = False self.selectedEntry = None self.subMenuSort = None self.createMenuList() ProtectedScreen.__init__(self) # ProtectedScreen needs self.menuID # For the skin: first try a menu_<menuID>, then Menu. self.skinName = [] if self.menuID is not None: if config.usage.menuType.value == "horzanim" and findSkinScreen( "Animmain"): self.skinName.append("Animmain") elif config.usage.menuType.value == "horzicon" and findSkinScreen( "Iconmain"): self.skinName.append("Iconmain") else: self.skinName.append("Menu%s" % self.menuID) self.skinName.append("menu_%s" % self.menuID) self.skinName.append("Menu") if config.usage.menuType.value == "horzanim" and findSkinScreen( "Animmain"): self.onShown.append(self.openTestA) elif config.usage.menuType.value == "horzicon" and findSkinScreen( "Iconmain"): self.onShown.append(self.openTestB) self["menuActions"] = HelpableNumberActionMap( self, [ "OkCancelActions", "MenuActions", "ColorActions", "NumberActions" ], { "ok": (self.okbuttonClick, _("Select the current menu item")), "cancel": (self.closeNonRecursive, _("Exit menu")), "close": (self.closeRecursive, _("Exit all menus")), "menu": (self.keySetupMenu, _("Change OSD Settings")), "red": (self.closeNonRecursive, _("Exit menu")), "1": (self.keyNumberGlobal, _("Direct menu item selection")), "2": (self.keyNumberGlobal, _("Direct menu item selection")), "3": (self.keyNumberGlobal, _("Direct menu item selection")), "4": (self.keyNumberGlobal, _("Direct menu item selection")), "5": (self.keyNumberGlobal, _("Direct menu item selection")), "6": (self.keyNumberGlobal, _("Direct menu item selection")), "7": (self.keyNumberGlobal, _("Direct menu item selection")), "8": (self.keyNumberGlobal, _("Direct menu item selection")), "9": (self.keyNumberGlobal, _("Direct menu item selection")), "0": (self.keyNumberGlobal, _("Direct menu item selection")) }, prio=0, description=_("Menu Common Actions")) if config.usage.menuSortOrder.value == "user": self["moveActions"] = HelpableActionMap( self, ["NavigationActions"], { "top": (self.keyTop, _("Move to first line / screen")), "pageUp": (self.keyPageUp, _("Move up a screen")), "up": (self.keyUp, _("Move up a line")), # "first": (self.keyFirst, _("Jump to first item in list or the start of text")), # "left": (self.keyLeft, _("Select the previous item in list or move cursor left")), "left": (self.keyPageUp, _("Move up a screen")), "right": (self.keyPageDown, _("Move down a screen")), # "right": (self.keyRight, _("Select the next item in list or move cursor right")), # "last": (self.keyLast, _("Jump to last item in list or the end of text")), "down": (self.keyDown, _("Move down a line")), "pageDown": (self.keyPageDown, _("Move down a screen")), "bottom": (self.keyBottom, _("Move to last line / screen")) }, prio=-1, description=_("Menu Navigation Actions")) self["editActions"] = HelpableActionMap( self, ["ColorActions"], { "green": (self.keyGreen, _("Toggle item move mode on/off")), "yellow": (self.keyYellow, _("Toggle hide/show of the current item")), "blue": (self.toggleSortMode, _("Toggle item edit mode on/off")) }, prio=0, description=_("Menu Edit Actions")) title = parentMenu.get("title", "") or None title = title and _(title) if title is None: title = _(parentMenu.get("text", "")) self.setTitle(title) self.number = 0 self.nextNumberTimer = eTimer() self.nextNumberTimer.callback.append(self.okbuttonClick) if len( self.menuList ) == 1: # Does this menu have only one item, if so just run that item. self.onExecBegin.append(self.singleItemMenu) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, parent): Screen.__init__(self, session) HelpableScreen.__init__(self) self.parentMenu = parent self.menuList = [] self["menu"] = List(self.menuList) self["menu"].enableWrapAround = True self["menu"].onSelectionChanged.append(self.selectionChanged) self.showNumericHelp = False self["green"] = Label() self["yellow"] = Label() self["blue"] = Label() self.sort_mode = False self.selected_entry = None self.sub_menu_sort = None self.createMenuList() ProtectedScreen.__init__(self) # for the skin: first try a menu_<menuID>, then Menu self.skinName = [] if self.menuID is not None: if config.usage.menutype.value == "horzanim" and findSkinScreen( "Animmain"): self.skinName.append("Animmain") elif config.usage.menutype.value == "horzicon" and findSkinScreen( "Iconmain"): self.skinName.append("Iconmain") else: self.skinName.append("menu_" + self.menuID) self.skinName.append("Menu") if config.usage.menu_sort_mode.value == "user": self["MoveActions"] = ActionMap( ["WizardActions"], { "left": self.keyLeft, "right": self.keyRight, "up": self.keyUp, "down": self.keyDown, }, -1) self["EditActions"] = ActionMap( ["ColorActions"], { "green": self.keyGreen, "yellow": self.keyYellow, "blue": self.keyBlue, }) self["menuActions"] = HelpableNumberActionMap( self, ["OkCancelActions", "NumberActions", "MenuActions"], { "ok": (self.okbuttonClick, _("Select the current menu item")), "cancel": (self.closeNonRecursive, _("Exit menu")), "close": (self.closeRecursive, _("Exit all menus")), "menu": (self.closeRecursive, _("Exit all menus")), "1": (self.keyNumberGlobal, _("Direct menu item selection")), "2": (self.keyNumberGlobal, _("Direct menu item selection")), "3": (self.keyNumberGlobal, _("Direct menu item selection")), "4": (self.keyNumberGlobal, _("Direct menu item selection")), "5": (self.keyNumberGlobal, _("Direct menu item selection")), "6": (self.keyNumberGlobal, _("Direct menu item selection")), "7": (self.keyNumberGlobal, _("Direct menu item selection")), "8": (self.keyNumberGlobal, _("Direct menu item selection")), "9": (self.keyNumberGlobal, _("Direct menu item selection")), "0": (self.keyNumberGlobal, _("Direct menu item selection")) }, prio=0, description=_("Common Menu Actions")) title = parent.get("title", "").encode("UTF-8") if PY2 else parent.get( "title", "") or None title = title and _(title) if title is None: title = _(parent.get("text", "").encode( "UTF-8", "ignore")) if PY2 else _(parent.get("text", "")) else: t_history.reset() self["title"] = StaticText(title) self.setTitle(title) self.menu_title = title self["thistory"] = StaticText(t_history.thistory) history_len = len(t_history.thistory) self["title0"] = StaticText("") self["title1"] = StaticText("") self["title2"] = StaticText("") if history_len < 13: self["title0"] = StaticText(title) elif history_len < 21: self["title0"] = StaticText("") self["title1"] = StaticText(title) else: self["title0"] = StaticText("") self["title1"] = StaticText("") self["title2"] = StaticText(title) if t_history.thistory == "": t_history.thistory = str(title) + " > " else: t_history.thistory = t_history.thistory + str(title) + " > " if config.usage.menutype.value == "horzanim" and findSkinScreen( "Animmain"): self["label1"] = StaticText() self["label2"] = StaticText() self["label3"] = StaticText() self["label4"] = StaticText() self["label5"] = StaticText() self.onShown.append(self.openTestA) elif config.usage.menutype.value == "horzicon" and findSkinScreen( "Iconmain"): self["label1"] = StaticText() self["label2"] = StaticText() self["label3"] = StaticText() self["label4"] = StaticText() self["label5"] = StaticText() self["label6"] = StaticText() self["label1s"] = StaticText() self["label2s"] = StaticText() self["label3s"] = StaticText() self["label4s"] = StaticText() self["label5s"] = StaticText() self["label6s"] = StaticText() self["pointer"] = Pixmap() self["pixmap1"] = Pixmap() self["pixmap2"] = Pixmap() self["pixmap3"] = Pixmap() self["pixmap4"] = Pixmap() self["pixmap5"] = Pixmap() self["pixmap6"] = Pixmap() self.onShown.append(self.openTestB) self.number = 0 self.nextNumberTimer = eTimer() self.nextNumberTimer.callback.append(self.okbuttonClick) if len(self.menuList) == 1: self.onExecBegin.append(self.__onExecBegin) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, parent): Screen.__init__(self, session) self.sort_mode = False self.selected_entry = None self.sub_menu_sort = None self["green"] = Label() self["yellow"] = Label() self["blue"] = Label() m_list = [] menuID = None for x in parent: #walk through the actual nodelist if not x.tag: continue if x.tag == 'item': item_level = int(x.get("level", 0)) if item_level <= config.usage.setup_level.index: self.addItem(m_list, x) count += 1 elif x.tag == 'menu': item_level = int(x.get("level", 0)) if item_level <= config.usage.setup_level.index: self.addMenu(m_list, x) count += 1 elif x.tag == "id": menuID = x.get("val") count = 0 if menuID is not None: # menuupdater? if menuupdater.updatedMenuAvailable(menuID): for x in menuupdater.getUpdatedMenu(menuID): if x[1] == count: description = x.get('description', '').encode('UTF-8') or None description = description and _(description) menupng = MenuEntryPixmap(menuID, self.png_cache, lastMenuID) m_list.append((x[0], boundFunction(self.runScreen, (x[2], x[3] + ", ")), x[4], description, menupng)) count += 1 self.menuID = menuID if config.ParentalControl.configured.value: ProtectedScreen.__init__(self) 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 m_list: if x[2] == plugin_menuid: m_list.remove(x) break description = plugins.getDescriptionForMenuEntryID(menuID, plugin_menuid) menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID) if len(l) > 4 and l[4]: m_list.append((l[0], boundFunction(l[1], self.session, self.close), l[2], l[3] or 50, description, menupng)) else: m_list.append((l[0], boundFunction(l[1], self.session), l[2], l[3] or 50, description, menupng)) # for the skin: first try a menu_<menuID>, then Menu self.skinName = [ ] if menuID is not None: if config.usage.menutype.value == 'horzanim' and findSkinScreen("Animmain"): self.skinName.append('Animmain') elif config.usage.menutype.value == 'horzicon' and findSkinScreen("Iconmain"): self.skinName.append('Iconmain') else: self.skinName.append('menu_' + menuID) self.skinName.append("Menu") self.menuID = menuID ProtectedScreen.__init__(self) if config.usage.menu_sort_mode.value == "user" and menuID == "mainmenu": plugin_list = [] id_list = [] for l in plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU ,PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]): l.id = (l.name.lower()).replace(' ','_') if l.id not in id_list: id_list.append(l.id) plugin_list.append((l.name, boundFunction(l.__call__, session), l.id, 200)) self.list = m_list if menuID is not None and config.usage.menu_sort_mode.value == "user": self.sub_menu_sort = NoSave(ConfigDictionarySet()) self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(self.menuID, "submenu") or {} idx = 0 for x in self.list: entry = list(self.list.pop(idx)) m_weight = self.sub_menu_sort.getConfigValue(entry[2], "sort") or entry[3] entry.append(m_weight) self.list.insert(idx, tuple(entry)) self.sub_menu_sort.changeConfigValue(entry[2], "sort", m_weight) idx += 1 self.full_list = list(m_list) if config.usage.menu_sort_mode.value == "a_z": # Sort by Name m_list.sort(key=self.sortByName) elif config.usage.menu_sort_mode.value == "user": self["blue"].setText(_("Edit mode on")) self.hide_show_entries() m_list = self.list else: # Sort by Weight m_list.sort(key=lambda x: int(x[3])) if config.usage.menu_show_numbers.value: m_list = [(str(x[0] + 1) + " " +x[1][0], x[1][1], x[1][2]) for x in enumerate(m_list)] self["menu"] = List(m_list) self["menu"].enableWrapAround = True if config.usage.menu_sort_mode.value == "user": self["menu"].onSelectionChanged.append(self.selectionChanged) self["actions"] = NumberActionMap(["OkCancelActions", "MenuActions", "NumberActions"], { "ok": self.okbuttonClick, "cancel": self.closeNonRecursive, "menu": self.closeRecursive, #"0": self.resetSortOrder, "0": self.keyNumberGlobal, "1": self.keyNumberGlobal, "2": self.keyNumberGlobal, "3": self.keyNumberGlobal, "4": self.keyNumberGlobal, "5": self.keyNumberGlobal, "6": self.keyNumberGlobal, "7": self.keyNumberGlobal, "8": self.keyNumberGlobal, "9": self.keyNumberGlobal }) if config.usage.menu_sort_mode.value == "user": self["MoveActions"] = ActionMap(["WizardActions"], { "left": self.keyLeft, "right": self.keyRight, "up": self.keyUp, "down": self.keyDown, }, -1 ) self["EditActions"] = ActionMap(["ColorActions"], { "green": self.keyGreen, "yellow": self.keyYellow, "blue": self.keyBlue, }) a = parent.get("title", "").encode("UTF-8") or None a = a and _(a) if a is None: a = _(parent.get("text", "").encode("UTF-8")) else: t_history.reset() self["title"] = StaticText(a) Screen.setTitle(self, a) self.menu_title = a self["thistory"] = StaticText(t_history.thistory) history_len = len(t_history.thistory) self["title0"] = StaticText('') self["title1"] = StaticText('') self["title2"] = StaticText('') if history_len < 13 : self["title0"] = StaticText(a) elif history_len < 21 : self["title0"] = StaticText('') self["title1"] = StaticText(a) else: self["title0"] = StaticText('') self["title1"] = StaticText('') self["title2"] = StaticText(a) if(t_history.thistory ==''): t_history.thistory = str(a) + ' > ' else: t_history.thistory = t_history.thistory + str(a) + ' > ' if config.usage.menutype.value == 'horzanim' and findSkinScreen("Animmain"): self['label1'] = StaticText() self['label2'] = StaticText() self['label3'] = StaticText() self['label4'] = StaticText() self['label5'] = StaticText() self.onShown.append(self.openTestA) elif config.usage.menutype.value == 'horzicon' and findSkinScreen("Iconmain"): self['label1'] = StaticText() self['label2'] = StaticText() self['label3'] = StaticText() self['label4'] = StaticText() self['label5'] = StaticText() self['label6'] = StaticText() self['label1s'] = StaticText() self['label2s'] = StaticText() self['label3s'] = StaticText() self['label4s'] = StaticText() self['label5s'] = StaticText() self['label6s'] = StaticText() self['pointer'] = Pixmap() self['pixmap1'] = Pixmap() self['pixmap2'] = Pixmap() self['pixmap3'] = Pixmap() self['pixmap4'] = Pixmap() self['pixmap5'] = Pixmap() self['pixmap6'] = Pixmap() self.onShown.append(self.openTestB) self.number = 0 self.nextNumberTimer = eTimer() self.nextNumberTimer.callback.append(self.okbuttonClick)
def __init__(self, session, parent): self.parentmenu = parent Screen.__init__(self, session) self.menuHorizontalSkinName = "MenuHorizontal" self.menuHorizontal = self.__class__.__name__ != "MenuSort" and config.usage.menu_style.value == "horizontal" and findSkinScreen(self.menuHorizontalSkinName) self.onHorizontalSelectionChanged = [] self["key_blue"] = StaticText("") HelpableScreen.__init__(self) self.menulength = 0 if not self.menuHorizontal: self["menu"] = List([]) self["menu"].enableWrapAround = True self.createMenuList() # for the skin: first try a menu_<menuID>, then Menu self.skinName = [] if self.menuHorizontal: if self.menuID: self.skinName.append(self.menuHorizontalSkinName + "_" + self.menuID) self.skinName.append(self.menuHorizontalSkinName) elif self.menuID: self.skinName.append("menu_" + self.menuID) self.skinName.append("Menu") ProtectedScreen.__init__(self) self["menuActions"] = HelpableActionMap(self, ["OkCancelActions", "MenuActions"], { "ok": (self.okbuttonClick, self.okbuttontext if hasattr(self, "okbuttontext") else _("Select the current menu item")), "cancel": (self.closeNonRecursive, self.exitbuttontext if hasattr(self, "exitbuttontext") else _("Exit menu")), "close": (self.closeRecursive, self.exitbuttontext if hasattr(self, "exitbuttontext") else _("Exit all menus")), "menu": (self.closeRecursive, _("Exit all menus")), }, prio=0, description=_("Common Menu Actions")) if self.__class__.__name__ != "MenuSort": self["menuActions2"] = HelpableNumberActionMap(self, ["NumberActions", "ColorActions"], { "0": (self.keyNumberGlobal, _("Direct menu item selection")), "1": (self.keyNumberGlobal, _("Direct menu item selection")), "2": (self.keyNumberGlobal, _("Direct menu item selection")), "3": (self.keyNumberGlobal, _("Direct menu item selection")), "4": (self.keyNumberGlobal, _("Direct menu item selection")), "5": (self.keyNumberGlobal, _("Direct menu item selection")), "6": (self.keyNumberGlobal, _("Direct menu item selection")), "7": (self.keyNumberGlobal, _("Direct menu item selection")), "8": (self.keyNumberGlobal, _("Direct menu item selection")), "9": (self.keyNumberGlobal, _("Direct menu item selection")), "blue": (self.keyBlue, _("Sort menu")), }, prio=0, description=_("Common Menu Actions")) title = parent.get("title", "") title = title and _(title) or _(parent.get("text", "")) title = self.__class__.__name__ == "MenuSort" and _("Menusort (%s)") % title or title self["title"] = StaticText(title) self.setTitle(title) self.number = 0 self.nextNumberTimer = eTimer() self.nextNumberTimer.callback.append(self.okbuttonClick) if len(self.list) == 1: self.onExecBegin.append(self.__onExecBegin) if self.menuHorizontal: self.initMenuHorizontal()