-
-
Notifications
You must be signed in to change notification settings - Fork 52
Introduce a SearchBar #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6597cd3
Introduce a SearchBar
leolost2605 152aa06
dump granite dep
danirabbit 54b15ed
Merge main
danirabbit e4bbd09
Add search placeholder, reset search when empty
danirabbit e67e406
Update music.metainfo.xml.in
danirabbit f5de99c
Merge branch 'main' into leolost/search-bar
danirabbit 09c44db
Merge branch 'main' into leolost/search-bar
ryonakano 4b9945f
Add to POTFILES
danirabbit a4520c6
Address review comments
danirabbit 1c50ff0
Merge branch 'main' into leolost/search-bar
danirabbit 06479a7
Update placeholder with search changed, not filter
danirabbit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * SPDX-License-Identifier: LGPL-3.0-or-later | ||
| * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) | ||
| */ | ||
|
|
||
| public class Music.SearchBar : Granite.Bin { | ||
| public signal void activated (); | ||
|
|
||
| public ListModel list_model { get; construct; } | ||
|
|
||
| public Gtk.SearchEntry search_entry { get; private set; } | ||
|
|
||
| /** | ||
| * The new model with the search applied. Make sure to use this one in further UI | ||
| * instead of the old given model. | ||
| */ | ||
| public Gtk.FilterListModel filter_model { get; private set; } | ||
|
|
||
| private Gtk.StringFilter filter; | ||
|
|
||
| public SearchBar (ListModel list_model) { | ||
| Object (list_model: list_model); | ||
| } | ||
|
|
||
| construct { | ||
| var expression = new Gtk.PropertyExpression (typeof (AudioObject), null, "title"); | ||
|
|
||
| filter = new Gtk.StringFilter (expression) { | ||
| ignore_case = true, | ||
| match_mode = SUBSTRING | ||
| }; | ||
|
|
||
| filter_model = new Gtk.FilterListModel (list_model, filter); | ||
|
|
||
| search_entry = new Gtk.SearchEntry () { | ||
| placeholder_text = _("Search titles in playlist") | ||
danirabbit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| child = search_entry; | ||
|
|
||
| search_entry.search_changed.connect (on_search_changed); | ||
| search_entry.activate.connect (() => activated ()); | ||
| } | ||
|
|
||
| private void on_search_changed () { | ||
| filter.search = search_entry.text; | ||
| } | ||
|
|
||
| public void start_search () { | ||
| search_entry.grab_focus (); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.