Esempio n. 1
0
File: Menu.py Progetto: popazerty/12
	def __init__(self, session, parent):
		Screen.__init__(self, session)
		list = []

		menuID = None
		count = 0
		for x in parent:	#walk through the actual nodelist
			if x.tag == 'item':
				item_level = int(x.get("level", 0))
				if item_level <= config.usage.setup_level.index:
					self.addItem(list, x)
					count += 1
			elif x.tag == 'menu':
				self.addMenu(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)
							list.append((x[0], boundFunction(self.runScreen, (x[2], x[3] + ", ")), x[4], description, menupng))
							count += 1

		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
				description = plugins.getDescriptionForMenuEntryID(menuID, plugin_menuid)
				menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
				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:
			self.skinName.append("menu_" + menuID)
		self.skinName.append("Menu")

		# Sort by Weight
		list.sort(key=lambda x: int(x[3]))

		self["menu"] = List(list)

		self["actions"] = NumberActionMap(["OkCancelActions", "MenuActions", "NumberActions"],
			{
				"ok": self.okbuttonClick,
				"cancel": self.closeNonRecursive,
				"menu": self.closeRecursive,
				"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
			})

		a = parent.get("title", "").encode("UTF-8") or None
		a = a and _(a)
		if a is None:
			a = _(parent.get("text", "").encode("UTF-8"))
		self["title"] = StaticText(a)
		self.menu_title = a
Esempio n. 2
0
 def createMenuList(self, showNumericHelp=False):
     self.menuID = self.parentMenu.get("key")
     self.menuList = []
     for menu in self.parentMenu:  # Walk through the menu node list.
         if not menu.tag:
             continue
         if menu.tag == "item":
             itemLevel = int(menu.get("level", 0))
             if itemLevel <= config.usage.setup_level.index:
                 data = self.addItem(menu)
                 if data:
                     self.menuList.append(data)
         elif menu.tag == "menu":
             itemLevel = int(menu.get("level", 0))
             if itemLevel <= config.usage.setup_level.index:
                 data = self.addMenu(menu)
                 if data:
                     self.menuList.append(data)
     if self.menuID:
         for plugin in plugins.getPluginsForMenu(self.menuID):  # Plugins.
             # print("[Menu] DEBUG 1: Plugin data=%s." % str(plugin))
             pluginKey = plugin[
                 PLUGIN_KEY]  # Check if a plugin overrides an existing menu.
             for entry in self.menuList:
                 if entry[PLUGIN_KEY] == pluginKey:
                     self.menuList.remove(entry)
                     break
             description = plugins.getDescriptionForMenuEntryID(
                 self.menuID, pluginKey
             )  # It is assumed that description is already translated by the plugin!
             if "%s %s" in description:
                 description = description % (DISPLAY_BRAND, DISPLAY_MODEL)
             image = self.getMenuEntryImage(plugin[PLUGIN_KEY], lastKey)
             if len(plugin) > PLUGIN_CLOSEALL and plugin[
                     PLUGIN_CLOSEALL]:  # Was "len(plugin) > 4".
                 self.menuList.append(
                     (plugin[PLUGIN_TEXT],
                      boundFunction(plugin[PLUGIN_MODULE], self.session,
                                    self.close), plugin[PLUGIN_KEY],
                      plugin[PLUGIN_WEIGHT] or 50, description, image))
             else:
                 self.menuList.append(
                     (plugin[PLUGIN_TEXT],
                      boundFunction(plugin[PLUGIN_MODULE],
                                    self.session), plugin[PLUGIN_KEY],
                      plugin[PLUGIN_WEIGHT] or 50, description, image))
     if config.usage.menuSortOrder.value == "user" and self.menuID == "mainmenu":
         idList = []
         for plugin in plugins.getPlugins([
                 PluginDescriptor.WHERE_PLUGINMENU,
                 PluginDescriptor.WHERE_EXTENSIONSMENU,
                 PluginDescriptor.WHERE_EVENTINFO
         ]):
             # print("[Menu] DEBUG 2: Plugin data=%s." % str(plugin))
             plugin.id = (plugin.name.lower()).replace(" ", "_")
             if plugin.id not in idList:
                 idList.append(plugin.id)
     if self.menuID is not None and config.usage.menuSortOrder.value == "user":
         self.subMenuSort = NoSave(ConfigDictionarySet())
         self.subMenuSort.value = config.usage.menu_sort_weight.getConfigValue(
             self.menuID, "submenu") or {}
         for index, entry in enumerate(self.menuList):
             data = list(self.menuList.pop(index))
             sort = self.subMenuSort.getConfigValue(
                 data[MENU_KEY], "sort") or data[MENU_WEIGHT]
             data.append(sort)
             self.menuList.insert(index, tuple(data))
             self.subMenuSort.changeConfigValue(data[MENU_KEY], "sort",
                                                sort)
         self.fullMenuList = list(self.menuList)
     if config.usage.menuSortOrder.value == "alpha":  # Sort by menu item text.
         self.menuList.sort(key=lambda x: x[MENU_TEXT].lower())
     elif config.usage.menuSortOrder.value == "user":  # Sort by user defined sequence.
         self["key_blue"].setText(_("Edit Mode On"))
         self.hideShowEntries()
     else:  # Sort by menu item weight.
         self.menuList.sort(key=lambda x: int(x[MENU_WEIGHT]))
     self.setMenuList(self.menuList)
