Exemplo n.º 1
0
def updateButtons():
    items = addonList.getSelectedItems()
    if len(items) == 0:
        settingsButton.disable()
        uninstallButton.disable()
        infoButton.disable()
        return

    if len(items) > 1:
        # More than one.
        settingsButton.disable()

        canUninstall = False
        # At least one uninstallable?
        for addon in items:
            if ao.isUninstallable(addon):
                uninstallButton.enable()
                canUninstall = True
                break
        if not canUninstall:
            uninstallButton.disable()

        infoButton.disable()
        return

    sel = items[0]
    settingsButton.enable(st.haveSettingsForAddon(sel))
    infoButton.enable()

    # Can this be uninstalled?
    uninstallButton.enable(ao.isUninstallable(sel))
Exemplo n.º 2
0
def updateButtons():
    items = addonList.getSelectedItems()
    if len(items) == 0:
        settingsButton.disable()
        uninstallButton.disable()
        infoButton.disable()
        return
        
    if len(items) > 1:
        # More than one.
        settingsButton.disable() 

        canUninstall = False
        # At least one uninstallable?
        for addon in items:
            if ao.isUninstallable(addon):
                uninstallButton.enable()
                canUninstall = True
                break
        if not canUninstall:
            uninstallButton.disable()

        infoButton.disable()
        return

    sel = items[0]
    settingsButton.enable(st.haveSettingsForAddon(sel))
    infoButton.enable()
        
    # Can this be uninstalled?
    uninstallButton.enable(ao.isUninstallable(sel))
Exemplo n.º 3
0
def handleNotification(event):
    """This is called when someone sends a notification event.

    @param event An events.Notify object.
    """
    global tabVisible
    global mustRefreshList

    if event.hasId('addon-list-icon-click'):
        # Clicking on the list icon will attach/detach the addon.
        profile = pr.getActive()
        if event.item in profile.getUsedAddons():
            profile.dontUseAddon(event.item)
        else:
            profile.useAddon(event.item)

    elif event.hasId('addon-attached') or event.hasId('addon-detached'):
        refreshItemInList(event.getAddon())

    elif event.hasId('addon-list-filter-mode-selected'):
        refreshListIfVisible()

    elif event.hasId('addon-list-check-column-click') or \
         event.hasId('addon-list-name-column-click') or \
         event.hasId('addon-list-version-column-click'):
        global listSortMode
        if 'check' in event.getId():
            listSortMode = 'check'
        elif 'version' in event.getId():
            listSortMode = 'version'
        else:
            listSortMode = 'name'
        sortList()

    elif event.hasId('tab-selected'):
        # If there is a refresh pending, do it now that the tab has
        # been selected.
        if event.getSelection() == ADDONS:
            tabVisible = True
            if mustRefreshList:
                refreshList()
        else:
            tabVisible = False

    elif event.hasId('active-profile-changed'):
        refreshListIfVisible()

        # Fill the tree with an updated listing of addons.
        #tree.populateWithAddons(pr.getActive())
        #settingsButton.disable()

    elif event.hasId('addon-list-popup-update-request'):
        # The addon list is requesting an updated popup menu.
        # Menu items depend on which items are selected.
        items = addonList.getSelectedItems()
        menu = []

        if len(items) == 1:
            # One addon is selected.
            if ao.get(items[0]).getBox():
                menu += ['addon-show-parent-box']
            if ao.get(items[0]).getType() == 'addon-type-box':
                menu += ['addon-show-box-category']
            # Info is always available for all addons.
            menu += ['addon-info']
            if st.haveSettingsForAddon(items[0]):
                menu += ['addon-settings']
        elif len(items) > 1:
            # Multiple addons selected.
            menu += [
                'addon-list-check-selected', 'addon-list-uncheck-selected'
            ]

        if len(items) > 0: menu += ['uninstall-addon']

        # Append the common items.
        if len(menu) > 0: menu.append('-')
        menu += ['install-addon']
        menu += ['load-order']

        menu += ['-', 'addon-list-check-all', 'addon-list-uncheck-all']

        addonList.setPopupMenu(menu)

    elif event.hasId('category-tree-selected'):
        refreshListIfVisible()
        # Enable the settings button if there are settings for this
        # addon.
        #if st.haveSettingsForAddon(event.getSelection()):
        #    settingsButton.enable()
        #else:
        #    settingsButton.disable()

        # Can this be uninstalled?
        #uninstallButton.enable(ao.exists(event.getSelection()) and
        #                       ao.get(event.getSelection()).getBox() == None)

    elif event.hasId('addon-list-selected') or event.hasId(
            'addon-list-deselected'):
        updateButtons()

    elif event.hasId('addon-installed'):
        refreshCategories()
        refreshListIfVisible()
        #tree.selectAddon(event.addon)

    elif event.hasId('addon-database-reloaded'):
        refreshCategories()
        refreshListIfVisible()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
