uihelpers: Drop global error dialog
Just have callers pass one in.
This commit is contained in:
parent
f08313513b
commit
2ca9e364a5
|
@ -1356,8 +1356,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||||
if not res:
|
if not res:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
uihelpers.check_path_search_for_qemu(self.topwin,
|
uihelpers.check_path_search_for_qemu(self.err, self.conn, disk.path)
|
||||||
self.conn, disk.path)
|
|
||||||
|
|
||||||
# Add a SCSI controller with model virtio-scsi if needed
|
# Add a SCSI controller with model virtio-scsi if needed
|
||||||
disk.vmm_controller = None
|
disk.vmm_controller = None
|
||||||
|
@ -1394,7 +1393,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||||
return self.err.val_err(_("Invalid MAC address"),
|
return self.err.val_err(_("Invalid MAC address"),
|
||||||
_("A MAC address must be entered."))
|
_("A MAC address must be entered."))
|
||||||
|
|
||||||
ret = uihelpers.validate_network(self.topwin, self.conn,
|
ret = uihelpers.validate_network(self.err, self.conn,
|
||||||
nettype, devname, mac, model)
|
nettype, devname, mac, model)
|
||||||
if ret is False:
|
if ret is False:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -112,7 +112,7 @@ class vmmChooseCD(vmmGObjectUI):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return self.err.val_err(_("Invalid Media Path"), e)
|
return self.err.val_err(_("Invalid Media Path"), e)
|
||||||
|
|
||||||
uihelpers.check_path_search_for_qemu(self.topwin, self.conn, path)
|
uihelpers.check_path_search_for_qemu(self.err, self.conn, path)
|
||||||
|
|
||||||
self.emit("cdrom-chosen", self.disk, path)
|
self.emit("cdrom-chosen", self.disk, path)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
|
@ -1591,8 +1591,7 @@ class vmmCreate(vmmGObjectUI):
|
||||||
path = None
|
path = None
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
uihelpers.check_path_search_for_qemu(self.topwin,
|
uihelpers.check_path_search_for_qemu(self.err, self.conn, path)
|
||||||
self.conn, path)
|
|
||||||
|
|
||||||
# Validation passed, store the install path (if there is one) in
|
# Validation passed, store the install path (if there is one) in
|
||||||
# gconf
|
# gconf
|
||||||
|
@ -1712,7 +1711,7 @@ class vmmCreate(vmmGObjectUI):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not oldguest:
|
if not oldguest:
|
||||||
uihelpers.check_path_search_for_qemu(self.topwin,
|
uihelpers.check_path_search_for_qemu(self.err,
|
||||||
self.conn, disk.path)
|
self.conn, disk.path)
|
||||||
|
|
||||||
self.disk = disk
|
self.disk = disk
|
||||||
|
@ -1742,7 +1741,7 @@ class vmmCreate(vmmGObjectUI):
|
||||||
_("Network device required for %s install.") %
|
_("Network device required for %s install.") %
|
||||||
methname)
|
methname)
|
||||||
|
|
||||||
nic = uihelpers.validate_network(self.topwin,
|
nic = uihelpers.validate_network(self.err,
|
||||||
self.conn, nettype, devname, macaddr)
|
self.conn, nettype, devname, macaddr)
|
||||||
if nic is False:
|
if nic is False:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -32,7 +32,6 @@ import libvirt
|
||||||
import virtinst
|
import virtinst
|
||||||
|
|
||||||
from virtManager import packageutils
|
from virtManager import packageutils
|
||||||
from virtManager import uihelpers
|
|
||||||
from virtManager import util
|
from virtManager import util
|
||||||
from virtManager.about import vmmAbout
|
from virtManager.about import vmmAbout
|
||||||
from virtManager.baseclass import vmmGObject
|
from virtManager.baseclass import vmmGObject
|
||||||
|
@ -343,7 +342,6 @@ class vmmEngine(vmmGObject):
|
||||||
self.idle_add(self.exit_app, src)
|
self.idle_add(self.exit_app, src)
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
uihelpers.cleanup()
|
|
||||||
self.err = None
|
self.err = None
|
||||||
|
|
||||||
if self.inspection:
|
if self.inspection:
|
||||||
|
|
|
@ -29,7 +29,6 @@ from gi.repository import Gtk
|
||||||
import virtinst
|
import virtinst
|
||||||
|
|
||||||
from virtManager import util
|
from virtManager import util
|
||||||
from virtManager.error import vmmErrorDialog
|
|
||||||
|
|
||||||
OPTICAL_DEV_PATH = 0
|
OPTICAL_DEV_PATH = 0
|
||||||
OPTICAL_LABEL = 1
|
OPTICAL_LABEL = 1
|
||||||
|
@ -39,39 +38,10 @@ OPTICAL_MEDIA_KEY = 4
|
||||||
OPTICAL_IS_VALID = 5
|
OPTICAL_IS_VALID = 5
|
||||||
|
|
||||||
|
|
||||||
##############################################################
|
|
||||||
# Initialize an error object to use for validation functions #
|
|
||||||
##############################################################
|
|
||||||
|
|
||||||
err_dial = vmmErrorDialog()
|
|
||||||
|
|
||||||
|
|
||||||
def set_error_parent(parent):
|
|
||||||
global err_dial
|
|
||||||
err_dial.set_parent(parent)
|
|
||||||
err_dial = err_dial
|
|
||||||
|
|
||||||
|
|
||||||
def cleanup():
|
|
||||||
global err_dial
|
|
||||||
err_dial = None
|
|
||||||
|
|
||||||
|
|
||||||
def spin_get_helper(widget):
|
|
||||||
adj = widget.get_adjustment()
|
|
||||||
txt = widget.get_text()
|
|
||||||
|
|
||||||
try:
|
|
||||||
ret = int(txt)
|
|
||||||
except:
|
|
||||||
ret = adj.get_value()
|
|
||||||
return ret
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Helpers for shared storage UI between create/addhardware #
|
# Helpers for shared storage UI between create/addhardware #
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
|
|
||||||
def set_sparse_tooltip(widget):
|
def set_sparse_tooltip(widget):
|
||||||
sparse_str = _("Fully allocating storage may take longer now, "
|
sparse_str = _("Fully allocating storage may take longer now, "
|
||||||
"but the OS install phase will be quicker. \n\n"
|
"but the OS install phase will be quicker. \n\n"
|
||||||
|
@ -136,11 +106,11 @@ def check_default_pool_active(err, conn):
|
||||||
(default_pool.get_name(), str(e)))
|
(default_pool.get_name(), str(e)))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# Hardware model list building (for details, addhw) #
|
# Hardware model list building (for details, addhw) #
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
def build_video_combo(vm, video_dev, no_default=None):
|
def build_video_combo(vm, video_dev, no_default=None):
|
||||||
video_dev_model = Gtk.ListStore(str, str)
|
video_dev_model = Gtk.ListStore(str, str)
|
||||||
video_dev.set_model(video_dev_model)
|
video_dev.set_model(video_dev_model)
|
||||||
|
@ -441,11 +411,11 @@ def build_vnc_keymap_combo(vm, combo, no_default=False):
|
||||||
|
|
||||||
combo.set_active(-1)
|
combo.set_active(-1)
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Storage format list/combo helpers #
|
# Storage format list/combo helpers #
|
||||||
#####################################
|
#####################################
|
||||||
|
|
||||||
|
|
||||||
def build_storage_format_combo(vm, combo):
|
def build_storage_format_combo(vm, combo):
|
||||||
dev_model = Gtk.ListStore(str)
|
dev_model = Gtk.ListStore(str)
|
||||||
combo.set_model(dev_model)
|
combo.set_model(dev_model)
|
||||||
|
@ -461,11 +431,11 @@ def build_storage_format_combo(vm, combo):
|
||||||
|
|
||||||
combo.set_active(0)
|
combo.set_active(0)
|
||||||
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Widgets for listing network device options (in create, addhardware) #
|
# Widgets for listing network device options (in create, addhardware) #
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
|
||||||
def pretty_network_desc(nettype, source=None, netobj=None):
|
def pretty_network_desc(nettype, source=None, netobj=None):
|
||||||
if nettype == virtinst.VirtualNetworkInterface.TYPE_USER:
|
if nettype == virtinst.VirtualNetworkInterface.TYPE_USER:
|
||||||
return _("Usermode networking")
|
return _("Usermode networking")
|
||||||
|
@ -700,9 +670,7 @@ def populate_network_list(net_list, conn, show_direct_interfaces=True):
|
||||||
return return_warn
|
return return_warn
|
||||||
|
|
||||||
|
|
||||||
def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
def validate_network(err, conn, nettype, devname, macaddr, model=None):
|
||||||
set_error_parent(parent)
|
|
||||||
|
|
||||||
net = None
|
net = None
|
||||||
addr = None
|
addr = None
|
||||||
|
|
||||||
|
@ -718,10 +686,10 @@ def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
||||||
break
|
break
|
||||||
|
|
||||||
if netobj and not netobj.is_active():
|
if netobj and not netobj.is_active():
|
||||||
res = err_dial.yes_no(_("Virtual Network is not active."),
|
res = err.yes_no(_("Virtual Network is not active."),
|
||||||
_("Virtual Network '%s' is not active. "
|
_("Virtual Network '%s' is not active. "
|
||||||
"Would you like to start the network "
|
"Would you like to start the network "
|
||||||
"now?") % devname)
|
"now?") % devname)
|
||||||
if not res:
|
if not res:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -731,8 +699,8 @@ def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
||||||
netobj.tick()
|
netobj.tick()
|
||||||
logging.info("Started network '%s'", devname)
|
logging.info("Started network '%s'", devname)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return err_dial.show_err(_("Could not start virtual network "
|
return err.show_err(_("Could not start virtual network "
|
||||||
"'%s': %s") % (devname, str(e)))
|
"'%s': %s") % (devname, str(e)))
|
||||||
|
|
||||||
# Create network device
|
# Create network device
|
||||||
try:
|
try:
|
||||||
|
@ -759,16 +727,16 @@ def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
||||||
net.set_address(addr)
|
net.set_address(addr)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return err_dial.val_err(_("Error with network parameters."), e)
|
return err.val_err(_("Error with network parameters."), e)
|
||||||
|
|
||||||
# Make sure there is no mac address collision
|
# Make sure there is no mac address collision
|
||||||
isfatal, errmsg = net.is_conflict_net(conn.get_backend())
|
isfatal, errmsg = net.is_conflict_net(conn.get_backend())
|
||||||
if isfatal:
|
if isfatal:
|
||||||
return err_dial.val_err(_("Mac address collision."), errmsg)
|
return err.val_err(_("Mac address collision."), errmsg)
|
||||||
elif errmsg is not None:
|
elif errmsg is not None:
|
||||||
retv = err_dial.yes_no(_("Mac address collision."),
|
retv = err.yes_no(_("Mac address collision."),
|
||||||
_("%s Are you sure you want to use this "
|
_("%s Are you sure you want to use this "
|
||||||
"address?") % errmsg)
|
"address?") % errmsg)
|
||||||
if not retv:
|
if not retv:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -972,14 +940,12 @@ def build_shutdown_button_menu(widget, shutdown_cb, reboot_cb, reset_cb,
|
||||||
save.connect("activate", save_cb)
|
save.connect("activate", save_cb)
|
||||||
menu.add(save)
|
menu.add(save)
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Path permissions checker for qemu #
|
# Path permissions checker for qemu #
|
||||||
#####################################
|
#####################################
|
||||||
|
|
||||||
|
def check_path_search_for_qemu(err, conn, path):
|
||||||
def check_path_search_for_qemu(parent, conn, path):
|
|
||||||
set_error_parent(parent)
|
|
||||||
|
|
||||||
if conn.is_remote() or not conn.is_qemu_system():
|
if conn.is_remote() or not conn.is_qemu_system():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -997,7 +963,7 @@ def check_path_search_for_qemu(parent, conn, path):
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.debug("No search access for dirs: %s", broken_paths)
|
logging.debug("No search access for dirs: %s", broken_paths)
|
||||||
resp, chkres = err_dial.warn_chkbox(
|
resp, chkres = err.warn_chkbox(
|
||||||
_("The emulator may not have search permissions "
|
_("The emulator may not have search permissions "
|
||||||
"for the path '%s'.") % path,
|
"for the path '%s'.") % path,
|
||||||
_("Do you want to correct this now?"),
|
_("Do you want to correct this now?"),
|
||||||
|
@ -1025,17 +991,17 @@ def check_path_search_for_qemu(parent, conn, path):
|
||||||
|
|
||||||
logging.debug("Permission errors:\n%s", details)
|
logging.debug("Permission errors:\n%s", details)
|
||||||
|
|
||||||
ignore, chkres = err_dial.err_chkbox(errmsg, details,
|
ignore, chkres = err.err_chkbox(errmsg, details,
|
||||||
_("Don't ask about these directories again."))
|
_("Don't ask about these directories again."))
|
||||||
|
|
||||||
if chkres:
|
if chkres:
|
||||||
util.running_config.add_perms_fix_ignore(errors.keys())
|
util.running_config.add_perms_fix_ignore(errors.keys())
|
||||||
|
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
# Interface startmode widget builder #
|
# Interface startmode widget builder #
|
||||||
######################################
|
######################################
|
||||||
|
|
||||||
|
|
||||||
def build_startmode_combo(start_list):
|
def build_startmode_combo(start_list):
|
||||||
start_model = Gtk.ListStore(str)
|
start_model = Gtk.ListStore(str)
|
||||||
start_list.set_model(start_model)
|
start_list.set_model(start_model)
|
||||||
|
@ -1072,3 +1038,18 @@ def build_keycombo_menu(cb):
|
||||||
|
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
# Misc bits #
|
||||||
|
#############
|
||||||
|
|
||||||
|
def spin_get_helper(widget):
|
||||||
|
adj = widget.get_adjustment()
|
||||||
|
txt = widget.get_text()
|
||||||
|
|
||||||
|
try:
|
||||||
|
ret = int(txt)
|
||||||
|
except:
|
||||||
|
ret = adj.get_value()
|
||||||
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue