[virt-tools-list] [virt-manager PATCH v2 2/3] addhardware: introduce populate_controller_model_combo
Chen Hanxiao
chenhanxiao at cn.fujitsu.com
Wed Apr 23 10:23:29 UTC 2014
Introduce populate_controller_model_combo for details
and addhardware.
Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
virtManager/addhardware.py | 34 ++++++++++++++++++++++++++++++++++
virtManager/details.py | 14 ++------------
2 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 5e8030b..78235bb 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -113,6 +113,8 @@ class vmmAddHardware(vmmGObjectUI):
"on_rng_type_changed": self.change_rng,
"on_rng_backend_mode_changed": self.change_rng,
"on_rng_backend_type_changed": self.change_rng,
+
+ "on_controller_type_changed": self.populate_controller_model,
})
self.bind_escape_key_close()
@@ -737,6 +739,27 @@ class vmmAddHardware(vmmGObjectUI):
combo.set_active_iter(row.iter)
break
+ @staticmethod
+ def populate_controller_model_combo(combo, controller_type, widget_name, add_default=False):
+ model = combo.get_model()
+ model.clear()
+
+ if controller_type == virtinst.VirtualController.TYPE_USB:
+ model.append(["default", "Default"])
+ model.append(["ich9-ehci1", "USB 2"])
+ model.append(["nec-xhci", "USB 3"])
+ if widget_name is not None:
+ widget_name.set_sensitive(False)
+ elif controller_type == virtinst.VirtualController.TYPE_SCSI:
+ model.append(["default", "Default"])
+ model.append(["virtio-scsi", "VirtIO SCSI"])
+ else:
+ if add_default:
+ model.append([None, "Default"])
+ combo.set_sensitive(False)
+ if widget_name is not None:
+ widget_name.set_sensitive(True)
+
#########################
# UI population methods #
@@ -844,6 +867,17 @@ class vmmAddHardware(vmmGObjectUI):
if len(model) > 0:
widget.set_active(0)
+ def populate_controller_model(self, src):
+ ignore = src
+
+ controller_type = self.get_config_controller_type()
+ modellist = self.widget("controller-model")
+ modellist.set_sensitive(True)
+ self.populate_controller_model_combo(modellist, controller_type, None, True)
+
+ if len(modellist.get_model()) > 0:
+ modellist.set_active(0)
+
########################
# get_config_* methods #
diff --git a/virtManager/details.py b/virtManager/details.py
index 10afb68..38017d1 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -3035,18 +3035,8 @@ class vmmDetails(vmmGObjectUI):
combo = self.widget("controller-model")
uiutil.set_grid_row_visible(combo, True)
- model = combo.get_model()
- model.clear()
- if dev.type == virtinst.VirtualController.TYPE_USB:
- model.append(["default", "Default"])
- model.append(["ich9-ehci1", "USB 2"])
- model.append(["nec-xhci", "USB 3"])
- self.widget("config-remove").set_sensitive(False)
- elif dev.type == virtinst.VirtualController.TYPE_SCSI:
- model.append(["default", "Default"])
- model.append(["virtio-scsi", "VirtIO SCSI"])
- else:
- self.widget("config-remove").set_sensitive(True)
+ vmmAddHardware.populate_controller_model_combo(combo, dev.type,
+ self.widget("config-remove"), False)
uiutil.set_combo_entry(self.widget("controller-model"),
dev.model or "Default")
--
1.9.0
More information about the virt-tools-list
mailing list