本文整理汇总了Python中ubuntutweak.gui.dialogs.QuestionDialog类的典型用法代码示例。如果您正苦于以下问题:Python QuestionDialog类的具体用法?Python QuestionDialog怎么用?Python QuestionDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuestionDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_reset_button_clicked
def on_reset_button_clicked(self, widget):
iter = self.backup_combobox.get_active_iter()
model = self.backup_combobox.get_model()
directory = self.dir_label.get_text()
if directory.count('/') == 2:
message = _('Would you like to reset settings for: <b>%s</b>?') % directory
else:
message = _('Would you like to reset all settings under: <b>%s</b>?') % directory
addon_message = _('<b>NOTES</b>: Whilst resetting, your desktop may be unresponsive for a moment.')
dialog = QuestionDialog(message=message + '\n\n' + addon_message)
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
stdout, stderr = do_reset_task(directory)
if stderr:
log.error(stderr)
#TODO raise error or others
return
self._show_successful_dialog(title=_('Reset Successful!'),
message=_('You may need to restart your desktop for changes to take effect'))
示例2: on_recover_button_clicked
def on_recover_button_clicked(self, widget):
model, iter = self.list_selection.get_selected()
if iter:
list_path = model[iter][0]
list_name = model[iter][1]
backup_iter = self.backup_combobox.get_active_iter()
if backup_iter:
backup_path = self.backup_model[backup_iter][0]
backup_name = self.backup_model[backup_iter][1]
dialog = QuestionDialog(message=_('Would you like to recover the '
'backup "<b>%s</b>" for "<b>%s</b>"?') % (
backup_name, list_name))
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
if proxy.restore_source(backup_path, list_path):
self.infobar.response(Gtk.ResponseType.CLOSE)
else:
ErrorDialog(title=_('Recovery Failed!'),
message=_('You may need to check the permission '
'of source list.')).launch()
示例3: on_recover_button_clicked
def on_recover_button_clicked(self, widget):
iter = self.backup_combobox.get_active_iter()
model = self.backup_combobox.get_model()
directory = self.dir_label.get_text()
path = model.get_value(iter, 1)
if directory.count('/') == 2:
message = _('Would you like to recover the backup: <b>%s/%s</b>?') % (
directory, os.path.basename(path)[:-4])
else:
message = _('Would you like to recover the backup of all'
'<b>%s</b> settings named <b>%s</b>?') % (
directory, os.path.basename(path)[:-4])
addon_message = _('<b>NOTES</b>: While recovering, your desktop may be unresponsive for a moment.')
dialog = QuestionDialog(message=message + '\n\n' + addon_message)
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
if directory.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_dialog(title=_('Recovery Successful!'),
message=_('You may need to restart your desktop for changes to take effect'))
示例4: on_rebuild_clicked
def on_rebuild_clicked(self, widget):
dialog = QuestionDialog(message=_('This will delete all disabled scripts.\nDo you wish to continue?'))
if dialog.run() == Gtk.ResponseType.YES:
self.default.remove()
self.default.create()
self.disable_scripts.update_model()
dialog.destroy()
示例5: on_redo_button_clicked
def on_redo_button_clicked(self, widget):
dialog = QuestionDialog(message=_('The current content will be lost after reloading!\nDo you wish to continue?'))
if dialog.run() == Gtk.ResponseType.YES:
self.textview.update_content()
self.save_button.set_sensitive(False)
self.redo_button.set_sensitive(False)
dialog.destroy()
示例6: on_icon_reset_button_clicked
def on_icon_reset_button_clicked(self, widget):
dialog = QuestionDialog(title=_("Would you like to reset the launcher items?"),
message=_('If you continue, launcher will be set to default and all your current items will be lost.'))
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
self.launcher_setting.set_value(self.launcher_setting.get_schema_value())
示例7: on_backup_delete_button_clicked
def on_backup_delete_button_clicked(self, widget):
iter = self.backup_combobox.get_active_iter()
path = self.backup_model[iter][0]
dialog = QuestionDialog(message=_("Would you like to delete the backup:" "<b>%s</b>?") % os.path.basename(path))
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
proxy.delete_source(path)
self.update_backup_model()
示例8: on_purge_ppa_button_clicked
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)
示例9: on_delete_button_clicked
def on_delete_button_clicked(self, widget):
if self.textview.get_path() == SOURCES_LIST:
ErrorDialog(_('You can\'t delete sources.list!')).launch()
else:
dialog = QuestionDialog(message=_('The "%s" will be deleted!\nDo you wish to continue?') % self.textview.get_path())
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
model, iter = self.list_selection.get_selected()
if iter:
list_path = model[iter][0]
proxy.delete_source(list_path)
self.update_source_model()
self.update_backup_model()
示例10: upgrade_sources
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.ResponseType.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()
示例11: on_redo_action_button_clicked
def on_redo_action_button_clicked(self, widget):
model, iter = self.icon_view.get_selection().get_selected()
if iter:
name = model[iter][self.DESKTOP_NAME]
dialog = QuestionDialog(title=_('Would you like to reset "%s"?') % name,
message=_('If you continue, the actions of %s will be set to default.') % name)
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
entry = model[iter][self.DESKTOP_ENTRY]
# log.debug("Before reset the actions is: %s" % entry.get_actions())
entry.reset()
log.debug("After reset the actions is: %s" % entry.get_actions())
self.on_icon_view_selection_changed(self.icon_view.get_selection())
示例12: on_delete_button_clicked
def on_delete_button_clicked(self, widget):
def try_remove_record_in_root_backup(directory, path):
rootpath = build_backup_prefix('/'.join(directory.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()
directory = self.dir_label.get_text()
path = model.get_value(iter, 1)
if directory.count('/') == 2:
dialog = QuestionDialog(message=_('Would you like to delete the backup '
'"<b>%s/%s</b>"?') %
(directory, os.path.basename(path)[:-4]))
else:
dialog = QuestionDialog(message=_('Would you like to delete the backup of'
' all "<b>%(setting_name)s</b>" settings named "<b>%(backup_name)s</b>"?') % \
{'setting_name': directory,
'backup_name': os.path.basename(path)[:-4]})
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.YES:
if directory.count('/') == 2:
try_remove_record_in_root_backup(directory, path)
else:
try_remove_all_subback(path)
os.remove(path)
self.update_backup_model(directory)
示例13: on_restore_directory
def on_restore_directory(self, widget):
model, iter = self.get_selection().get_selected()
userdir = model.get_value(iter, self.COLUMN_DIR)
dialog = QuestionDialog(message=_('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.ResponseType.YES:
newdir = os.path.join(os.getenv("HOME"), self.uf.get_restorename(userdir))
self.uf.set_userdir(userdir, newdir)
model.set_value(iter, self.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()
示例14: clean_cruft
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)
示例15: on_change_icon_clicked
def on_change_icon_clicked(self, widget):
dialog = Gtk.FileChooserDialog(_('Choose a new logo image'),
action=Gtk.FileChooserAction.OPEN,
buttons=(Gtk.STOCK_REVERT_TO_SAVED, Gtk.ResponseType.DELETE_EVENT,
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.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)
icon_theme = GconfSetting('/desktop/gnome/interface/icon_theme').get_value()
dest = os.path.expanduser('~/.icons/%s/apps/24/start-here' % icon_theme)
revert_button = dialog.get_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.ResponseType.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 = GdkPixbuf.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(message=_("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, GdkPixbuf.InterpType.BILINEAR)
image = Gtk.Image.new_from_pixbuf(pixbuf)
widget.set_image(image)
elif response == Gtk.ResponseType.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(message=_('Do you want your changes to take effect immediately?'))
if dialog.run() == Gtk.ResponseType.YES:
os.system('killall gnome-panel')
dialog.destroy()