def clean_cruft(self, parent, cruft_list):
     set_busy(parent)
     dialog = CleanConfigDialog(parent, [cruft.get_name() for cruft in cruft_list])
     dialog.run()
     dialog.destroy()
     self.emit('cleaned', True)
     unset_busy(parent)
示例#2
0
    def on_purge_ppa_button_clicked(self, widget):
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        set_busy(self)
        name_list = []
        url_list = []
        log.debug("self.sourceview.to_purge: %s" % self.sourceview.to_purge)
        for url in self.sourceview.to_purge:
            name_list.append(ppa.get_short_name(url))
            url_list.append(url)

        log.debug("PPAs to purge: url_list: %s" % url_list)

        package_view = DowngradeView(self)
        package_view.update_downgrade_model(url_list)
        sw = Gtk.ScrolledWindow(shadow_type=Gtk.ShadowType.IN)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _(
                "It's safe to purge the PPA, no packages need to be downgraded."
            )
            sw.hide()
        else:
            message = _(
                "To safely purge the PPA, the following packages must be downgraded."
            )
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(title=_("You're going to purge \"%s\":") %
                                ', '.join(name_list),
                                message=message)
        dialog.set_resizable(True)
        dialog.get_content_area().pack_start(sw, True, True, 0)
        dialog.show_all()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages
        #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == Gtk.ResponseType.YES:
            log.debug("The select pkgs is: %s", str(select_pkgs))
            worker = AptWorker(widget.get_toplevel(),
                               finish_handler=self.on_package_work_finished,
                               data={
                                   'parent': self,
                                   'url_list': url_list
                               })
            worker.downgrade_packages(select_pkgs)
        else:
            unset_busy(self)
示例#3
0
 def on_button_clicked(self, widget):
     set_busy(widget.get_toplevel())
     try:
         yield self._action.do_authenticate()
     except Exception, e:
         import logging
         logging.getLogger('PolkitButton').debug(e)
         unset_busy(widget.get_toplevel())
         return
示例#4
0
 def on_button_clicked(self, widget):
     set_busy(widget.get_toplevel())
     try:
         yield self._action.do_authenticate()
     except Exception, e:
         import logging
         logging.getLogger('PolkitButton').debug(e)
         unset_busy(widget.get_toplevel())
         return
示例#5
0
 def on_update_work_finished(self, transaction, status, kwargs):
     parent = kwargs["parent"]
     proxy.update_apt_cache(True)
     if proxy.is_package_upgradable(self.current_app) or (
         not proxy.is_package_installed(self.current_app) and proxy.is_package_avaiable(self.current_app)
     ):
         worker = AptWorker(self.get_toplevel(), finish_handler=self.on_package_work_finished, data={"parent": self})
         worker.install_packages([self.current_app])
     else:
         unset_busy(parent)
         self.reset_install_button()
示例#6
0
    def clean_cruft(self, parent, cruft_list):
        set_busy(parent)

        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        name_list = []
        url_list = []
        for cruft in cruft_list:
            name_list.append(ppa.get_short_name(cruft.get_uri()))
            url_list.append(cruft.get_uri())

        package_view = DowngradeView(self)
        package_view.update_model(url_list)
        sw = Gtk.ScrolledWindow(shadow_type=Gtk.ShadowType.IN)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _("It's safe to purge the PPA, no packages need to be downgraded.")
            sw.hide()
        else:
            message = _("To safely purge the PPA, the following packages must be downgraded.")
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(message=message,
                                title=_("You're going to purge: %s") % ', '.join(name_list))
        dialog.set_resizable(True)
        dialog.get_content_area().pack_start(sw, True, True, 0)
        dialog.show()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages
        #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == Gtk.ResponseType.YES:
            log.debug("The select pkgs is: %s", str(select_pkgs))
            dialog = CleanPpaDialog(parent, select_pkgs, url_list)
            dialog.run()
            dialog.destroy()
            if dialog.error:
                log.error("Error: %s" % dialog.error)
                ErrorDialog(dialog.error).launch()
        # TODO refresh source?

        self.emit('cleaned', True)
        unset_busy(parent)
示例#7
0
 def on_update_work_finished(self, transaction, status, kwargs):
     parent = kwargs['parent']
     proxy.update_apt_cache(True)
     if proxy.is_package_upgradable(self.current_app) or \
        (not proxy.is_package_installed(self.current_app) and \
         proxy.is_package_avaiable(self.current_app)):
         worker = AptWorker(self.get_toplevel(),
                            finish_handler=self.on_package_work_finished,
                            data={'parent': self})
         worker.install_packages([self.current_app])
     else:
         unset_busy(parent)
         self.reset_install_button()
示例#8
0
    def on_package_work_finished(self, transaction, status, kwargs):
        to_add, to_rm = kwargs['add_and_rm']
        parent = kwargs['parent']

        AptWorker.update_apt_cache(init=True)

        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list', {})

        self.appview.to_add = []
        self.appview.to_rm = []
        self.on_category_changed(self.cateview.get_selection())
        self.apply_button.set_sensitive(False)
        unset_busy(parent)
示例#9
0
    def on_package_work_finished(self, transaction, status, kwargs):
        to_add, to_rm = kwargs['add_and_rm']
        parent = kwargs['parent']

        AptWorker.update_apt_cache(init=True)

        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list', {})

        self.appview.to_add = []
        self.appview.to_rm = []
        self.on_category_changed(self.cateview.get_selection())
        self.apply_button.set_sensitive(False)
        unset_busy(parent)
