コード例 #1
0
    def on_recover_button_clicked(self, widget):
        iter = self.backup_combobox.get_active_iter()
        model = self.backup_combobox.get_model()
        dir = self.dir_label.get_text()
        path = model.get_value(iter, 1)

        if dir.count('/') == 2:
            message = _('Would you like to recover the backup: <b>%s/%s</b>?') % (dir, os.path.basename(path)[:-4])
        else:
            message = _('Would you like to recover the backup of all <b>%s</b> settings named <b>%s</b>?') % (dir, os.path.basename(path)[:-4])

        addon_message = _('<b>NOTES</b>: While recovering, your desktop may be unresponsive for a moment.')

        dialog = QuestionDialog(message + '\n\n' + addon_message)
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            if dir.count('/') == 1:
                for line in open(path):
                    stdout, stderr = do_recover_task(line.strip())
            else:
                stdout, stderr = do_recover_task(path)

            if stderr:
                log.error(stderr)
                #TODO raise error or others
                return
            self.__show_successful_with_logout_button(_('Recovery Successful!\nYou may need to restart your desktop for changes to take effect'))
コード例 #2
0
    def on_reset_button_clicked(self, widget):
        iter = self.backup_combobox.get_active_iter()
        model = self.backup_combobox.get_model()
        dir = self.dir_label.get_text()

        if dir.count('/') == 2:
            message = _(
                'Would you like to reset settings for: <b>%s</b>?') % dir
        else:
            message = _(
                'Would you like to reset all settings under: <b>%s</b>?') % dir

        addon_message = _(
            '<b>NOTES</b>: Whilst resetting, your desktop may be unresponsive for a moment.'
        )

        dialog = QuestionDialog(message + '\n\n' + addon_message)
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            stdout, stderr = do_reset_task(dir)

            if stderr:
                log.error(stderr)
                #TODO raise error or others
                return
            self.__show_successful_with_logout_button(
                _('Reset Successful!\nYou may need to restart your desktop for changes to take effect'
                  ))
コード例 #3
0
 def upgrade_sources(self):
     dialog = QuestionDialog(_('After a successful distribution upgrade, '
         'any third-party sources you use will be disabled by default.\n'
         'Would you like to re-enable any sources disabled by Update Manager?'),
         title=_('Upgrade Third Party Sources'))
     response = dialog.run()
     dialog.destroy()
     if response == gtk.RESPONSE_YES:
         proxy.upgrade_sources(self.__get_disable_string(), UPGRADE_DICT)
         if not self.check_source_upgradable():
             InfoDialog(_('Upgrade Successful!')).launch()
         else:
             ErrorDialog(_('Upgrade Failed!')).launch()
         self.emit('call', 'ubuntutweak.modules.sourceeditor', 'update_source_combo', {})
         self.update_thirdparty()
コード例 #4
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
 def upgrade_sources(self):
     dialog = QuestionDialog(_(
         'After a successful distribution upgrade, '
         'any third-party sources you use will be disabled by default.\n'
         'Would you like to re-enable any sources disabled by Update Manager?'
     ),
                             title=_('Upgrade Third Party Sources'))
     response = dialog.run()
     dialog.destroy()
     if response == gtk.RESPONSE_YES:
         proxy.upgrade_sources(self.__get_disable_string(), UPGRADE_DICT)
         if not self.check_source_upgradable():
             InfoDialog(_('Upgrade Successful!')).launch()
         else:
             ErrorDialog(_('Upgrade Failed!')).launch()
         self.emit('call', 'ubuntutweak.modules.sourceeditor',
                   'update_source_combo', {})
         self.update_thirdparty()
コード例 #5
0
    def create_task_dialog(self, title, desc, updateview):
        dialog = QuestionDialog(desc, title=title)
        vbox = dialog.vbox
        swindow = gtk.ScrolledWindow()
        swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        swindow.set_size_request(-1, 200)
        vbox.pack_start(swindow, False, False, 0)
        swindow.add(updateview)
        swindow.show_all()

        return dialog
