[gjs/gnome-42] doc: Reflect support for constructor with GObject
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-42] doc: Reflect support for constructor with GObject
- Date: Thu, 21 Jul 2022 17:11:40 +0000 (UTC)
commit 32dcf800b515031b49793c65c6ba9717e1cd6607
Author: Sonny Piers <sonny fastmail net>
Date: Wed Jul 20 18:42:01 2022 +0200
doc: Reflect support for constructor with GObject
doc/Mapping.md | 11 +++++------
examples/glistmodel.js | 4 ++--
examples/gtk-application.js | 4 ++--
examples/gtk3-template.js | 4 ++--
examples/gtk4-template.js | 4 ++--
5 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/doc/Mapping.md b/doc/Mapping.md
index 48ff8f8f6..130145386 100644
--- a/doc/Mapping.md
+++ b/doc/Mapping.md
@@ -41,10 +41,9 @@ var MyLabel = GObject.registerClass({
Children: [ 'label-child' ], // Template children
InternalChildren: [ 'internal-box' ] // Template internal (private) children
}, class MyLabel extends Gtk.Label {
- // Currently GObjects use _init, not construct
- _init(params) {
+ constructor(params) {
// Chaining up
- super._init(params);
+ super(params);
}
});
```
@@ -168,8 +167,8 @@ var MyLabel = GObject.registerClass({
}
}
}, class ExampleApplication extends GObject.Object {
- _init() {
- super._init();
+ constructor() {
+ super();
this.emit('my-signal', 'a string parameter');
}
});
@@ -241,4 +240,4 @@ try {
} catch(e) {
log('Failed to read file: ' + e.message);
}
-```
\ No newline at end of file
+```
diff --git a/examples/glistmodel.js b/examples/glistmodel.js
index ab7ba4339..890b2d308 100644
--- a/examples/glistmodel.js
+++ b/examples/glistmodel.js
@@ -17,8 +17,8 @@ var GjsListStore = GObject.registerClass({
GTypeName: 'GjsListStore',
Implements: [Gio.ListModel],
}, class MyList extends GObject.Object {
- _init() {
- super._init();
+ constructor() {
+ super();
/* We'll use a native Array as internal storage for the list model */
this._items = [];
diff --git a/examples/gtk-application.js b/examples/gtk-application.js
index 2cc5b9569..bc45f41b1 100644
--- a/examples/gtk-application.js
+++ b/examples/gtk-application.js
@@ -28,8 +28,8 @@ var ExampleApplication = GObject.registerClass({
},
Signals: {'examplesig': {param_types: [GObject.TYPE_INT]}},
}, class ExampleApplication extends Gtk.Application {
- _init() {
- super._init({
+ constructor() {
+ super({
application_id: 'org.gnome.gjs.ExampleApplication',
flags: Gio.ApplicationFlags.FLAGS_NONE,
});
diff --git a/examples/gtk3-template.js b/examples/gtk3-template.js
index 0ba1dbf28..3ec64cb5b 100644
--- a/examples/gtk3-template.js
+++ b/examples/gtk3-template.js
@@ -29,8 +29,8 @@ const ExampleWindow = GObject.registerClass({
'button',
],
}, class ExampleWindow extends Gtk.Window {
- _init(params = {}) {
- super._init(params);
+ constructor(params = {}) {
+ super(params);
// The template has been initialized and you can access the children
this.box.visible = true;
diff --git a/examples/gtk4-template.js b/examples/gtk4-template.js
index ac274f104..de34c588e 100644
--- a/examples/gtk4-template.js
+++ b/examples/gtk4-template.js
@@ -29,8 +29,8 @@ const ExampleWindow = GObject.registerClass({
'button',
],
}, class ExampleWindow extends Gtk.Window {
- _init(params = {}) {
- super._init(params);
+ constructor(params = {}) {
+ super(params);
// The template has been initialized and you can access the children
this.box.visible = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]