From 4201a3a727ebdf140f3c6c1287f5efce1852ac3a Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Sun, 1 Dec 2024 01:31:25 -0500 Subject: [PATCH] Allow selecting test mode with command-line argument Useful for local development. --- qubes_menu/appmenu.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/qubes_menu/appmenu.py b/qubes_menu/appmenu.py index 0d1af02..b67cadb 100644 --- a/qubes_menu/appmenu.py +++ b/qubes_menu/appmenu.py @@ -117,6 +117,15 @@ def __init__(self, qapp, dispatcher): self.appmenu_position: str = 'mouse' def _add_cli_options(self): + self.add_main_option( + "mock-qubes", + ord("m"), + GLib.OptionFlags.NONE, + GLib.OptionArg.NONE, + "Use fake Qubes object (FOR TESTING AND DEBUGGING ONLY)", + None, + ) + self.add_main_option( "keep-visible", ord("k"), @@ -168,6 +177,18 @@ def parse_options(self, options: Dict[str, Any]): self.initial_page = PAGE_LIST[int(options["page"])] if "background" in options: self.start_in_background = True + if "mock-qubes" in options: + from qubesadmin.tests.mock_app import MockQubesComplete, MockDispatcher, MockQube + self.qapp = MockQubesComplete() + + self.qapp._qubes['test-vm2'] = MockQube(name="test-vm2", qapp=self.qapp, + features={'menu-favorites': ''}) + self.qapp._qubes['dom0'].features['menu-initial-page'] = 'favorites_page' + self.qapp._qubes['dom0'].features['menu-sort-running'] = '1' + self.qapp._qubes['dom0'].features['menu-position'] = 'top-left' + self.qapp.update_vm_calls() + + self.dispatcher = MockDispatcher(self.qapp) @staticmethod def _do_power_button(_widget):