mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Added more to Properties section
This commit is contained in:
parent
fe5001ca96
commit
f560802e77
@ -313,13 +313,27 @@ class Animal : GLib.Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int eyes { get; set; default = 5; } // Shorter way
|
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();
|
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.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.legs += 2;
|
rabbit.legs += 2;
|
||||||
rabbit.eyes = 2;
|
rabbit.eyes = 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
* More Vala documentation can be found [here](https://valadoc.org/).
|
* More Vala documentation can be found [here](https://valadoc.org/).
|
||||||
* Read about building GUIs with GTK+ and Vala [here](http://archive.is/7C7bw).
|
* Read about building GUIs with GTK+ and Vala [here](http://archive.is/7C7bw).
|
||||||
|
Loading…
Reference in New Issue
Block a user