[virt-tools-list] [PATCH virt-manager] virtManager: hide "Remove Hardware" for non-devices

Giuseppe Scrivano gscrivan at redhat.com
Thu Mar 27 11:56:35 UTC 2014


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 at redhat.com>
---
 virtManager/details.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

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):
-- 
1.8.5.3




More information about the virt-tools-list mailing list