コード例 #1
0
    def update_updates(self, pkgs):
        '''apps is a list to iter pkgname,
        cates is a dict to find what the category the pkg is
        '''
        model = self.get_model()
        length = len(pkgs)

        if pkgs:
            model.append((None,
                          None,
                          None,
                          None,
                          None,
                          '<span size="large" weight="bold">%s</span>' %
                          ngettext('Available %d Package Update',
                                   'Available %d Package Updates',
                                   length) % length,
                          None,
                          None))

            apps = []
            updates = []
            for pkg in pkgs:
                if pkg in APP_PARSER:
                    apps.append(pkg)
                else:
                    updates.append(pkg)

            for pkgname in apps:
                pixbuf = self.get_app_logo(APP_PARSER[pkgname]['logo'])

                package = PackageInfo(pkgname)
                appname = package.get_name()
                desc = APP_PARSER.get_summary(pkgname)

                self.append_app(False,
                        pixbuf,
                        pkgname,
                        appname,
                        desc,
                        0,
                        'update')

            for pkgname in updates:
                package = PACKAGE_WORKER.get_cache()[pkgname]

                self.append_update(False, package.name, package.summary)
        else:
            model.append((None,
                            None,
                            None,
                            None,
                            None,
                            '<span size="large" weight="bold">%s</span>' %
                            _('No Available Package Update'),
                            None,
                            None))
コード例 #2
0
    def update_updates(self, pkgs):
        '''apps is a list to iter pkgname,
        cates is a dict to find what the category the pkg is
        '''
        model = self.get_model()
        length = len(pkgs)

        if pkgs:
            iter = model.append()
            model.set(iter,
                      self.COLUMN_DISPLAY,
                      '<span size="large" weight="bold">%s</span>' %
                      ngettext('%d Package Update Available',
                               '%d Package Updates Available',
                               length) % length)

            apps = []
            updates = []
            for pkg in pkgs:
                if pkg in APP_PARSER:
                    apps.append(pkg)
                else:
                    updates.append(pkg)

            for pkgname in apps:
                pixbuf = self.get_app_logo(APP_PARSER[pkgname]['logo'])

                package = PackageInfo(pkgname)
                appname = package.get_name()
                desc = APP_PARSER.get_summary(pkgname)

                iter = model.append()
                model.set(iter,
                          self.COLUMN_INSTALLED, False,
                          self.COLUMN_ICON, pixbuf,
                          self.COLUMN_PKG, pkgname,
                          self.COLUMN_NAME, appname,
                          self.COLUMN_DESC, desc,
                          self.COLUMN_DISPLAY, '<b>%s</b>\n%s' % (appname, desc),
                          self.COLUMN_TYPE, 'update')

            for pkgname in updates:
                package = PACKAGE_WORKER.get_cache()[pkgname]

                self.append_update(False, package.name, package.summary)
        else:
            iter = model.append()
            model.set(iter,
                      self.COLUMN_DISPLAY,
                        '<span size="large" weight="bold">%s</span>' %
                        _('No Available Package Updates'))
コード例 #3
0
ファイル: appcenter.py プロジェクト: jonolumb/ubuntu-tweak
    def update_model(self, apps=None):
        '''apps is a list to iter pkgname,
        '''
        model = self.get_model()
        model.clear()

        app_parser = AppParser()

        if self.__status:
            self.__status.load_objects_from_parser(app_parser)

        if not apps:
            apps = app_parser.keys()

        for pkgname in apps:
            category = app_parser.get_category(pkgname)
            pixbuf = self.get_app_logo(app_parser[pkgname]['logo'])

            try:
                package = PackageInfo(pkgname)
                is_installed = package.check_installed()
                appname = package.get_name()
                desc = app_parser.get_summary(pkgname)
            except:
                # Confirm the invalid package isn't in the count
                # But in the future, Ubuntu Tweak should display the invalid package too
                if self.__status and not self.__status.get_read_status(pkgname):
                    self.__status.set_as_read(pkgname)
                continue

            if self.filter == None or self.filter == category:
                iter = model.append()
                if pkgname in self.to_add or pkgname in self.to_rm:
                    status = not is_installed
                    display = self.__fill_changed_display(appname, desc)
                else:
                    status = is_installed
                    if self.__status and not self.__status.get_read_status(pkgname):
                        display = '<b>%s <span foreground="#ff0000">(New!!!)</span>\n%s</b>' % (appname, desc)
                    else:
                        display = '<b>%s</b>\n%s' % (appname, desc)

                model.set(iter,
                          self.COLUMN_INSTALLED, status,
                          self.COLUMN_ICON, pixbuf,
                          self.COLUMN_PKG, pkgname,
                          self.COLUMN_NAME, appname,
                          self.COLUMN_DESC, desc,
                          self.COLUMN_DISPLAY, display,
                          self.COLUMN_CATE, category,
                          self.COLUMN_TYPE, 'app')
