virt-manager/53341e7e-hide-hardware-removal-for-non-devices.patch

62 lines
2.0 KiB
Diff
Raw Normal View History

Subject: virtManager: hide "Remove Hardware" for non-devices
From: Giuseppe Scrivano gscrivan@redhat.com Thu Mar 27 12:40:42 2014 +0100
Date: Thu Mar 27 13:50:06 2014 +0100:
Git: 37eecb215d137ffb6e98f36adfa37f96220d7287
The menu item "Remove Hardware" in the Overview window is valid only
when a hardware device is selected, hide it in any other case.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1081373
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
diff --git a/virtManager/details.py b/virtManager/details.py
index c1833ae..8c72efa 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -530,6 +530,7 @@ class vmmDetails(vmmGObjectUI):
self.oldhwkey = None
self.addhwmenu = None
+ self._addhwmenuitems = None
self.keycombo_menu = None
self.init_menus()
self.init_details()
@@ -706,6 +707,7 @@ class vmmDetails(vmmGObjectUI):
self.vm = None
self.conn = None
self.addhwmenu = None
+ self._addhwmenuitems = None
self.gfxdetails.cleanup()
self.gfxdetails = None
@@ -801,8 +803,9 @@ class vmmDetails(vmmGObjectUI):
rmHW.show()
rmHW.connect("activate", self.remove_xml_dev)
- self.addhwmenu.add(addHW)
- self.addhwmenu.add(rmHW)
+ self._addhwmenuitems = {"add" : addHW, "remove" : rmHW}
+ for i in self._addhwmenuitems.values():
+ self.addhwmenu.add(i)
# Don't allowing changing network/disks for Dom0
dom0 = self.vm.is_management_domain()
@@ -1075,6 +1078,16 @@ class vmmDetails(vmmGObjectUI):
if event.button != 3:
return
+ devobj = self.get_hw_selection(HW_LIST_COL_DEVICE)
+ if not devobj:
+ return
+
+ rmdev = self._addhwmenuitems["remove"]
+ if hasattr(devobj, "virtual_device_type"):
+ rmdev.show()
+ else:
+ rmdev.hide()
+
self.addhwmenu.popup(None, None, None, None, 0, event.time)
def control_fullscreen(self, src):