From 0589ae8a242b3be6a1b8985c6eb8900e5236152a Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Mon, 1 Jul 2024 12:25:35 +0330 Subject: [PATCH] Support substring matching in qube name text fields fixes: https://github.com/QubesOS/qubes-issues/issues/8583 --- qrexec/tools/qrexec_policy_agent.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/qrexec/tools/qrexec_policy_agent.py b/qrexec/tools/qrexec_policy_agent.py index fb92a423..0d8b724e 100644 --- a/qrexec/tools/qrexec_policy_agent.py +++ b/qrexec/tools/qrexec_policy_agent.py @@ -184,11 +184,22 @@ def apply_model( completion.set_inline_selection(True) completion.set_inline_completion(True) completion.set_popup_completion(True) - completion.set_popup_single_match(False) + completion.set_popup_single_match(True) completion.set_model(list_store) completion.set_text_column(1) entry_box.set_completion(completion) + + def qube_matching_function(completion: Gtk.EntryCompletion, + key: str, + iterator: Gtk.TreeIter, + user_data: object) -> bool: + # pylint: disable=unused-argument + modelstr = completion.get_model()[iterator][1] + return key.lower() in modelstr.lower() + + completion.set_match_func(qube_matching_function, None) + if activation_trigger: entry_box.connect( "activate",