def createWidgets(): """Create all the setting widgets and tabs. This is done at startup and when addons are installed or uninstalled.""" # Start with a fresh category tab area. categoryArea.removeAllTabs() # An array that contains all the existing setting groups. global categoryTabs categoryTabs = [] # Create all the category icons. allSettingGroups = st.getSettingGroups() for group in allSettingGroups: area = categoryArea.addTab(group) categoryTabs.append((group, area)) # Addon settings all go inside one tab. area = categoryArea.addTab('addons-options') categoryTabs.append(('addons-options', area)) # The Addons tab contains another tab area, where we'll have one # tab for each configurable addon that will be loaded. global addonArea addonArea = area.createTabArea('addontab', sb.widget.tab.TabArea.STYLE_DROP_LIST) # Get all addons that exist, get their identifiers, and sort them # by name. allAddons = map(lambda a: a.getId(), ao.getAddons()) ao.sortIdentifiersByName(allAddons) for addon in allAddons: # Only create tabs for the addons that actually have settings # defined for them. if st.haveSettingsForAddon(addon): area = addonArea.addTab(addon) categoryTabs.append((addon, area)) # Each addon may have multiple pages inside its area. # These are determined by the groups. addonGroups = st.getSettingGroups(addon) if len(addonGroups) > 0: # Create tabs for each group. area = area.createTabArea(addon + '-tab', sb.widget.tab.TabArea.STYLE_HORIZ_ICON) for group in addonGroups: groupId = addon + '-' + group categoryTabs.append((groupId, area.addTab(groupId))) # Populate all the tabs with the setting widgets. When a profile # becomes active, the settings that are not applicable will be # disabled. Certain tab pages may be hidden if they are not # applicable. populateTabs() # Request others to create additional widgets in the tabs. requestPopulation() # Redo the layout. ui.getArea(SETTINGS).updateLayout()
def refreshList(): """Refreshes the list of addons.""" addonList.freeze() # Try to keep the old selection, if there is one. oldSelections = addonList.getSelectedItems() addonList.clear() # Filtering parameters. profile = pr.getActive() isDefaults = profile is pr.getDefaults() if tree.getSelectedItem(): filterCategory = ao.getCategory(tree.getSelectedItem()) else: filterCategory = None # Which addons are currently attached? defaultAddons = pr.getDefaults().getAddons() if not isDefaults: profileAddons = pr.getActive().getAddons() else: profileAddons = None # Categories that will be in bold font in category-tree. boldCategories = [] # Determine filtering options. mode = listFilter.getSelectedItem() onlyCompatible = False onlyPWAD = False alsoBoxes = False if 'compatible' in mode: onlyCompatible = True if 'pwad' in mode: onlyPWAD = True if 'with-boxes' in mode: alsoBoxes = True for addon in ao.getAddons(): # Does this addon pass the filter? if not isDefaults and onlyCompatible: if not addon.isCompatibleWith(pr.getActive()): # Cannot be listed. continue if onlyPWAD and (addon.getType() != 'addon-type-wad' or not addon.isPWAD()): continue # Has a category been selected? if filterCategory and not filterCategory.isAncestorOf( addon.getCategory()): # Not in the category. continue # Addons in boxes are not listed unless the correct category is selected. if not alsoBoxes and addon.getBox(): # Addons in boxes are only visible if the selected category is a box category. boxCateg = addon.getBox().getContentCategoryLongId() if not filterCategory: continue if filterCategory.getLongId().find(boxCateg) != 0: # Not the right category. continue # Passed the filter! id = addon.getId() versionStr = '' icon = determineIcon(addon, profile, defaultAddons, profileAddons) if language.isDefined(id + '-version'): versionStr = language.translate(id + '-version') name = language.translate(id) if addon.getBox() and alsoBoxes: name += ' ' + language.translate('addon-list-in-box') addonList.addItemWithColumns(id, icon, name, versionStr) # Reselect old items. oldSelections.reverse() for sel in oldSelections: addonList.selectItem(sel) addonList.ensureVisible(sel) sortList() updateButtons() addonList.unfreeze() # Update the counter text. countText.setText( language.expand(language.translate('addon-counter'), str(len(addonList.getItems())), str(ao.getAddonCount()))) # Update boldings in category-tree. # --TODO!-- global mustRefreshList mustRefreshList = False
def refreshList(): """Refreshes the list of addons.""" addonList.freeze() # Try to keep the old selection, if there is one. oldSelections = addonList.getSelectedItems() addonList.clear() # Filtering parameters. profile = pr.getActive() isDefaults = profile is pr.getDefaults() if tree.getSelectedItem(): filterCategory = ao.getCategory(tree.getSelectedItem()) else: filterCategory = None # Which addons are currently attached? defaultAddons = pr.getDefaults().getAddons() if not isDefaults: profileAddons = pr.getActive().getAddons() else: profileAddons = None # Categories that will be in bold font in category-tree. boldCategories = [] # Determine filtering options. mode = listFilter.getSelectedItem() onlyCompatible = False onlyPWAD = False alsoBoxes = False if 'compatible' in mode: onlyCompatible = True if 'pwad' in mode: onlyPWAD = True if 'with-boxes' in mode: alsoBoxes = True for addon in ao.getAddons(): # Does this addon pass the filter? if not isDefaults and onlyCompatible: if not addon.isCompatibleWith(pr.getActive()): # Cannot be listed. continue if onlyPWAD and (addon.getType() != 'addon-type-wad' or not addon.isPWAD()): continue # Has a category been selected? if filterCategory and not filterCategory.isAncestorOf(addon.getCategory()): # Not in the category. continue # Addons in boxes are not listed unless the correct category is selected. if not alsoBoxes and addon.getBox(): # Addons in boxes are only visible if the selected category is a box category. boxCateg = addon.getBox().getContentCategoryLongId() if not filterCategory: continue if filterCategory.getLongId().find(boxCateg) != 0: # Not the right category. continue # Passed the filter! id = addon.getId() versionStr = '' icon = determineIcon(addon, profile, defaultAddons, profileAddons) if language.isDefined(id + '-version'): versionStr = language.translate(id + '-version') name = language.translate(id) if addon.getBox() and alsoBoxes: name += ' ' + language.translate('addon-list-in-box') addonList.addItemWithColumns(id, icon, name, versionStr) # Reselect old items. oldSelections.reverse() for sel in oldSelections: addonList.selectItem(sel) addonList.ensureVisible(sel) sortList() updateButtons() addonList.unfreeze() # Update the counter text. countText.setText(language.expand(language.translate('addon-counter'), str(len(addonList.getItems())), str(ao.getAddonCount()))) # Update boldings in category-tree. # --TODO!-- global mustRefreshList mustRefreshList = False