... | @@ -28,16 +28,16 @@ if (label.halign === Gtk.Align.CENTER) { |
... | @@ -28,16 +28,16 @@ if (label.halign === Gtk.Align.CENTER) { |
|
|
|
|
|
### Signals
|
|
### Signals
|
|
|
|
|
|
Every object inherited from GObject has `connect()`, `disconnect()` and `emit()` methods. Example:
|
|
Every object inherited from GObject has `connect()`, `disconnect()` and `emit()` methods.
|
|
|
|
|
|
```js
|
|
```js
|
|
let handlerId = label.connect('activate-link', (label, uri) => {
|
|
let handlerId = label.connect('activate-link', (label, uri) => {
|
|
Gtk.show_uri_on_window(
|
|
Gtk.show_uri_on_window(
|
|
this.get_top_level(),
|
|
label.get_top_level(),
|
|
uri,
|
|
uri,
|
|
Gdk.get_current_time()
|
|
Gdk.get_current_time()
|
|
);
|
|
);
|
|
return false;
|
|
return true;
|
|
});
|
|
});
|
|
|
|
|
|
label.emit('activate-link', 'https://www.gnome.org');
|
|
label.emit('activate-link', 'https://www.gnome.org');
|
... | @@ -49,12 +49,24 @@ label.disconnect(handlerId); |
... | @@ -49,12 +49,24 @@ label.disconnect(handlerId); |
|
|
|
|
|
## Enumerations and Flags
|
|
## Enumerations and Flags
|
|
|
|
|
|
Both enumerations and flags appear as entries under the namespace, with associated member properties. Example:
|
|
Both enumerations and flags appear as entries under the namespace, with associated member properties. These are defined in the official GJS [Gnome API documentation][gjs-docs].
|
|
|
|
|
|
```js
|
|
```js
|
|
|
|
// enum GtkAlign
|
|
|
|
// member GTK_ALIGN_CENTER
|
|
|
|
Gtk.Align.CENTER;
|
|
|
|
|
|
|
|
// enum GtkWindowType
|
|
|
|
// member GTK_WINDOW_TOPLEVEL
|
|
Gtk.WindowType.TOPLEVEL;
|
|
Gtk.WindowType.TOPLEVEL;
|
|
|
|
|
|
|
|
// enum GApplicationFlags
|
|
|
|
// member G_APPLICATION_FLAGS_NONE
|
|
|
|
Gio.ApplicationFlags.FLAGS_NONE
|
|
```
|
|
```
|
|
|
|
|
|
|
|
[gjs-docs]: http://devdocs.baznga.org/
|
|
|
|
|
|
## Structures
|
|
## Structures
|
|
|
|
|
|
C structures have JavaScript properties for each member. Generally you should treat these as read-only.
|
|
C structures have JavaScript properties for each member. Generally you should treat these as read-only.
|
... | | ... | |