utils: Make chkbox_helper always return button response
Don't have it predict what the caller expects
This commit is contained in:
parent
1a6e803a09
commit
0ab1f99230
|
@ -1140,13 +1140,14 @@ class vmmDetails(vmmGObjectUI):
|
|||
if not self.widget("config-apply").get_property("sensitive"):
|
||||
return False
|
||||
|
||||
if util.chkbox_helper(self,
|
||||
if not util.chkbox_helper(self,
|
||||
self.config.get_confirm_unapplied,
|
||||
self.config.set_confirm_unapplied,
|
||||
text1=(_("There are unapplied changes. Would you like to apply "
|
||||
"them now?")),
|
||||
chktext=_("Don't warn me again."),
|
||||
alwaysrecord=True):
|
||||
alwaysrecord=True,
|
||||
default=False):
|
||||
return False
|
||||
|
||||
return not self.config_apply(row=row)
|
||||
|
@ -2231,7 +2232,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
def remove_device(self, dev_type, dev_id_info):
|
||||
logging.debug("Removing device: %s %s" % (dev_type, dev_id_info))
|
||||
|
||||
if util.chkbox_helper(self, self.config.get_confirm_removedev,
|
||||
if not util.chkbox_helper(self, self.config.get_confirm_removedev,
|
||||
self.config.set_confirm_removedev,
|
||||
text1=(_("Are you sure you want to remove this device?"))):
|
||||
return
|
||||
|
|
|
@ -876,7 +876,7 @@ class vmmEngine(vmmGObject):
|
|||
"libvirt version or hypervisor."))
|
||||
return
|
||||
|
||||
if util.chkbox_helper(src, self.config.get_confirm_poweroff,
|
||||
if not util.chkbox_helper(src, self.config.get_confirm_poweroff,
|
||||
self.config.set_confirm_poweroff,
|
||||
text1=_("Are you sure you want to save '%s'?" % vm.get_name())):
|
||||
return
|
||||
|
@ -959,7 +959,7 @@ class vmmEngine(vmmGObject):
|
|||
conn = self._lookup_connection(uri)
|
||||
vm = conn.get_vm(uuid)
|
||||
|
||||
if util.chkbox_helper(src, self.config.get_confirm_forcepoweroff,
|
||||
if not util.chkbox_helper(src, self.config.get_confirm_forcepoweroff,
|
||||
self.config.set_confirm_forcepoweroff,
|
||||
text1=_("Are you sure you want to force poweroff '%s'?" %
|
||||
vm.get_name()),
|
||||
|
@ -975,7 +975,7 @@ class vmmEngine(vmmGObject):
|
|||
conn = self._lookup_connection(uri)
|
||||
vm = conn.get_vm(uuid)
|
||||
|
||||
if util.chkbox_helper(src, self.config.get_confirm_pause,
|
||||
if not util.chkbox_helper(src, self.config.get_confirm_pause,
|
||||
self.config.set_confirm_pause,
|
||||
text1=_("Are you sure you want to pause '%s'?" %
|
||||
vm.get_name())):
|
||||
|
@ -1018,7 +1018,7 @@ class vmmEngine(vmmGObject):
|
|||
conn = self._lookup_connection(uri)
|
||||
vm = conn.get_vm(uuid)
|
||||
|
||||
if util.chkbox_helper(src, self.config.get_confirm_poweroff,
|
||||
if not util.chkbox_helper(src, self.config.get_confirm_poweroff,
|
||||
self.config.set_confirm_poweroff,
|
||||
text1=_("Are you sure you want to poweroff '%s'?" %
|
||||
vm.get_name())):
|
||||
|
@ -1032,7 +1032,7 @@ class vmmEngine(vmmGObject):
|
|||
conn = self._lookup_connection(uri)
|
||||
vm = conn.get_vm(uuid)
|
||||
|
||||
if util.chkbox_helper(src, self.config.get_confirm_poweroff,
|
||||
if not util.chkbox_helper(src, self.config.get_confirm_poweroff,
|
||||
self.config.set_confirm_poweroff,
|
||||
text1=_("Are you sure you want to reboot '%s'?" %
|
||||
vm.get_name())):
|
||||
|
|
|
@ -903,7 +903,7 @@ class vmmHost(vmmGObjectUI):
|
|||
if interface is None:
|
||||
return
|
||||
|
||||
if util.chkbox_helper(self, self.config.get_confirm_interface,
|
||||
if not util.chkbox_helper(self, self.config.get_confirm_interface,
|
||||
self.config.set_confirm_interface,
|
||||
text1=_("Are you sure you want to stop the interface "
|
||||
"'%s'?" % interface.get_name())):
|
||||
|
@ -918,7 +918,7 @@ class vmmHost(vmmGObjectUI):
|
|||
if interface is None:
|
||||
return
|
||||
|
||||
if util.chkbox_helper(self, self.config.get_confirm_interface,
|
||||
if not util.chkbox_helper(self, self.config.get_confirm_interface,
|
||||
self.config.set_confirm_interface,
|
||||
text1=_("Are you sure you want to start the interface "
|
||||
"'%s'?" % interface.get_name())):
|
||||
|
|
|
@ -361,17 +361,22 @@ def pretty_bytes(val):
|
|||
|
||||
xpath = virtinst.util.get_xml_path
|
||||
|
||||
def chkbox_helper(src, getcb, setcb, text1, text2=None, alwaysrecord=False,
|
||||
def chkbox_helper(src, getcb, setcb, text1, text2=None,
|
||||
alwaysrecord=False,
|
||||
default=True,
|
||||
chktext=_("Don't ask me again")):
|
||||
"""
|
||||
Helper to prompt user about proceeding with an operation
|
||||
Returns True if operation should be cancelled
|
||||
Returns True if the 'yes' or 'ok' button was selected, False otherwise
|
||||
|
||||
@alwaysrecord: Don't require user to select 'yes' to record chkbox value
|
||||
@default: What value to return if getcb tells us not to prompt
|
||||
"""
|
||||
import gtk
|
||||
|
||||
do_prompt = getcb()
|
||||
if not do_prompt:
|
||||
return False
|
||||
return default
|
||||
|
||||
res = src.err.warn_chkbox(text1=text1, text2=text2,
|
||||
chktext=chktext,
|
||||
|
@ -380,7 +385,7 @@ def chkbox_helper(src, getcb, setcb, text1, text2=None, alwaysrecord=False,
|
|||
if alwaysrecord or response:
|
||||
setcb(not skip_prompt)
|
||||
|
||||
return not response
|
||||
return response
|
||||
|
||||
def get_list_selection(widget):
|
||||
selection = widget.get_selection()
|
||||
|
|
Loading…
Reference in New Issue