mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-08 04:58:29 +03:00
details: Unify controller model handling with addhardware
This commit is contained in:
parent
4b5c836a16
commit
2168f33799
@ -317,6 +317,8 @@
|
||||
<object class="GtkGrid" id="grid5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="vexpand">False</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<child>
|
||||
@ -358,16 +360,6 @@
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="controller-model">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="controller-tooltip">
|
||||
<property name="visible">True</property>
|
||||
@ -379,6 +371,22 @@
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="controller-model">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="combobox-entry4">
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
@ -391,7 +399,7 @@
|
||||
<object class="GtkLabel" id="label24">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Controller</property>
|
||||
<property name="label" translatable="yes">ctrl</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
|
@ -782,26 +782,19 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
break
|
||||
|
||||
@staticmethod
|
||||
def populate_controller_model_combo(combo, controller_type, remove_widget,
|
||||
add_default=False):
|
||||
def populate_controller_model_combo(combo, controller_type):
|
||||
model = combo.get_model()
|
||||
model.clear()
|
||||
|
||||
if remove_widget:
|
||||
remove_widget.set_sensitive(
|
||||
controller_type != virtinst.VirtualController.TYPE_USB)
|
||||
|
||||
model.append([None, _("Hypervisor default")])
|
||||
if controller_type == virtinst.VirtualController.TYPE_USB:
|
||||
model.append(["default", _("Hypervisor default")])
|
||||
model.append(["ich9-ehci1", "USB 2"])
|
||||
model.append(["nec-xhci", "USB 3"])
|
||||
elif controller_type == virtinst.VirtualController.TYPE_SCSI:
|
||||
model.append(["default", _("Hypervisor default")])
|
||||
model.append(["virtio-scsi", "VirtIO SCSI"])
|
||||
else:
|
||||
if add_default:
|
||||
model.append([None, _("Hypervisor default")])
|
||||
uiutil.set_grid_row_visible(combo, False)
|
||||
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def label_for_input_device(typ, bus):
|
||||
@ -899,8 +892,8 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
model_tooltip.set_tooltip_text(tooltip)
|
||||
|
||||
controller_type = self.get_config_controller_type()
|
||||
modellist = self.widget("controller-model")
|
||||
modellist.set_sensitive(True)
|
||||
combo = self.widget("controller-model")
|
||||
combo.set_sensitive(True)
|
||||
model_tooltip = self.widget("controller-tooltip")
|
||||
show_tooltip(model_tooltip, False)
|
||||
|
||||
@ -910,7 +903,8 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
(x.type == VirtualController.TYPE_USB)]
|
||||
if (len(usb_controllers) == 0):
|
||||
self.widget("create-finish").set_sensitive(True)
|
||||
elif (len(usb_controllers) == 1 and usb_controllers[0].model == "none"):
|
||||
elif (len(usb_controllers) == 1 and
|
||||
usb_controllers[0].model == "none"):
|
||||
self._remove_usb_controller = usb_controllers[0]
|
||||
self.widget("create-finish").set_sensitive(True)
|
||||
else:
|
||||
@ -918,11 +912,9 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self.widget("create-finish").set_sensitive(False)
|
||||
else:
|
||||
self.widget("create-finish").set_sensitive(True)
|
||||
uiutil.set_grid_row_visible(modellist, True)
|
||||
self.populate_controller_model_combo(modellist, controller_type, None, True)
|
||||
|
||||
if len(modellist.get_model()) > 0:
|
||||
modellist.set_active(0)
|
||||
self.populate_controller_model_combo(combo, controller_type)
|
||||
uiutil.set_grid_row_visible(combo, len(combo.get_model()) > 1)
|
||||
|
||||
|
||||
########################
|
||||
@ -1124,7 +1116,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
return uiutil.get_list_selection(self.widget("controller-type"), 0)
|
||||
|
||||
def get_config_controller_model(self):
|
||||
return uiutil.get_list_selection(self.widget("controller-model"), 0)
|
||||
return uiutil.get_combo_entry(self.widget("controller-model"), 0)
|
||||
|
||||
################
|
||||
# UI listeners #
|
||||
|
@ -2299,8 +2299,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
if self.edited(EDIT_CONTROLLER_MODEL):
|
||||
model = uiutil.get_combo_entry(self.widget("controller-model"))
|
||||
if model:
|
||||
kwargs["model"] = model
|
||||
kwargs["model"] = model
|
||||
|
||||
return vmmAddHardware.change_config_helper(self.vm.define_controller,
|
||||
kwargs, self.vm, self.err,
|
||||
@ -3101,20 +3100,18 @@ class vmmDetails(vmmGObjectUI):
|
||||
if not dev:
|
||||
return
|
||||
|
||||
self.widget("config-remove").set_sensitive(
|
||||
dev.type != virtinst.VirtualController.TYPE_USB)
|
||||
|
||||
type_label = dev.pretty_desc()
|
||||
model_label = dev.model
|
||||
if not model_label:
|
||||
model_label = _("Default")
|
||||
|
||||
self.widget("controller-type").set_text(type_label)
|
||||
|
||||
combo = self.widget("controller-model")
|
||||
uiutil.set_grid_row_visible(combo, True)
|
||||
|
||||
vmmAddHardware.populate_controller_model_combo(combo, dev.type,
|
||||
self.widget("config-remove"), False)
|
||||
|
||||
vmmAddHardware.populate_controller_model_combo(combo, dev.type)
|
||||
uiutil.set_grid_row_visible(combo,
|
||||
dev.model or len(combo.get_model()) > 1)
|
||||
uiutil.set_combo_entry(self.widget("controller-model"),
|
||||
dev.model or "Default")
|
||||
dev.model or None)
|
||||
|
||||
def refresh_filesystem_page(self):
|
||||
dev = self.get_hw_selection(HW_LIST_COL_DEVICE)
|
||||
|
@ -968,15 +968,11 @@ class vmmDomain(vmmLibvirtObject):
|
||||
else:
|
||||
dev = VirtualController(guest.conn)
|
||||
dev.type = "usb"
|
||||
if model != "default":
|
||||
dev.model = model
|
||||
dev.model = model
|
||||
guest.add_device(dev)
|
||||
|
||||
elif editdev.type == "scsi":
|
||||
if model == "default":
|
||||
editdev.model = None
|
||||
else:
|
||||
editdev.model = model
|
||||
else:
|
||||
editdev.model = model
|
||||
self.hotplug(device=editdev)
|
||||
|
||||
if model != _SENTINEL:
|
||||
|
Loading…
x
Reference in New Issue
Block a user