[gnome-games] game: Add matches_search_terms()



commit 76407e9705677d4cc8df055cdf678bae6c5cde9e
Author: Yetizone <andreii lisita gmail com>
Date:   Mon Dec 31 12:49:40 2018 +0200

    game: Add matches_search_terms()
    
    The sidebar-view will also need the search logic and this method is added
    to avoid having to duplicate the search logic in the sidebar-view and in the
    collection-icon-view

 src/core/game.vala | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/core/game.vala b/src/core/game.vala
index 7a981a6f..66745528 100644
--- a/src/core/game.vala
+++ b/src/core/game.vala
@@ -17,6 +17,15 @@ public interface Games.Game : Object {
        public abstract Platform get_platform ();
        public abstract Runner get_runner () throws Error;
 
+       public bool matches_search_terms (string[] search_terms) {
+               if (search_terms.length != 0)
+                       foreach (var term in search_terms)
+                               if (!(term.casefold () in name.casefold ()))
+                                       return false;
+
+               return true;
+       }
+
        public static uint hash (Game key) {
                var uid = "";
                try {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]