コード例 #6
0
ファイル: userdir.py プロジェクト: daning/ubuntu-tweak
    def on_restore_directory(self, widget):
        model, iter = self.get_selection().get_selected()
        userdir = model.get_value(iter, COLUMN_DIR)

        dialog = QuestionDialog(_('Ubuntu Tweak will restore the selected '
            'directory to it\'s default location.\n'
            'However, you must move your files back into place manually.\n'
            'Do you wish to continue?'))

        if dialog.run() == gtk.RESPONSE_YES:
            newdir = os.path.join(os.getenv("HOME"), self.uf.get_restorename(userdir))
            self.uf.set_userdir(userdir, newdir)
            model.set_value(iter, COLUMN_PATH, newdir)

            if not os.path.exists(newdir):
                os.mkdir(newdir)
            elif os.path.isfile(newdir):
                os.remove(newdir)
                os.mkdir(newdir)

        dialog.destroy()
コード例 #7
0
    def check_version(self):
        gtk.gdk.threads_enter()

        version = TweakSettings.get_version()
        if version > VERSION:
            dialog = QuestionDialog(_(
                'A newer version: %s is available online.\nWould you like to update?\n\nNote: if you prefer to update from the source code, you can disable this feature in Preferences.'
            ) % version,
                                    title=_('Software Update'))

            update = False

            if dialog.run() == gtk.RESPONSE_YES:
                update = True
            dialog.destroy()

            if update:
                dialog = UpdateDialog(parent=self.get_toplevel())
                dialog.run()
                dialog.destroy()

        gtk.gdk.threads_leave()
コード例 #8
0
    def on_delete_button_clicked(self, widget):
        def try_remove_record_in_root_backup(dir, path):
            rootpath = build_backup_prefix('/'.join(dir.split('/')[:2])) + os.path.basename(path)
            if os.path.exists(rootpath):
                lines = open(rootpath).read().split()
                lines.remove(path)

                if len(lines) == 0:
                    os.remove(rootpath)
                else:
                    new = open(rootpath, 'w')
                    new.write('\n'.join(lines))
                    new.close()

        def try_remove_all_subback(path):
            for line in open(path):
                os.remove(line.strip())

        iter = self.backup_combobox.get_active_iter()
        model = self.backup_combobox.get_model()

        dir = self.dir_label.get_text()

        path = model.get_value(iter, 1)
        if dir.count('/') == 2:
            dialog = QuestionDialog(_('Would you like to delete the backup: <b>%s/%s</b>?') % (dir, os.path.basename(path)[:-4]))
        else:
            dialog = QuestionDialog(_('Would you like to delete the backup of all <b>%s</b> settings named <b>%s</b>?') % (dir, os.path.basename(path)[:-4]))
        response = dialog.run()
        dialog.destroy()
        if response == gtk.RESPONSE_YES:
            if dir.count('/') == 2:
                try_remove_record_in_root_backup(dir, path)
            else:
                try_remove_all_subback(path)

            os.remove(path)
            self.update_backup_model(dir)
コード例 #9
0
ファイル: mainwindow.py プロジェクト: Adriarson/ubuntu-tweak
    def check_version(self):
        gtk.gdk.threads_enter()

        version = TweakSettings.get_version()
        if version > VERSION:
            dialog = QuestionDialog(_('A newer version: %s is available online.\nWould you like to update?\n\nNote: if you prefer to update from the source code, you can disable this feature in Preferences.') % version, 
                                    title=_('Software Update'))

            update = False

            if dialog.run() == gtk.RESPONSE_YES:
                update = True
            dialog.destroy()

            if update: 
                dialog = UpdateDialog(parent=self.get_toplevel())
                dialog.run()
                dialog.destroy()

        gtk.gdk.threads_leave()