示例#10
0
    def on_purge_ppa_button_clicked(self, widget):
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        set_busy(self)
        name_list = []
        url_list = []
        log.debug("self.sourceview.to_purge: %s" % self.sourceview.to_purge)
        for url in self.sourceview.to_purge:
            name_list.append(ppa.get_short_name(url))
            url_list.append(url)

        log.debug("PPAs to purge: url_list: %s" % url_list)

        package_view = DowngradeView(self)
        package_view.update_downgrade_model(url_list)
        sw = Gtk.ScrolledWindow(shadow_type=Gtk.ShadowType.IN)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _("It's safe to purge the PPA, no packages need to be downgraded.")
            sw.hide()
        else:
            message = _("To safely purge the PPA, the following packages must be downgraded.")
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(title=_("You're going to purge \"%s\":") % ', '.join(name_list),
                                message=message)
        dialog.set_resizable(True)
        dialog.get_content_area().pack_start(sw, True, True, 0)
        dialog.show_all()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages
        #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == Gtk.ResponseType.YES:
            log.debug("The select pkgs is: %s", str(select_pkgs))
            worker = AptWorker(widget.get_toplevel(),
                               finish_handler=self.on_package_work_finished,
                               data={'parent': self,
                                     'url_list': url_list})
            worker.downgrade_packages(select_pkgs)
        else:
            unset_busy(self)
示例#11
0
    def on_package_work_finished(self, transaction, status, kwargs):
        unset_busy(self)

        parent = kwargs['parent']
        url_list = kwargs['url_list']

        for url in url_list:
            #TODO remove vendor key
            result = proxy.purge_source(url, '')
            log.debug("Set source: %s to %s" % (url, str(result)))
        self.sourceview.to_purge = []
        self.update_sourceview()

        notify = Notify.Notification(summary=_('PPA has been purged'),
                                     body=_('It is highly recommend to do a "Refresh" source operation.'))
        notify.set_icon_from_pixbuf(self.get_pixbuf(size=48))
        notify.set_hint_string ("x-canonical-append", "")
        notify.show()
示例#12
0
    def on_package_work_finished(self, transaction, status, kwargs):
        unset_busy(self)

        parent = kwargs['parent']
        url_list = kwargs['url_list']

        for url in url_list:
            #TODO remove vendor key
            result = proxy.purge_source(url, '')
            log.debug("Set source: %s to %s" % (url, str(result)))
        self.sourceview.to_purge = []
        self.update_sourceview()

        notify = Notify.Notification(
            summary=_('PPA has been purged'),
            body=_(
                'It is highly recommend to do a "Refresh" source operation.'))
        notify.set_icon_from_pixbuf(self.get_pixbuf(size=48))
        notify.set_hint_string("x-canonical-append", "")
        notify.show()
示例#13
0
class PolkitButton(Gtk.Button):
    __gsignals__ = {
        'authenticated': (GObject.SignalFlags.RUN_FIRST, None, ()),
    }

    def __init__(self, action):
        GObject.GObject.__init__(self)
        self.icon_unlock = ('changes-allow-symbolic', 'changes-allow')
        self.icon_lock = ('changes-prevent-symbolic', 'changes-prevent')

        self.hbox = Gtk.HBox(spacing=6)
        self.add(self.hbox)

        self.image = Gtk.Image.new_from_gicon(Gio.ThemedIcon.new_from_names(self.icon_lock),
                                         Gtk.IconSize.BUTTON)
        self.hbox.pack_start(self.image, False, False, 0)

        self.label = Gtk.Label(_('_Unlock'))
        self.label.set_use_underline(True)
        self.hbox.pack_start(self.label, False, False, 0)

        self._action = PolkitAction(action)
        self.connect('clicked', self.on_button_clicked)

        self.show_all()

    @inline_callbacks
    def on_button_clicked(self, widget):
        set_busy(widget.get_toplevel())
        try:
            yield self._action.do_authenticate()
        except Exception, e:
            import logging
            logging.getLogger('PolkitButton').debug(e)
            unset_busy(widget.get_toplevel())
            return

        self.emit('authenticated')
        self._change_button_state()
        unset_busy(widget.get_toplevel())
示例#14
0
 def on_clean_finished(self, transaction, status, parent):
     unset_busy(parent)
     self.update_apt_cache(True)
     self.emit('cleaned', True)
示例#15
0
 def on_package_work_finished(self, transaction, status, kwargs):
     parent = kwargs['parent']
     proxy.update_apt_cache(True)
     unset_busy(parent)
     self.reset_install_button()
示例#16
0
 def unset_busy(self):
     unset_busy(self.parent_window)
示例#17
0
 def on_clean_finished(self, transaction, status, parent):
     unset_busy(parent)
     AptWorker.update_apt_cache(True)
     self.emit('all_cleaned', True)
示例#18
0
 def unset_busy(self):
     unset_busy(self.parent_window)
示例#19
0
 def on_update_finished(transaction, status, parent):
     log.debug("on_update_finished")
     unset_busy(parent)
示例#20
0
 def on_package_work_finished(self, transaction, status, kwargs):
     parent = kwargs['parent']
     proxy.update_apt_cache(True)
     unset_busy(parent)
     self.reset_install_button()
示例#21
0
 def on_update_finished(transaction, status, parent):
     log.debug("on_update_finished")
     unset_busy(parent)