[virt-tools-list] [virt-manager PATCH 5/5] details: Set tooltip on config-remove while it's not available
Cole Robinson
crobinso at redhat.com
Tue Jul 31 14:51:18 UTC 2018
Thanks for the patch. We can simplify code here and make this mistake
more obvious with a helper function. I'm pushing the attached commit to
add a _disable_device_remove helper that takes only a tooltip as an
argument, will save having to track can_remove. Please adapt patch #2
and this one to use it.
On 07/18/2018 06:00 AM, Lin Ma wrote:
> It informs users that why the device can't be removed.
>
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
> virtManager/details.py | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/virtManager/details.py b/virtManager/details.py
> index cb298f3f..7308cde3 100644
> --- a/virtManager/details.py
> +++ b/virtManager/details.py
> @@ -3016,6 +3016,7 @@ class vmmDetails(vmmGObjectUI):
> can_remove = True
> if self.vm.xmlobj.devices.graphics:
> can_remove = False
> + tooltip = _("Please remove the Graphics/Display devices first.")
I prefer "Cannot remove device while Graphics/Display is attached."
> self.widget("config-remove").set_sensitive(can_remove)
> self.widget("config-remove").set_tooltip_text(tooltip)
>
> @@ -3043,8 +3044,10 @@ class vmmDetails(vmmGObjectUI):
> can_remove = True
> if self.vm.get_xmlobj().os.is_x86() and controller.type == "usb":
> can_remove = False
> + tooltip = _("Hypervisor does not support removing this device")
> if controller.type == "pci":
> can_remove = False
> + tooltip = _("Hypervisor does not support removing this device")
> elif controller.type in ["scsi", "sata", "ide", "fdc"]:
> model = self.widget("controller-device-list").get_model()
> model.clear()
> @@ -3056,6 +3059,8 @@ class vmmDetails(vmmGObjectUI):
> model.append([infoStr])
> uiutil.set_grid_row_visible(self.widget("device-list-label"), True)
> uiutil.set_grid_row_visible(self.widget("controller-device-box"), True)
> + if can_remove is False:
> + tooltip = _("Disks are attaching to it")
I prefer: _("Cannot remove controller while devices are attached.")
> elif controller.type == "virtio-serial":
> for dev in self.vm.xmlobj.devices.channel:
> if dev.address.compare_controller(controller, dev.address.type):
> @@ -3069,6 +3074,8 @@ class vmmDetails(vmmGObjectUI):
> if controller.index == 0 and dev.target_type == "virtio":
> can_remove = False
> break
> + if can_remove is False:
> + tooltip = _("Channels or Consoles are attaching to it")
Same as above
>
> self.widget("config-remove").set_sensitive(can_remove)
> self.widget("config-remove").set_tooltip_text(tooltip)
>
Thanks,
Cole
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-details-Add-_disable_device_remove-helper.patch
Type: text/x-patch
Size: 2488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180731/63663693/attachment.bin>
More information about the virt-tools-list
mailing list