コード例 #10
0
    def on_recover_button_clicked(self, widget):
        iter = self.backup_combobox.get_active_iter()
        model = self.backup_combobox.get_model()
        dir = self.dir_label.get_text()
        path = model.get_value(iter, 1)

        if dir.count('/') == 2:
            message = _('Would you like to recover the backup: <b>%s/%s</b>?'
                        ) % (dir, os.path.basename(path)[:-4])
        else:
            message = _(
                'Would you like to recover the backup of all <b>%s</b> settings named <b>%s</b>?'
            ) % (dir, os.path.basename(path)[:-4])

        addon_message = _(
            '<b>NOTES</b>: While recovering, your desktop may be unresponsive for a moment.'
        )

        dialog = QuestionDialog(message + '\n\n' + addon_message)
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            if dir.count('/') == 1:
                for line in open(path):
                    stdout, stderr = do_recover_task(line.strip())
            else:
                stdout, stderr = do_recover_task(path)

            if stderr:
                log.error(stderr)
                #TODO raise error or others
                return
            self.__show_successful_with_logout_button(
                _('Recovery Successful!\nYou may need to restart your desktop for changes to take effect'
                  ))
コード例 #11
0
    def on_reset_button_clicked(self, widget):
        iter = self.backup_combobox.get_active_iter()
        model = self.backup_combobox.get_model()
        dir = self.dir_label.get_text()

        if dir.count('/') == 2:
            message = _('Would you like to reset settings for: <b>%s</b>?') % dir
        else:
            message = _('Would you like to reset all settings under: <b>%s</b>?') % dir

        addon_message = _('<b>NOTES</b>: Whilst resetting, your desktop may be unresponsive for a moment.')

        dialog = QuestionDialog(message + '\n\n' + addon_message)
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            stdout, stderr = do_reset_task(dir)

            if stderr:
                log.error(stderr)
                #TODO raise error or others
                return
            self.__show_successful_with_logout_button(_('Reset Successful!\nYou may need to restart your desktop for changes to take effect'))
コード例 #12
0
ファイル: nautilus.py プロジェクト: Adriarson/ubuntu-tweak
    def on_clean_thumbnails_clicked(self, widget):
        question = QuestionDialog(_('The thumbnail cache will be deleted. Do you wish to continue?'),
            title = _('Warning'))
        if question.run() == gtk.RESPONSE_YES:
            question.destroy()

            dialog = CleanDialog(widget.get_toplevel())
            dialog.run()
            InfoDialog(_('Clean up Successful!')).launch()
            self.set_clean_button_label(widget)
        else:
            question.destroy()
コード例 #13
0
    def on_delete_button_clicked(self, widget):
        def try_remove_record_in_root_backup(dir, path):
            rootpath = build_backup_prefix('/'.join(
                dir.split('/')[:2])) + os.path.basename(path)
            if os.path.exists(rootpath):
                lines = open(rootpath).read().split()
                lines.remove(path)

                if len(lines) == 0:
                    os.remove(rootpath)
                else:
                    new = open(rootpath, 'w')
                    new.write('\n'.join(lines))
                    new.close()

        def try_remove_all_subback(path):
            for line in open(path):
                os.remove(line.strip())

        iter = self.backup_combobox.get_active_iter()
        model = self.backup_combobox.get_model()

        dir = self.dir_label.get_text()

        path = model.get_value(iter, 1)
        if dir.count('/') == 2:
            dialog = QuestionDialog(
                _('Would you like to delete the backup: <b>%s/%s</b>?') %
                (dir, os.path.basename(path)[:-4]))
        else:
            dialog = QuestionDialog(
                _('Would you like to delete the backup of all <b>%s</b> settings named <b>%s</b>?'
                  ) % (dir, os.path.basename(path)[:-4]))
        response = dialog.run()
        dialog.destroy()
        if response == gtk.RESPONSE_YES:
            if dir.count('/') == 2:
                try_remove_record_in_root_backup(dir, path)
            else:
                try_remove_all_subback(path)

            os.remove(path)
            self.update_backup_model(dir)
コード例 #14
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
 def on_sync_button_clicked(self, widget):
     dialog = CheckSourceDialog(widget.get_toplevel(), self.url)
     dialog.run()
     dialog.destroy()
     if dialog.status == True:
         dialog = QuestionDialog(
             _("Update available, Would you like to update?"))
         response = dialog.run()
         dialog.destroy()
         if response == gtk.RESPONSE_YES:
             dialog = FetchingDialog(parent=self.get_toplevel(),
                                     url=get_source_data_url())
             dialog.connect('destroy', self.on_source_data_downloaded)
             dialog.run()
             dialog.destroy()
     elif dialog.error == True:
         ErrorDialog(
             _("Network Error, Please check your network connection or the remote server is down."
               )).launch()
     else:
         utdata.save_synced_timestamp(SOURCE_ROOT)
         self.update_timestamp()
         InfoDialog(_("No update available.")).launch()
