Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions src/SearchView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,11 @@ public class Switchboard.SearchView : Granite.Bin {
return _query;
}
set {
Gtk.FilterChange filter_change = DIFFERENT;
if (value.has_prefix (query)) {
filter_change = MORE_STRICT;
}

_query = value;

alert_view.title = _("No Results for “%s”").printf (query);
alert_view.title = _("No Results for “%s”").printf (value);

filter_model.filter.changed (filter_change);
((Gtk.StringFilter) filter_model.filter).search = value;
listbox.invalidate_sort ();
listbox.select_row (null);
}
Expand All @@ -50,7 +45,13 @@ public class Switchboard.SearchView : Granite.Bin {
construct {
list_store = new ListStore (typeof (SearchRow));

filter_model = new Gtk.FilterListModel (list_store, new Gtk.CustomFilter (filter_func)) {
filter_model = new Gtk.FilterListModel (
list_store,
new Gtk.StringFilter (new Gtk.PropertyExpression (typeof (SearchRow), null, "last-item")) {
ignore_case = true,
match_mode = SUBSTRING
}
) {
incremental = true
};

Expand Down Expand Up @@ -88,19 +89,6 @@ public class Switchboard.SearchView : Granite.Bin {
listbox.get_row_at_y (0).activate ();
}

private bool filter_func (Object object) {
if (query == "" || query == null) {
return true;
}

bool valid = query.match_string (((SearchRow) object).last_item, true);
if (valid) {
((SearchRow) object).pattern = query;
}

return valid;
}

private int sort_func (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
var search_text = query.down ();
var row1_label = ((SearchRow) row1).last_item.down ();
Expand Down
Loading