summaryrefslogtreecommitdiff
path: root/virtManager
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2022-02-12 10:53:51 -0500
committerCole Robinson <crobinso@redhat.com>2022-02-12 11:24:44 -0500
commita39bd561b09ff5102dac79bf20e48fcdaa878d92 (patch)
treec7fff197d56f6d501a9116656987ebb27294c09d /virtManager
parenta4c02b1aed30c6e0ec92e75bf8560ab39b39db60 (diff)
downloadvirt-manager-a39bd561b09ff5102dac79bf20e48fcdaa878d92.tar.gz
addhardware: tweak mdev inactive UI
- Move tooltip to the tree row instead of the finish button - Some style cleanups - Add a hack so we can hit it in the test suite Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virtManager')
-rw-r--r--virtManager/addhardware.py32
-rw-r--r--virtManager/object/nodedev.py5
2 files changed, 19 insertions, 18 deletions
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 88ed4579..1f257db4 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -753,32 +753,22 @@ class vmmAddHardware(vmmGObjectUI):
def _build_hostdev_treeview(self):
host_dev = self.widget("host-device")
- # [ xmlobj, label]
- host_dev_model = Gtk.ListStore(object, str, bool)
+ # [ xmlobj, label, sensitive, tooltip]
+ host_dev_model = Gtk.ListStore(object, str, bool, str)
host_dev.set_model(host_dev_model)
host_col = Gtk.TreeViewColumn()
text = Gtk.CellRendererText()
host_col.pack_start(text, True)
host_col.add_attribute(text, 'text', 1)
host_col.add_attribute(text, 'sensitive', 2)
+ host_dev.set_tooltip_column(3)
host_dev_model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
host_dev.append_column(host_col)
def _hostdev_row_selected_cb(self, selection):
model, treeiter = selection.get_selected()
-
- if treeiter is None:
- return
-
- row = model[treeiter]
- tooltip = None
- sensitive = row[2]
- if row[0] and sensitive is False:
- tooltip = (_("%s is not active in the host system.\n"
- "Please start the mdev in the host system before adding it to the guest.")
- % row[1])
- self.widget("create-finish").set_tooltip_text(tooltip)
+ sensitive = treeiter and model[treeiter][2] or False
self.widget("create-finish").set_sensitive(sensitive)
@@ -809,15 +799,21 @@ class vmmAddHardware(vmmGObjectUI):
prettyname = "%s %s" % (
parentdev.pretty_name(), prettyname)
- model.append([dev.xmlobj, prettyname, dev.is_active()])
+ tooltip = None
+ sensitive = dev.is_active()
+ if not sensitive:
+ tooltip = _("%s is not active in the host system.\n"
+ "Please start the mdev in the host system before "
+ "adding it to the guest.") % prettyname
+ model.append([dev.xmlobj, prettyname, sensitive, tooltip])
if len(model) == 0:
- model.append([None, _("No Devices Available"), False])
+ model.append([None, _("No Devices Available"), False, None])
uiutil.set_list_selection_by_number(devlist, 0)
- devlist.get_selection().connect("changed",
- self._hostdev_row_selected_cb)
+ devlist.get_selection().connect(
+ "changed", self._hostdev_row_selected_cb)
devlist.get_selection().emit("changed")
diff --git a/virtManager/object/nodedev.py b/virtManager/object/nodedev.py
index 68f05b14..2a6510fa 100644
--- a/virtManager/object/nodedev.py
+++ b/virtManager/object/nodedev.py
@@ -66,6 +66,11 @@ class vmmNodeDevice(vmmLibvirtObject):
is_active = True
if self.conn.support.nodedev_isactive(self._backend):
is_active = self._backend.isActive() # pragma: no cover
+
+ if self.conn.is_test() and self.xmlobj.name.endswith("-fakeinactive"):
+ # Testsuite hack to mock inactive device
+ is_active = False
+
return (is_active and
self._STATUS_ACTIVE or
self._STATUS_INACTIVE)