[gnome-games/wip/exalm/cache2: 36/45] rating: Add 'has-loaded' property and remove changed()



commit 6eec14eea8b9c522da046cc435320add8502a791
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Oct 2 18:56:38 2018 +0500

    rating: Add 'has-loaded' property and remove changed()

 src/core/rating.vala            | 2 +-
 src/dummy/dummy-rating.vala     | 2 ++
 src/generic/generic-rating.vala | 6 ++++++
 src/grilo/grilo-rating.vala     | 9 ++++-----
 4 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/core/rating.vala b/src/core/rating.vala
index 88313378..b2bc2f23 100644
--- a/src/core/rating.vala
+++ b/src/core/rating.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public interface Games.Rating : Object {
-       public signal void changed ();
+       public abstract bool has_loaded { get; protected set; }
 
        public abstract float get_rating ();
 }
diff --git a/src/dummy/dummy-rating.vala b/src/dummy/dummy-rating.vala
index 216bd42c..9d53c77f 100644
--- a/src/dummy/dummy-rating.vala
+++ b/src/dummy/dummy-rating.vala
@@ -1,6 +1,8 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public class Games.DummyRating : Object, Rating {
+       public bool has_loaded { get; protected set; }
+
        public float get_rating () {
                return 0;
        }
diff --git a/src/generic/generic-rating.vala b/src/generic/generic-rating.vala
index 315240c8..62d8d0aa 100644
--- a/src/generic/generic-rating.vala
+++ b/src/generic/generic-rating.vala
@@ -3,6 +3,12 @@
 public class Games.GenericRating : Object, Rating {
        private float rating;
 
+       public bool has_loaded { get; protected set; }
+
+       construct {
+               has_loaded = true;
+       }
+
        public GenericRating (float rating) {
                this.rating = rating;
        }
diff --git a/src/grilo/grilo-rating.vala b/src/grilo/grilo-rating.vala
index 508d7dc1..4a3a6741 100644
--- a/src/grilo/grilo-rating.vala
+++ b/src/grilo/grilo-rating.vala
@@ -4,7 +4,8 @@ public class Games.GriloRating : Object, Rating {
        private GriloMedia media;
        private float rating;
        private bool resolving;
-       private bool resolved;
+
+       public bool has_loaded { get; protected set; }
 
        public GriloRating (GriloMedia media) {
                this.media = media;
@@ -13,7 +14,7 @@ public class Games.GriloRating : Object, Rating {
        }
 
        public float get_rating () {
-               if (resolving || resolved)
+               if (resolving || has_loaded)
                        return rating;
 
                resolving = true;
@@ -33,8 +34,6 @@ public class Games.GriloRating : Object, Rating {
 
                rating = grl_media.get_rating ();
 
-               resolved = true;
-
-               changed ();
+               has_loaded = true;
        }
 }


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