Esempio n. 3
0
    def __init__(self, session, parent):
        Screen.__init__(self, session)
        list = []

        menuID = None
        count = 0
        for x in parent:  #walk through the actual nodelist
            if x.tag == 'item':
                item_level = int(x.get("level", 0))
                if item_level <= config.usage.setup_level.index:
                    self.addItem(list, x)
                    count += 1
            elif x.tag == 'menu':
                self.addMenu(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)
                            list.append((x[0],
                                         boundFunction(self.runScreen,
                                                       (x[2], x[3] + ", ")),
                                         x[4], description, menupng))
                            count += 1

        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
                description = plugins.getDescriptionForMenuEntryID(
                    menuID, plugin_menuid)
                menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
                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:
            self.skinName.append("menu_" + menuID)
        self.skinName.append("Menu")

        # Sort by Weight
        list.sort(key=lambda x: int(x[3]))

        self._list = List(list)
        self._list.onSelectionChanged.append(self._onSelectionChanged)
        self["menu"] = self._list
        self["pixmap"] = Pixmap()
        self["description"] = StaticText()

        self["actions"] = NumberActionMap(
            ["OkCancelActions", "MenuActions", "NumberActions"], {
                "ok": self.okbuttonClick,
                "cancel": self.closeNonRecursive,
                "menu": self.closeRecursive,
                "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
            })

        a = parent.get("title", "").encode("UTF-8") or None
        a = a and _(a)
        if a is None:
            a = _(parent.get("text", "").encode("UTF-8"))
        self["title"] = StaticText(a)
        self.menu_title = a
        self.onLayoutFinish.append(self._onLayoutFinish)
Esempio n. 4
0
	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 = [ ]
                skfile = '/usr/share/enigma2/' + config.skin.primary_skin.value
                f1 = open(skfile, 'r')
                self.sktxt = f1.read()
                f1.close()
                if menuID is not None:
                        if '<screen name="Animmain" ' in self.sktxt and config.usage.menutype.value == 'horzanim':
                                self.skinName.append('Animmain')
                        elif '<screen name="Iconmain" ' in self.sktxt and config.usage.menutype.value == 'horzicon':
                                if '<screen name="Iconmain" ' in self.sktxt:
                                        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 '<screen name="Animmain" ' in self.sktxt and config.usage.menutype.value == 'horzanim':
                        self.onShown.append(self.openTestA)
                elif '<screen name="Iconmain" ' in self.sktxt and config.usage.menutype.value == 'horzicon':
                        if '<screen name="Iconmain" ' in self.sktxt:
                                self.onShown.append(self.openTestB)

		self.number = 0
		self.nextNumberTimer = eTimer()
		self.nextNumberTimer.callback.append(self.okbuttonClick)
