コード例 #1
0
    def set_enable(self, key, enable):
        # To make other module use the source enable feature, move the logical to here
        # So that other module can call
        gpg_key = self.get_key(key)
        url = self.get_url(key)
        distro = self.get_distro(key)
        comps = self.get_comps(key)
        comment = self.get_name(key)
        package = self.get_slug(key)

        if gpg_key:
            proxy.add_apt_key_from_content(gpg_key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps,
                                               comment, enable, package)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        return str(result)
コード例 #2
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
    def set_enable(self, key, enable):
        # To make other module use the source enable feature, move the logical to here
        # So that other module can call
        gpg_key = self.get_key(key)
        url = self.get_url(key)
        distro = self.get_distro(key)
        comps = self.get_comps(key)
        comment = self.get_name(key)

        if ppa.is_ppa(url):
            file_name = '%s-%s' % (ppa.get_source_file_name(url), distro)
        else:
            file_name = self.get_slug(key)

        if gpg_key:
            proxy.add_apt_key_from_content(gpg_key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps, comment,
                                               enable, file_name)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        return str(result)
コード例 #3
0
    def do_source_enable(self, iter, enable):
        """
        Do the really source enable or disable action by iter
        Only emmit signal when source is changed
        """
        model = self.modelfilter.get_model()

        url = model.get_value(iter, self.COLUMN_URL)
        icon = model.get_value(iter, self.COLUMN_LOGO)
        distro = model.get_value(iter, self.COLUMN_DISTRO)
        comment = model.get_value(iter, self.COLUMN_NAME)
        package = model.get_value(iter, self.COLUMN_SLUG)
        comps = model.get_value(iter, self.COLUMN_COMPS)
        key = model.get_value(iter, self.COLUMN_KEY)

        pre_status = self.get_sourcelist_status(url)

        if key:
            proxy.add_apt_key_from_content(key)

        if not comps and distro:
            distro = distro + "/"
        elif not comps and not distro:
            distro = "./"

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps, comment, enable, package)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        if str(result) == "enabled":
            model.set(iter, self.COLUMN_ENABLED, True)
        else:
            model.set(iter, self.COLUMN_ENABLED, False)

        if pre_status != enable:
            self.emit("sourcechanged")

        if enable:
            notify = pynotify.Notification(
                _("New source has been enabled"),
                _("%s is enabled now, Please click the refresh button to update the application cache.") % comment,
            )
            notify.set_icon_from_pixbuf(icon)
            notify.set_hint_string("x-canonical-append", "")
            notify.show()
コード例 #4
0
    def do_source_enable(self, iter, enable):
        '''
        Do the really source enable or disable action by iter
        Only emmit signal when source is changed
        '''
        model = self.modelfilter.get_model()

        url = model.get_value(iter, self.COLUMN_URL)
        icon = model.get_value(iter, self.COLUMN_LOGO)
        distro = model.get_value(iter, self.COLUMN_DISTRO)
        comment = model.get_value(iter, self.COLUMN_NAME)
        package = model.get_value(iter, self.COLUMN_SLUG)
        comps = model.get_value(iter, self.COLUMN_COMPS)
        key = model.get_value(iter, self.COLUMN_KEY)

        pre_status = self.get_sourcelist_status(url)

        if key:
            proxy.add_apt_key_from_content(key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        if TweakSettings.get_separated_sources():
            result = proxy.set_separated_entry(url, distro, comps,
                                               comment, enable, package)
        else:
            result = proxy.set_entry(url, distro, comps, comment, enable)

        if str(result) == 'enabled':
            model.set(iter, self.COLUMN_ENABLED, True)
        else:
            model.set(iter, self.COLUMN_ENABLED, False)

        if pre_status != enable:
            self.emit('sourcechanged')

        if enable:
            notify.update(_('New source has been enabled'),
                          _('%s is enabled now, Please click the refresh button to update the application cache.') % comment)
            notify.set_icon_from_pixbuf(icon)
            notify.show()