コード例 #15
0
ファイル: computer.py プロジェクト: daning/ubuntu-tweak
    def on_hostname_button_clicked(self, widget, label):
        old_name = os.uname()[1]
        dialog = QuestionDialog(_(
            'Please enter your new hostname. Blank characters should not be used.'
        ),
                                title=_('New hostname'))

        entry = gtk.Entry()
        dialog.add_widget(entry)

        res = dialog.run()
        new_name = entry.get_text()
        dialog.destroy()

        if res == gtk.RESPONSE_YES:
            ret = proxy.exec_command('hostname %s' % new_name)
            ret = proxy.exec_command('echo %s > /etc/hostname' % new_name)
            ret = proxy.exec_command("sed -i 's/%s/%s/g' /etc/hosts" %
                                     (old_name, new_name))
            log.debug("New name is: %s, The ret is: %s" % (new_name, ret))
            if os.popen('hostname').read().strip() == new_name:
                label.set_label(new_name)
コード例 #16
0
ファイル: computer.py プロジェクト: Adriarson/ubuntu-tweak
    def on_hostname_button_clicked(self, widget, label):
        old_name = os.uname()[1]
        dialog = QuestionDialog(_('Please enter your new hostname. Blank characters should not be used.'),
            title = _('New hostname'))

        entry = gtk.Entry()
        dialog.add_widget(entry)

        res = dialog.run()
        new_name = entry.get_text()
        dialog.destroy()

        if res == gtk.RESPONSE_YES:
            ret = proxy.exec_command('hostname %s' % new_name)
            ret = proxy.exec_command('echo %s > /etc/hostname' % new_name)
            ret = proxy.exec_command("sed -i 's/%s/%s/g' /etc/hosts" % (old_name, new_name))
            log.debug("New name is: %s, The ret is: %s" % (new_name, ret))
            if os.popen('hostname').read().strip() == new_name:
                label.set_label(new_name)
コード例 #17
0
    def on_enable_toggled(self, cell, path):
        model = self.get_model()
        iter = model.get_iter((int(path),))

        id = model.get_value(iter, self.COLUMN_ID)
        name = model.get_value(iter, self.COLUMN_NAME)
        enabled = model.get_value(iter, self.COLUMN_ENABLED)

        conflicts = SOURCE_PARSER.get_conflicts(id)
        dependencies = SOURCE_PARSER.get_dependencies(id)

        #Convert to real model, because will involke the set method
        if type(model) == gtk.TreeModelFilter:
            iter = model.convert_iter_to_child_iter(iter)
            model = model.get_model()

        if not enabled and conflicts:
            conflict_list = []
            conflict_name_list = []
            for conflict_id in conflicts:
                if self.get_source_enabled(conflict_id):
                    conflict_list.append(conflict_id)
                    name_list = [r[self.COLUMN_NAME] for r in model if r[self.COLUMN_ID] == conflict_id]
                    if name_list:
                            conflict_name_list.extend(name_list)

            if conflict_list and conflict_name_list:
                full_name = ', '.join(conflict_name_list)
                ErrorDialog(_('You can\'t enable this Source because'
                              '<b>"%(SOURCE)s"</b> conflicts with it.\nTo '
                              'continue you need to disable <b>"%(SOURCE)s"</b>' \
                              'first.') % {'SOURCE': full_name}).launch()

                model.set(iter, self.COLUMN_ENABLED, enabled)
                return

        if enabled is False and dependencies:
            depend_list = []
            depend_name_list = []
            for depend_id in dependencies:
                if self.get_source_enabled(depend_id) is False:
                    depend_list.append(depend_id)
                    name_list = [r[self.COLUMN_NAME] for r in model if r[self.COLUMN_ID] == depend_id]
                    if name_list:
                            depend_name_list.extend(name_list)

            if depend_list and depend_name_list:
                full_name = ', '.join(depend_name_list)

                dialog = QuestionDialog(\
                            _('To enable this Source, You need to enable <b>"%s"</b> at first.\nDo you wish to continue?') \
                            % full_name,
                            title=_('Dependency Notice'))
                if dialog.run() == gtk.RESPONSE_YES:
                    for depend_id in depend_list:
                        self.set_source_enabled(depend_id)
                    self.set_source_enabled(id)
                else:
                    model.set(iter, self.COLUMN_ENABLED, enabled)

                dialog.destroy()
                return

        if enabled and SOURCE_PARSER.has_reverse_depends(id):
            depend_list = []
            depend_name_list = []
            for depend_id in SOURCE_PARSER.get_reverse_depends(id):
                if self.get_source_enabled(depend_id):
                    depend_list.append(depend_id)
                    name_list = [r[self.COLUMN_NAME] for r in model if r[self.COLUMN_ID] == depend_id]
                    if name_list:
                            depend_name_list.extend(name_list)

            if depend_list and depend_name_list:
                full_name = ', '.join(depend_name_list)

                ErrorDialog(_('You can\'t disable this Source because '
                            '<b>"%(SOURCE)s"</b> depends on it.\nTo continue '
                            'you need to disable <b>"%(SOURCE)s"</b> first.') \
                                 % {'SOURCE': full_name}).launch()

                model.set(iter, self.COLUMN_ENABLED, enabled)
                return

        self.do_source_enable(iter, not enabled)