Esempio n. 5
0
    def createMenuList(self, showNumericHelp=False):
        self.menuList = []
        self.menuID = None
        for x in self.parentMenu:  # walk through the actual nodelist
            if not x.tag:
                continue
            if x.tag == "item":
                itemLevel = int(x.get("level", 0))
                if itemLevel <= config.usage.setup_level.index:
                    self.addItem(self.menuList, x)
                    count += 1
            elif x.tag == "menu":
                itemLevel = int(x.get("level", 0))
                if itemLevel <= config.usage.setup_level.index:
                    self.addMenu(self.menuList, x)
                    count += 1
            elif x.tag == "id":
                self.menuID = x.get("val")
                count = 0

            if self.menuID:
                # menuupdater?
                if menuUpdater.updatedMenuAvailable(self.menuID):
                    for x in menuUpdater.getUpdatedMenu(self.menuID):
                        if x[1] == count:
                            description = _(
                                x.get("description", "").encode(
                                    "UTF-8", "ignore")) if PY2 else _(
                                        x.get("description", ""))
                            menupng = MenuEntryPixmap(self.menuID,
                                                      self.png_cache,
                                                      lastMenuID)
                            self.menuList.append(
                                (x[0],
                                 boundFunction(self.runScreen,
                                               (x[2], x[3] + ", ")), x[4],
                                 description, menupng))
                            count += 1

        if self.menuID:
            # plugins
            for l in plugins.getPluginsForMenu(self.menuID):
                # check if a plugin overrides an existing menu
                plugin_menuid = l[2]
                for x in self.menuList:
                    if x[2] == plugin_menuid:
                        self.menuList.remove(x)
                        break
                description = plugins.getDescriptionForMenuEntryID(
                    self.menuID, plugin_menuid)
                menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
                if len(l) > 4 and l[4]:
                    self.menuList.append(
                        (l[0], boundFunction(l[1], self.session,
                                             self.close), l[2], l[3]
                         or 50, description, menupng))
                else:
                    self.menuList.append(
                        (l[0], boundFunction(l[1], self.session), l[2], l[3]
                         or 50, description, menupng))

        if config.usage.menu_sort_mode.value == "user" and self.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__,
                                               self.session), l.id, 200))

        if self.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.menuList:
                entry = list(self.menuList.pop(idx))
                m_weight = self.sub_menu_sort.getConfigValue(
                    entry[2], "sort") or entry[3]
                entry.append(m_weight)
                self.menuList.insert(idx, tuple(entry))
                self.sub_menu_sort.changeConfigValue(entry[2], "sort",
                                                     m_weight)
                idx += 1
            self.full_list = list(self.menuList)

        if config.usage.menu_sort_mode.value == "a_z":
            # Sort by Name
            self.menuList.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == "user":
            self["blue"].setText(_("Edit Mode On"))
            self.hide_show_entries()
        else:
            # Sort by Weight
            self.menuList.sort(key=lambda x: int(x[3]))

        if config.usage.menu_show_numbers.value:
            self.menuList = [(str(x[0] + 1) + " " + x[1][0], x[1][1], x[1][2])
                             for x in enumerate(self.menuList)]

        self["menu"].setList(self.menuList)
