🎉 Add effect search
This commit is contained in:
@@ -178,6 +178,29 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
|
||||
});
|
||||
});
|
||||
|
||||
// search for effect feature
|
||||
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');
|
||||
|
||||
@@ -239,6 +262,10 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
|
||||
row.set_title(effect.getLabel());
|
||||
}
|
||||
|
||||
// this is the fix for the merge issue when an effect doesn't have a discription
|
||||
row.name = effect.getLabel();
|
||||
|
||||
|
||||
// Un-expand any previously expanded effect row. This way we ensure that there
|
||||
// is only one expanded row at any time.
|
||||
if (hasPrefs) {
|
||||
|
||||
+112
-20
@@ -214,39 +214,131 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</child>
|
||||
</object>
|
||||
|
||||
|
||||
<object class="AdwPreferencesPage" id="general-prefs">
|
||||
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup" id="effects-group">
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="margin-start">20</property>
|
||||
<property name="margin-end">20</property>
|
||||
<property name="title" translatable="yes">Effect Selection</property>
|
||||
<property name="description" translatable="yes">If multiple are selected, one is chosen randomly.</property>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<!--these are extra title and description that is not needed-->
|
||||
<!-- <property name="title" translatable="yes">Effect Selection</property> -->
|
||||
<!-- <property name="description" translatable="yes">If multiple are selected, one is chosen randomly.</property> -->
|
||||
|
||||
<child type="header-suffix">
|
||||
<object class="GtkBox">
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="linked" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkGrid" id="selection-controls">
|
||||
<property name="row-spacing">5</property>
|
||||
<property name="column-spacing">5</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="choose-all-effects-button">
|
||||
<property name="label" translatable="yes">All</property>
|
||||
<object class="AdwPreferencesGroup" id="header-text">
|
||||
<property name="title" translatable="yes">Effect Selection</property>
|
||||
<property name="description" translatable="yes">If multiple are selected, one is chosen randomly.</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
<property name="column-span">8</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="choose-no-effects-button">
|
||||
<property name="label" translatable="yes">None</property>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Search Entry -->
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="placeholder-text" translatable="yes">Search...</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
<property name="column-span">8</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
<!-- maybe later add a way to only show enabled|disabled|both -->
|
||||
|
||||
<!-- <child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="homogeneous">true</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
<property name="column-span">3</property>
|
||||
</layout>
|
||||
|
||||
<style>
|
||||
<class name="linked" />
|
||||
</style>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="show-enabled-effects-button">
|
||||
<property name="label" translatable="yes">Show Enabled</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="show-disabled-effects-button">
|
||||
<property name="label" translatable="yes">Show Disable</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="show-all-effects-button">
|
||||
<property name="label" translatable="yes">Show All</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child> -->
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="homogeneous">true</property>
|
||||
<layout>
|
||||
<property name="column">8</property>
|
||||
<property name="row">1</property>
|
||||
<property name="column-span">2</property>
|
||||
</layout>
|
||||
|
||||
<style>
|
||||
<class name="linked" />
|
||||
</style>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="choose-all-effects-button">
|
||||
<property name="label" translatable="yes">Enable All</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="choose-no-effects-button">
|
||||
<property name="label" translatable="yes">Disable All</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup" id="effects-group">
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="margin-start">0</property>
|
||||
<property name="margin-end">0</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
|
||||
|
||||
|
||||
</interface>
|
||||
Reference in New Issue
Block a user