[gnome-games] sidebar-view: Add filter_game()



commit 18e13f5bd4228affe26f5332419ad89b40d2570d
Author: Yetizone <andreii lisita gmail com>
Date:   Tue Dec 18 16:06:42 2018 +0200

    sidebar-view: Add filter_game()

 src/ui/developers-view.vala | 12 ++++++++++++
 src/ui/platforms-view.vala  | 10 ++++++++++
 src/ui/sidebar-view.vala    |  1 +
 3 files changed, 23 insertions(+)
---
diff --git a/src/ui/developers-view.vala b/src/ui/developers-view.vala
index 0cce1477..a93da398 100644
--- a/src/ui/developers-view.vala
+++ b/src/ui/developers-view.vala
@@ -5,6 +5,7 @@ private class Games.DevelopersView : SidebarView {
        // and can't be stored in a GenericSet without breaking.
        private List<Developer> shown_developers;
        private List<Developer> all_developers;
+       private Developer selected_developer;
 
        construct {
                shown_developers = new List<Developer> ();
@@ -69,6 +70,7 @@ private class Games.DevelopersView : SidebarView {
        protected override void invalidate (Gtk.ListBoxRow row_item) {
                var row = row_item as DeveloperListItem;
                var developer = row.developer;
+               selected_developer = developer;
                collection_view.filtering_developer = developer;
        }
 
@@ -78,4 +80,14 @@ private class Games.DevelopersView : SidebarView {
 
                return DeveloperListItem.compare (item1, item2);
        }
+
+       protected override bool filter_game (Game game) {
+               string game_developer = game.get_developer ().get_developer ();
+
+               if (selected_developer != null &&
+                   selected_developer.get_developer () != game_developer)
+                       return false;
+
+               return true;
+       }
 }
diff --git a/src/ui/platforms-view.vala b/src/ui/platforms-view.vala
index ba071fc8..0b4833c2 100644
--- a/src/ui/platforms-view.vala
+++ b/src/ui/platforms-view.vala
@@ -2,6 +2,7 @@
 
 private class Games.PlatformsView : SidebarView {
        private GenericSet<Platform> platforms = new GenericSet<Platform> (Platform.hash, Platform.equal);
+       private Platform selected_platform;
 
        protected override void game_added (Game game) {
                var platform = game.get_platform ();
@@ -16,6 +17,7 @@ private class Games.PlatformsView : SidebarView {
        protected override void invalidate (Gtk.ListBoxRow row_item) {
                var row = row_item as PlatformListItem;
                var platform = row.platform;
+               selected_platform = platform;
                collection_view.filtering_platform = platform;
        }
 
@@ -25,4 +27,12 @@ private class Games.PlatformsView : SidebarView {
 
                return PlatformListItem.compare (item1, item2);
        }
+
+       protected override bool filter_game (Game game) {
+               if (selected_platform != null &&
+                   selected_platform.get_name () != game.get_platform ().get_name ())
+                       return false;
+
+               return true;
+       }
 }
diff --git a/src/ui/sidebar-view.vala b/src/ui/sidebar-view.vala
index f3f5996e..6dab5360 100644
--- a/src/ui/sidebar-view.vala
+++ b/src/ui/sidebar-view.vala
@@ -161,6 +161,7 @@ private abstract class Games.SidebarView : Gtk.Box {
        protected abstract void game_added (Game game);
        protected abstract void invalidate (Gtk.ListBoxRow row_item);
        protected abstract int sort_rows (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2);
+       protected abstract bool filter_game (Game game);
 
        [GtkCallback]
        private void on_list_box_row_selected (Gtk.ListBoxRow? row_item) {


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