From f560802e77202d249c024678308ee422480df0cb Mon Sep 17 00:00:00 2001 From: Milo Gilad Date: Fri, 25 Aug 2017 13:03:09 -0400 Subject: Added more to Properties section --- vala.html.markdown | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'vala.html.markdown') diff --git a/vala.html.markdown b/vala.html.markdown index f0141eb4..b87e16e6 100755 --- a/vala.html.markdown +++ b/vala.html.markdown @@ -313,12 +313,26 @@ class Animal : GLib.Object { } public int eyes { get; set; default = 5; } // Shorter way -} + public int kingdom { get; private set; default = "Animalia"} // Read-only + + public static void main(string args[]) { + rabbit = new Animal(); + + // All GLib.Objects have a signal "notify" emitted when a property changes. + + // If you specify a specific property, replace all underscores with dashes + // to conform with the GObject naming convention. -rabbit = new Animal(); -rabbit.legs = 2; -rabbit.legs += 2; -rabbit.eyes = 2; + rabbit.notify["eyes"].connect((s, p) => { // Remove the ["eyes"] for all + stdout.printf("Property '%s' has changed!\n", p.name); + }); + + rabbit.legs = 2; + rabbit.legs += 2; + rabbit.eyes = 2; + + } +} ``` * More Vala documentation can be found [here](https://valadoc.org/). -- cgit v1.2.3