mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
uiutil: Merge get_combo_entry into get_list_selection
There's no reason we can't handle it together
This commit is contained in:
parent
fdad3efe24
commit
5219e49eec
@ -1523,7 +1523,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self.widget("config-storage-devtype"))
|
||||
cache = uiutil.get_list_selection(
|
||||
self.widget("config-storage-cache"))
|
||||
fmt = uiutil.get_combo_entry(self.widget("config-storage-format"))
|
||||
fmt = uiutil.get_list_selection(self.widget("config-storage-format"))
|
||||
|
||||
controller_model = None
|
||||
if bus == "virtio-scsi":
|
||||
@ -1565,7 +1565,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_network(self):
|
||||
nettype = self._netlist.get_network_selection()[0]
|
||||
model = uiutil.get_combo_entry(self.widget("net-model"))
|
||||
model = uiutil.get_list_selection(self.widget("net-model"))
|
||||
mac = None
|
||||
if self.widget("mac-address").get_active():
|
||||
mac = self.widget("create-mac-address").get_text()
|
||||
@ -1818,7 +1818,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
conn = self.conn.get_backend()
|
||||
controller_type = uiutil.get_list_selection(
|
||||
self.widget("controller-type"))
|
||||
model = uiutil.get_combo_entry(self.widget("controller-model"))
|
||||
model = uiutil.get_list_selection(self.widget("controller-model"))
|
||||
|
||||
self._dev = VirtualController(conn)
|
||||
self._selected_model = model
|
||||
|
@ -2012,7 +2012,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs["machine"] = uiutil.get_list_selection(
|
||||
self.widget("overview-chipset"), column=1)
|
||||
else:
|
||||
kwargs["machine"] = uiutil.get_combo_entry(
|
||||
kwargs["machine"] = uiutil.get_list_selection(
|
||||
self.widget("machine-type"))
|
||||
|
||||
if self.edited(EDIT_DESC):
|
||||
@ -2162,20 +2162,21 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.widget("disk-removable").get_active())
|
||||
|
||||
if self.edited(EDIT_DISK_CACHE):
|
||||
kwargs["cache"] = uiutil.get_combo_entry(self.widget("disk-cache"))
|
||||
kwargs["cache"] = uiutil.get_list_selection(
|
||||
self.widget("disk-cache"))
|
||||
|
||||
if self.edited(EDIT_DISK_IO):
|
||||
kwargs["io"] = uiutil.get_combo_entry(self.widget("disk-io"))
|
||||
kwargs["io"] = uiutil.get_list_selection(self.widget("disk-io"))
|
||||
|
||||
if self.edited(EDIT_DISK_FORMAT):
|
||||
kwargs["driver_type"] = uiutil.get_combo_entry(
|
||||
kwargs["driver_type"] = uiutil.get_list_selection(
|
||||
self.widget("disk-format"))
|
||||
|
||||
if self.edited(EDIT_DISK_SERIAL):
|
||||
kwargs["serial"] = self.get_text("disk-serial")
|
||||
|
||||
if self.edited(EDIT_DISK_SGIO):
|
||||
sgio = uiutil.get_combo_entry(self.widget("disk-sgio"))
|
||||
sgio = uiutil.get_list_selection(self.widget("disk-sgio"))
|
||||
kwargs["sgio"] = sgio
|
||||
|
||||
if self.edited(EDIT_DISK_IOTUNE):
|
||||
@ -2193,7 +2194,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.widget("disk-iotune-wis").get_value())
|
||||
|
||||
if self.edited(EDIT_DISK_BUS):
|
||||
bus = uiutil.get_combo_entry(self.widget("disk-bus"))
|
||||
bus = uiutil.get_list_selection(self.widget("disk-bus"))
|
||||
addr = None
|
||||
if bus == "spapr-vscsi":
|
||||
bus = "scsi"
|
||||
@ -2210,7 +2211,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs = {}
|
||||
|
||||
if self.edited(EDIT_SOUND_MODEL):
|
||||
model = uiutil.get_combo_entry(self.widget("sound-model"))
|
||||
model = uiutil.get_list_selection(self.widget("sound-model"))
|
||||
if model:
|
||||
kwargs["model"] = model
|
||||
|
||||
@ -2222,7 +2223,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs = {}
|
||||
|
||||
if self.edited(EDIT_SMARTCARD_MODE):
|
||||
model = uiutil.get_combo_entry(self.widget("smartcard-mode"))
|
||||
model = uiutil.get_list_selection(self.widget("smartcard-mode"))
|
||||
if model:
|
||||
kwargs["model"] = model
|
||||
|
||||
@ -2234,7 +2235,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs = {}
|
||||
|
||||
if self.edited(EDIT_NET_MODEL):
|
||||
model = uiutil.get_combo_entry(self.widget("network-model"))
|
||||
model = uiutil.get_list_selection(self.widget("network-model"))
|
||||
addrstr = None
|
||||
if model == "spapr-vlan":
|
||||
addrstr = "spapr-vio"
|
||||
@ -2285,7 +2286,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs = {}
|
||||
|
||||
if self.edited(EDIT_VIDEO_MODEL):
|
||||
model = uiutil.get_combo_entry(self.widget("video-model"))
|
||||
model = uiutil.get_list_selection(self.widget("video-model"))
|
||||
if model:
|
||||
kwargs["model"] = model
|
||||
|
||||
@ -2297,7 +2298,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs = {}
|
||||
|
||||
if self.edited(EDIT_CONTROLLER_MODEL):
|
||||
model = uiutil.get_combo_entry(self.widget("controller-model"))
|
||||
model = uiutil.get_list_selection(self.widget("controller-model"))
|
||||
kwargs["model"] = model
|
||||
|
||||
return vmmAddHardware.change_config_helper(self.vm.define_controller,
|
||||
@ -2308,11 +2309,11 @@ class vmmDetails(vmmGObjectUI):
|
||||
kwargs = {}
|
||||
|
||||
if self.edited(EDIT_WATCHDOG_MODEL):
|
||||
kwargs["model"] = uiutil.get_combo_entry(
|
||||
kwargs["model"] = uiutil.get_list_selection(
|
||||
self.widget("watchdog-model"))
|
||||
|
||||
if self.edited(EDIT_WATCHDOG_ACTION):
|
||||
kwargs["action"] = uiutil.get_combo_entry(
|
||||
kwargs["action"] = uiutil.get_list_selection(
|
||||
self.widget("watchdog-action"))
|
||||
|
||||
return vmmAddHardware.change_config_helper(self.vm.define_watchdog,
|
||||
|
@ -135,7 +135,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
||||
gtype = uiutil.get_list_selection(self.widget("graphics-type"))
|
||||
port, tlsport = self._get_config_graphics_ports()
|
||||
addr = uiutil.get_list_selection(self.widget("graphics-address"))
|
||||
keymap = uiutil.get_combo_entry(self.widget("graphics-keymap"))
|
||||
keymap = uiutil.get_list_selection(self.widget("graphics-keymap"))
|
||||
if keymap == "auto":
|
||||
keymap = None
|
||||
|
||||
|
@ -316,11 +316,11 @@ class vmmNetworkList(vmmGObjectUI):
|
||||
|
||||
mode = None
|
||||
if self.widget("net-source-mode").is_visible():
|
||||
mode = uiutil.get_combo_entry(self.widget("net-source-mode"))
|
||||
mode = uiutil.get_list_selection(self.widget("net-source-mode"))
|
||||
|
||||
portgroup = None
|
||||
if self.widget("net-portgroup").is_visible():
|
||||
portgroup = uiutil.get_combo_entry(self.widget("net-portgroup"))
|
||||
portgroup = uiutil.get_list_selection(self.widget("net-portgroup"))
|
||||
|
||||
return net_type, net_src, mode, portgroup or None
|
||||
|
||||
|
@ -86,12 +86,19 @@ def get_list_selected_row(widget, check_visible=False):
|
||||
|
||||
def get_list_selection(widget, column=0, check_visible=False):
|
||||
"""
|
||||
Helper to simplify getting the selected row and value in a list/tree/combo
|
||||
Helper to simplify getting the selected row and value in a list/tree/combo.
|
||||
If nothing is selected, and the widget is a combo box with a text entry,
|
||||
return the value of that.
|
||||
"""
|
||||
row = get_list_selected_row(widget, check_visible=check_visible)
|
||||
if row is None:
|
||||
return None
|
||||
return row[column]
|
||||
if row is not None:
|
||||
return row[column]
|
||||
|
||||
if hasattr(widget, "get_has_entry"):
|
||||
if widget.get_has_entry():
|
||||
return widget.get_child().get_text().strip()
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def select_list_row_by_number(widget, rownum):
|
||||
@ -150,19 +157,6 @@ def set_combo_entry(combo, value, column=0):
|
||||
combo.get_child().set_text(value or "")
|
||||
|
||||
|
||||
def get_combo_entry(combo, column=0):
|
||||
"""
|
||||
Helper to get the value specified in a combo box, with or
|
||||
without and entry
|
||||
"""
|
||||
row = get_list_selected_row(combo)
|
||||
if row:
|
||||
return row[column]
|
||||
if not combo.get_has_entry():
|
||||
return None
|
||||
return combo.get_child().get_text().strip()
|
||||
|
||||
|
||||
def child_get_property(parent, child, propname):
|
||||
"""
|
||||
Wrapper for child_get_property, which pygobject doesn't properly
|
||||
|
Loading…
Reference in New Issue
Block a user