コード例 #18
0
ファイル: cleaner.py プロジェクト: Adriarson/ubuntu-tweak
    def clean_selected_ppa(self):
        self.set_busy()
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        name_list = []
        url_list = []
        for id in self.get_list():
            #TODO
            try:
                name_list.append(SOURCE_PARSER.get_name(int(id)))
                url_list.append(SOURCE_PARSER.get_url(int(id)))
            except:
                name_list.append(ppa.get_short_name(id))
                url_list.append(id)

        package_view = DowngradeView()
        package_view.update_model(url_list)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_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, title=_("You're going to purge: %s") % ', '.join(name_list))
        dialog.set_resizable(True)
        dialog.vbox.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.RESPONSE_YES:
            self.set_busy()
            log.debug("The select pkgs is: %s", str(select_pkgs))
            dialog = CleanPpaDialog(self.get_toplevel(), select_pkgs, url_list)
            dialog.run()
            dialog.destroy()
            if dialog.error:
                self.show_failed_dialog(dialog.error)
            else:
                self.show_success_dialog()
            self.update_ppa_model()
            self.unset_busy()
        else:
            self.update_ppa_model()
        # TODO refresh source?
        self.__check_list = []
        self.emit('cleaned')
        self.unset_busy()
コード例 #19
0
    def on_have_update(self, client, id, entry, data):
        if entry.get_value().get_bool():
            if self.check_update():
                dialog = QuestionDialog(_('New source data available, would you like to update?'))
                response = dialog.run()
                dialog.destroy()

                if response == gtk.RESPONSE_YES:
                    dialog = FetchingDialog(get_source_data_url(),
                                            self.get_toplevel())
                    dialog.connect('destroy', self.on_source_data_downloaded)
                    dialog.run()
                    dialog.destroy()
コード例 #20
0
ファイル: cleaner.py プロジェクト: daning/ubuntu-tweak
    def clean_selected_ppa(self):
        self.set_busy()
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        name_list = []
        url_list = []
        for id in self.get_list():
            #TODO
            try:
                name_list.append(SOURCE_PARSER.get_name(int(id)))
                url_list.append(SOURCE_PARSER.get_url(int(id)))
            except:
                name_list.append(ppa.get_short_name(id))
                url_list.append(id)

        package_view = DowngradeView()
        package_view.update_model(url_list)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_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,
                                title=_("You're going to purge: %s") %
                                ', '.join(name_list))
        dialog.set_resizable(True)
        dialog.vbox.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.RESPONSE_YES:
            self.set_busy()
            log.debug("The select pkgs is: %s", str(select_pkgs))
            dialog = CleanPpaDialog(self.get_toplevel(), select_pkgs, url_list)
            dialog.run()
            dialog.destroy()
            if dialog.error == False:
                self.show_success_dialog()
            else:
                self.show_failed_dialog()
            self.update_ppa_model()
            self.unset_busy()
        else:
            self.update_ppa_model()
        # TODO refresh source?
        self.__check_list = []
        self.emit('cleaned')
        self.unset_busy()