def handleNotification(event):
    """This is called when someone sends a notification event.

    @param event An events.Notify object.
    """
    global tabVisible
    global mustRefreshList

    if event.hasId('addon-list-icon-click'):
        # Clicking on the list icon will attach/detach the addon.
        profile = pr.getActive()
        if event.item in profile.getUsedAddons():
            profile.dontUseAddon(event.item)
        else:
            profile.useAddon(event.item)
            
    elif event.hasId('addon-attached') or event.hasId('addon-detached'):
        refreshItemInList(event.getAddon())

    elif event.hasId('addon-list-filter-mode-selected'):
        refreshListIfVisible()

    elif event.hasId('addon-list-check-column-click') or \
         event.hasId('addon-list-name-column-click') or \
         event.hasId('addon-list-version-column-click'):
        global listSortMode
        if 'check' in event.getId():
            listSortMode = 'check'
        elif 'version' in event.getId():
            listSortMode = 'version'
        else:
            listSortMode = 'name'
        sortList()

    elif event.hasId('tab-selected'):
        # If there is a refresh pending, do it now that the tab has 
        # been selected.
        if event.getSelection() == ADDONS:
            tabVisible = True
            if mustRefreshList:
                refreshList()
        else:
            tabVisible = False
    
    elif event.hasId('active-profile-changed'):
        refreshListIfVisible()
            
        # Fill the tree with an updated listing of addons.
        #tree.populateWithAddons(pr.getActive())
        #settingsButton.disable()

    elif event.hasId('addon-list-popup-update-request'):
        # The addon list is requesting an updated popup menu.
        # Menu items depend on which items are selected.
        items = addonList.getSelectedItems()
        menu = []
        
        if len(items) == 1:
            # One addon is selected.
            if ao.get(items[0]).getBox():
                menu += ['addon-show-parent-box']
            if ao.get(items[0]).getType() == 'addon-type-box':
                menu += ['addon-show-box-category']
            # Info is always available for all addons.
            menu += ['addon-info'] 
            if st.haveSettingsForAddon(items[0]):
                menu += ['addon-settings']
        elif len(items) > 1:
            # Multiple addons selected.
            menu += ['addon-list-check-selected',
                     'addon-list-uncheck-selected']

        if len(items) > 0: menu += ['uninstall-addon']

        # Append the common items.
        if len(menu) > 0: menu.append('-')
        menu += ['install-addon'] 
        menu += ['load-order']

        menu += ['-', 'addon-list-check-all', 'addon-list-uncheck-all']
        
        addonList.setPopupMenu(menu)

    elif event.hasId('category-tree-selected'):
        refreshListIfVisible()
        # Enable the settings button if there are settings for this
        # addon.
        #if st.haveSettingsForAddon(event.getSelection()):
        #    settingsButton.enable()
        #else:
        #    settingsButton.disable()

        # Can this be uninstalled?
        #uninstallButton.enable(ao.exists(event.getSelection()) and
        #                       ao.get(event.getSelection()).getBox() == None)

    elif event.hasId('addon-list-selected') or event.hasId('addon-list-deselected'):
        updateButtons()

    elif event.hasId('addon-installed'):
        refreshCategories()
        refreshListIfVisible()
        #tree.selectAddon(event.addon)

    elif event.hasId('addon-database-reloaded'):
        refreshCategories()
        refreshListIfVisible()