Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:bmwiedemann:reproducible:distribution:ring1
virt-manager
081-systray-Cleanups-and-improvements-for-show-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 081-systray-Cleanups-and-improvements-for-show-systray.patch of Package virt-manager
Subject: systray: Cleanups and improvements for --show-systray From: Cole Robinson crobinso@redhat.com Sun Mar 3 11:54:37 2024 -0500 Date: Sun Mar 3 14:18:04 2024 -0500: Git: a6b62a20b62ac86e0c40d18f188b312513bafdd9 - 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> diff --git a/man/virt-manager.rst b/man/virt-manager.rst index e06a0ecc..44316ab3 100644 --- a/man/virt-manager.rst +++ b/man/virt-manager.rst @@ -88,6 +88,7 @@ URI. ``--show-host-summary`` Display the host/connection details window. + 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: ``--show-systray`` - Launch virt-manager in system tray + Launch virt-manager only in system tray + BUGS ==== diff --git a/tests/uitests/test_cli.py b/tests/uitests/test_cli.py index e55ce396..e9f11db8 100644 --- a/tests/uitests/test_cli.py +++ b/tests/uitests/test_cli.py @@ -80,6 +80,19 @@ def testShowDelete(app): 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): """ Test the remote app dbus connection diff --git a/virtManager/engine.py b/virtManager/engine.py index e5aa3eb4..ebc020ab 100644 --- a/virtManager/engine.py +++ b/virtManager/engine.py @@ -64,8 +64,6 @@ class vmmEngine(vmmGObject): self._exiting = False - self.systray_instance = None - self._window_count = 0 self._gtkapplication = None self._init_gtk_application() @@ -98,7 +96,7 @@ class vmmEngine(vmmGObject): """ 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() self.add_gsettings_handle( @@ -335,6 +333,30 @@ class vmmEngine(vmmGObject): """ 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): return (self._window_count <= 0 and not self._systray_is_embedded()) @@ -445,8 +467,8 @@ class vmmEngine(vmmGObject): 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() + # Handled elsewhere + pass else: # pragma: no cover raise RuntimeError("Unknown cli window command '%s'" % show_window) @@ -466,12 +488,13 @@ 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 + 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") self._get_manager().show() return diff --git a/virtManager/systray.py b/virtManager/systray.py index cba06cc1..a3cef04a 100644 --- a/virtManager/systray.py +++ b/virtManager/systray.py @@ -434,6 +434,9 @@ class vmmSystray(vmmGObject): def is_embedded(self): return self._systray and self._systray.is_embedded() + def show_from_cli(self): + self._show_systray() + def _cleanup(self): self._hide_systray() self._systray = None diff --git a/virtManager/virtmanager.py b/virtManager/virtmanager.py index 418fd336..e25c7628 100644 --- a/virtManager/virtmanager.py +++ b/virtManager/virtmanager.py @@ -156,7 +156,7 @@ def parse_commandline(): parser.add_argument("--show-host-summary", action="store_true", help="Show connection details window") 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()
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor