Exemplo n.º 1
0
    def update_source_model(self, find='all', limit=-1, only_enabled=False):
        self.model.clear()
        sourceslist = self.get_sourceslist()
        enabled_list = []

        for source in sourceslist.list:
            if source.type == 'deb' and not source.disabled:
                enabled_list.append(source.uri)

        if self._status:
            self._status.load_objects_from_parser(SOURCE_PARSER)

        index = 0

        for id in SOURCE_PARSER:
            enabled = False
            index = index + 1
            url = SOURCE_PARSER.get_url(id)
            enabled = url in enabled_list

            if enabled:
                enabled_list.remove(url)

            if only_enabled:
                if not enabled:
                    continue
                elif not ppa.is_ppa(url):
                    continue
                else:
                    enabled = not enabled

            slug = SOURCE_PARSER.get_slug(id)
            comps = SOURCE_PARSER.get_comps(id)
            distro = SOURCE_PARSER.get_distro(id)
            category = SOURCE_PARSER.get_category(id)

            if find != 'all' and category != find:
                continue

            #TODO real top-10
            if limit > 0 and index >= limit:
                break

            name = SOURCE_PARSER.get_name(id)
            comment = SOURCE_PARSER.get_summary(id)
            pixbuf = get_source_logo_from_filename(SOURCE_PARSER[id]['logo'])
            website = SOURCE_PARSER.get_website(id)
            key = SOURCE_PARSER.get_key(id)

            if self._status and not self._status.get_read_status(slug):
                display = '<b>%s <span foreground="#ff0000">(New!!!)</span>\n%s</b>' % (
                    name, comment)
            else:
                display = '<b>%s</b>\n%s' % (name, comment)

            iter = self.model.append()
            self.model.set(
                iter,
                self.COLUMN_ENABLED,
                enabled,
                self.COLUMN_ID,
                id,
                self.COLUMN_CATE,
                category,
                self.COLUMN_URL,
                url,
                self.COLUMN_DISTRO,
                distro,
                self.COLUMN_COMPS,
                comps,
                self.COLUMN_COMMENT,
                comment,
                self.COLUMN_SLUG,
                slug,
                self.COLUMN_NAME,
                name,
                self.COLUMN_DISPLAY,
                display,
                self.COLUMN_LOGO,
                pixbuf,
                self.COLUMN_HOME,
                website,
                self.COLUMN_KEY,
                key,
            )

        path = os.path.join(consts.DATA_DIR, 'pixmaps/ppa-logo.png')

        pixbuf = icon.get_from_file(path, size=32)

        if enabled_list and only_enabled:
            for url in enabled_list:
                if ppa.is_ppa(url):
                    iter = self.model.append()
                    self.model.set(
                        iter,
                        self.COLUMN_ENABLED,
                        False,
                        self.COLUMN_ID,
                        9999,
                        self.COLUMN_CATE,
                        -1,
                        self.COLUMN_URL,
                        url,
                        self.COLUMN_DISTRO,
                        distro,
                        self.COLUMN_COMPS,
                        comps,
                        self.COLUMN_COMMENT,
                        '',
                        self.COLUMN_SLUG,
                        url,
                        self.COLUMN_NAME,
                        ppa.get_basename(url),
                        self.COLUMN_DISPLAY,
                        ppa.get_long_name(url),
                        self.COLUMN_LOGO,
                        pixbuf,
                        self.COLUMN_HOME,
                        ppa.get_homepage(url),
                        self.COLUMN_KEY,
                        '',
                    )
Exemplo n.º 2
0
    def update_source_model(self, find='all', limit=-1, only_enabled=False):
        self.model.clear()
        sourceslist = self.get_sourceslist()
        enabled_list = []

        for source in sourceslist.list:
            if source.type == 'deb' and not source.disabled:
                enabled_list.append(source.uri)

        if self._status:
            self._status.load_objects_from_parser(SOURCE_PARSER)

        index = 0

        for id in SOURCE_PARSER:
            enabled = False
            index = index + 1
            url = SOURCE_PARSER.get_url(id)
            enabled = url in enabled_list

            if enabled:
                enabled_list.remove(url)

            if only_enabled:
                if not enabled:
                    continue
                elif not ppa.is_ppa(url):
                    continue
                else:
                    enabled = not enabled

            slug = SOURCE_PARSER.get_slug(id)
            comps = SOURCE_PARSER.get_comps(id)
            distro = SOURCE_PARSER.get_distro(id)
            category = SOURCE_PARSER.get_category(id)
            
            if find != 'all' and category != find:
                continue

            #TODO real top-10
            if limit > 0 and index >= limit:
                break

            name = SOURCE_PARSER.get_name(id)
            comment = SOURCE_PARSER.get_summary(id)
            pixbuf = get_source_logo_from_filename(SOURCE_PARSER[id]['logo'])
            website = SOURCE_PARSER.get_website(id)
            key = SOURCE_PARSER.get_key(id)

            if self._status and not self._status.get_read_status(slug):
                display = '<b>%s <span foreground="#ff0000">(New!!!)</span>\n%s</b>' % (name, comment)
            else:
                display = '<b>%s</b>\n%s' % (name, comment)

            iter = self.model.append()
            self.model.set(iter,
                           self.COLUMN_ENABLED, enabled,
                           self.COLUMN_ID, id,
                           self.COLUMN_CATE, category,
                           self.COLUMN_URL, url,
                           self.COLUMN_DISTRO, distro,
                           self.COLUMN_COMPS, comps,
                           self.COLUMN_COMMENT, comment,
                           self.COLUMN_SLUG, slug,
                           self.COLUMN_NAME, name,
                           self.COLUMN_DISPLAY, display,
                           self.COLUMN_LOGO, pixbuf,
                           self.COLUMN_HOME, website,
                           self.COLUMN_KEY, key,
            )

        path = os.path.join(consts.DATA_DIR, 'pixmaps/ppa-logo.png')

        pixbuf = icon.get_from_file(path, size=32)

        if enabled_list and only_enabled:
            for url in enabled_list:
                if ppa.is_ppa(url):
                    iter = self.model.append()
                    self.model.set(iter,
                                   self.COLUMN_ENABLED, False,
                                   self.COLUMN_ID, 9999,
                                   self.COLUMN_CATE, -1,
                                   self.COLUMN_URL, url,
                                   self.COLUMN_DISTRO, distro,
                                   self.COLUMN_COMPS, comps,
                                   self.COLUMN_COMMENT, '',
                                   self.COLUMN_SLUG, url,
                                   self.COLUMN_NAME, ppa.get_basename(url),
                                   self.COLUMN_DISPLAY, ppa.get_long_name(url),
                                   self.COLUMN_LOGO, pixbuf,
                                   self.COLUMN_HOME, ppa.get_homepage(url),
                                   self.COLUMN_KEY, '',
                    )
Exemplo n.º 3
0
    def get_icon(self):
        path = os.path.join(consts.DATA_DIR, 'pixmaps/ppa-logo.png')

        return icon.get_from_file(path)