soreaus menu: Revert to faster filter algorithm
This is a partial revert of 0b00a950, which changed the filter algorithm to be slower and yeild less results for the same strings.
This is a partial revert of 0b00a950, which changed the filter algorithm to be slower and yeild less results for the same strings.
by soreau, Wednesday, 20 August 2025, 19:17:17 (1755717437), pushed by roundabout, Wednesday, 20 August 2025, 19:57:25 (1755719845)
Author identity: Scott Moreau <oreaus@gmail.com>
b71a26d2ca643699969dc4f4423fa52581d41270
def on_search_changed(self, search_entry):
self.flowbox.remove_all()
self.populate_menu_entries()
text = self.search_entry.get_text()
for button in self.cached_buttons:
if (button.name and text in button.name) or \
(button.desc and text in button.desc) or \
(button.exe and text in button.exe):
self.flowbox.append(button)
def on_logout_button_clicked(self, button):
self.logout_ui.present()
self.popover.popdown()
def populate_menu_entries(self):
if self.search_entry.get_text():
desktop_names = Gio.DesktopAppInfo.search(self.search_entry.get_text().lower())
app_infos = []
for sublist in desktop_names:
for desktop_name in sublist:
try:
app_infos.append(Gio.DesktopAppInfo.new(desktop_name))
except TypeError:
# The constructor may return a C NULL if the file is unable to be launched,
# so skip the app
pass
else:
app_infos = Gio.AppInfo.get_all()
app_infos.sort(key=lambda app_info: app_info.get_display_name())
app_infos = Gio.AppInfo.get_all()
app_infos.sort(key=lambda app_info: app_info.get_display_name().lower())
self.cached_buttons = []
for app_info in app_infos:
app_categories = app_info.get_categories()
self.flowbox.append(app_button)
app_button.connect("clicked", self.app_button_clicked)
app_button_box.prepend(image)
self.cached_buttons.append(app_button)