Split uihelpers into sharedui and uiutil
Reserve uiutil for the little gtk helper functions, rest goes into shared UI (which all should probably be factored into their own files but thats a task for another day)
This commit is contained in:
parent
2a34b353da
commit
708a2737cf
|
@ -34,7 +34,8 @@ from virtinst import (VirtualChannelDevice, VirtualParallelDevice,
|
|||
VirtualTPMDevice, VirtualPanicDevice)
|
||||
from virtinst import VirtualController
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import sharedui
|
||||
from virtManager import uiutil
|
||||
from virtManager.fsdetails import vmmFSDetails
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
from virtManager.storagebrowse import vmmStorageBrowser
|
||||
|
@ -176,7 +177,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
# Virtual network list
|
||||
net_list = self.widget("net-list")
|
||||
bridge_box = self.widget("net-bridge-box")
|
||||
uihelpers.build_network_list(net_list, bridge_box)
|
||||
sharedui.build_network_list(net_list, bridge_box)
|
||||
|
||||
# Network model list
|
||||
netmodel_list = self.widget("net-model")
|
||||
|
@ -187,7 +188,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
# [bus, label]
|
||||
model = Gtk.ListStore(str, str)
|
||||
widget.set_model(model)
|
||||
uihelpers.set_combo_text_column(widget, 1)
|
||||
uiutil.set_combo_text_column(widget, 1)
|
||||
|
||||
# Disk device type
|
||||
target_list = self.widget("config-storage-devtype")
|
||||
|
@ -212,7 +213,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
# Sparse tooltip
|
||||
sparse_info = self.widget("config-storage-nosparse-info")
|
||||
uihelpers.set_sparse_tooltip(sparse_info)
|
||||
sharedui.set_sparse_tooltip(sparse_info)
|
||||
|
||||
# Input device type
|
||||
input_list = self.widget("input-type")
|
||||
|
@ -275,7 +276,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
lst = self.widget("char-target-type")
|
||||
model = Gtk.ListStore(str, str)
|
||||
lst.set_model(model)
|
||||
uihelpers.set_combo_text_column(lst, 1)
|
||||
uiutil.set_combo_text_column(lst, 1)
|
||||
if self.conn.is_qemu():
|
||||
model.append(["virtio", "virtio"])
|
||||
else:
|
||||
|
@ -285,7 +286,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
lst = self.widget("char-target-name")
|
||||
model = Gtk.ListStore(str)
|
||||
lst.set_model(model)
|
||||
uihelpers.set_combo_text_column(lst, 0)
|
||||
uiutil.set_combo_text_column(lst, 0)
|
||||
for n in VirtualChannelDevice.CHANNEL_NAMES:
|
||||
model.append([n])
|
||||
|
||||
|
@ -293,7 +294,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
lst = self.widget("char-device-type")
|
||||
model = Gtk.ListStore(str, str)
|
||||
lst.set_model(model)
|
||||
uihelpers.set_combo_text_column(lst, 1)
|
||||
uiutil.set_combo_text_column(lst, 1)
|
||||
|
||||
# Watchdog widgets
|
||||
combo = self.widget("watchdog-model")
|
||||
|
@ -404,7 +405,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
# Storage init
|
||||
label_widget = self.widget("phys-hd-label")
|
||||
label_widget.set_markup("")
|
||||
uihelpers.update_host_space(self.conn, label_widget)
|
||||
sharedui.update_host_space(self.conn, label_widget)
|
||||
|
||||
self.widget("config-storage-create").set_active(True)
|
||||
self.widget("config-storage-size").set_value(8)
|
||||
|
@ -429,7 +430,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
net_list = self.widget("net-list")
|
||||
net_warn = self.widget("net-list-warn")
|
||||
uihelpers.populate_network_list(net_list, self.conn)
|
||||
sharedui.populate_network_list(net_list, self.conn)
|
||||
|
||||
error = self.conn.netdev_error
|
||||
if error:
|
||||
|
@ -542,7 +543,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_video_combo(vm, combo, no_default=None):
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
combo.get_model().set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
||||
|
||||
vmmAddHardware.populate_video_combo(vm, combo, no_default)
|
||||
|
@ -551,7 +552,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_sound_combo(vm, combo, no_default=False):
|
||||
model = Gtk.ListStore(str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 0)
|
||||
uiutil.set_combo_text_column(combo, 0)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
stable_defaults = vm.stable_defaults()
|
||||
|
@ -573,7 +574,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
ignore = vm
|
||||
model = Gtk.ListStore(str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 0)
|
||||
uiutil.set_combo_text_column(combo, 0)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
for m in virtinst.VirtualWatchdog.MODELS:
|
||||
|
@ -588,7 +589,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
ignore = vm
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
for m in virtinst.VirtualWatchdog.ACTIONS:
|
||||
|
@ -615,7 +616,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_network_source_mode_combo(vm, combo):
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
vmmAddHardware.populate_network_source_mode_combo(vm, combo)
|
||||
combo.set_active(0)
|
||||
|
@ -645,7 +646,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_network_model_combo(vm, combo):
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
vmmAddHardware.populate_network_model_combo(vm, combo)
|
||||
|
@ -665,7 +666,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_smartcard_mode_combo(vm, combo):
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
vmmAddHardware.populate_smartcard_mode_combo(vm, combo)
|
||||
|
@ -693,7 +694,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_redir_type_combo(vm, combo):
|
||||
model = Gtk.ListStore(str, str, bool)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
vmmAddHardware.populate_redir_type_combo(vm, combo)
|
||||
combo.set_active(0)
|
||||
|
@ -712,7 +713,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def build_tpm_type_combo(vm, combo):
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
vmmAddHardware.populate_tpm_type_combo(vm, combo)
|
||||
|
@ -731,7 +732,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
ignore = vm
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
if not no_default:
|
||||
model.append([None, "default"])
|
||||
|
@ -750,7 +751,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
ignore = vm
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
combo.set_active(-1)
|
||||
for m in virtinst.VirtualDisk.cache_types:
|
||||
|
@ -764,7 +765,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
ignore = vm
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
combo.set_active(-1)
|
||||
|
@ -780,7 +781,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
ignore = vm
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
||||
|
||||
if not no_default:
|
||||
|
@ -791,7 +792,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
def populate_disk_format_combo(vm, combo, create):
|
||||
model = Gtk.ListStore(str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 0)
|
||||
uiutil.set_combo_text_column(combo, 0)
|
||||
|
||||
formats = ["raw", "qcow2", "qed"]
|
||||
no_create_formats = []
|
||||
|
@ -901,7 +902,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
if len(model) == 0:
|
||||
model.append([_("No Devices Available"), None, None, None])
|
||||
uihelpers.set_list_selection(devlist, 0)
|
||||
uiutil.set_list_selection(devlist, 0)
|
||||
|
||||
def populate_disk_format_combo_wrapper(self, create):
|
||||
format_list = self.widget("config-storage-format")
|
||||
|
@ -993,7 +994,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
sparse = not self.widget("config-storage-nosparse").get_active()
|
||||
|
||||
if self.is_default_storage():
|
||||
path = uihelpers.get_default_path(self.conn,
|
||||
path = sharedui.get_default_path(self.conn,
|
||||
self.vm.get_name(),
|
||||
collidelist=collidelist)
|
||||
logging.debug("Default storage path is: %s", path)
|
||||
|
@ -1006,7 +1007,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
# See if the ideal disk path (/default/pool/vmname.img)
|
||||
# exists, and if unused, prompt the use for using it
|
||||
conn = self.conn.get_backend()
|
||||
ideal = uihelpers.get_ideal_path(self.conn, self.vm.get_name())
|
||||
ideal = sharedui.get_ideal_path(self.conn, self.vm.get_name())
|
||||
if ideal in collidelist:
|
||||
return diskpath
|
||||
do_exist = False
|
||||
|
@ -1087,7 +1088,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
net_list = self.widget("net-list")
|
||||
bridge_ent = self.widget("net-bridge")
|
||||
|
||||
net_type, net_src = uihelpers.get_network_selection(net_list,
|
||||
net_type, net_src = sharedui.get_network_selection(net_list,
|
||||
bridge_ent)
|
||||
|
||||
return net_type, net_src
|
||||
|
@ -1124,7 +1125,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
return usb_info
|
||||
|
||||
def get_config_host_device_info(self):
|
||||
devrow = uihelpers.get_list_selection(self.widget("host-device"))
|
||||
devrow = uiutil.get_list_selection(self.widget("host-device"))
|
||||
if not devrow:
|
||||
return []
|
||||
return devrow
|
||||
|
@ -1229,10 +1230,10 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
################
|
||||
|
||||
def set_hw_selection(self, page):
|
||||
uihelpers.set_list_selection(self.widget("hw-list"), page)
|
||||
uiutil.set_list_selection(self.widget("hw-list"), page)
|
||||
|
||||
def get_hw_selection(self):
|
||||
return uihelpers.get_list_selection(self.widget("hw-list"))
|
||||
return uiutil.get_list_selection(self.widget("hw-list"))
|
||||
|
||||
def update_char_device_type_model(self):
|
||||
stable_blacklist = ["pipe", "udp"]
|
||||
|
@ -1316,7 +1317,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
is_auto = self.widget("graphics-port-auto").get_active()
|
||||
is_spice = (gtype == "spice")
|
||||
|
||||
uihelpers.set_grid_row_visible(self.widget("graphics-port-box"),
|
||||
uiutil.set_grid_row_visible(self.widget("graphics-port-box"),
|
||||
not is_auto)
|
||||
self.widget("graphics-port-box").set_visible(not is_auto)
|
||||
self.widget("graphics-tlsport-box").set_visible(is_spice)
|
||||
|
@ -1404,7 +1405,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
for param_name, widget_name in tpm_widget_mappings.items():
|
||||
make_visible = self._dev.supports_property(param_name)
|
||||
uihelpers.set_grid_row_visible(self.widget(widget_name + "-label"),
|
||||
uiutil.set_grid_row_visible(self.widget(widget_name + "-label"),
|
||||
make_visible)
|
||||
|
||||
def change_char_auto_socket(self, src):
|
||||
|
@ -1412,8 +1413,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
return
|
||||
|
||||
doshow = not src.get_active()
|
||||
uihelpers.set_grid_row_visible(self.widget("char-path-label"), doshow)
|
||||
uihelpers.set_grid_row_visible(self.widget("char-mode-label"), doshow)
|
||||
uiutil.set_grid_row_visible(self.widget("char-path-label"), doshow)
|
||||
uiutil.set_grid_row_visible(self.widget("char-mode-label"), doshow)
|
||||
|
||||
def change_char_target_name(self, src):
|
||||
if not src.get_visible():
|
||||
|
@ -1426,7 +1427,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
elif (text == VirtualChannelDevice.CHANNEL_NAME_QEMUGA or
|
||||
text == VirtualChannelDevice.CHANNEL_NAME_LIBGUESTFS):
|
||||
settype = "unix"
|
||||
uihelpers.set_row_selection(self.widget("char-device-type"), settype)
|
||||
uiutil.set_row_selection(self.widget("char-device-type"), settype)
|
||||
|
||||
def change_char_device_type(self, src):
|
||||
idx = src.get_active()
|
||||
|
@ -1454,14 +1455,14 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
for param_name, widget_name in char_widget_mappings.items():
|
||||
make_visible = self._dev.supports_property(param_name)
|
||||
uihelpers.set_grid_row_visible(self.widget(widget_name + "-label"),
|
||||
uiutil.set_grid_row_visible(self.widget(widget_name + "-label"),
|
||||
make_visible)
|
||||
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("char-target-name-label"), ischan)
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("char-target-type-label"), iscon)
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("char-auto-socket-label"), show_auto)
|
||||
self.widget("char-auto-socket").emit("toggled")
|
||||
|
||||
|
@ -1475,7 +1476,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
return
|
||||
|
||||
showhost = src.get_model()[src.get_active()][2]
|
||||
uihelpers.set_grid_row_visible(self.widget("usbredir-host-box"),
|
||||
uiutil.set_grid_row_visible(self.widget("usbredir-host-box"),
|
||||
showhost)
|
||||
|
||||
def change_rng(self, ignore1):
|
||||
|
@ -1484,8 +1485,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
return
|
||||
|
||||
is_egd = model == virtinst.VirtualRNGDevice.TYPE_EGD
|
||||
uihelpers.set_grid_row_visible(self.widget("rng-device"), not is_egd)
|
||||
uihelpers.set_grid_row_visible(self.widget("rng-backend-type"), is_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 = self.get_config_rng_backend_type()
|
||||
backend_mode = self.get_config_rng_backend_mode()
|
||||
|
@ -1493,13 +1494,13 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
bind = backend_mode == virtinst.VirtualRNGDevice.BACKEND_MODE_BIND
|
||||
|
||||
v = is_egd and (udp or bind)
|
||||
uihelpers.set_grid_row_visible(self.widget("rng-bind-host-box"), v)
|
||||
uiutil.set_grid_row_visible(self.widget("rng-bind-host-box"), v)
|
||||
|
||||
v = is_egd and (udp or not bind)
|
||||
uihelpers.set_grid_row_visible(self.widget("rng-connect-host-box"), v)
|
||||
uiutil.set_grid_row_visible(self.widget("rng-connect-host-box"), v)
|
||||
|
||||
v = is_egd and not udp
|
||||
uihelpers.set_grid_row_visible(self.widget("rng-backend-mode"), v)
|
||||
uiutil.set_grid_row_visible(self.widget("rng-backend-mode"), v)
|
||||
|
||||
|
||||
######################
|
||||
|
@ -1659,7 +1660,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
# Make sure default pool is running
|
||||
if self.is_default_storage():
|
||||
ret = uihelpers.check_default_pool_active(self.err, self.conn)
|
||||
ret = sharedui.check_default_pool_active(self.err, self.conn)
|
||||
if not ret:
|
||||
return False
|
||||
|
||||
|
@ -1721,7 +1722,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
if not res:
|
||||
return False
|
||||
|
||||
uihelpers.check_path_search_for_qemu(self.err, self.conn, disk.path)
|
||||
sharedui.check_path_search_for_qemu(self.err, self.conn, disk.path)
|
||||
|
||||
# Add a SCSI controller with model virtio-scsi if needed
|
||||
disk.vmm_controller = None
|
||||
|
@ -1765,7 +1766,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
return self.err.val_err(_("Invalid MAC address"),
|
||||
_("A MAC address must be entered."))
|
||||
|
||||
ret = uihelpers.validate_network(self.err, self.conn,
|
||||
ret = sharedui.validate_network(self.err, self.conn,
|
||||
nettype, devname, mac, model)
|
||||
if ret is False:
|
||||
return False
|
||||
|
|
|
@ -28,7 +28,7 @@ from gi.repository import GLib
|
|||
from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
|
||||
# pylint: disable=E1101
|
||||
# pylint can't detect functions we inheirit from Gtk, ex:
|
||||
|
@ -92,10 +92,10 @@ class OverBox(Gtk.Box):
|
|||
actual_min = self._get_actual_min()
|
||||
|
||||
if self.overWidget:
|
||||
expand = uihelpers.child_get_property(self, self.overWidget,
|
||||
expand = uiutil.child_get_property(self, self.overWidget,
|
||||
"expand")
|
||||
fill = uihelpers.child_get_property(self, self.overWidget, "fill")
|
||||
padding = uihelpers.child_get_property(self, self.overWidget,
|
||||
fill = uiutil.child_get_property(self, self.overWidget, "fill")
|
||||
padding = uiutil.child_get_property(self, self.overWidget,
|
||||
"padding")
|
||||
|
||||
if expand and fill:
|
||||
|
@ -257,9 +257,9 @@ class OverBox(Gtk.Box):
|
|||
self.overWidth = over.width
|
||||
self.overHeight = over.height
|
||||
|
||||
expand = uihelpers.child_get_property(self, self.overWidget, "expand")
|
||||
fill = uihelpers.child_get_property(self, self.overWidget, "fill")
|
||||
padding = uihelpers.child_get_property(self, self.overWidget, "padding")
|
||||
expand = uiutil.child_get_property(self, self.overWidget, "expand")
|
||||
fill = uiutil.child_get_property(self, self.overWidget, "fill")
|
||||
padding = uiutil.child_get_property(self, self.overWidget, "padding")
|
||||
|
||||
if expand or fill:
|
||||
wpad = 0
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
# MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
||||
# pylint: disable=E0611
|
||||
from gi.repository import GObject
|
||||
# pylint: enable=E0611
|
||||
|
||||
import logging
|
||||
|
||||
import virtManager.uihelpers as uihelpers
|
||||
from virtManager import sharedui
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.mediadev import MEDIA_FLOPPY
|
||||
from virtManager.storagebrowse import vmmStorageBrowser
|
||||
|
@ -103,7 +103,7 @@ class vmmChooseCD(vmmGObjectUI):
|
|||
idx = cd.get_active()
|
||||
model = cd.get_model()
|
||||
if idx != -1:
|
||||
path = model[idx][uihelpers.OPTICAL_DEV_PATH]
|
||||
path = model[idx][sharedui.OPTICAL_DEV_PATH]
|
||||
|
||||
if path == "" or path is None:
|
||||
return self.err.val_err(_("Invalid Media Path"),
|
||||
|
@ -123,7 +123,7 @@ class vmmChooseCD(vmmGObjectUI):
|
|||
if not res:
|
||||
return False
|
||||
|
||||
uihelpers.check_path_search_for_qemu(self.err, self.conn, path)
|
||||
sharedui.check_path_search_for_qemu(self.err, self.conn, path)
|
||||
|
||||
self.emit("cdrom-chosen", self.disk, path)
|
||||
self.close()
|
||||
|
@ -149,8 +149,8 @@ class vmmChooseCD(vmmGObjectUI):
|
|||
warn = self.widget("cd-path-warn")
|
||||
|
||||
error = self.conn.mediadev_error
|
||||
uihelpers.build_mediadev_combo(widget)
|
||||
uihelpers.populate_mediadev_combo(self.conn, widget, self.media_type)
|
||||
sharedui.build_mediadev_combo(widget)
|
||||
sharedui.populate_mediadev_combo(self.conn, widget, self.media_type)
|
||||
|
||||
if error:
|
||||
warn.show()
|
||||
|
|
|
@ -31,7 +31,8 @@ from gi.repository import Gdk
|
|||
import virtinst
|
||||
from virtinst import util
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import sharedui
|
||||
from virtManager import uiutil
|
||||
from virtManager.mediadev import MEDIA_CDROM
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
|
@ -291,13 +292,13 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
# Physical CD-ROM model
|
||||
cd_list = self.widget("install-local-cdrom-combo")
|
||||
uihelpers.build_mediadev_combo(cd_list)
|
||||
sharedui.build_mediadev_combo(cd_list)
|
||||
|
||||
# Networking
|
||||
# [ interface type, device name, label, sensitive ]
|
||||
net_list = self.widget("config-netdev")
|
||||
bridge_box = self.widget("config-netdev-bridge-box")
|
||||
uihelpers.build_network_list(net_list, bridge_box)
|
||||
sharedui.build_network_list(net_list, bridge_box)
|
||||
|
||||
# Archtecture
|
||||
# [value, label]
|
||||
|
@ -327,7 +328,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
# Sparse tooltip
|
||||
sparse_info = self.widget("config-storage-nosparse-info")
|
||||
uihelpers.set_sparse_tooltip(sparse_info)
|
||||
sharedui.set_sparse_tooltip(sparse_info)
|
||||
|
||||
def reset_state(self, urihint=None):
|
||||
self.failed_guest = None
|
||||
|
@ -398,7 +399,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
# Storage
|
||||
label_widget = self.widget("phys-hd-label")
|
||||
label_widget.set_markup("")
|
||||
uihelpers.update_host_space(self.conn, label_widget)
|
||||
sharedui.update_host_space(self.conn, label_widget)
|
||||
self.widget("enable-storage").set_active(True)
|
||||
self.widget("config-storage-create").set_active(True)
|
||||
self.widget("config-storage-size").set_value(8)
|
||||
|
@ -502,7 +503,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
"microblaze" in self.capsguest.arch or
|
||||
"ppc" in self.capsguest.arch)
|
||||
self.widget("config-kernel-box").set_visible(show_kernel)
|
||||
uihelpers.set_grid_row_visible(self.widget("config-dtb"), show_dtb)
|
||||
uiutil.set_grid_row_visible(self.widget("config-dtb"), show_dtb)
|
||||
|
||||
def set_conn_state(self):
|
||||
# Update all state that has some dependency on the current connection
|
||||
|
@ -536,7 +537,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
show_arch = (self.widget("config-hv").get_visible() or
|
||||
self.widget("config-arch").get_visible() or
|
||||
self.widget("config-machine").get_visible())
|
||||
uihelpers.set_grid_row_visible(self.widget("arch-expander"), show_arch)
|
||||
uiutil.set_grid_row_visible(self.widget("arch-expander"), show_arch)
|
||||
|
||||
if self.conn.is_xen():
|
||||
if self.conn.caps.hw_virt_supported():
|
||||
|
@ -565,7 +566,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
cdrom_list = self.widget("install-local-cdrom-combo")
|
||||
cdrom_warn = self.widget("install-local-cdrom-warn")
|
||||
|
||||
sigs = uihelpers.populate_mediadev_combo(self.conn, cdrom_list,
|
||||
sigs = sharedui.populate_mediadev_combo(self.conn, cdrom_list,
|
||||
MEDIA_CDROM)
|
||||
self.conn_signals.extend(sigs)
|
||||
|
||||
|
@ -636,7 +637,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
net_warn_box.hide()
|
||||
net_expander.set_expanded(False)
|
||||
|
||||
do_warn = uihelpers.populate_network_list(net_list, self.conn, False)
|
||||
do_warn = sharedui.populate_network_list(net_list, self.conn, False)
|
||||
self.set_net_warn(self.conn.netdev_error or do_warn,
|
||||
self.conn.netdev_error, True)
|
||||
|
||||
|
@ -697,7 +698,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
model.append([label, gtype])
|
||||
|
||||
show = bool(guests)
|
||||
uihelpers.set_grid_row_visible(hv_list, show)
|
||||
uiutil.set_grid_row_visible(hv_list, show)
|
||||
if show:
|
||||
hv_list.set_active(default)
|
||||
|
||||
|
@ -740,7 +741,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
model.append([arch, pretty_arch(arch)])
|
||||
|
||||
show = not (len(archs) < 2)
|
||||
uihelpers.set_grid_row_visible(arch_list, show)
|
||||
uiutil.set_grid_row_visible(arch_list, show)
|
||||
arch_list.set_active(default)
|
||||
|
||||
def populate_machine(self):
|
||||
|
@ -778,7 +779,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
model.append([m])
|
||||
|
||||
show = (len(machines) > 1)
|
||||
uihelpers.set_grid_row_visible(lst, show)
|
||||
uiutil.set_grid_row_visible(lst, show)
|
||||
if show:
|
||||
lst.set_active(default)
|
||||
else:
|
||||
|
@ -1051,7 +1052,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
idx = cd.get_active()
|
||||
model = cd.get_model()
|
||||
if idx != -1:
|
||||
return model[idx][uihelpers.OPTICAL_DEV_PATH]
|
||||
return model[idx][sharedui.OPTICAL_DEV_PATH]
|
||||
return None
|
||||
else:
|
||||
ret = self.widget("install-local-box").get_child().get_text()
|
||||
|
@ -1100,7 +1101,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
if disks:
|
||||
return disks[0].path
|
||||
|
||||
return uihelpers.get_default_path(self.conn, name)
|
||||
return sharedui.get_default_path(self.conn, name)
|
||||
|
||||
def is_default_storage(self):
|
||||
usedef = self.widget("config-storage-create").get_active()
|
||||
|
@ -1109,7 +1110,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
def get_storage_info(self):
|
||||
path = None
|
||||
size = uihelpers.spin_get_helper(self.widget("config-storage-size"))
|
||||
size = uiutil.spin_get_helper(self.widget("config-storage-size"))
|
||||
sparse = not self.widget("config-storage-nosparse").get_active()
|
||||
|
||||
if self.get_config_install_page() == INSTALL_PAGE_IMPORT:
|
||||
|
@ -1130,7 +1131,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
bridge_ent = self.widget("config-netdev-bridge")
|
||||
macaddr = self.widget("config-macaddr").get_text()
|
||||
|
||||
net_type, net_src = uihelpers.get_network_selection(net_list,
|
||||
net_type, net_src = sharedui.get_network_selection(net_list,
|
||||
bridge_ent)
|
||||
|
||||
return net_type, net_src, macaddr.strip()
|
||||
|
@ -1167,7 +1168,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
machine = self.get_config_machine()
|
||||
show_dtb_virtio = (self.capsguest.arch == "armv7l" and
|
||||
machine in ["vexpress-a9", "vexpress-15"])
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("config-dtb-warn-virtio"), show_dtb_virtio)
|
||||
|
||||
def netdev_changed(self, ignore):
|
||||
|
@ -1734,7 +1735,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
path = None
|
||||
|
||||
if path:
|
||||
uihelpers.check_path_search_for_qemu(self.err, self.conn, path)
|
||||
sharedui.check_path_search_for_qemu(self.err, self.conn, path)
|
||||
|
||||
# Validation passed, store the install path (if there is one) in
|
||||
# gconf
|
||||
|
@ -1780,7 +1781,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
# Make sure default pool is running
|
||||
if self.is_default_storage():
|
||||
ret = uihelpers.check_default_pool_active(self.err, self.conn)
|
||||
ret = sharedui.check_default_pool_active(self.err, self.conn)
|
||||
if not ret:
|
||||
return False
|
||||
|
||||
|
@ -1791,7 +1792,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
if self.is_default_storage():
|
||||
# See if the ideal disk path (/default/pool/vmname.img)
|
||||
# exists, and if unused, prompt the use for using it
|
||||
ideal = uihelpers.get_ideal_path(self.conn,
|
||||
ideal = sharedui.get_ideal_path(self.conn,
|
||||
self.guest.name)
|
||||
do_exist = False
|
||||
ret = True
|
||||
|
@ -1846,7 +1847,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
if not res:
|
||||
return False
|
||||
|
||||
uihelpers.check_path_search_for_qemu(self.err, self.conn, disk.path)
|
||||
sharedui.check_path_search_for_qemu(self.err, self.conn, disk.path)
|
||||
|
||||
self.disk = disk
|
||||
self.guest.add_device(self.disk)
|
||||
|
@ -1880,7 +1881,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
_("Network device required for %s install.") %
|
||||
methname)
|
||||
|
||||
nic = uihelpers.validate_network(self.err,
|
||||
nic = sharedui.validate_network(self.err,
|
||||
self.conn, nettype, devname, macaddr)
|
||||
if nic is False:
|
||||
return False
|
||||
|
|
|
@ -27,7 +27,7 @@ import logging
|
|||
|
||||
from virtinst import Interface, InterfaceProtocol
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
|
||||
|
@ -181,7 +181,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
def build_interface_startmode_combo(combo):
|
||||
model = Gtk.ListStore(str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 0)
|
||||
uiutil.set_combo_text_column(combo, 0)
|
||||
|
||||
model.append(["none"])
|
||||
model.append(["onboot"])
|
||||
|
@ -590,7 +590,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
iface = ifaces[0][INTERFACE_ROW_NAME]
|
||||
|
||||
if itype == Interface.INTERFACE_TYPE_VLAN:
|
||||
tag = uihelpers.spin_get_helper(self.widget("vlan-tag"))
|
||||
tag = uiutil.spin_get_helper(self.widget("vlan-tag"))
|
||||
name = "%s.%s" % (iface, int(tag))
|
||||
|
||||
elif itype == Interface.INTERFACE_TYPE_ETHERNET:
|
||||
|
@ -1079,7 +1079,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
|
||||
|
||||
def validate_vlan(self, iobj, ifaces):
|
||||
idx = uihelpers.spin_get_helper(self.widget("vlan-tag"))
|
||||
idx = uiutil.spin_get_helper(self.widget("vlan-tag"))
|
||||
|
||||
iobj.tag = int(idx)
|
||||
return True
|
||||
|
|
|
@ -30,7 +30,7 @@ from gi.repository import Gdk
|
|||
|
||||
from virtinst import Network
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
|
||||
|
@ -506,27 +506,27 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
enabled = self.get_config_routev4_enable()
|
||||
ntwk = self.widget("net-routev4-network")
|
||||
gway = self.widget("net-routev4-gateway")
|
||||
uihelpers.set_grid_row_visible(ntwk, enabled)
|
||||
uihelpers.set_grid_row_visible(gway, enabled)
|
||||
uiutil.set_grid_row_visible(ntwk, enabled)
|
||||
uiutil.set_grid_row_visible(gway, enabled)
|
||||
def change_routev6_enable(self, ignore):
|
||||
enabled = self.get_config_routev6_enable()
|
||||
ntwk = self.widget("net-routev6-network")
|
||||
gway = self.widget("net-routev6-gateway")
|
||||
uihelpers.set_grid_row_visible(ntwk, enabled)
|
||||
uihelpers.set_grid_row_visible(gway, enabled)
|
||||
uiutil.set_grid_row_visible(ntwk, enabled)
|
||||
uiutil.set_grid_row_visible(gway, enabled)
|
||||
|
||||
def change_dhcpv4_enable(self, ignore):
|
||||
enabled = self.get_config_dhcpv4_enable()
|
||||
start = self.widget("net-dhcpv4-start")
|
||||
end = self.widget("net-dhcpv4-end")
|
||||
uihelpers.set_grid_row_visible(start, enabled)
|
||||
uihelpers.set_grid_row_visible(end, enabled)
|
||||
uiutil.set_grid_row_visible(start, enabled)
|
||||
uiutil.set_grid_row_visible(end, enabled)
|
||||
def change_dhcpv6_enable(self, ignore):
|
||||
enabled = self.get_config_dhcpv6_enable()
|
||||
start = self.widget("net-dhcpv6-start")
|
||||
end = self.widget("net-dhcpv6-end")
|
||||
uihelpers.set_grid_row_visible(start, enabled)
|
||||
uihelpers.set_grid_row_visible(end, enabled)
|
||||
uiutil.set_grid_row_visible(start, enabled)
|
||||
uiutil.set_grid_row_visible(end, enabled)
|
||||
|
||||
def change_dhcpv4_start(self, src):
|
||||
start = self.get_config_dhcpv4_start()
|
||||
|
|
|
@ -27,7 +27,7 @@ import logging
|
|||
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
|
||||
from virtinst import StoragePool
|
||||
|
||||
|
@ -255,7 +255,7 @@ class vmmCreatePool(vmmGObjectUI):
|
|||
def show_options_by_pool(self):
|
||||
def show_row(base, do_show):
|
||||
widget = self.widget(base + "-label")
|
||||
uihelpers.set_grid_row_visible(widget, do_show)
|
||||
uiutil.set_grid_row_visible(widget, do_show)
|
||||
|
||||
src = self._pool.supports_property("source_path")
|
||||
src_b = src and not self.conn.is_remote()
|
||||
|
|
|
@ -26,7 +26,7 @@ from gi.repository import Gtk
|
|||
from gi.repository import Gdk
|
||||
# pylint: enable=E0611
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
|
||||
|
@ -147,7 +147,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
def _show_alloc(self, *args, **kwargs):
|
||||
ignore = args
|
||||
ignore = kwargs
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("vol-allocation"), self._can_alloc())
|
||||
|
||||
def _can_backing(self):
|
||||
|
@ -157,7 +157,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
return True
|
||||
return False
|
||||
def _show_backing(self):
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("backing-expander"), self._can_backing())
|
||||
|
||||
def reset_state(self):
|
||||
|
@ -169,7 +169,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
|
||||
self.populate_vol_format()
|
||||
hasformat = bool(len(self.vol.list_formats()))
|
||||
uihelpers.set_grid_row_visible(self.widget("vol-format"), hasformat)
|
||||
uiutil.set_grid_row_visible(self.widget("vol-format"), hasformat)
|
||||
if hasformat:
|
||||
# Select the default storage format
|
||||
self.widget("vol-format").set_active(0)
|
||||
|
|
|
@ -33,7 +33,7 @@ from virtinst import util
|
|||
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
|
||||
STORAGE_ROW_CONFIRM = 0
|
||||
STORAGE_ROW_CANT_DELETE = 1
|
||||
|
@ -97,7 +97,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
|||
|
||||
# Show warning message if VM is running
|
||||
vm_active = self.vm.is_active()
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("delete-warn-running-vm-box"), vm_active)
|
||||
|
||||
# Disable storage removal by default
|
||||
|
@ -109,7 +109,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
|||
|
||||
def toggle_remove_storage(self, src):
|
||||
dodel = src.get_active()
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("delete-storage-scroll"), dodel)
|
||||
|
||||
def get_config_format(self):
|
||||
|
|
|
@ -29,7 +29,8 @@ from gi.repository import Gdk
|
|||
|
||||
import libvirt
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import sharedui
|
||||
from virtManager import uiutil
|
||||
from virtManager.storagebrowse import vmmStorageBrowser
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.addhardware import vmmAddHardware
|
||||
|
@ -641,14 +642,14 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
def init_menus(self):
|
||||
# Virtual Machine menu
|
||||
menu = uihelpers.VMShutdownMenu(self, lambda: self.vm)
|
||||
menu = sharedui.VMShutdownMenu(self, lambda: self.vm)
|
||||
self.widget("control-shutdown").set_menu(menu)
|
||||
self.widget("control-shutdown").set_icon_name("system-shutdown")
|
||||
|
||||
topmenu = self.widget("details-vm-menu")
|
||||
submenu = topmenu.get_submenu()
|
||||
newmenu = uihelpers.VMActionMenu(self, lambda: self.vm,
|
||||
show_open=False)
|
||||
newmenu = sharedui.VMActionMenu(self, lambda: self.vm,
|
||||
show_open=False)
|
||||
for child in submenu.get_children():
|
||||
submenu.remove(child)
|
||||
newmenu.add(child) # pylint: disable=E1101
|
||||
|
@ -759,7 +760,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
machtype_model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
show_machine = (arch not in ["i686", "x86_64"])
|
||||
uihelpers.set_grid_row_visible(self.widget("machine-type"),
|
||||
uiutil.set_grid_row_visible(self.widget("machine-type"),
|
||||
show_machine)
|
||||
|
||||
if show_machine:
|
||||
|
@ -936,7 +937,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
net_bridge = self.widget("network-bridge-box")
|
||||
source_mode_combo = self.widget("network-source-mode")
|
||||
vport_expander = self.widget("vport-expander")
|
||||
uihelpers.build_network_list(net_source, net_bridge,
|
||||
sharedui.build_network_list(net_source, net_bridge,
|
||||
source_mode_combo, vport_expander)
|
||||
|
||||
# source mode
|
||||
|
@ -951,7 +952,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
gfx_type = self.widget("gfx-type")
|
||||
model = Gtk.ListStore(str, str)
|
||||
gfx_type.set_model(model)
|
||||
uihelpers.set_combo_text_column(gfx_type, 1)
|
||||
uiutil.set_combo_text_column(gfx_type, 1)
|
||||
model.append([virtinst.VirtualGraphics.TYPE_VNC, "VNC"])
|
||||
model.append([virtinst.VirtualGraphics.TYPE_SPICE, "Spice"])
|
||||
gfx_type.set_active(-1)
|
||||
|
@ -989,7 +990,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
combo = self.widget("controller-model")
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
combo.set_active(-1)
|
||||
|
||||
|
||||
|
@ -1593,9 +1594,9 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
# Memory
|
||||
def config_get_maxmem(self):
|
||||
return uihelpers.spin_get_helper(self.widget("config-maxmem"))
|
||||
return uiutil.spin_get_helper(self.widget("config-maxmem"))
|
||||
def config_get_memory(self):
|
||||
return uihelpers.spin_get_helper(self.widget("config-memory"))
|
||||
return uiutil.spin_get_helper(self.widget("config-memory"))
|
||||
|
||||
def config_maxmem_changed(self, src_ignore):
|
||||
self.enable_apply(EDIT_MEM)
|
||||
|
@ -1619,9 +1620,9 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
# VCPUS
|
||||
def config_get_vcpus(self):
|
||||
return uihelpers.spin_get_helper(self.widget("config-vcpus"))
|
||||
return uiutil.spin_get_helper(self.widget("config-vcpus"))
|
||||
def config_get_maxvcpus(self):
|
||||
return uihelpers.spin_get_helper(self.widget("config-maxvcpus"))
|
||||
return uiutil.spin_get_helper(self.widget("config-maxvcpus"))
|
||||
|
||||
def config_vcpupin_generate(self, ignore):
|
||||
try:
|
||||
|
@ -2140,8 +2141,8 @@ class vmmDetails(vmmGObjectUI):
|
|||
mode = None
|
||||
net_list = self.widget("network-source")
|
||||
net_bridge = self.widget("network-bridge")
|
||||
nettype, source = uihelpers.get_network_selection(net_list,
|
||||
net_bridge)
|
||||
nettype, source = sharedui.get_network_selection(net_list,
|
||||
net_bridge)
|
||||
if nettype == "direct":
|
||||
mode = self.get_combo_entry("network-source-mode")
|
||||
|
||||
|
@ -2417,7 +2418,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
def refresh_inspection_page(self):
|
||||
inspection_supported = self.config.support_inspection
|
||||
uihelpers.set_grid_row_visible(self.widget("details-overview-error"),
|
||||
uiutil.set_grid_row_visible(self.widget("details-overview-error"),
|
||||
self.vm.inspection.error)
|
||||
if self.vm.inspection.error:
|
||||
msg = _("Error while inspecting the guest configuration")
|
||||
|
@ -2650,7 +2651,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
self.widget("disk-readonly").set_sensitive(not is_cdrom)
|
||||
self.widget("disk-shareable").set_active(share)
|
||||
self.widget("disk-removable").set_active(removable)
|
||||
uihelpers.set_grid_row_visible(self.widget("disk-removable"),
|
||||
uiutil.set_grid_row_visible(self.widget("disk-removable"),
|
||||
can_set_removable)
|
||||
self.widget("disk-size").set_text(size)
|
||||
self.set_combo_entry("disk-cache", cache)
|
||||
|
@ -2704,10 +2705,10 @@ class vmmDetails(vmmGObjectUI):
|
|||
if source and source in name_dict:
|
||||
netobj = name_dict[source]
|
||||
|
||||
desc = uihelpers.pretty_network_desc(nettype, source, netobj)
|
||||
desc = sharedui.pretty_network_desc(nettype, source, netobj)
|
||||
|
||||
self.widget("network-mac-address").set_text(net.macaddr)
|
||||
uihelpers.populate_network_list(
|
||||
sharedui.populate_network_list(
|
||||
self.widget("network-source"),
|
||||
self.conn)
|
||||
self.widget("network-source").set_active(-1)
|
||||
|
@ -2731,7 +2732,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
comparefunc=compare_network)
|
||||
|
||||
is_direct = (nettype == "direct")
|
||||
uihelpers.set_grid_row_visible(self.widget("network-source-mode"),
|
||||
uiutil.set_grid_row_visible(self.widget("network-source-mode"),
|
||||
is_direct)
|
||||
self.widget("vport-expander").set_visible(is_direct)
|
||||
|
||||
|
@ -2793,7 +2794,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
table.foreach(lambda w, ignore: w.hide(), ())
|
||||
|
||||
def show_row(name):
|
||||
uihelpers.set_grid_row_visible(self.widget(name), True)
|
||||
uiutil.set_grid_row_visible(self.widget(name), True)
|
||||
|
||||
def port_to_string(port):
|
||||
if port is None:
|
||||
|
@ -2889,7 +2890,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
if not val and doshow:
|
||||
val = getattr(tpmdev, param)
|
||||
|
||||
uihelpers.set_grid_row_visible(self.widget(widgetname), doshow)
|
||||
uiutil.set_grid_row_visible(self.widget(widgetname), doshow)
|
||||
self.widget(widgetname).set_text(val or "-")
|
||||
|
||||
dev_type = tpmdev.type
|
||||
|
@ -2912,7 +2913,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
propername = param.upper() + "_DEFAULT"
|
||||
val = getattr(virtinst.VirtualPanicDevice, propername, "-").upper()
|
||||
|
||||
uihelpers.set_grid_row_visible(self.widget(widgetname), True)
|
||||
uiutil.set_grid_row_visible(self.widget(widgetname), True)
|
||||
self.widget(widgetname).set_text(val or "-")
|
||||
|
||||
ptyp = virtinst.VirtualPanicDevice.get_pretty_type(dev.type)
|
||||
|
@ -2940,7 +2941,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
}
|
||||
|
||||
def set_visible(widget, v):
|
||||
uihelpers.set_grid_row_visible(self.widget(widget), v)
|
||||
uiutil.set_grid_row_visible(self.widget(widget), v)
|
||||
|
||||
is_egd = dev.type == VirtualRNGDevice.TYPE_EGD
|
||||
udp = dev.backend_type == VirtualRNGDevice.BACKEND_TYPE_UDP
|
||||
|
@ -2989,7 +2990,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
if not val and doshow:
|
||||
val = getattr(chardev, param)
|
||||
|
||||
uihelpers.set_grid_row_visible(self.widget(widgetname), doshow)
|
||||
uiutil.set_grid_row_visible(self.widget(widgetname), doshow)
|
||||
self.widget(widgetname).set_text(val or "-")
|
||||
|
||||
def build_host_str(base):
|
||||
|
@ -3103,7 +3104,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
self.widget("controller-type").set_text(type_label)
|
||||
combo = self.widget("controller-model")
|
||||
uihelpers.set_grid_row_visible(combo, True)
|
||||
uiutil.set_grid_row_visible(combo, True)
|
||||
|
||||
model = combo.get_model()
|
||||
model.clear()
|
||||
|
|
|
@ -26,7 +26,7 @@ from gi.repository import GObject
|
|||
|
||||
from virtinst import VirtualFilesystem, StorageVolume
|
||||
from virtinst import util
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.storagebrowse import vmmStorageBrowser
|
||||
|
||||
|
@ -250,21 +250,21 @@ class vmmFSDetails(vmmGObjectUI):
|
|||
show_mode = bool(ismount and
|
||||
(fsdriver == VirtualFilesystem.DRIVER_PATH or
|
||||
fsdriver == VirtualFilesystem.DRIVER_DEFAULT))
|
||||
uihelpers.set_grid_row_visible(self.widget("fs-mode-box"), show_mode)
|
||||
uiutil.set_grid_row_visible(self.widget("fs-mode-box"), show_mode)
|
||||
|
||||
show_wrpol = bool(ismount and
|
||||
fsdriver and (fsdriver == VirtualFilesystem.DRIVER_PATH or
|
||||
fsdriver == VirtualFilesystem.DRIVER_HANDLE))
|
||||
uihelpers.set_grid_row_visible(self.widget("fs-wrpolicy-box"),
|
||||
uiutil.set_grid_row_visible(self.widget("fs-wrpolicy-box"),
|
||||
show_wrpol)
|
||||
|
||||
show_ram_source = fstype == VirtualFilesystem.TYPE_RAM
|
||||
uihelpers.set_grid_row_visible(self.widget("fs-ram-source-box"), show_ram_source)
|
||||
uihelpers.set_grid_row_visible(self.widget("fs-source-box"), not show_ram_source)
|
||||
uiutil.set_grid_row_visible(self.widget("fs-ram-source-box"), show_ram_source)
|
||||
uiutil.set_grid_row_visible(self.widget("fs-source-box"), not show_ram_source)
|
||||
|
||||
show_format = bool(
|
||||
fsdriver == VirtualFilesystem.DRIVER_NBD)
|
||||
uihelpers.set_grid_row_visible(self.widget("fs-format-box"), show_format)
|
||||
uiutil.set_grid_row_visible(self.widget("fs-format-box"), show_format)
|
||||
self.show_pair_combo("fs-format", True)
|
||||
|
||||
show_mode_combo = False
|
||||
|
@ -292,7 +292,7 @@ class vmmFSDetails(vmmGObjectUI):
|
|||
conn = self.conn.get_backend()
|
||||
source = self.widget("fs-source").get_text()
|
||||
target = self.widget("fs-target").get_text()
|
||||
usage = uihelpers.spin_get_helper(self.widget("fs-ram-source-spin"))
|
||||
usage = uiutil.spin_get_helper(self.widget("fs-ram-source-spin"))
|
||||
mode = self.get_config_fs_mode()
|
||||
fstype = self.get_config_fs_type()
|
||||
readonly = self.get_config_fs_readonly()
|
||||
|
|
|
@ -30,7 +30,7 @@ from virtinst import VirtualDisk
|
|||
from virtinst import StoragePool
|
||||
from virtinst import Interface
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
from virtManager.connection import vmmConnection
|
||||
from virtManager.createnet import vmmCreateNetwork
|
||||
|
@ -582,7 +582,7 @@ class vmmHost(vmmGObjectUI):
|
|||
self.widget("net-ipv4-dhcp-range").set_text(dhcpstr)
|
||||
self.widget("net-ipv4-network").set_text(netstr)
|
||||
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("net-ipv4-route"), bool(routevia))
|
||||
if routevia:
|
||||
routevia = routeaddr + ", gateway=" + routevia
|
||||
|
@ -613,7 +613,7 @@ class vmmHost(vmmGObjectUI):
|
|||
self.widget("net-ipv6-dhcp-range").set_text(dhcpstr)
|
||||
self.widget("net-ipv6-network").set_text(netstr or "")
|
||||
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("net-ipv6-route"), bool(routevia))
|
||||
if routevia:
|
||||
routevia = routeaddr + ", gateway=" + routevia
|
||||
|
@ -627,7 +627,7 @@ class vmmHost(vmmGObjectUI):
|
|||
self.widget("net-name").set_editable(not active)
|
||||
self.widget("net-device").set_text(net.get_bridge_device() or "")
|
||||
self.widget("net-name-domain").set_text(net.get_name_domain() or "")
|
||||
uihelpers.set_grid_row_visible(self.widget("net-name-domain"),
|
||||
uiutil.set_grid_row_visible(self.widget("net-name-domain"),
|
||||
bool(net.get_name_domain()))
|
||||
|
||||
state = active and _("Active") or _("Inactive")
|
||||
|
@ -690,7 +690,7 @@ class vmmHost(vmmGObjectUI):
|
|||
Gtk.IconSize.LARGE_TOOLBAR,
|
||||
bool(net.is_active())])
|
||||
|
||||
uihelpers.set_row_selection(net_list,
|
||||
uiutil.set_row_selection(net_list,
|
||||
curnet and curnet.get_uuid() or None)
|
||||
|
||||
|
||||
|
@ -1240,7 +1240,7 @@ class vmmHost(vmmGObjectUI):
|
|||
Gtk.IconSize.LARGE_TOOLBAR,
|
||||
bool(iface.is_active())])
|
||||
|
||||
uihelpers.set_row_selection(iface_list,
|
||||
uiutil.set_row_selection(iface_list,
|
||||
curiface and curiface.get_name() or None)
|
||||
|
||||
def populate_interface_children(self):
|
||||
|
@ -1303,7 +1303,7 @@ def populate_storage_pools(pool_list, conn, curpool):
|
|||
model.append([uuid, label, pool.is_active(), per])
|
||||
|
||||
pool_list.set_model(model)
|
||||
uihelpers.set_row_selection(pool_list,
|
||||
uiutil.set_row_selection(pool_list,
|
||||
curpool and curpool.get_uuid() or None)
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ from gi.repository import GdkPixbuf
|
|||
|
||||
from virtinst import util
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import sharedui
|
||||
from virtManager import uiutil
|
||||
from virtManager.connection import vmmConnection
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.graphwidgets import CellRendererSparkline
|
||||
|
@ -125,7 +126,7 @@ class vmmManager(vmmGObjectUI):
|
|||
self.topwin.set_default_size(w or 550, h or 550)
|
||||
self.prev_position = None
|
||||
|
||||
self.vmmenu = uihelpers.VMActionMenu(self, self.current_vm)
|
||||
self.vmmenu = sharedui.VMActionMenu(self, self.current_vm)
|
||||
self.connmenu = Gtk.Menu()
|
||||
self.connmenu_items = {}
|
||||
|
||||
|
@ -296,7 +297,7 @@ class vmmManager(vmmGObjectUI):
|
|||
self.widget("vm-new").set_icon_name("vm_new")
|
||||
self.widget("vm-open").set_icon_name("icon_console")
|
||||
|
||||
menu = uihelpers.VMShutdownMenu(self, self.current_vm)
|
||||
menu = sharedui.VMShutdownMenu(self, self.current_vm)
|
||||
self.widget("vm-shutdown").set_icon_name("system-shutdown")
|
||||
self.widget("vm-shutdown").set_menu(menu)
|
||||
|
||||
|
@ -786,7 +787,7 @@ class vmmManager(vmmGObjectUI):
|
|||
row[ROW_MARKUP] = self._build_vm_markup(name, status)
|
||||
|
||||
desc = vm.get_description()
|
||||
if not uihelpers.can_set_row_none:
|
||||
if not uiutil.can_set_row_none:
|
||||
desc = desc or ""
|
||||
row[ROW_HINT] = util.xml_escape(desc)
|
||||
except libvirt.libvirtError, e:
|
||||
|
@ -823,7 +824,7 @@ class vmmManager(vmmGObjectUI):
|
|||
return
|
||||
|
||||
new_icon = _get_inspection_icon_pixbuf(vm, 16, 16)
|
||||
if not uihelpers.can_set_row_none:
|
||||
if not uiutil.can_set_row_none:
|
||||
new_icon = new_icon or ""
|
||||
row[ROW_INSPECTION_OS_ICON] = new_icon
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ from gi.repository import Gtk
|
|||
from gi.repository import Gdk
|
||||
# pylint: enable=E0611
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ class vmmPreferences(vmmGObjectUI):
|
|||
[2, _("Always")]]:
|
||||
model.append(row)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
combo = self.widget("prefs-graphics-type")
|
||||
# [gsettings value, string]
|
||||
|
@ -112,7 +112,7 @@ class vmmPreferences(vmmGObjectUI):
|
|||
["vnc", "VNC"], ["spice", "Spice"]]:
|
||||
model.append(row)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
combo = self.widget("prefs-storage-format")
|
||||
# [gsettings value, string]
|
||||
|
@ -123,7 +123,7 @@ class vmmPreferences(vmmGObjectUI):
|
|||
["qcow2", "QCOW2"]]:
|
||||
model.append(row)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
combo = self.widget("prefs-cpu-default")
|
||||
# [gsettings value, string]
|
||||
|
@ -135,7 +135,7 @@ class vmmPreferences(vmmGObjectUI):
|
|||
["host-model", _("Copy host CPU definition")]]:
|
||||
model.append(row)
|
||||
combo.set_model(model)
|
||||
uihelpers.set_combo_text_column(combo, 1)
|
||||
uiutil.set_combo_text_column(combo, 1)
|
||||
|
||||
|
||||
#########################
|
||||
|
@ -156,7 +156,7 @@ class vmmPreferences(vmmGObjectUI):
|
|||
def refresh_console_scaling(self):
|
||||
combo = self.widget("prefs-console-scaling")
|
||||
val = self.config.get_console_scaling()
|
||||
uihelpers.set_row_selection(combo, val)
|
||||
uiutil.set_row_selection(combo, val)
|
||||
|
||||
def refresh_new_vm_sound(self):
|
||||
self.widget("prefs-new-vm-sound").set_active(
|
||||
|
@ -164,15 +164,15 @@ class vmmPreferences(vmmGObjectUI):
|
|||
def refresh_graphics_type(self):
|
||||
combo = self.widget("prefs-graphics-type")
|
||||
gtype = self.config.get_graphics_type(raw=True)
|
||||
uihelpers.set_row_selection(combo, gtype)
|
||||
uiutil.set_row_selection(combo, gtype)
|
||||
def refresh_storage_format(self):
|
||||
combo = self.widget("prefs-storage-format")
|
||||
val = self.config.get_default_storage_format(raw=True)
|
||||
uihelpers.set_row_selection(combo, val)
|
||||
uiutil.set_row_selection(combo, val)
|
||||
def refresh_cpu_default(self):
|
||||
combo = self.widget("prefs-cpu-default")
|
||||
val = self.config.get_default_cpu_setting(raw=True)
|
||||
uihelpers.set_row_selection(combo, val)
|
||||
uiutil.set_row_selection(combo, val)
|
||||
|
||||
def refresh_disk_poll(self):
|
||||
self.widget("prefs-stats-enable-disk").set_active(
|
||||
|
|
|
@ -24,26 +24,12 @@ import statvfs
|
|||
import pwd
|
||||
|
||||
# pylint: disable=E0611
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
import virtinst
|
||||
from virtManager import config
|
||||
|
||||
OPTICAL_DEV_PATH = 0
|
||||
OPTICAL_LABEL = 1
|
||||
OPTICAL_IS_MEDIA_PRESENT = 2
|
||||
OPTICAL_DEV_KEY = 3
|
||||
OPTICAL_MEDIA_KEY = 4
|
||||
OPTICAL_IS_VALID = 5
|
||||
|
||||
try:
|
||||
import gi
|
||||
gi.check_version("3.7.4")
|
||||
can_set_row_none = True
|
||||
except (ValueError, AttributeError):
|
||||
can_set_row_none = False
|
||||
from virtManager import uiutil
|
||||
|
||||
|
||||
############################################################
|
||||
|
@ -255,11 +241,11 @@ def _net_list_changed(net_list, bridge_box,
|
|||
|
||||
if source_mode_combo is not None:
|
||||
doshow = (row[0] == virtinst.VirtualNetworkInterface.TYPE_DIRECT)
|
||||
set_grid_row_visible(source_mode_combo, doshow)
|
||||
uiutil.set_grid_row_visible(source_mode_combo, doshow)
|
||||
vport_expander.set_visible(doshow)
|
||||
|
||||
show_bridge = row[5]
|
||||
set_grid_row_visible(bridge_box, show_bridge)
|
||||
uiutil.set_grid_row_visible(bridge_box, show_bridge)
|
||||
|
||||
|
||||
def pretty_network_desc(nettype, source=None, netobj=None):
|
||||
|
@ -538,6 +524,14 @@ def validate_network(err, conn, nettype, devname, macaddr, model=None):
|
|||
# Populate media widget (choosecd, create) #
|
||||
############################################
|
||||
|
||||
OPTICAL_DEV_PATH = 0
|
||||
OPTICAL_LABEL = 1
|
||||
OPTICAL_IS_MEDIA_PRESENT = 2
|
||||
OPTICAL_DEV_KEY = 3
|
||||
OPTICAL_MEDIA_KEY = 4
|
||||
OPTICAL_IS_VALID = 5
|
||||
|
||||
|
||||
def _set_mediadev_default(model):
|
||||
if len(model) == 0:
|
||||
model.append([None, _("No device present"), False, None, None, False])
|
||||
|
@ -796,95 +790,3 @@ class VMActionMenu(_VMMenu):
|
|||
for child in self.get_children():
|
||||
if getattr(child, "vmm_widget_name", None) == "run":
|
||||
child.get_child().set_label(text)
|
||||
|
||||
|
||||
|
||||
|
||||
################
|
||||
# Misc helpers #
|
||||
################
|
||||
|
||||
def set_combo_text_column(combo, col):
|
||||
if combo.get_has_entry():
|
||||
combo.set_entry_text_column(col)
|
||||
else:
|
||||
text = Gtk.CellRendererText()
|
||||
combo.pack_start(text, True)
|
||||
combo.add_attribute(text, 'text', col)
|
||||
|
||||
|
||||
def spin_get_helper(widget):
|
||||
adj = widget.get_adjustment()
|
||||
txt = widget.get_text()
|
||||
|
||||
try:
|
||||
return int(txt)
|
||||
except:
|
||||
return adj.get_value()
|
||||
|
||||
|
||||
def get_list_selection(widget):
|
||||
selection = widget.get_selection()
|
||||
active = selection.get_selected()
|
||||
|
||||
treestore, treeiter = active
|
||||
if treeiter is not None:
|
||||
return treestore[treeiter]
|
||||
return None
|
||||
|
||||
|
||||
def set_list_selection(widget, rownum):
|
||||
path = str(rownum)
|
||||
selection = widget.get_selection()
|
||||
|
||||
selection.unselect_all()
|
||||
widget.set_cursor(path)
|
||||
selection.select_path(path)
|
||||
|
||||
|
||||
def set_row_selection(listwidget, prevkey):
|
||||
model = listwidget.get_model()
|
||||
_iter = None
|
||||
if prevkey:
|
||||
for row in model:
|
||||
if row[0] == prevkey:
|
||||
_iter = row.iter
|
||||
break
|
||||
if not _iter:
|
||||
_iter = model.get_iter_first()
|
||||
|
||||
if hasattr(listwidget, "get_selection"):
|
||||
selection = listwidget.get_selection()
|
||||
cb = selection.select_iter
|
||||
else:
|
||||
selection = listwidget
|
||||
cb = selection.set_active_iter
|
||||
if _iter:
|
||||
cb(_iter)
|
||||
selection.emit("changed")
|
||||
|
||||
|
||||
def child_get_property(parent, child, propname):
|
||||
# Wrapper for child_get_property, which pygobject doesn't properly
|
||||
# introspect
|
||||
value = GObject.Value()
|
||||
value.init(GObject.TYPE_INT)
|
||||
parent.child_get_property(child, propname, value)
|
||||
return value.get_int()
|
||||
|
||||
|
||||
def set_grid_row_visible(child, visible):
|
||||
# For the passed widget, find its parent GtkGrid, and hide/show all
|
||||
# elements that are in the same row as it. Simplifies having to name
|
||||
# every element in a row when we want to dynamically hide things
|
||||
# based on UI interraction
|
||||
|
||||
parent = child.get_parent()
|
||||
if not type(parent) is Gtk.Grid:
|
||||
raise RuntimeError("Programming error, parent must be grid, "
|
||||
"not %s" % type(parent))
|
||||
|
||||
row = child_get_property(parent, child, "top-attach")
|
||||
for child in parent.get_children():
|
||||
if child_get_property(parent, child, "top-attach") == row:
|
||||
child.set_visible(visible)
|
|
@ -33,7 +33,7 @@ from gi.repository import Gtk
|
|||
from virtinst import DomainSnapshot
|
||||
from virtinst import util
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager.asyncjob import vmmAsyncJob
|
||||
|
||||
|
@ -214,7 +214,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||
has_internal = False
|
||||
for snap in snapshots:
|
||||
desc = snap.get_xmlobj().description
|
||||
if not uihelpers.can_set_row_none:
|
||||
if not uiutil.can_set_row_none:
|
||||
desc = desc or ""
|
||||
|
||||
name = snap.get_name()
|
||||
|
@ -237,7 +237,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||
model.append([None, None, None, None, "2"])
|
||||
|
||||
select_name = select_name or (cursnap and cursnap.get_name() or None)
|
||||
uihelpers.set_row_selection(self.widget("snapshot-list"), select_name)
|
||||
uiutil.set_row_selection(self.widget("snapshot-list"), select_name)
|
||||
self._initial_populate = True
|
||||
|
||||
def _make_screenshot_pixbuf(self, mime, sdata):
|
||||
|
@ -307,7 +307,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||
self.widget("snapshot-status-icon").set_from_icon_name(
|
||||
icon, Gtk.IconSize.BUTTON)
|
||||
|
||||
uihelpers.set_grid_row_visible(self.widget("snapshot-mode"),
|
||||
uiutil.set_grid_row_visible(self.widget("snapshot-mode"),
|
||||
is_external)
|
||||
if is_external:
|
||||
is_mem = xmlobj.memory_type == "external"
|
||||
|
@ -396,7 +396,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||
self.vm.run_status_icon_name(), Gtk.IconSize.BUTTON)
|
||||
|
||||
sn = self._get_screenshot()
|
||||
uihelpers.set_grid_row_visible(
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("snapshot-new-screenshot"), bool(sn))
|
||||
if sn:
|
||||
self.widget("snapshot-new-screenshot").set_from_pixbuf(sn)
|
||||
|
|
|
@ -28,7 +28,7 @@ from gi.repository import Gtk
|
|||
from virtManager import host
|
||||
from virtManager.createvol import vmmCreateVolume
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
from virtManager import uihelpers
|
||||
from virtManager import uiutil
|
||||
|
||||
|
||||
class vmmStorageBrowser(vmmGObjectUI):
|
||||
|
@ -180,7 +180,7 @@ class vmmStorageBrowser(vmmGObjectUI):
|
|||
if not self._first_run:
|
||||
self._first_run = True
|
||||
pool = self.conn.get_default_pool()
|
||||
uihelpers.set_row_selection(
|
||||
uiutil.set_row_selection(
|
||||
self.widget("pool-list"), pool and pool.get_uuid() or None)
|
||||
# Manually trigger vol_selected, so buttons are in the correct state
|
||||
self.vol_selected()
|
||||
|
@ -216,7 +216,7 @@ class vmmStorageBrowser(vmmGObjectUI):
|
|||
return data["enable_create"]
|
||||
|
||||
def current_pool(self):
|
||||
row = uihelpers.get_list_selection(self.widget("pool-list"))
|
||||
row = uiutil.get_list_selection(self.widget("pool-list"))
|
||||
if not row:
|
||||
return
|
||||
try:
|
||||
|
@ -227,7 +227,7 @@ class vmmStorageBrowser(vmmGObjectUI):
|
|||
def current_vol_row(self):
|
||||
if not self.current_pool():
|
||||
return
|
||||
return uihelpers.get_list_selection(self.widget("vol-list"))
|
||||
return uiutil.get_list_selection(self.widget("vol-list"))
|
||||
|
||||
def current_vol(self):
|
||||
pool = self.current_pool()
|
||||
|
@ -283,7 +283,7 @@ class vmmStorageBrowser(vmmGObjectUI):
|
|||
vol_list = self.widget("vol-list")
|
||||
def select_volume(model, path, it, volume_name):
|
||||
if model.get(it, 0)[0] == volume_name:
|
||||
uihelpers.set_list_selection(vol_list, path)
|
||||
uiutil.set_list_selection(vol_list, path)
|
||||
|
||||
vol_list.get_model().foreach(select_volume, createvol.vol.name)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ from gi.repository import GObject
|
|||
from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
from virtManager import uihelpers
|
||||
from virtManager import sharedui
|
||||
from virtManager.baseclass import vmmGObject
|
||||
from virtManager.error import vmmErrorDialog
|
||||
|
||||
|
@ -303,7 +303,7 @@ class vmmSystray(vmmGObject):
|
|||
# Build VM list entry
|
||||
menu_item = build_image_menu_item(vm.get_name())
|
||||
vm_mappings[uuid] = menu_item
|
||||
vm_action_menu = uihelpers.VMActionMenu(self, lambda: vm)
|
||||
vm_action_menu = sharedui.VMActionMenu(self, lambda: vm)
|
||||
menu_item.set_submenu(vm_action_menu)
|
||||
self.vm_action_dict[uuid] = vm_action_menu
|
||||
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
#
|
||||
# Copyright (C) 2009, 2013, 2014 Red Hat, Inc.
|
||||
# Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
# pylint: disable=E0611
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
try:
|
||||
import gi
|
||||
gi.check_version("3.7.4")
|
||||
can_set_row_none = True
|
||||
except (ValueError, AttributeError):
|
||||
can_set_row_none = False
|
||||
|
||||
|
||||
def set_combo_text_column(combo, col):
|
||||
if combo.get_has_entry():
|
||||
combo.set_entry_text_column(col)
|
||||
else:
|
||||
text = Gtk.CellRendererText()
|
||||
combo.pack_start(text, True)
|
||||
combo.add_attribute(text, 'text', col)
|
||||
|
||||
|
||||
def spin_get_helper(widget):
|
||||
adj = widget.get_adjustment()
|
||||
txt = widget.get_text()
|
||||
|
||||
try:
|
||||
return int(txt)
|
||||
except:
|
||||
return adj.get_value()
|
||||
|
||||
|
||||
def get_list_selection(widget):
|
||||
selection = widget.get_selection()
|
||||
active = selection.get_selected()
|
||||
|
||||
treestore, treeiter = active
|
||||
if treeiter is not None:
|
||||
return treestore[treeiter]
|
||||
return None
|
||||
|
||||
|
||||
def set_list_selection(widget, rownum):
|
||||
path = str(rownum)
|
||||
selection = widget.get_selection()
|
||||
|
||||
selection.unselect_all()
|
||||
widget.set_cursor(path)
|
||||
selection.select_path(path)
|
||||
|
||||
|
||||
def set_row_selection(listwidget, prevkey):
|
||||
model = listwidget.get_model()
|
||||
_iter = None
|
||||
if prevkey:
|
||||
for row in model:
|
||||
if row[0] == prevkey:
|
||||
_iter = row.iter
|
||||
break
|
||||
if not _iter:
|
||||
_iter = model.get_iter_first()
|
||||
|
||||
if hasattr(listwidget, "get_selection"):
|
||||
selection = listwidget.get_selection()
|
||||
cb = selection.select_iter
|
||||
else:
|
||||
selection = listwidget
|
||||
cb = selection.set_active_iter
|
||||
if _iter:
|
||||
cb(_iter)
|
||||
selection.emit("changed")
|
||||
|
||||
|
||||
def child_get_property(parent, child, propname):
|
||||
# Wrapper for child_get_property, which pygobject doesn't properly
|
||||
# introspect
|
||||
value = GObject.Value()
|
||||
value.init(GObject.TYPE_INT)
|
||||
parent.child_get_property(child, propname, value)
|
||||
return value.get_int()
|
||||
|
||||
|
||||
def set_grid_row_visible(child, visible):
|
||||
# For the passed widget, find its parent GtkGrid, and hide/show all
|
||||
# elements that are in the same row as it. Simplifies having to name
|
||||
# every element in a row when we want to dynamically hide things
|
||||
# based on UI interraction
|
||||
|
||||
parent = child.get_parent()
|
||||
if not type(parent) is Gtk.Grid:
|
||||
raise RuntimeError("Programming error, parent must be grid, "
|
||||
"not %s" % type(parent))
|
||||
|
||||
row = child_get_property(parent, child, "top-attach")
|
||||
for child in parent.get_children():
|
||||
if child_get_property(parent, child, "top-attach") == row:
|
||||
child.set_visible(visible)
|
Loading…
Reference in New Issue