コード例 #1
0
ファイル: MainWidget.py プロジェクト: Tayyib/uludag
    def createComponentList(self, packages, allComponent=False):
        # filter for selecting only apps with gui
        def appGuiFilter(pkg_name):
            if self.state == remove_state:
                package = PisiIface.get_installed_package(pkg_name)
                return "app:gui" in package.isA
            elif self.state == install_state:
                package = PisiIface.get_repo_package(pkg_name)
                return "app:gui" in package.isA

        self.componentsList.clear()
        self.componentDict.clear()

        # eliminate components that are not visible to users. This is achieved by a tag in component.xmls
        componentNames = [cname for cname in PisiIface.get_components() if PisiIface.is_component_visible(cname)]

        showOnlyGuiApp = self.settings.getBoolValue(Settings.general, "ShowOnlyGuiApp")

        # this list is required to find 'Others' group, that is group of packages not belong to any component
        componentPackages = []
        for componentName in componentNames:
            # just check the component existance
            try:
                component = PisiIface.get_union_component(componentName)
            except Exception:
                continue

            # get all packages of the component
            compPkgs = PisiIface.get_union_component_packages(componentName, walk=True)

            # find which packages belong to this component
            component_packages = list(set(packages).intersection(compPkgs))
            componentPackages += component_packages

            if self.state != upgrade_state and showOnlyGuiApp:
                    component_packages = filter(appGuiFilter, component_packages)

            if len(component_packages):
                # create ListView item for component
                item = KListViewItem(self.componentsList)
                if component.localName:
                    name = component.localName
                else:
                    name = component.name

                if component.icon:
                    icon = component.icon
                else:
                    icon = "package"

                item.setText(0,u"%s (%s)" % (name, len(component_packages)))
                item.setPixmap(0, KGlobal.iconLoader().loadIcon(icon, KIcon.Desktop,KIcon.SizeMedium))

                # create component object that has a list of its own packages and a summary
                self.componentDict[item] = Component(name, component_packages, component.summary)

        # Rest of the packages
        rest_packages = list(set(packages) - set(componentPackages))
        if self.state != upgrade_state and showOnlyGuiApp:
            rest_packages = filter(appGuiFilter, rest_packages)
        if rest_packages:
            item = KListViewItem(self.componentsList)
            name = i18n("Others")
            item.setText(0, u"%s (%s)" % (name, len(rest_packages)))
            item.setPixmap(0, KGlobal.iconLoader().loadIcon("package_applications",KIcon.Desktop,KIcon.SizeMedium))
            self.componentDict[item] = Component(name, rest_packages, name)

        # All of the component's packages
        if allComponent:
            item = KListViewItem(self.componentsList)
            name = i18n("All")
            item.setText(0, u"%s (%s)" % (name, len(packages)))
            item.setPixmap(0, KGlobal.iconLoader().loadIcon("package_network",KIcon.Desktop,KIcon.SizeMedium))
            self.componentDict[item] = Component(name, packages, name)
コード例 #2
0
ファイル: MainWidget.py プロジェクト: Tayyib/uludag
    def componentsReady(self):
        if not PisiIface.get_components(): # Repo metadata empty
            return False

        return True