mirror of
https://github.com/virt-manager/virt-manager.git
synced 2026-08-05 10:47:23 -05:00
uiutil: streamline column vs rowidx parameter name
This commit is contained in:
+29
-29
@@ -947,7 +947,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
model_tooltip.set_tooltip_text(tooltip)
|
||||
|
||||
controller_type = uiutil.get_list_selection(
|
||||
self.widget("controller-type"), 0)
|
||||
self.widget("controller-type"))
|
||||
combo = self.widget("controller-model")
|
||||
combo.set_sensitive(True)
|
||||
model_tooltip = self.widget("controller-tooltip")
|
||||
@@ -1046,7 +1046,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
uiutil.select_list_row_by_number(self.widget("hw-list"), page)
|
||||
|
||||
def _get_hw_selection(self):
|
||||
return uiutil.get_list_selection(self.widget("hw-list"), None)
|
||||
return uiutil.get_list_selected_row(self.widget("hw-list"))
|
||||
|
||||
|
||||
################
|
||||
@@ -1177,7 +1177,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _change_storage_devtype(self, ignore):
|
||||
devtype = uiutil.get_list_selection(
|
||||
self.widget("config-storage-devtype"), 0)
|
||||
self.widget("config-storage-devtype"))
|
||||
self._refresh_disk_bus(devtype)
|
||||
|
||||
allow_create = devtype not in ["cdrom", "floppy"]
|
||||
@@ -1193,7 +1193,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self.widget("create-mac-address").set_sensitive(False)
|
||||
|
||||
def _change_tpm_device_type(self, src):
|
||||
devtype = uiutil.get_list_selection(src, 0)
|
||||
devtype = uiutil.get_list_selection(src)
|
||||
if devtype is None:
|
||||
return
|
||||
|
||||
@@ -1235,7 +1235,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
settype)
|
||||
|
||||
def _change_char_device_type(self, src):
|
||||
devtype = uiutil.get_list_selection(src, 0)
|
||||
devtype = uiutil.get_list_selection(src)
|
||||
if devtype is None:
|
||||
return
|
||||
|
||||
@@ -1275,22 +1275,22 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self.widget("char-mode").set_active(0)
|
||||
|
||||
def _change_usbredir_type(self, src):
|
||||
showhost = uiutil.get_list_selection(src, 2)
|
||||
showhost = uiutil.get_list_selection(src, column=2)
|
||||
if showhost is None:
|
||||
return
|
||||
uiutil.set_grid_row_visible(self.widget("usbredir-host-box"),
|
||||
showhost)
|
||||
|
||||
def _change_rng(self, ignore1):
|
||||
rtype = uiutil.get_list_selection(self.widget("rng-type"), 0)
|
||||
rtype = uiutil.get_list_selection(self.widget("rng-type"))
|
||||
is_egd = rtype == virtinst.VirtualRNGDevice.TYPE_EGD
|
||||
uiutil.set_grid_row_visible(self.widget("rng-device"), not is_egd)
|
||||
uiutil.set_grid_row_visible(self.widget("rng-backend-type"), is_egd)
|
||||
|
||||
backend_type = uiutil.get_list_selection(
|
||||
self.widget("rng-backend-type"), 0)
|
||||
self.widget("rng-backend-type"))
|
||||
backend_mode = uiutil.get_list_selection(
|
||||
self.widget("rng-backend-mode"), 0)
|
||||
self.widget("rng-backend-mode"))
|
||||
udp = backend_type == virtinst.VirtualRNGDevice.BACKEND_TYPE_UDP
|
||||
bind = backend_mode == virtinst.VirtualRNGDevice.BACKEND_MODE_BIND
|
||||
|
||||
@@ -1518,11 +1518,11 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_storage(self):
|
||||
bus = uiutil.get_list_selection(
|
||||
self.widget("config-storage-bustype"), 0)
|
||||
self.widget("config-storage-bustype"))
|
||||
device = uiutil.get_list_selection(
|
||||
self.widget("config-storage-devtype"), 0)
|
||||
self.widget("config-storage-devtype"))
|
||||
cache = uiutil.get_list_selection(
|
||||
self.widget("config-storage-cache"), 0)
|
||||
self.widget("config-storage-cache"))
|
||||
fmt = uiutil.get_combo_entry(self.widget("config-storage-format"))
|
||||
|
||||
controller_model = None
|
||||
@@ -1585,7 +1585,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self._dev = ret
|
||||
|
||||
def _validate_page_input(self):
|
||||
row = uiutil.get_list_selection(self.widget("input-type"), None)
|
||||
row = uiutil.get_list_selected_row(self.widget("input-type"))
|
||||
dev = virtinst.VirtualInputDevice(self.conn.get_backend())
|
||||
dev.type = row[1]
|
||||
dev.bus = row[2]
|
||||
@@ -1609,7 +1609,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self.err.val_err(_("Graphics device parameter error"), e)
|
||||
|
||||
def _validate_page_sound(self):
|
||||
smodel = uiutil.get_list_selection(self.widget("sound-model"), 0)
|
||||
smodel = uiutil.get_list_selection(self.widget("sound-model"))
|
||||
|
||||
try:
|
||||
self._dev = virtinst.VirtualAudio(self.conn.get_backend())
|
||||
@@ -1618,7 +1618,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
return self.err.val_err(_("Sound device parameter error"), e)
|
||||
|
||||
def _validate_page_hostdev(self):
|
||||
row = uiutil.get_list_selection(self.widget("host-device"), None)
|
||||
row = uiutil.get_list_selected_row(self.widget("host-device"))
|
||||
is_dup = False
|
||||
|
||||
if row is None:
|
||||
@@ -1663,7 +1663,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
modebox = self.widget("char-mode")
|
||||
devbox = self.widget("char-device-type")
|
||||
typebox = self.widget("char-target-type")
|
||||
devtype = uiutil.get_list_selection(devbox, 0)
|
||||
devtype = uiutil.get_list_selection(devbox)
|
||||
conn = self.conn.get_backend()
|
||||
|
||||
devclass = char_class(conn)
|
||||
@@ -1671,13 +1671,13 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
source_path = self.widget("char-path").get_text()
|
||||
source_channel = self.widget("char-channel").get_text()
|
||||
source_mode = uiutil.get_list_selection(modebox, 0)
|
||||
source_mode = uiutil.get_list_selection(modebox)
|
||||
source_host = self.widget("char-host").get_text()
|
||||
bind_host = self.widget("char-bind-host").get_text()
|
||||
source_port = self.widget("char-port").get_value()
|
||||
bind_port = self.widget("char-bind-port").get_value()
|
||||
target_name = self.widget("char-target-name").get_child().get_text()
|
||||
target_type = uiutil.get_list_selection(typebox, 0)
|
||||
target_type = uiutil.get_list_selection(typebox)
|
||||
|
||||
if self.widget("char-use-telnet").get_active():
|
||||
protocol = VirtualSerialDevice.PROTOCOL_TELNET
|
||||
@@ -1722,7 +1722,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_video(self):
|
||||
conn = self.conn.get_backend()
|
||||
model = uiutil.get_list_selection(self.widget("video-model"), 0)
|
||||
model = uiutil.get_list_selection(self.widget("video-model"))
|
||||
|
||||
try:
|
||||
self._dev = VirtualVideoDevice(conn)
|
||||
@@ -1732,8 +1732,8 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_watchdog(self):
|
||||
conn = self.conn.get_backend()
|
||||
model = uiutil.get_list_selection(self.widget("watchdog-model"), 0)
|
||||
action = uiutil.get_list_selection(self.widget("watchdog-action"), 0)
|
||||
model = uiutil.get_list_selection(self.widget("watchdog-model"))
|
||||
action = uiutil.get_list_selection(self.widget("watchdog-action"))
|
||||
|
||||
try:
|
||||
self._dev = VirtualWatchdog(conn)
|
||||
@@ -1749,7 +1749,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_smartcard(self):
|
||||
conn = self.conn.get_backend()
|
||||
mode = uiutil.get_list_selection(self.widget("smartcard-mode"), 0)
|
||||
mode = uiutil.get_list_selection(self.widget("smartcard-mode"))
|
||||
|
||||
try:
|
||||
self._dev = VirtualSmartCardDevice(conn)
|
||||
@@ -1759,7 +1759,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_usbredir(self):
|
||||
conn = self.conn.get_backend()
|
||||
stype = uiutil.get_list_selection(self.widget("usbredir-list"), 0)
|
||||
stype = uiutil.get_list_selection(self.widget("usbredir-list"))
|
||||
host = None
|
||||
service = None
|
||||
if self.widget("usbredir-host").is_visible():
|
||||
@@ -1779,7 +1779,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _validate_page_tpm(self):
|
||||
conn = self.conn.get_backend()
|
||||
typ = uiutil.get_list_selection(self.widget("tpm-type"), 0)
|
||||
typ = uiutil.get_list_selection(self.widget("tpm-type"))
|
||||
|
||||
device_path = self.widget("tpm-device-path").get_text()
|
||||
|
||||
@@ -1817,8 +1817,8 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
def _validate_page_controller(self):
|
||||
conn = self.conn.get_backend()
|
||||
controller_type = uiutil.get_list_selection(
|
||||
self.widget("controller-type"), 0)
|
||||
model = uiutil.get_combo_entry(self.widget("controller-model"), 0)
|
||||
self.widget("controller-type"))
|
||||
model = uiutil.get_combo_entry(self.widget("controller-model"))
|
||||
|
||||
self._dev = VirtualController(conn)
|
||||
self._selected_model = model
|
||||
@@ -1838,11 +1838,11 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self._dev.model = model
|
||||
|
||||
def _validate_page_rng(self):
|
||||
rtype = uiutil.get_list_selection(self.widget("rng-type"), 0)
|
||||
rtype = uiutil.get_list_selection(self.widget("rng-type"))
|
||||
backend_type = uiutil.get_list_selection(
|
||||
self.widget("rng-backend-type"), 0)
|
||||
self.widget("rng-backend-type"))
|
||||
backend_mode = uiutil.get_list_selection(
|
||||
self.widget("rng-backend-mode"), 0)
|
||||
self.widget("rng-backend-mode"))
|
||||
|
||||
connect_host = self.widget("rng-connect-host").get_text()
|
||||
connect_service = uiutil.spin_get_helper(
|
||||
|
||||
@@ -369,7 +369,7 @@ class vmmConnect(vmmGObjectUI):
|
||||
self.widget("username-entry").set_text(default_user)
|
||||
|
||||
def generate_uri(self):
|
||||
hv = uiutil.get_list_selection(self.widget("hypervisor"), 0)
|
||||
hv = uiutil.get_list_selection(self.widget("hypervisor"))
|
||||
conn = self.widget("transport").get_active()
|
||||
host = self.widget("hostname").get_child().get_text().strip()
|
||||
user = self.widget("username-entry").get_text()
|
||||
|
||||
+8
-11
@@ -940,7 +940,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
return self.widget("create-vm-name").get_text()
|
||||
|
||||
def get_config_machine(self):
|
||||
return uiutil.get_list_selection(self.widget("config-machine"), 0,
|
||||
return uiutil.get_list_selection(self.widget("config-machine"),
|
||||
check_visible=True)
|
||||
|
||||
def is_install_page(self):
|
||||
@@ -965,10 +965,8 @@ class vmmCreate(vmmGObjectUI):
|
||||
return INSTALL_PAGE_CONTAINER_OS
|
||||
|
||||
def get_config_os_info(self):
|
||||
drow = uiutil.get_list_selection(
|
||||
self.widget("install-os-type"), None)
|
||||
vrow = uiutil.get_list_selection(
|
||||
self.widget("install-os-version"), None)
|
||||
drow = uiutil.get_list_selected_row(self.widget("install-os-type"))
|
||||
vrow = uiutil.get_list_selected_row(self.widget("install-os-version"))
|
||||
distro = None
|
||||
dlabel = None
|
||||
variant = None
|
||||
@@ -1060,7 +1058,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
|
||||
# Listeners
|
||||
def conn_changed(self, src):
|
||||
uri = uiutil.get_list_selection(src, 0)
|
||||
uri = uiutil.get_list_selection(src)
|
||||
conn = None
|
||||
if uri:
|
||||
conn = self.engine.conns[uri]["conn"]
|
||||
@@ -1112,7 +1110,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
"<small>%s</small>" % _("Network selection does not support PXE"))
|
||||
|
||||
def hv_changed(self, src):
|
||||
hv = uiutil.get_list_selection(src, 1)
|
||||
hv = uiutil.get_list_selection(src, column=1)
|
||||
if not hv:
|
||||
return
|
||||
|
||||
@@ -1120,7 +1118,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
self.populate_arch()
|
||||
|
||||
def arch_changed(self, src):
|
||||
arch = uiutil.get_list_selection(src, 0)
|
||||
arch = uiutil.get_list_selection(src)
|
||||
if not arch:
|
||||
return
|
||||
|
||||
@@ -1166,8 +1164,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
self.detect_media_os()
|
||||
|
||||
def _selected_os_row(self):
|
||||
return uiutil.get_list_selection(
|
||||
self.widget("install-os-type"), None)
|
||||
return uiutil.get_list_selected_row(self.widget("install-os-type"))
|
||||
|
||||
def change_os_type(self, box):
|
||||
ignore = box
|
||||
@@ -1181,7 +1178,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
return
|
||||
|
||||
def change_os_version(self, box):
|
||||
show_all = uiutil.get_list_selection(box, 3)
|
||||
show_all = uiutil.get_list_selection(box, column=3)
|
||||
if not show_all:
|
||||
return
|
||||
|
||||
|
||||
@@ -590,7 +590,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
#########################
|
||||
|
||||
def get_config_interface_type(self):
|
||||
return uiutil.get_list_selection(self.widget("interface-type"), 0)
|
||||
return uiutil.get_list_selection(self.widget("interface-type"))
|
||||
|
||||
def set_interface_name(self, name):
|
||||
if self.widget("interface-name-entry").get_visible():
|
||||
@@ -607,7 +607,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
return self.widget("interface-name-label").get_text()
|
||||
|
||||
def get_config_interface_startmode(self):
|
||||
return uiutil.get_list_selection(self.widget("interface-startmode"), 0)
|
||||
return uiutil.get_list_selection(self.widget("interface-startmode"))
|
||||
|
||||
def get_config_selected_interfaces(self):
|
||||
iface_list = self.widget("interface-list")
|
||||
@@ -672,7 +672,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
self.set_interface_name(name)
|
||||
|
||||
def bond_monitor_mode_changed(self, src):
|
||||
value = uiutil.get_list_selection(src, 1)
|
||||
value = uiutil.get_list_selection(src, column=1)
|
||||
bond_pages = self.widget("bond-pages")
|
||||
|
||||
if value == "arpmon":
|
||||
@@ -706,8 +706,9 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
self.widget("bridge-config-label").set_text(txt)
|
||||
|
||||
def update_bond_desc(self):
|
||||
mode = uiutil.get_list_selection(self.widget("bond-mode"), 0)
|
||||
mon = uiutil.get_list_selection(self.widget("bond-monitor-mode"), 1)
|
||||
mode = uiutil.get_list_selection(self.widget("bond-mode"))
|
||||
mon = uiutil.get_list_selection(
|
||||
self.widget("bond-monitor-mode"), column=1)
|
||||
|
||||
txt = mode
|
||||
if mon:
|
||||
@@ -771,8 +772,8 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
|
||||
is_manual = self.widget("ip-do-manual").get_active()
|
||||
|
||||
copy_row = uiutil.get_list_selection(
|
||||
self.widget("ip-copy-interface-combo"), None)
|
||||
copy_row = uiutil.get_list_selected_row(
|
||||
self.widget("ip-copy-interface-combo"))
|
||||
|
||||
v4_mode = self.widget("ipv4-mode").get_active()
|
||||
v4_addr = self.widget("ipv4-address").get_text()
|
||||
@@ -1022,10 +1023,11 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
|
||||
|
||||
def validate_bond(self, iobj, ifaces):
|
||||
mode = uiutil.get_list_selection(self.widget("bond-mode"), 1)
|
||||
mon = uiutil.get_list_selection(self.widget("bond-monitor-mode"), 1)
|
||||
arp_val = uiutil.get_list_selection(self.widget("arp-validate"), 0)
|
||||
mii_car = uiutil.get_list_selection(self.widget("mii-carrier"), 0)
|
||||
mode = uiutil.get_list_selection(self.widget("bond-mode"), column=1)
|
||||
mon = uiutil.get_list_selection(
|
||||
self.widget("bond-monitor-mode"), column=1)
|
||||
arp_val = uiutil.get_list_selection(self.widget("arp-validate"))
|
||||
mii_car = uiutil.get_list_selection(self.widget("mii-carrier"))
|
||||
|
||||
# ARP params
|
||||
arp_int = self.widget("arp-interval").get_value()
|
||||
|
||||
@@ -226,8 +226,9 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
if self.widget("net-forward-none").get_active():
|
||||
return [None, None]
|
||||
|
||||
name = uiutil.get_list_selection(self.widget("net-forward"), 1)
|
||||
mode = uiutil.get_list_selection(self.widget("net-forward-mode"), 1)
|
||||
name = uiutil.get_list_selection(self.widget("net-forward"), column=1)
|
||||
mode = uiutil.get_list_selection(
|
||||
self.widget("net-forward-mode"), column=1)
|
||||
return [name, mode]
|
||||
|
||||
def get_config_routev4_network(self):
|
||||
|
||||
@@ -310,7 +310,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
|
||||
|
||||
def get_config_type(self):
|
||||
return uiutil.get_list_selection(self.widget("pool-type"), 0)
|
||||
return uiutil.get_list_selection(self.widget("pool-type"))
|
||||
|
||||
def get_config_name(self):
|
||||
return self.widget("pool-name").get_text()
|
||||
@@ -320,7 +320,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
if not src.get_sensitive():
|
||||
return None
|
||||
|
||||
ret = uiutil.get_list_selection(src, 1)
|
||||
ret = uiutil.get_list_selection(src, column=1)
|
||||
if ret is not None:
|
||||
return ret
|
||||
return src.get_child().get_text()
|
||||
@@ -330,7 +330,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
if not src.get_sensitive():
|
||||
return None
|
||||
|
||||
ret = uiutil.get_list_selection(src, 1)
|
||||
ret = uiutil.get_list_selection(src, column=1)
|
||||
if ret is not None:
|
||||
return ret
|
||||
return src.get_child().get_text().strip()
|
||||
@@ -348,7 +348,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
return None
|
||||
|
||||
def get_config_format(self):
|
||||
return uiutil.get_list_selection(self.widget("pool-format"), 0)
|
||||
return uiutil.get_list_selection(self.widget("pool-format"))
|
||||
|
||||
def get_config_iqn(self):
|
||||
iqn = self.widget("pool-iqn")
|
||||
@@ -479,9 +479,9 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
source_list = self.widget("pool-source-path")
|
||||
target_list = self.widget("pool-target-path")
|
||||
|
||||
pool = uiutil.get_list_selection(source_list, 2)
|
||||
pool = uiutil.get_list_selection(source_list, column=2)
|
||||
if pool is None:
|
||||
pool = uiutil.get_list_selection(target_list, 2)
|
||||
pool = uiutil.get_list_selection(target_list, column=2)
|
||||
|
||||
return pool
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
|
||||
|
||||
def get_config_format(self):
|
||||
return uiutil.get_list_selection(self.widget("vol-format"), 0)
|
||||
return uiutil.get_list_selection(self.widget("vol-format"))
|
||||
|
||||
def populate_vol_format(self):
|
||||
stable_whitelist = ["raw", "qcow2", "qed"]
|
||||
|
||||
@@ -1107,7 +1107,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.widget("toolbar-box").hide()
|
||||
|
||||
def get_boot_selection(self):
|
||||
return uiutil.get_list_selection(self.widget("config-boot-list"), None)
|
||||
return uiutil.get_list_selected_row(self.widget("config-boot-list"))
|
||||
|
||||
def set_hw_selection(self, page, disable_apply=True):
|
||||
if disable_apply:
|
||||
@@ -1115,7 +1115,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
uiutil.select_list_row_by_number(self.widget("hw-list"), page)
|
||||
|
||||
def get_hw_row(self):
|
||||
return uiutil.get_list_selection(self.widget("hw-list"), None)
|
||||
return uiutil.get_list_selected_row(self.widget("hw-list"))
|
||||
|
||||
def get_hw_selection(self, field):
|
||||
row = self.get_hw_row()
|
||||
@@ -2005,12 +2005,12 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
if self.edited(EDIT_FIRMWARE):
|
||||
kwargs["loader"] = uiutil.get_list_selection(
|
||||
self.widget("overview-firmware"), 1)
|
||||
self.widget("overview-firmware"), column=1)
|
||||
|
||||
if self.edited(EDIT_MACHTYPE):
|
||||
if self.widget("overview-chipset").is_visible():
|
||||
kwargs["machine"] = uiutil.get_list_selection(
|
||||
self.widget("overview-chipset"), 1)
|
||||
self.widget("overview-chipset"), column=1)
|
||||
else:
|
||||
kwargs["machine"] = uiutil.get_combo_entry(
|
||||
self.widget("machine-type"))
|
||||
@@ -2627,7 +2627,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
else:
|
||||
uiutil.set_combo_entry(
|
||||
self.widget("cpu-model"),
|
||||
virtinst.CPU.SPECIAL_MODE_HV_DEFAULT, 2)
|
||||
virtinst.CPU.SPECIAL_MODE_HV_DEFAULT, column=2)
|
||||
|
||||
# Warn about hyper-threading setting
|
||||
cpu_model = self.get_config_cpu_model()
|
||||
|
||||
@@ -153,15 +153,15 @@ class vmmFSDetails(vmmGObjectUI):
|
||||
return self._dev
|
||||
|
||||
def get_config_fs_mode(self):
|
||||
return uiutil.get_list_selection(self.widget("fs-mode-combo"), 0,
|
||||
return uiutil.get_list_selection(self.widget("fs-mode-combo"),
|
||||
check_visible=True)
|
||||
|
||||
def get_config_fs_wrpolicy(self):
|
||||
return uiutil.get_list_selection(self.widget("fs-wrpolicy-combo"), 0,
|
||||
return uiutil.get_list_selection(self.widget("fs-wrpolicy-combo"),
|
||||
check_visible=True)
|
||||
|
||||
def get_config_fs_type(self):
|
||||
return uiutil.get_list_selection(self.widget("fs-type-combo"), 0,
|
||||
return uiutil.get_list_selection(self.widget("fs-type-combo"),
|
||||
check_visible=True)
|
||||
|
||||
def get_config_fs_readonly(self):
|
||||
@@ -170,11 +170,11 @@ class vmmFSDetails(vmmGObjectUI):
|
||||
return self.widget("fs-readonly").get_active()
|
||||
|
||||
def get_config_fs_driver(self):
|
||||
return uiutil.get_list_selection(self.widget("fs-driver-combo"), 0,
|
||||
return uiutil.get_list_selection(self.widget("fs-driver-combo"),
|
||||
check_visible=True)
|
||||
|
||||
def get_config_fs_format(self):
|
||||
return uiutil.get_list_selection(self.widget("fs-format-combo"), 0,
|
||||
return uiutil.get_list_selection(self.widget("fs-format-combo"),
|
||||
check_visible=True)
|
||||
|
||||
# Setters
|
||||
|
||||
@@ -100,7 +100,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
||||
def _get_config_graphics_ports(self):
|
||||
port = uiutil.spin_get_helper(self.widget("graphics-port"))
|
||||
tlsport = uiutil.spin_get_helper(self.widget("graphics-tlsport"))
|
||||
gtype = uiutil.get_list_selection(self.widget("graphics-type"), 0)
|
||||
gtype = uiutil.get_list_selection(self.widget("graphics-type"))
|
||||
|
||||
if self.widget("graphics-port-auto").get_active():
|
||||
port = -1
|
||||
@@ -132,9 +132,9 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
||||
self.widget("graphics-password-chk").set_active(False)
|
||||
|
||||
def get_values(self):
|
||||
gtype = uiutil.get_list_selection(self.widget("graphics-type"), 0)
|
||||
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"), 0)
|
||||
addr = uiutil.get_list_selection(self.widget("graphics-address"))
|
||||
keymap = uiutil.get_combo_entry(self.widget("graphics-keymap"))
|
||||
if keymap == "auto":
|
||||
keymap = None
|
||||
@@ -178,9 +178,9 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
||||
|
||||
set_port("graphics-port", gfx.port)
|
||||
uiutil.set_combo_entry(
|
||||
self.widget("graphics-address"), gfx.listen, 0)
|
||||
self.widget("graphics-address"), gfx.listen)
|
||||
uiutil.set_combo_entry(
|
||||
self.widget("graphics-keymap"), gfx.keymap or None, 0)
|
||||
self.widget("graphics-keymap"), gfx.keymap or None)
|
||||
|
||||
self.widget("graphics-password").set_text(gfx.passwd or "")
|
||||
self.widget("graphics-password-chk").set_active(use_passwd)
|
||||
@@ -197,7 +197,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
||||
self.widget("graphics-xauth").set_text(
|
||||
gfx.xauth or _("Unknown"))
|
||||
|
||||
uiutil.set_combo_entry(self.widget("graphics-type"), gtype, 0)
|
||||
uiutil.set_combo_entry(self.widget("graphics-type"), gtype)
|
||||
return title
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
||||
"graphics-password-box", "graphics-keymap", "graphics-port-box",
|
||||
"graphics-tlsport-box"]
|
||||
|
||||
gtype = uiutil.get_list_selection(self.widget("graphics-type"), 0)
|
||||
gtype = uiutil.get_list_selection(self.widget("graphics-type"))
|
||||
sdl_rows = ["graphics-xauth", "graphics-display"]
|
||||
vnc_rows = ["graphics-password-box", "graphics-address",
|
||||
"graphics-port-box", "graphics-keymap"]
|
||||
|
||||
+3
-3
@@ -489,7 +489,7 @@ class vmmHost(vmmGObjectUI):
|
||||
self.enable_net_apply(EDIT_NET_AUTOSTART)
|
||||
|
||||
def current_network(self):
|
||||
connkey = uiutil.get_list_selection(self.widget("net-list"), 0)
|
||||
connkey = uiutil.get_list_selection(self.widget("net-list"))
|
||||
return connkey and self.conn.get_net(connkey)
|
||||
|
||||
def refresh_network(self, net):
|
||||
@@ -772,7 +772,7 @@ class vmmHost(vmmGObjectUI):
|
||||
self.refresh_interface(cp)
|
||||
|
||||
def current_interface(self):
|
||||
connkey = uiutil.get_list_selection(self.widget("interface-list"), 0)
|
||||
connkey = uiutil.get_list_selection(self.widget("interface-list"))
|
||||
return connkey and self.conn.get_interface(connkey)
|
||||
|
||||
def interface_apply(self):
|
||||
@@ -781,7 +781,7 @@ class vmmHost(vmmGObjectUI):
|
||||
return
|
||||
|
||||
newmode = uiutil.get_list_selection(
|
||||
self.widget("interface-startmode"), 0)
|
||||
self.widget("interface-startmode"))
|
||||
|
||||
logging.debug("Applying changes for interface '%s'",
|
||||
interface.get_name())
|
||||
|
||||
@@ -418,7 +418,7 @@ class vmmManager(vmmGObjectUI):
|
||||
##################
|
||||
|
||||
def current_row(self):
|
||||
return uiutil.get_list_selection(self.widget("vm-list"), None)
|
||||
return uiutil.get_list_selected_row(self.widget("vm-list"))
|
||||
|
||||
def current_vm(self):
|
||||
row = self.current_row()
|
||||
|
||||
@@ -167,7 +167,9 @@ class vmmMediaCombo(vmmGObjectUI):
|
||||
logging.debug("Error populating mediadev combo", exc_info=True)
|
||||
|
||||
def get_path(self):
|
||||
return uiutil.get_list_selection(self.combo, self.OPTICAL_DEV_PATH)
|
||||
return uiutil.get_list_selection(
|
||||
self.combo, column=self.OPTICAL_DEV_PATH)
|
||||
|
||||
def has_media(self):
|
||||
return uiutil.get_list_selection(self.combo, self.OPTICAL_HAS_MEDIA)
|
||||
return uiutil.get_list_selection(
|
||||
self.combo, column=self.OPTICAL_HAS_MEDIA)
|
||||
|
||||
@@ -190,7 +190,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
||||
self._finish()
|
||||
|
||||
def _destconn_changed(self, src):
|
||||
row = uiutil.get_list_selection(src, None)
|
||||
row = uiutil.get_list_selected_row(src)
|
||||
if not row:
|
||||
return
|
||||
|
||||
@@ -258,7 +258,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
||||
self.widget("migrate-port-label").set_visible(not enable)
|
||||
|
||||
def _is_tunnel_selected(self):
|
||||
return uiutil.get_list_selection(self.widget("migrate-mode"), 1)
|
||||
return uiutil.get_list_selection(self.widget("migrate-mode"), column=1)
|
||||
|
||||
def _mode_changed(self, src):
|
||||
ignore = src
|
||||
@@ -366,7 +366,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
||||
|
||||
def _finish(self):
|
||||
try:
|
||||
row = uiutil.get_list_selection(self.widget("migrate-dest"), None)
|
||||
row = uiutil.get_list_selected_row(self.widget("migrate-dest"))
|
||||
destlabel = row[COL_LABEL]
|
||||
destconn = self._conns.get(row[COL_URI])
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ class vmmNetworkList(vmmGObjectUI):
|
||||
###############
|
||||
|
||||
def get_network_row(self):
|
||||
return uiutil.get_list_selection(self.widget("net-source"), None)
|
||||
return uiutil.get_list_selected_row(self.widget("net-source"))
|
||||
|
||||
def get_network_selection(self):
|
||||
bridge_entry = self.widget("net-bridge-name")
|
||||
@@ -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"), 0)
|
||||
mode = uiutil.get_combo_entry(self.widget("net-source-mode"))
|
||||
|
||||
portgroup = None
|
||||
if self.widget("net-portgroup").is_visible():
|
||||
portgroup = uiutil.get_combo_entry(self.widget("net-portgroup"), 0)
|
||||
portgroup = uiutil.get_combo_entry(self.widget("net-portgroup"))
|
||||
|
||||
return net_type, net_src, mode, portgroup or None
|
||||
|
||||
@@ -488,7 +488,7 @@ class vmmNetworkList(vmmGObjectUI):
|
||||
ignore = kwargs
|
||||
|
||||
netlist = self.widget("net-source")
|
||||
label = uiutil.get_list_selection(netlist, 2)
|
||||
label = uiutil.get_list_selection(netlist, column=2)
|
||||
self._populate_network_list()
|
||||
|
||||
for row in netlist.get_model():
|
||||
|
||||
@@ -338,24 +338,24 @@ class vmmPreferences(vmmGObjectUI):
|
||||
def change_console_scaling(self, box):
|
||||
self.config.set_console_scaling(box.get_active())
|
||||
def change_console_resizeguest(self, box):
|
||||
val = uiutil.get_list_selection(box, 0)
|
||||
val = uiutil.get_list_selection(box)
|
||||
self.config.set_console_resizeguest(val)
|
||||
|
||||
def change_new_vm_sound(self, src):
|
||||
self.config.set_new_vm_sound(src.get_active())
|
||||
def change_graphics_type(self, src):
|
||||
val = uiutil.get_list_selection(src, 0)
|
||||
val = uiutil.get_list_selection(src)
|
||||
self.config.set_graphics_type(val)
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("prefs-add-spice-usbredir"),
|
||||
self.config.get_graphics_type() == "spice")
|
||||
def change_add_spice_usbredir(self, src):
|
||||
self.config.set_add_spice_usbredir(uiutil.get_list_selection(src, 0))
|
||||
self.config.set_add_spice_usbredir(uiutil.get_list_selection(src))
|
||||
def change_storage_format(self, src):
|
||||
typ = uiutil.get_list_selection(src, 0) or "default"
|
||||
typ = uiutil.get_list_selection(src) or "default"
|
||||
self.config.set_storage_format(typ.lower())
|
||||
def change_cpu_default(self, src):
|
||||
typ = uiutil.get_list_selection(src, 0) or "default"
|
||||
typ = uiutil.get_list_selection(src) or "default"
|
||||
self.config.set_default_cpu_setting(typ.lower())
|
||||
|
||||
def change_cpu_poll(self, src):
|
||||
|
||||
@@ -262,7 +262,7 @@ class vmmStorageList(vmmGObjectUI):
|
||||
####################
|
||||
|
||||
def _current_pool(self):
|
||||
connkey = uiutil.get_list_selection(self.widget("pool-list"), 0)
|
||||
connkey = uiutil.get_list_selection(self.widget("pool-list"))
|
||||
return connkey and self.conn.get_pool(connkey)
|
||||
|
||||
def _current_vol(self):
|
||||
@@ -270,7 +270,7 @@ class vmmStorageList(vmmGObjectUI):
|
||||
if not pool:
|
||||
return None
|
||||
|
||||
connkey = uiutil.get_list_selection(self.widget("vol-list"), 0)
|
||||
connkey = uiutil.get_list_selection(self.widget("vol-list"))
|
||||
return connkey and pool.get_volume(connkey)
|
||||
|
||||
def _enable_pool_apply(self, *arglist):
|
||||
|
||||
+19
-13
@@ -60,11 +60,9 @@ def spin_get_helper(widget):
|
||||
return adj.get_value()
|
||||
|
||||
|
||||
def get_list_selection(widget, rowindex, check_visible=False):
|
||||
def get_list_selected_row(widget, check_visible=False):
|
||||
"""
|
||||
Helper to simplify getting the selected row and value in a list/tree/combo
|
||||
|
||||
If rowindex is None, return the whole row.
|
||||
Helper to simplify getting the selected row in a list/tree/combo
|
||||
"""
|
||||
if check_visible and not widget.get_visible():
|
||||
return None
|
||||
@@ -83,9 +81,17 @@ def get_list_selection(widget, rowindex, check_visible=False):
|
||||
|
||||
row = widget.get_model()[idx]
|
||||
|
||||
if rowindex is None:
|
||||
return row
|
||||
return row[rowindex]
|
||||
return row
|
||||
|
||||
|
||||
def get_list_selection(widget, column=0, check_visible=False):
|
||||
"""
|
||||
Helper to simplify getting the selected row and value in a list/tree/combo
|
||||
"""
|
||||
row = get_list_selected_row(widget, check_visible=check_visible)
|
||||
if row is None:
|
||||
return None
|
||||
return row[column]
|
||||
|
||||
|
||||
def select_list_row_by_number(widget, rownum):
|
||||
@@ -126,15 +132,15 @@ def select_list_row_by_value(listwidget, prevkey, column=0):
|
||||
selection.emit("changed")
|
||||
|
||||
|
||||
def set_combo_entry(combo, value, rowidx=0):
|
||||
def set_combo_entry(combo, value, column=0):
|
||||
"""
|
||||
Search the passed combobox for value, comparing against
|
||||
rowidx. If found, select it. If not found, and
|
||||
value of 'column'. If found, select it. If not found, and
|
||||
the combobox has a text entry, stick the value in their and
|
||||
select it.
|
||||
"""
|
||||
idx = -1
|
||||
model_list = [x[rowidx] for x in combo.get_model()]
|
||||
model_list = [x[column] for x in combo.get_model()]
|
||||
model_in_list = (value in model_list)
|
||||
if model_in_list:
|
||||
idx = model_list.index(value)
|
||||
@@ -144,14 +150,14 @@ def set_combo_entry(combo, value, rowidx=0):
|
||||
combo.get_child().set_text(value or "")
|
||||
|
||||
|
||||
def get_combo_entry(combo, rowidx=0):
|
||||
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_selection(combo, None)
|
||||
row = get_list_selected_row(combo)
|
||||
if row:
|
||||
return row[rowidx]
|
||||
return row[column]
|
||||
if not combo.get_has_entry():
|
||||
return None
|
||||
return combo.get_child().get_text().strip()
|
||||
|
||||
Reference in New Issue
Block a user