コード例 #4
0
    def update_model(self, apps=None):
        '''apps is a list to iter pkgname,
        '''
        model = self.get_model()
        model.clear()

        app_parser = AppParser()

        if self.__status:
            self.__status.load_objects_from_parser(app_parser)

        if not apps:
            apps = app_parser.keys()

        for pkgname in apps:
            category = app_parser.get_category(pkgname)
            pixbuf = self.get_app_logo(app_parser[pkgname]['logo'])

            try:
                package = PackageInfo(pkgname)
                is_installed = package.check_installed()
                appname = package.get_name()
                desc = app_parser.get_summary(pkgname)
            except:
                # Confirm the invalid package isn't in the count
                # But in the future, Ubuntu Tweak should display the invalid package too
                if self.__status and not self.__status.get_read_status(
                        pkgname):
                    self.__status.set_as_read(pkgname)
                continue

            if self.filter == None or self.filter == category:
                iter = model.append()
                if pkgname in self.to_add or pkgname in self.to_rm:
                    status = not is_installed
                    display = self.__fill_changed_display(appname, desc)
                else:
                    status = is_installed
                    if self.__status and not self.__status.get_read_status(
                            pkgname):
                        display = '<b>%s <span foreground="#ff0000">(New!!!)</span>\n%s</b>' % (
                            appname, desc)
                    else:
                        display = '<b>%s</b>\n%s' % (appname, desc)

                model.set(iter, self.COLUMN_INSTALLED, status,
                          self.COLUMN_ICON, pixbuf, self.COLUMN_PKG, pkgname,
                          self.COLUMN_NAME, appname, self.COLUMN_DESC, desc,
                          self.COLUMN_DISPLAY, display, self.COLUMN_CATE,
                          str(category), self.COLUMN_TYPE, 'app')
コード例 #5
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
    def update_updates(self, pkgs):
        '''apps is a list to iter pkgname,
        cates is a dict to find what the category the pkg is
        '''
        model = self.get_model()
        length = len(pkgs)

        if pkgs:
            iter = model.append()
            model.set(
                iter, self.COLUMN_DISPLAY,
                '<span size="large" weight="bold">%s</span>' %
                ngettext('%d Package Update Available',
                         '%d Package Updates Available', length) % length)

            apps = []
            updates = []
            for pkg in pkgs:
                if pkg in APP_PARSER:
                    apps.append(pkg)
                else:
                    updates.append(pkg)

            for pkgname in apps:
                pixbuf = self.get_app_logo(APP_PARSER[pkgname]['logo'])

                package = PackageInfo(pkgname)
                appname = package.get_name()
                desc = APP_PARSER.get_summary(pkgname)

                iter = model.append()
                model.set(iter, self.COLUMN_INSTALLED, False, self.COLUMN_ICON,
                          pixbuf, self.COLUMN_PKG, pkgname, self.COLUMN_NAME,
                          appname, self.COLUMN_DESC, desc, self.COLUMN_DISPLAY,
                          '<b>%s</b>\n%s' % (appname, desc), self.COLUMN_TYPE,
                          'update')

            for pkgname in updates:
                package = PACKAGE_WORKER.get_cache()[pkgname]

                self.append_update(False, package.name, package.summary)
        else:
            iter = model.append()
            model.set(
                iter, self.COLUMN_DISPLAY,
                '<span size="large" weight="bold">%s</span>' %
                _('No Available Package Updates'))
