[libgnome-games-support] Prefer GObject-style construction
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnome-games-support] Prefer GObject-style construction
- Date: Mon, 5 Feb 2018 04:35:28 +0000 (UTC)
commit b42a2515acf70dc865908d9ef29c4a1af00e166e
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Feb 4 17:07:58 2018 -0600
Prefer GObject-style construction
games/gridframe.vala | 2 +-
games/scores/category.vala | 3 +--
games/scores/score.vala | 19 ++++++++++++++-----
3 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/games/gridframe.vala b/games/gridframe.vala
index 14c0a93..1580bcf 100644
--- a/games/gridframe.vala
+++ b/games/gridframe.vala
@@ -114,7 +114,7 @@ public class GridFrame : Gtk.Bin
public GridFrame (int width, int height)
{
- @set (width, height);
+ Object (width: width, height: height);
}
public new void @set (int width, int height)
diff --git a/games/scores/category.vala b/games/scores/category.vala
index 4fb0ff6..328b8ee 100644
--- a/games/scores/category.vala
+++ b/games/scores/category.vala
@@ -45,8 +45,7 @@ public class Category : Object
public Category (string key, string name)
{
- this.key = key;
- this.name = name;
+ Object (key: key, name: name);
}
}
diff --git a/games/scores/score.vala b/games/scores/score.vala
index 692e43a..9dfa269 100644
--- a/games/scores/score.vala
+++ b/games/scores/score.vala
@@ -24,18 +24,27 @@ namespace Scores {
public class Score : Object
{
public long score { get; set; }
- public string user { get; set; }
/* Although the scores dialog does not currently display the time a
* score was achieved, it did in the past and it might again in the future.
*/
- public int64 time { get; set; }
+ private int64 _time;
+ public int64 time
+ {
+ get { return _time; }
+ set { _time = (value == 0 ? new DateTime.now_local ().to_unix () : value); }
+ }
+
+ private string _user;
+ public string user
+ {
+ get { return _user; }
+ set { _user = (value == null ? Environment.get_real_name () : user); }
+ }
public Score (long score, int64 time = 0, string? user = null)
{
- this.score = score;
- this.time = (time == 0 ? new DateTime.now_local ().to_unix () : time);
- this.user = (user == null ? Environment.get_real_name () : user);
+ Object (score: score, time: time, user: user);
}
public static bool equals (Score a, Score b)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]