mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
systray: Cleanups and improvements for --show-systray
- Add UI coverage - Drop redundant systray_instance caching - Tweaks help test and docs - Show an error if the systray doesn't embed Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
2043847ade
commit
a6b62a20b6
@ -88,6 +88,7 @@ URI.
|
|||||||
``--show-host-summary``
|
``--show-host-summary``
|
||||||
Display the host/connection details window.
|
Display the host/connection details window.
|
||||||
|
|
||||||
|
|
||||||
SYSTEM TRAY OPTION
|
SYSTEM TRAY OPTION
|
||||||
==================
|
==================
|
||||||
|
|
||||||
@ -95,7 +96,8 @@ Connection autostart will not be disabled and thus don't require specifying a
|
|||||||
manual ``--connect`` URI. But it supports ``--connect`` URI as well:
|
manual ``--connect`` URI. But it supports ``--connect`` URI as well:
|
||||||
|
|
||||||
``--show-systray``
|
``--show-systray``
|
||||||
Launch virt-manager in system tray
|
Launch virt-manager only in system tray
|
||||||
|
|
||||||
|
|
||||||
BUGS
|
BUGS
|
||||||
====
|
====
|
||||||
|
@ -80,6 +80,19 @@ def testShowDelete(app):
|
|||||||
app.wait_for_exit()
|
app.wait_for_exit()
|
||||||
|
|
||||||
|
|
||||||
|
def testShowSystray(app):
|
||||||
|
opts = ["--test-options=fake-systray", "--show-systray"]
|
||||||
|
app.open(use_uri=False,
|
||||||
|
extra_opts=opts,
|
||||||
|
window_name="vmm-fake-systray")
|
||||||
|
app.sleep(1)
|
||||||
|
app.stop()
|
||||||
|
|
||||||
|
app.open(uri="test:///default",
|
||||||
|
extra_opts=opts,
|
||||||
|
window_name="vmm-fake-systray")
|
||||||
|
|
||||||
|
|
||||||
def testShowRemoteDBusConnect(app):
|
def testShowRemoteDBusConnect(app):
|
||||||
"""
|
"""
|
||||||
Test the remote app dbus connection
|
Test the remote app dbus connection
|
||||||
|
@ -64,8 +64,6 @@ class vmmEngine(vmmGObject):
|
|||||||
|
|
||||||
self._exiting = False
|
self._exiting = False
|
||||||
|
|
||||||
self.systray_instance = None
|
|
||||||
|
|
||||||
self._window_count = 0
|
self._window_count = 0
|
||||||
self._gtkapplication = None
|
self._gtkapplication = None
|
||||||
self._init_gtk_application()
|
self._init_gtk_application()
|
||||||
@ -98,7 +96,7 @@ class vmmEngine(vmmGObject):
|
|||||||
"""
|
"""
|
||||||
Actual startup routines if we are running a new instance of the app
|
Actual startup routines if we are running a new instance of the app
|
||||||
"""
|
"""
|
||||||
self.systray_instance = vmmSystray.get_instance()
|
vmmSystray.get_instance()
|
||||||
vmmInspection.get_instance()
|
vmmInspection.get_instance()
|
||||||
|
|
||||||
self.add_gsettings_handle(
|
self.add_gsettings_handle(
|
||||||
@ -335,6 +333,30 @@ class vmmEngine(vmmGObject):
|
|||||||
"""
|
"""
|
||||||
return vmmSystray.get_instance().is_embedded()
|
return vmmSystray.get_instance().is_embedded()
|
||||||
|
|
||||||
|
def _show_systray_from_cli(self):
|
||||||
|
"""
|
||||||
|
Handler for --show-systray from CLI.
|
||||||
|
We force show the systray, and wait for a timeout to report if
|
||||||
|
its embedded. If not we raise an error and exit the app
|
||||||
|
"""
|
||||||
|
vmmSystray.get_instance().show_from_cli()
|
||||||
|
|
||||||
|
@_show_startup_error
|
||||||
|
def check(self, count):
|
||||||
|
count -= 1
|
||||||
|
if self._systray_is_embedded():
|
||||||
|
log.debug("systray embedded")
|
||||||
|
return
|
||||||
|
if count <= 0: # pragma: no cover
|
||||||
|
raise RuntimeError("systray did not show up")
|
||||||
|
self.timeout_add(1000, check, self, count) # pragma: no cover
|
||||||
|
|
||||||
|
startcount = 5
|
||||||
|
timeout = 1000
|
||||||
|
if self.config.CLITestOptions.fake_systray:
|
||||||
|
timeout = 1
|
||||||
|
self.timeout_add(timeout, check, self, startcount)
|
||||||
|
|
||||||
def _can_exit(self):
|
def _can_exit(self):
|
||||||
return (self._window_count <= 0 and not
|
return (self._window_count <= 0 and not
|
||||||
self._systray_is_embedded())
|
self._systray_is_embedded())
|
||||||
@ -445,8 +467,8 @@ class vmmEngine(vmmGObject):
|
|||||||
self.CLI_SHOW_DOMAIN_DELETE]):
|
self.CLI_SHOW_DOMAIN_DELETE]):
|
||||||
self._cli_show_vm_helper(uri, clistr, show_window)
|
self._cli_show_vm_helper(uri, clistr, show_window)
|
||||||
elif show_window == self.CLI_SHOW_SYSTEM_TRAY:
|
elif show_window == self.CLI_SHOW_SYSTEM_TRAY:
|
||||||
log.debug("Showing in the system tray")
|
# Handled elsewhere
|
||||||
self.systray_instance._show_systray()
|
pass
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
raise RuntimeError("Unknown cli window command '%s'" %
|
raise RuntimeError("Unknown cli window command '%s'" %
|
||||||
show_window)
|
show_window)
|
||||||
@ -466,12 +488,13 @@ class vmmEngine(vmmGObject):
|
|||||||
|
|
||||||
log.debug("processing cli command uri=%s show_window=%s domain=%s",
|
log.debug("processing cli command uri=%s show_window=%s domain=%s",
|
||||||
uri, show_window, domain)
|
uri, show_window, domain)
|
||||||
if not uri:
|
|
||||||
if show_window == self.CLI_SHOW_SYSTEM_TRAY:
|
|
||||||
log.debug("Launching in the system tray without --connect")
|
|
||||||
self.systray_instance._show_systray()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
if show_window == self.CLI_SHOW_SYSTEM_TRAY:
|
||||||
|
log.debug("Launching only in the system tray")
|
||||||
|
self._show_systray_from_cli()
|
||||||
|
if not uri:
|
||||||
|
return
|
||||||
|
elif not uri:
|
||||||
log.debug("No cli action requested, launching default window")
|
log.debug("No cli action requested, launching default window")
|
||||||
self._get_manager().show()
|
self._get_manager().show()
|
||||||
return
|
return
|
||||||
|
@ -434,6 +434,9 @@ class vmmSystray(vmmGObject):
|
|||||||
def is_embedded(self):
|
def is_embedded(self):
|
||||||
return self._systray and self._systray.is_embedded()
|
return self._systray and self._systray.is_embedded()
|
||||||
|
|
||||||
|
def show_from_cli(self):
|
||||||
|
self._show_systray()
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
self._hide_systray()
|
self._hide_systray()
|
||||||
self._systray = None
|
self._systray = None
|
||||||
|
@ -156,7 +156,7 @@ def parse_commandline():
|
|||||||
parser.add_argument("--show-host-summary", action="store_true",
|
parser.add_argument("--show-host-summary", action="store_true",
|
||||||
help="Show connection details window")
|
help="Show connection details window")
|
||||||
parser.add_argument("--show-systray", action="store_true",
|
parser.add_argument("--show-systray", action="store_true",
|
||||||
help="Launch virt-manager in system tray")
|
help="Launch virt-manager only in system tray")
|
||||||
|
|
||||||
return parser.parse_known_args()
|
return parser.parse_known_args()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user