[gnome-games/wip/exalm/uid] game: Make media set a property



commit ff28c06820e6adbff5a668a93e9e91a6ca0bf7a0
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Feb 21 22:04:06 2020 +0500

    game: Make media set a property

 plugins/playstation/src/playstation-game-factory.vala |  4 ++--
 src/core/game.vala                                    | 10 +---------
 src/database/database.vala                            | 10 +++++-----
 src/retro/retro-runner.vala                           |  2 +-
 4 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index dc739300..32960fba 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -134,7 +134,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                        return;
 
                var is_complete = true;
-               game.get_media_set ().foreach_media (media => {
+               game.media_set.foreach_media (media => {
                        is_complete &= (media.get_uris ().length != 0);
                });
 
@@ -163,7 +163,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
 
                var game = new Game (uid, uri, title, platform);
                game.set_cover (cover);
-               game.set_media_set (media_set);
+               game.media_set = media_set;
 
                return game;
        }
diff --git a/src/core/game.vala b/src/core/game.vala
index 81fe0c3a..fbc3fb32 100644
--- a/src/core/game.vala
+++ b/src/core/game.vala
@@ -23,11 +23,11 @@ public class Games.Game : Object {
        public string uid { get; private set; }
        public Uri uri { get; private set; }
        public Platform platform { get; private set; }
+       public MediaSet? media_set { get; set; }
 
        private Title game_title;
        private Icon game_icon;
        private Cover game_cover;
-       private MediaSet? media_set;
 
        public Game (string uid, Uri uri, Title title, Platform platform) {
                this.uid = uid;
@@ -58,14 +58,6 @@ public class Games.Game : Object {
                game_cover = cover;
        }
 
-       public MediaSet? get_media_set () {
-               return media_set;
-       }
-
-       public void set_media_set (MediaSet? media_set) {
-               this.media_set = media_set;
-       }
-
        public bool matches_search_terms (string[] search_terms) {
                if (search_terms.length != 0)
                        foreach (var term in search_terms)
diff --git a/src/database/database.vala b/src/database/database.vala
index 5554fb2d..f9449f6f 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -160,7 +160,7 @@ private class Games.Database : Object {
        }
 
        private string? serialize_media_set (Game game) {
-               var media_set = game.get_media_set ();
+               var media_set = game.media_set;
 
                if (media_set == null)
                        return null;
@@ -169,7 +169,7 @@ private class Games.Database : Object {
        }
 
        private string[] get_media_uris (Game game) {
-               var media_set = game.get_media_set ();
+               var media_set = game.media_set;
 
                if (media_set == null)
                        return {};
@@ -202,7 +202,7 @@ private class Games.Database : Object {
 
                // TODO transaction
 
-               if (game.get_media_set () != null)
+               if (game.media_set != null)
                        foreach (var media_uri in get_media_uris (game))
                                store_game_uri (uid, media_uri);
                else
@@ -246,7 +246,7 @@ private class Games.Database : Object {
                if (update_game_query.step () != Sqlite.DONE)
                        throw new DatabaseError.EXECUTION_FAILED ("Couldn't update game (%s, %s, %s)", uid, 
title, media_set);
 
-               if (game.get_media_set () != null)
+               if (game.media_set != null)
                        foreach (var media_uri in get_media_uris (game))
                                store_game_uri (uid, media_uri);
                else
@@ -323,7 +323,7 @@ private class Games.Database : Object {
                var game = new Game (uid, game_uri, game_title, game_platform);
 
                if (media_set != null)
-                       game.set_media_set (new MediaSet.parse (new Variant.parsed (media_set)));
+                       game.media_set = new MediaSet.parse (new Variant.parsed (media_set));
 
                return game;
        }
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 026bdc15..a1464df0 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -66,7 +66,7 @@ public class Games.RetroRunner : Object, Runner {
        private RetroRunner (Game game) {
                this.game = game;
 
-               _media_set = game.get_media_set ();
+               _media_set = game.media_set;
                if (media_set == null && game.uri != null) {
                        var media = new Media ();
                        media.add_uri (game.uri);


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