コード例 #21
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
    def on_have_update(self, client, id, entry, data):
        if entry.get_value().get_bool():
            if self.check_update():
                dialog = QuestionDialog(
                    _('New source data available, would you like to update?'))
                response = dialog.run()
                dialog.destroy()

                if response == gtk.RESPONSE_YES:
                    dialog = FetchingDialog(get_source_data_url(),
                                            self.get_toplevel())
                    dialog.connect('destroy', self.on_source_data_downloaded)
                    dialog.run()
                    dialog.destroy()
コード例 #22
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
    def on_enable_toggled(self, cell, path):
        model = self.get_model()
        iter = model.get_iter((int(path), ))

        id = model.get_value(iter, self.COLUMN_ID)
        name = model.get_value(iter, self.COLUMN_NAME)
        enabled = model.get_value(iter, self.COLUMN_ENABLED)

        conflicts = SOURCE_PARSER.get_conflicts(id)
        dependencies = SOURCE_PARSER.get_dependencies(id)

        #Convert to real model, because will involke the set method
        if type(model) == gtk.TreeModelFilter:
            iter = model.convert_iter_to_child_iter(iter)
            model = model.get_model()

        if not enabled and conflicts:
            conflict_list = []
            conflict_name_list = []
            for conflict_id in conflicts:
                if self.get_source_enabled(conflict_id):
                    conflict_list.append(conflict_id)
                    name_list = [
                        r[self.COLUMN_NAME] for r in model
                        if r[self.COLUMN_ID] == conflict_id
                    ]
                    if name_list:
                        conflict_name_list.extend(name_list)

            if conflict_list and conflict_name_list:
                full_name = ', '.join(conflict_name_list)
                ErrorDialog(_('You can\'t enable this Source because'
                              '<b>"%(SOURCE)s"</b> conflicts with it.\nTo '
                              'continue you need to disable <b>"%(SOURCE)s"</b>' \
                              'first.') % {'SOURCE': full_name}).launch()

                model.set(iter, self.COLUMN_ENABLED, enabled)
                return

        if enabled is False and dependencies:
            depend_list = []
            depend_name_list = []
            for depend_id in dependencies:
                if self.get_source_enabled(depend_id) is False:
                    depend_list.append(depend_id)
                    name_list = [
                        r[self.COLUMN_NAME] for r in model
                        if r[self.COLUMN_ID] == depend_id
                    ]
                    if name_list:
                        depend_name_list.extend(name_list)

            if depend_list and depend_name_list:
                full_name = ', '.join(depend_name_list)

                dialog = QuestionDialog(\
                            _('To enable this Source, You need to enable <b>"%s"</b> at first.\nDo you wish to continue?') \
                            % full_name,
                            title=_('Dependency Notice'))
                if dialog.run() == gtk.RESPONSE_YES:
                    for depend_id in depend_list:
                        self.set_source_enabled(depend_id)
                    self.set_source_enabled(id)
                else:
                    model.set(iter, self.COLUMN_ENABLED, enabled)

                dialog.destroy()
                return

        if enabled and SOURCE_PARSER.has_reverse_depends(id):
            depend_list = []
            depend_name_list = []
            for depend_id in SOURCE_PARSER.get_reverse_depends(id):
                if self.get_source_enabled(depend_id):
                    depend_list.append(depend_id)
                    name_list = [
                        r[self.COLUMN_NAME] for r in model
                        if r[self.COLUMN_ID] == depend_id
                    ]
                    if name_list:
                        depend_name_list.extend(name_list)

            if depend_list and depend_name_list:
                full_name = ', '.join(depend_name_list)

                ErrorDialog(_('You can\'t disable this Source because '
                            '<b>"%(SOURCE)s"</b> depends on it.\nTo continue '
                            'you need to disable <b>"%(SOURCE)s"</b> first.') \
                                 % {'SOURCE': full_name}).launch()

                model.set(iter, self.COLUMN_ENABLED, enabled)
                return

        self.do_source_enable(iter, not enabled)
コード例 #23
0
ファイル: sourcecenter.py プロジェクト: daning/ubuntu-tweak
def refresh_source(parent):
    dialog = UpdateCacheDialog(parent)
    dialog.run()

    new_pkg = []
    for pkg in PACKAGE_WORKER.get_new_package():
        if pkg in APP_PARSER:
            new_pkg.append(pkg)

    new_updates = list(PACKAGE_WORKER.get_update_package())

    if new_pkg or new_updates:
        updateview = UpdateView()
        updateview.connect('select', on_select_action)

        if new_pkg:
            updateview.update_model(new_pkg)

        if new_updates:
            updateview.update_updates(new_updates)

        dialog = QuestionDialog(_(
            'You can install new applications by selecting them and choosing "Yes".\nOr you can install them at Application Center by choosing "No".'
        ),
                                title=_('New applications are available'))

        vbox = dialog.vbox
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_size_request(-1, 200)
        vbox.pack_start(sw, False, False, 0)
        sw.add(updateview)

        select_button = gtk.CheckButton(_('Select All'))
        select_button.connect('clicked', on_select_button_clicked, updateview)
        vbox.pack_start(select_button, False, False, 0)
        vbox.show_all()

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

        to_rm = updateview.to_rm
        to_add = updateview.to_add

        if res == gtk.RESPONSE_YES and to_add:
            PACKAGE_WORKER.perform_action(parent, to_add, to_rm)

            PACKAGE_WORKER.update_apt_cache(True)

            done = PACKAGE_WORKER.get_install_status(to_add, to_rm)

            if done:
                InfoDialog(_('Update Successful!')).launch()
            else:
                ErrorDialog(_('Update Failed!')).launch()

        return True
    else:
        dialog = InfoDialog(
            _("Your system is clean and there are no updates yet."),
            title=_('Software information is now up-to-date'))

        dialog.launch()
        return False
コード例 #24
0
    def on_change_icon_clicked(self, widget):
        dialog = gtk.FileChooserDialog(_('Choose a new logo image'),
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
                                                 gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
        filter = gtk.FileFilter()
        filter.set_name(_("PNG images with 24x24 size or SVG images"))
        filter.add_pattern('*.png')
        filter.add_pattern('*.svg')
        dialog.set_current_folder(os.path.expanduser('~'))
        dialog.add_filter(filter)

        if system.CODENAME == 'karmic':
            dest = os.path.expanduser('~/.icons/%s/places/24/start-here' % self.__setting.get_icon_theme())
        else:
            dest = os.path.expanduser('~/.icons/%s/apps/24/start-here' % self.__setting.get_icon_theme())

        revert_button = dialog.action_area.get_children()[-1]

        HAVE_ICON = os.path.exists(dest + '.png') or os.path.exists(dest + '.svg')

        if not HAVE_ICON:
            revert_button.set_sensitive(False)

        filename = ''
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                ext = os.path.splitext(filename)[1]
                log.debug('The select file name is: %s' % ext)
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()
                dest = dest + ext

                if ext == '.png' and (w != 24 or h != 24):
                    ErrorDialog(_("This image size isn't suitable for the panel.\nIt should measure 24x24.")).launch()
                    return
                else:
                    os.system('mkdir -p %s' % os.path.dirname(dest))
                    os.system('cp %s %s' % (filename, dest))

                    if ext == '.svg':
                        pixbuf = pixbuf.scale_simple(24, 24, gtk.gdk.INTERP_BILINEAR)
                    image = gtk.image_new_from_pixbuf(pixbuf)
                    widget.set_image(image)
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            for dest in glob.glob(dest + '*'):
                os.remove(dest)
            image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here', force_reload=True))
            widget.set_image(image)
        else:
            dialog.destroy()
            return

        dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
        if dialog.run() == gtk.RESPONSE_YES:
            os.system('killall gnome-panel')

        dialog.destroy()