... | @@ -49,19 +49,14 @@ label.disconnect(handlerId); |
... | @@ -49,19 +49,14 @@ label.disconnect(handlerId); |
|
|
|
|
|
## Enumerations and Flags
|
|
## Enumerations and Flags
|
|
|
|
|
|
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].
|
|
Both enumerations and flags appear as entries under the namespace, with associated member properties. These are available in the official GJS [Gnome API documentation][gjs-docs].
|
|
|
|
|
|
```js
|
|
```js
|
|
// enum GtkAlign
|
|
// enum GtkAlign, member GTK_ALIGN_CENTER
|
|
// member GTK_ALIGN_CENTER
|
|
|
|
Gtk.Align.CENTER;
|
|
Gtk.Align.CENTER;
|
|
|
|
// enum GtkWindowType, member GTK_WINDOW_TOPLEVEL
|
|
// enum GtkWindowType
|
|
|
|
// member GTK_WINDOW_TOPLEVEL
|
|
|
|
Gtk.WindowType.TOPLEVEL;
|
|
Gtk.WindowType.TOPLEVEL;
|
|
|
|
// enum GApplicationFlags, member G_APPLICATION_FLAGS_NONE
|
|
// enum GApplicationFlags
|
|
|
|
// member G_APPLICATION_FLAGS_NONE
|
|
|
|
Gio.ApplicationFlags.FLAGS_NONE
|
|
Gio.ApplicationFlags.FLAGS_NONE
|
|
```
|
|
```
|
|
|
|
|
... | @@ -81,16 +76,24 @@ Unions are currently opaque. |
... | @@ -81,16 +76,24 @@ Unions are currently opaque. |
|
|
|
|
|
## Multiple return values (caller-allocates)
|
|
## Multiple return values (caller-allocates)
|
|
|
|
|
|
|
|
In GJS caller-allocates (variables passed into a function) and functions with multiple out parameters are returned as an array of return values.
|
|
|
|
|
|
For functions which have multiple out parameters, the return values are gathered into an array. Example:
|
|
For functions which have multiple out parameters, the return values are gathered into an array. Example:
|
|
|
|
|
|
```js
|
|
```js
|
|
// Calling clutter_actor_get_size
|
|
let [minimumSize, naturalSize] = label.get_preferred_size();
|
|
let [x, y] = actor.get_size();
|
|
|
|
|
|
let file = new Gio.File({ path: '/proc/cpuinfo' });
|
|
|
|
let [ret, contents] = file.get_contents(null);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
log(contents);
|
|
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
If the function has a return value, in addition to the out parameters, the return value will be the first element of such array. Example:
|
|
If the function has a return value, in addition to the out parameters, the return value will be the first element of such array.
|
|
|
|
|
|
```js
|
|
```js
|
|
// Calling gtk_recent_info_get_application_info
|
|
let file = new Gio.File.new_for_path('/proc/cpuinfo');
|
|
let [success, appExec, count, time] = this._docInfo.get_application_info(appName);
|
|
let [ret, contents] = file.get_contents(null);
|
|
``` |
|
``` |
|
|
|
\ No newline at end of file |