Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion qrexec/tools/qrexec_policy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this change? It means you can't accept a single match (after typing it in) with a single click anymore, you need two clicks. OpenQA found this out, but TBH I'm not sure if that's a common case.

@alimirjamali alimirjamali Jul 4, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this change?

That is something I found only after using the patch for a while. The default logic (matching from the start) does not require to show the popup for a single match if user has entered the entire string.

In our case, if user wants to search for disp1234 and user has currenty disp1234, dips5678 and disp90 running at the moment and user types 1, there will be no popup to select disp1234 from it if popup_single_match is set to False.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.s. Actually the GTK default matching algorithm is also insufficient if a popup is not shown. As it is case in-senstivie and Qube names are case-sensitive.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, ok.

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",
Expand Down