[seahorse] search-provider: Simplify search filter
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] search-provider: Simplify search filter
- Date: Sat, 21 May 2022 14:29:26 +0000 (UTC)
commit 641a103ed36c5a9eb6d3da4bad698ac25cf3bb63
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sat May 21 16:24:55 2022 +0200
search-provider: Simplify search filter
Don't use `Seahorse.Predicate` (and actually, as it's the last usage,
remove it altogether) to filter out search provider terms, as the
conversion from/to `string[]` and `void*` is giving unexpected results.
To fix it, just use the filter function directly.
Fixes: https://gitlab.gnome.org/GNOME/seahorse/-/issues/338
common/meson.build | 1 -
common/predicate.vala | 70 ------------------------------------------------
src/search-provider.vala | 18 +++----------
3 files changed, 4 insertions(+), 85 deletions(-)
---
diff --git a/common/meson.build b/common/meson.build
index f19898fb..47a41175 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -18,7 +18,6 @@ common_sources = files(
'passphrase-prompt.vala',
'pgp-settings.vala',
'place.vala',
- 'predicate.vala',
'prefs.vala',
'registry.vala',
'server-category.vala',
diff --git a/src/search-provider.vala b/src/search-provider.vala
index aa4f705f..6873f191 100644
--- a/src/search-provider.vala
+++ b/src/search-provider.vala
@@ -112,14 +112,9 @@ public class Seahorse.SearchProvider : GLib.Object {
if (get_n_loading() >= 0)
yield load();
- Predicate predicate = Predicate () {
- custom = object_matches_search,
- custom_target = terms
- };
-
string?[] results = {};
foreach (unowned GLib.Object obj in this.collection.get_objects()) {
- if (predicate.match(obj)) {
+ if (object_matches_search(obj, terms)) {
string str = "%p".printf(obj);
if (!(str in this.handles)) {
@@ -138,18 +133,13 @@ public class Seahorse.SearchProvider : GLib.Object {
throws GLib.Error {
this.app.hold ();
- Predicate predicate = Predicate() {
- custom = object_matches_search,
- custom_target = new_terms
- };
-
string?[] results = {};
foreach (string previous_result in previous_results) {
unowned GLib.Object? object = this.handles.lookup(previous_result);
if (object == null || !this.collection.contains(object))
continue; // Bogus value
- if (predicate.match(object))
+ if (object_matches_search(object, new_terms))
results += previous_result;
}
@@ -213,7 +203,7 @@ public class Seahorse.SearchProvider : GLib.Object {
// TODO
}
- private static bool object_matches_search (GLib.Object? object, void* terms) {
+ private bool object_matches_search (GLib.Object? object, string[] terms) {
foreach (unowned string term in ((string[]) terms)) {
if (!object_contains_filtered_text (object, term))
return false;
@@ -223,7 +213,7 @@ public class Seahorse.SearchProvider : GLib.Object {
}
/* Search through row for text */
- private static bool object_contains_filtered_text (GLib.Object object, string? text) {
+ private bool object_contains_filtered_text (GLib.Object object, string? text) {
string? name = null;
object.get("label", out name, null);
if (name != null && (text in name.down()))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]