cli: add --show-systray option

This commit is contained in:
Gustavo Costa
2021-11-03 21:45:04 -03:00
committed by Cole Robinson
parent 014d1ef99b
commit 69290e0526
2 changed files with 21 additions and 4 deletions

View File

@@ -47,6 +47,7 @@ class vmmEngine(vmmGObject):
CLI_SHOW_DOMAIN_CONSOLE = "console"
CLI_SHOW_DOMAIN_DELETE = "delete"
CLI_SHOW_HOST_SUMMARY = "summary"
CLI_SHOW_SYSTEM_TRAY = "systray"
@classmethod
def get_instance(cls):
@@ -63,6 +64,8 @@ class vmmEngine(vmmGObject):
self._exiting = False
self.systray_instance = None
self._window_count = 0
self._gtkapplication = None
self._init_gtk_application()
@@ -95,7 +98,7 @@ class vmmEngine(vmmGObject):
"""
Actual startup routines if we are running a new instance of the app
"""
vmmSystray.get_instance()
self.systray_instance = vmmSystray.get_instance()
vmmInspection.get_instance()
self.add_gsettings_handle(
@@ -441,6 +444,9 @@ class vmmEngine(vmmGObject):
self.CLI_SHOW_DOMAIN_CONSOLE,
self.CLI_SHOW_DOMAIN_DELETE]):
self._cli_show_vm_helper(uri, clistr, show_window)
elif show_window == self.CLI_SHOW_SYSTEM_TRAY:
log.debug("Showing in the system tray")
self.systray_instance._show_systray()
else: # pragma: no cover
raise RuntimeError("Unknown cli window command '%s'" %
show_window)
@@ -461,6 +467,11 @@ class vmmEngine(vmmGObject):
log.debug("processing cli command uri=%s show_window=%s domain=%s",
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
log.debug("No cli action requested, launching default window")
self._get_manager().show()
return