コード例 #6
0
ファイル: appcenter.py プロジェクト: ubuntutweak/ubuntu-tweak
    def update_model(self, apps=None):
        '''apps is a list to iter pkgname,
        '''
        def do_append(is_installed, pixbuf, pkgname, appname, desc, category):
            if pkgname in self.to_add or pkgname in self.to_rm:
                self.append_changed_app(not is_installed,
                        pixbuf,
                        pkgname,
                        appname,
                        desc,
                        category)
            else:
                self.append_app(is_installed,
                        pixbuf,
                        pkgname,
                        appname,
                        desc,
                        category)

        model = self.get_model()
        model.clear()

        app_parser = AppParser()

        if not apps:
            apps = app_parser.keys()

        for pkgname in apps:
            category = app_parser.get_category(pkgname)
            pixbuf = self.get_app_logo(app_parser[pkgname]['logo'])

            try:
                package = PackageInfo(pkgname)
                is_installed = package.check_installed()
                appname = package.get_name()
                desc = app_parser.get_summary(pkgname)
            except:
                continue

            if self.filter == None or self.filter == category:
                do_append(is_installed, pixbuf,
                          pkgname, appname, desc, category)
コード例 #7
0
    def filter_remove_packages(self, string):
        pkgs_list = [
            pkg.strip('-') for pkg in string.split()
            if pkg.endswith('-') and pkg != '--'
        ]

        new_list = []
        for pkg in pkgs_list:
            if PackageInfo(pkg).check_installed():
                new_list.append(pkg)

        return new_list
コード例 #8
0
    def on_action_clicked(self, cell, path):
        iter = self.model.get_iter_from_string(path)
        installed = self.model.get_value(iter, self.COLUMN_ACTION)
        task = self.model.get_value(iter, self.COLUMN_TASK)
        name = self.model.get_value(iter, self.COLUMN_NAME)

        self.set_busy()
        updateview = UpdateView()
        updateview.set_headers_visible(False)

        if installed == 'Installed':
            dialog = InfoDialog(
                _('You\'ve installed the <b>"%s"</b> task.' % name))
            dialog.add_button(_('Remove'), gtk.RESPONSE_YES)
            res = dialog.run()
            dialog.destroy()
            if res == gtk.RESPONSE_YES:
                dialog = WarningDialog(_(
                    'It is dangerous to remove a task, it may remove the desktop related packages.\nPlease only continue when you know what you are doing.'
                ),
                                       title=_("Dangerous!"))
                res = dialog.run()
                dialog.destroy()

                if res == gtk.RESPONSE_YES:
                    data = os.popen('tasksel -t remove %s' % task).read()
                    pkgs = self.filter_remove_packages(data)
                    updateview.update_updates(pkgs)
                    updateview.select_all_action(True)

                    dialog = self.create_task_dialog(
                        title=_('Packages will be removed'),
                        desc=_(
                            'You are going to remove the <b>"%s"</b> task.\nThe following packages will be remove.'
                            % name),
                        updateview=updateview)

                    res = dialog.run()
                    dialog.destroy()

                    if res == gtk.RESPONSE_YES:
                        PACKAGE_WORKER.perform_action(self.get_toplevel(), [],
                                                      updateview.to_add)
                        PACKAGE_WORKER.update_apt_cache(True)
                        self.update_model()
        else:
            list = os.popen('tasksel --task-packages %s' %
                            task).read().split('\n')
            list = [
                pkg for pkg in list
                if pkg.strip() and not PackageInfo(pkg).check_installed()
            ]

            updateview.update_updates(list)
            updateview.select_all_action(True)

            dialog = self.create_task_dialog(
                title=_('New packages will be installed'),
                desc=_(
                    'You are going to install the <b>"%s"</b> task.\nThe following packager will be installed.'
                    % name),
                updateview=updateview)

            res = dialog.run()
            dialog.destroy()

            if res == gtk.RESPONSE_YES:
                PACKAGE_WORKER.perform_action(self.get_toplevel(),
                                              updateview.to_add, [])
                PACKAGE_WORKER.update_apt_cache(True)
                self.update_model()

        print self.model.get_value(iter, self.COLUMN_ACTION)

        self.unset_busy()