Esempio n. 6
0
    def __init__(self, session, parent):
        Screen.__init__(self, session)
        self.sort_mode = False
        self.selected_entry = None
        self.sub_menu_sort = None
        self['key_green'] = Label()
        self['key_yellow'] = Label()
        self['key_blue'] = Label()
        m_list = []
        menuID = None
        for x in parent:
            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:
                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:
            for l in plugins.getPluginsForMenu(menuID):
                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))

        self.skinName = []
        if menuID is not None:
            if config.usage.menutype.value == 'horzanim' and skin.dom_screens.has_key(
                    'Animmain'):
                self.skinName.append('Animmain')
            elif config.usage.menutype.value == 'horzicon' and skin.dom_screens.has_key(
                    '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':
            m_list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == 'user':
            self['key_blue'].setText(_('Edit mode on'))
            self.hide_show_entries()
            m_list = self.list
        else:
            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.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 skin.dom_screens.has_key(
                '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 skin.dom_screens.has_key(
                '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)
Esempio n. 7
0
    def createMenuList(self):
        self.list = []
        self.menuID = None
        count = 0
        for x in self.parentmenu:  #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(self.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(self.list, x)
                    count += 1
            elif x.tag == 'id':
                self.menuID = x.get('val')
                count = 0
            if self.menuID is not None:
                if menuupdater.updatedMenuAvailable(self.menuID):
                    for x in menuupdater.getUpdatedMenu(self.menuID):
                        if x[1] == count:
                            description = x.get('description',
                                                '').encode('UTF-8') or None
                            description = description and _(description)
                            menupng = MenuEntryPixmap(self.menuID,
                                                      self.png_cache,
                                                      lastMenuID)
                            self.list.append(
                                (x[0],
                                 boundFunction(self.runScreen,
                                               (x[2], x[3] + ', ')), x[4],
                                 description, menupng))
                            count += 1

        if self.menuID is not None:
            for l in plugins.getPluginsForMenu(self.menuID):
                plugin_menuid = l[2]
                for x in self.list:
                    if x[2] == plugin_menuid:
                        self.list.remove(x)
                        break

                description = plugins.getDescriptionForMenuEntryID(
                    self.menuID, plugin_menuid)
                menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
                self.list.append((l[0], boundFunction(l[1],
                                                      self.session), l[2], l[3]
                                  or 50, description, menupng))

        if config.usage.menu_sort_mode.value == 'user' and self.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__,
                                               self.session), l.id, 200))

        if self.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(self.list)
        if config.usage.menu_sort_mode.value == 'a_z':
            self.list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == 'user':
            self.hide_show_entries()
        else:
            self.list.sort(key=lambda x: int(x[3]))

        if config.usage.menu_show_numbers.value:
            self.list = [(str(x[0] + 1) + " " + x[1][0], x[1][1], x[1][2])
                         for x in enumerate(self.list)]

        self['menu'].updateList(self.list)
Esempio n. 8
0
    def createMenuList(self):
        self.list = []
        self.menuID = None
        count = 0
        for x in self.parentmenu: #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(self.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(self.list, x)
                    count += 1
            elif x.tag == 'id':
                self.menuID = x.get('val')
                count = 0
            if self.menuID is not None:
                if menuupdater.updatedMenuAvailable(self.menuID):
                    for x in menuupdater.getUpdatedMenu(self.menuID):
                        if x[1] == count:
                            description = x.get('description', '').encode('UTF-8') or None
                            description = description and _(description)
                            menupng = MenuEntryPixmap(self.menuID, self.png_cache, lastMenuID)
                            self.list.append((x[0], boundFunction(self.runScreen, (x[2], x[3] + ', ')),
                             x[4],
                             description,
                             menupng))
                            count += 1

        if self.menuID is not None:
            for l in plugins.getPluginsForMenu(self.menuID):
                plugin_menuid = l[2]
                for x in self.list:
                    if x[2] == plugin_menuid:
                        self.list.remove(x)
                        break

                description = plugins.getDescriptionForMenuEntryID(self.menuID, plugin_menuid)
                menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
                self.list.append((l[0],
                 boundFunction(l[1], self.session),
                 l[2],
                 l[3] or 50,
                 description,
                 menupng))

        if config.usage.menu_sort_mode.value == 'user' and self.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__, self.session),
                     l.id,
                     200))

        if self.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(self.list)
        if config.usage.menu_sort_mode.value == 'a_z':
            self.list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == 'user':
            self.hide_show_entries()
        else:
            self.list.sort(key=lambda x: int(x[3]))

        if config.usage.menu_show_numbers.value:
            self.list = [(str(x[0] + 1) + " " +x[1][0], x[1][1], x[1][2]) for x in enumerate(self.list)]

        self['menu'].updateList(self.list)