engine: Before launching any error, try to find a parent dialog
This commit is contained in:
parent
0b47635676
commit
f7b05912f0
|
@ -75,6 +75,7 @@ class vmmEngine(vmmGObject):
|
|||
|
||||
self.conns = {}
|
||||
self.err = vmmErrorDialog()
|
||||
self.err.set_find_parent_cb(self._find_error_parent_cb)
|
||||
|
||||
self.timer = None
|
||||
self.last_timeout = 0
|
||||
|
@ -456,6 +457,29 @@ class vmmEngine(vmmGObject):
|
|||
self.connect("conn-removed", self.inspection.conn_removed)
|
||||
return
|
||||
|
||||
def _find_error_parent_cb(self):
|
||||
"""
|
||||
Search over the toplevel windows for any that are visible or have
|
||||
focus, and use that
|
||||
"""
|
||||
windowlist = [self.windowManager]
|
||||
for conndict in self.conns.values():
|
||||
windowlist.extend(conndict["windowDetails"].values())
|
||||
windowlist.extend(
|
||||
[conndict["windowHost"] for conndict in self.conns.values()])
|
||||
|
||||
use_win = None
|
||||
for window in windowlist:
|
||||
if not window:
|
||||
continue
|
||||
if window.topwin.has_focus():
|
||||
use_win = window
|
||||
break
|
||||
if not use_win and window.is_visible():
|
||||
use_win = window
|
||||
|
||||
if use_win:
|
||||
return use_win.topwin
|
||||
|
||||
def make_conn(self, uri, probe=False):
|
||||
conn = self._check_conn(uri)
|
||||
|
@ -620,10 +644,6 @@ class vmmEngine(vmmGObject):
|
|||
msg += "\n\n"
|
||||
msg += _("Would you still like to remember this connection?")
|
||||
|
||||
if (self.windowManager and
|
||||
self.windowManager.is_visible()):
|
||||
self.err.set_parent(self.windowManager.topwin)
|
||||
|
||||
title = _("Virtual Machine Manager Connection Failure")
|
||||
if probe_connection:
|
||||
remember_connection = self.err.show_err(msg, details, title,
|
||||
|
|
|
@ -54,18 +54,27 @@ class vmmErrorDialog(vmmGObject):
|
|||
self._parent = parent
|
||||
self._simple = None
|
||||
|
||||
# Callback to lookup the parent window if none is specified.
|
||||
# Used by engine.py for properly parenting windows
|
||||
self._find_parent_cb = None
|
||||
|
||||
# Allows the error owner to easily override default modality
|
||||
self._modal_default = False
|
||||
|
||||
def _cleanup(self):
|
||||
pass
|
||||
self._find_parent_cb = None
|
||||
|
||||
def set_modal_default(self, val):
|
||||
self._modal_default = val
|
||||
def set_find_parent_cb(self, cb):
|
||||
self._find_parent_cb = cb
|
||||
def set_parent(self, parent):
|
||||
self._parent = parent
|
||||
def get_parent(self):
|
||||
return self._parent
|
||||
parent = self._parent
|
||||
if parent is None and self._find_parent_cb:
|
||||
parent = self._find_parent_cb()
|
||||
return parent
|
||||
|
||||
def show_err(self, summary, details=None, title="",
|
||||
modal=None, debug=True,
|
||||
|
@ -243,7 +252,7 @@ class vmmErrorDialog(vmmGObject):
|
|||
choose_button = Gtk.STOCK_OPEN
|
||||
|
||||
fcdialog = Gtk.FileChooserDialog(title=dialog_name,
|
||||
parent=self._parent,
|
||||
parent=self.get_parent(),
|
||||
action=dialog_type,
|
||||
buttons=(Gtk.STOCK_CANCEL,
|
||||
Gtk.ResponseType.CANCEL,
|
||||
|
|
Loading…
Reference in New Issue