当前位置: 首页>>代码示例>>Python>>正文


Python QuestionDialog.destroy方法代码示例

本文整理汇总了Python中ubuntutweak.widgets.dialogs.QuestionDialog.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionDialog.destroy方法的具体用法?Python QuestionDialog.destroy怎么用?Python QuestionDialog.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ubuntutweak.widgets.dialogs.QuestionDialog的用法示例。


在下文中一共展示了QuestionDialog.destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_restore_directory

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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()
开发者ID:priteshdesai,项目名称:ubuntu-tweak,代码行数:27,代码来源:userdir.py

示例2: on_recover_button_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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
            InfoDialog(
                _("Recovery Successful!\nYou may need to restart your desktop for changes to take effect")
            ).launch()
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:36,代码来源:desktoprecovery.py

示例3: check_version

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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()
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:27,代码来源:mainwindow.py

示例4: on_reset_button_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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:
            if dir.count("/") == 1:
                for line in open(path):
                    stdout, stderr = do_reset_task(line.strip())
            else:
                stdout, stderr = do_reset_task(dir)

            if stderr:
                log.error(stderr)
                # TODO raise error or others
                return
            InfoDialog(_("Reset Successful!\nYou may need to restart your desktop for changes to take effect")).launch()
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:30,代码来源:desktoprecovery.py

示例5: clean_selected_ppa

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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()
开发者ID:leeight,项目名称:ubuntu-tweak,代码行数:62,代码来源:cleaner.py

示例6: on_have_update

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    def on_have_update(self, client, id, entry, data):
        if entry.get_value().get_bool():
            dialog = QuestionDialog(_('New application data available, would you like to update?'))
            response = dialog.run()
            dialog.destroy()

            if response == gtk.RESPONSE_YES:
                dialog = FetchingDialog(get_app_data_url(), self.get_toplevel())
                dialog.connect('destroy', self.on_app_data_downloaded)
                dialog.run()
                dialog.destroy()
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:13,代码来源:appcenter.py

示例7: on_change_icon_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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 image (*.png)"))
        filter.add_mime_type("image/png")
        dialog.set_current_folder(os.path.expanduser('~'))
        dialog.add_filter(filter)

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

        revert_button = dialog.action_area.get_children()[-1]
        if not os.path.exists(dest):
            revert_button.set_sensitive(False)

        filename = ''
        response = dialog.run()

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

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

                    image = gtk.image_new_from_file(dest)
                    widget.set_image(image)
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            os.remove(dest)
            image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here', size=24, 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()
开发者ID:oldturkeybuzzard,项目名称:ubuntu-tweak,代码行数:56,代码来源:gnomesettings.py

示例8: on_clean_thumbnails_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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()
开发者ID:leeight,项目名称:ubuntu-tweak,代码行数:14,代码来源:nautilus.py

示例9: on_have_update

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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()
开发者ID:oldturkeybuzzard,项目名称:ubuntu-tweak,代码行数:14,代码来源:sourcecenter.py

示例10: on_idle_check

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    def on_idle_check(self):
        gtk.gdk.threads_enter()
        if self.check_update():
            dialog = QuestionDialog(_('New application data available, would you like to update?'))
            response = dialog.run()
            dialog.destroy()

            if response == gtk.RESPONSE_YES:
                dialog = FetchingDialog(APP_URL, self.get_toplevel())
                dialog.connect('destroy', self.on_app_data_downloaded)
                dialog.run()
                dialog.destroy()

        gtk.gdk.threads_leave()
开发者ID:DigGe,项目名称:ubuntu-tweak,代码行数:16,代码来源:appcenter.py

示例11: upgrade_sources

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
 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()
开发者ID:priteshdesai,项目名称:ubuntu-tweak,代码行数:17,代码来源:sourcecenter.py

示例12: on_hostname_button_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    def on_hostname_button_clicked(self, widget, label):
        dialog = QuestionDialog(_('Please enter your new hostname. Blank characters should not be used.'),
            title = _('New hostname'))

        vbox = dialog.vbox
        entry = gtk.Entry()
        vbox.pack_start(entry, False, False, 0)
        vbox.show_all()

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

        if res == gtk.RESPONSE_YES:
            new_name = entry.get_text()
            proxy.exec_command('hostname %s' % new_name)
            if os.popen('hostname').read().strip() == new_name:
                label.set_label(new_name)
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:19,代码来源:computer.py

示例13: on_delete_button_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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)
开发者ID:jonolumb,项目名称:ubuntu-tweak,代码行数:45,代码来源:desktoprecovery.py

示例14: on_reset_button_clicked

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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'))
开发者ID:leeight,项目名称:ubuntu-tweak,代码行数:26,代码来源:desktoprecovery.py

示例15: on_enable_toggled

# 需要导入模块: from ubuntutweak.widgets.dialogs import QuestionDialog [as 别名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import destroy [as 别名]
    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)
开发者ID:priteshdesai,项目名称:ubuntu-tweak,代码行数:87,代码来源:sourcecenter.py


注:本文中的ubuntutweak.widgets.dialogs.QuestionDialog.destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。