mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Handle the warning messages for disk device and non-disk device differently
add a remove-non-disk function and move the yes/no confirmation handling there Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
d62ca8220b
commit
2138cca6a5
@ -112,7 +112,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
||||
self.widget("delete-cancel").grab_focus()
|
||||
|
||||
# Show warning message if VM is running
|
||||
vm_active = self.vm.is_active()
|
||||
vm_active = self.vm.is_active() and not self.disk
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("delete-warn-running-vm-box"), vm_active)
|
||||
|
||||
|
@ -1107,6 +1107,12 @@ class vmmDetails(vmmGObjectUI):
|
||||
except Exception as e:
|
||||
self.err.show_err((_("Error launching hardware dialog: %s") %
|
||||
str(e)))
|
||||
def remove_non_disk(self, devobj):
|
||||
if not self.err.chkbox_helper(self.config.get_confirm_removedev,
|
||||
self.config.set_confirm_removedev,
|
||||
text1=(_("Are you sure you want to remove this device?"))):
|
||||
return
|
||||
self.remove_device(devobj)
|
||||
|
||||
def remove_disk(self, disk):
|
||||
from ..delete import vmmDeleteDialog
|
||||
@ -1119,7 +1125,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
if devobj.DEVICE_TYPE == "disk":
|
||||
self.remove_disk(devobj)
|
||||
else:
|
||||
self.remove_device(devobj)
|
||||
self.remove_non_disk(devobj)
|
||||
|
||||
|
||||
############################
|
||||
@ -1934,11 +1940,6 @@ class vmmDetails(vmmGObjectUI):
|
||||
def remove_device(self, devobj):
|
||||
log.debug("Removing device: %s", devobj)
|
||||
|
||||
if not self.err.chkbox_helper(self.config.get_confirm_removedev,
|
||||
self.config.set_confirm_removedev,
|
||||
text1=(_("Are you sure you want to remove this device?"))):
|
||||
return
|
||||
|
||||
# Define the change
|
||||
try:
|
||||
self.vm.remove_device(devobj)
|
||||
|
Loading…
Reference in New Issue
Block a user