[gnome-games] ui: Make (Developer|Platform)ListItem inherit from SidebarListItem



commit 18f21ea307ada780ed1d6cfa20939c290932a480
Author: Yetizone <andreii lisita gmail com>
Date:   Tue Jan 1 14:47:19 2019 +0200

    ui: Make (Developer|Platform)ListItem inherit from SidebarListItem

 data/org.gnome.Games.gresource.xml |  2 --
 data/ui/developer-list-item.ui     | 14 --------------
 data/ui/platform-list-item.ui      | 14 --------------
 src/ui/developer-list-item.vala    | 12 +++++++-----
 src/ui/platform-list-item.vala     | 12 +++++++-----
 5 files changed, 14 insertions(+), 40 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 52bd409c..789498a1 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -15,7 +15,6 @@
     <file preprocess="xml-stripblanks">ui/collection-box.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-header-bar.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-icon-view.ui</file>
-    <file preprocess="xml-stripblanks">ui/developer-list-item.ui</file>
     <file preprocess="xml-stripblanks">ui/display-box.ui</file>
     <file preprocess="xml-stripblanks">ui/display-header-bar.ui</file>
     <file preprocess="xml-stripblanks">ui/dummy-display.ui</file>
@@ -31,7 +30,6 @@
     <file preprocess="xml-stripblanks">ui/keyboard-tester.ui</file>
     <file preprocess="xml-stripblanks">ui/media-menu-button.ui</file>
     <file preprocess="xml-stripblanks">ui/media-selector.ui</file>
-    <file preprocess="xml-stripblanks">ui/platform-list-item.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-controllers.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins.ui</file>
diff --git a/src/ui/developer-list-item.vala b/src/ui/developer-list-item.vala
index 23871e8b..236dcac0 100644
--- a/src/ui/developer-list-item.vala
+++ b/src/ui/developer-list-item.vala
@@ -1,8 +1,4 @@
-[GtkTemplate (ui = "/org/gnome/Games/ui/developer-list-item.ui")]
-private class Games.DeveloperListItem: Gtk.ListBoxRow {
-       [GtkChild]
-       private Gtk.Label label;
-
+private class Games.DeveloperListItem: Games.SidebarListItem {
        private Developer _developer;
        public Developer developer {
                get { return _developer; }
@@ -17,6 +13,12 @@ private class Games.DeveloperListItem: Gtk.ListBoxRow {
                Object (developer: developer);
        }
 
+       public override bool has_game (Game game) {
+               string game_developer = game.get_developer ().get_developer ();
+
+               return (game_developer == developer.get_developer ());
+       }
+
        private void update_label () {
                var val = developer.get_developer ();
                label.label = val == "" ? _("Unknown") : val;
diff --git a/src/ui/platform-list-item.vala b/src/ui/platform-list-item.vala
index 98ce6f48..4aeb8753 100644
--- a/src/ui/platform-list-item.vala
+++ b/src/ui/platform-list-item.vala
@@ -1,8 +1,4 @@
-[GtkTemplate (ui = "/org/gnome/Games/ui/platform-list-item.ui")]
-private class Games.PlatformListItem: Gtk.ListBoxRow {
-       [GtkChild]
-       private Gtk.Label label;
-
+private class Games.PlatformListItem: Games.SidebarListItem {
        private Platform _platform;
        public Platform platform {
                get { return _platform; }
@@ -16,6 +12,12 @@ private class Games.PlatformListItem: Gtk.ListBoxRow {
                Object (platform : platform);
        }
 
+       public override bool has_game (Game game) {
+               string game_platform = game.get_platform ().get_name ();
+
+               return (game_platform == platform.get_name ());
+       }
+
        public static int compare (PlatformListItem a, PlatformListItem b) {
                return a.platform.get_name ().collate (b.platform.get_name ());
        }


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