search for effects

i'll keep this and if the owner wants it i'll submit a PR.
but i really did this to see if i could.
This commit is contained in:
Justin Garza
2024-10-27 11:31:07 -04:00
parent 6f9b56a69a
commit 2e54d0002b
24 changed files with 240 additions and 23 deletions
+24
View File
@@ -189,6 +189,28 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
});
});
this._searchEntry = this._builder.get_object("search_entry")
this._searchEntry.connect('search-changed', () => {
const query = this._searchEntry.get_text().toLowerCase();
this._effectRows.forEach(er => {
if (query === "") {
er.show(); // Show all effects if query is empty
} else {
// Show or hide each effect based on query match
const showEffect = er.name.toLowerCase().includes(query);
showEffect ? er.show() : er.hide();
//TODO
//maybe add a fuzzy search later
/*
const showEffect = utils.fuzzyMatch(er.name.toLowerCase(), query.toLowerCase());
showEffect ? er.show() : er.hide();
*/
}
});
});
// Then add a preferences group for the effect expander rows.
const group = this._builder.get_object('effects-group');
@@ -250,6 +272,8 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
row.set_title(effect.getLabel());
}
row.name = effect.getLabel() + effect?.description !== undefined ? effect?.description : "" ;
// Un-expand any previously expanded effect row. This way we ensure that there
// is only one expanded row at any time.
if (hasPrefs) {