appGenericName, appComment and appExec to the fuzzysearch function

This commit is contained in:
Jesper 2024-06-12 12:19:05 +02:00
parent 2e0f503d08
commit a31731f127

View File

@ -763,6 +763,8 @@ class pluginclass(object):
return value
def fuzzy_application_search(self, search_text):
shownList = []
keywords = self.strip_case_and_accents(search_text).split()
labels = [app["button"].appName for app in self.applicationList]
results = process.extract(search_text, labels, limit=len(labels))
@ -776,7 +778,22 @@ class pluginclass(object):
if first_button is True:
app["button"].grab_focus()
first_button = False
# TODO: Add appGenericName, appComment and appExec
shownList.append(app["button"])
# Non-fuzzy results for appGenericName, appComment and appExec
# Again I should really make it a function or something
for app in self.applicationList:
for item in shownList:
if app["button"].desktopFile == item.desktopFile:
continue
for keyword in keywords:
if keyword != "" and (self.strip_case_and_accents(app["button"].appGenericName).find(keyword) != -1 or self.strip_case_and_accents(app["button"].appComment).find(keyword) != -1 or self.strip_case_and_accents(app["button"].appExec).find(keyword) != -1):
self.applicationsBox.pack_start(app["button"], False, False, 0)
if first_button is True:
app["button"].grab_focus()
first_button = False
shownList.append(app["button"])
def exact_application_search(self, search_text):
shownList = []
@ -795,6 +812,7 @@ class pluginclass(object):
app["button"].grab_focus()
first_button = False
shownList.append(app["button"])
# Add applications that match appGenericName, appComment or appExec
for app in self.applicationList:
for item in shownList: