summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2020-03-11 22:17:51 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2020-04-19 11:12:12 -0700
commit962471c5d5c4d9a650dabef1c421f4e0c0f9c176 (patch)
treea04021b00101751a679e9428c8727b942048cd23 /examples
parenta147866bca54e8b752142c9c8bd66bcf46fe2688 (diff)
downloadgjs-962471c5d5c4d9a650dabef1c421f4e0c0f9c176.tar.gz
GObject: Allow omitting setters and getters
In the case where you don't need anything special from your GObject property getters and setters, just correct handling of notify signals and default values, it's now possible to leave out the getters and setters, and GJS will just do the right thing. This is convenient for JS code authors as well as avoiding problems caused by missing getters and setters. This only works for read-write properties. If a read-only or write-only property is missing its accessor, then one is generated which throws. If the property name consists of multiple words, then accessors will be generated for all three variants: kebab-case, snake_case, and camelCase. Additionally, if you do provide accessors for one of these, then they will be copied to the other two variants. See: #306
Diffstat (limited to 'examples')
-rw-r--r--examples/gtk-application.js17
1 files changed, 1 insertions, 16 deletions
diff --git a/examples/gtk-application.js b/examples/gtk-application.js
index 483a5ea5..514b8bdd 100644
--- a/examples/gtk-application.js
+++ b/examples/gtk-application.js
@@ -20,7 +20,7 @@ var ExampleApplication = GObject.registerClass({
'ExampleProperty', // nickname
'An example read write property', // description
GObject.ParamFlags.READWRITE, // read/write/construct...
- '', // implement defaults manually
+ 'a default value',
),
},
Signals: {'examplesig': {param_types: [GObject.TYPE_INT]}},
@@ -32,21 +32,6 @@ var ExampleApplication = GObject.registerClass({
});
}
- // Example property getter/setter
- get exampleprop() {
- if (typeof this._exampleprop === 'undefined')
- return 'a default value';
-
- return this._exampleprop;
- }
-
- set exampleprop(value) {
- this._exampleprop = value;
-
- // notify() has to be called, if you want it
- this.notify('exampleprop');
- }
-
// Example signal emission
emitExamplesig(number) {
this.emit('examplesig', number);