toolbox$ cat ./example.vala
#! /usr/bin/env -S vala --pkg libportal
void main() {
new Xdp.Portal().spawn.begin(".", {"true"}, null, null, null, NONE, null, null, null, () => {print("ok\n");});
new MainLoop().run();
}
toolbox$ ./example.vala
/tmp/example.vala.44UNS2.c: In function ‘_vala_main’:
/tmp/example.vala.44UNS2.c:67:40: warning: passing argument 3 of ‘xdp_portal_spawn’ from incompatible pointer type [-Wincompatible-pointer-types]
67 | xdp_portal_spawn (_tmp1_, ".", _tmp4_, NULL, NULL, (gint) 0, NULL, XDP_SPAWN_FLAG_NONE, NULL, NULL, NULL, ___lambda4__gasync_ready_callback, NULL);
| ^~~~~~
| |
| gchar ** {aka char **}
In file included from /usr/include/libportal/portal.h:37,
from /tmp/example.vala.44UNS2.c:4:
/usr/include/libportal/spawn.h:50:70: note: expected ‘const char * const*’ but argument is of type ‘gchar **’ {aka ‘char **’}
50 | const char * const *argv,
| ~~~~~~~~~~~~~~~~~~~~~~^~~~
(process:319024): GLib-CRITICAL **: 20:37:17.663: g_variant_builder_end: assertion 'valid_builder' failed
(process:319024): GLib-CRITICAL **: 20:37:17.663: g_variant_get_type: assertion 'value != NULL' failed
(process:319024): GLib-CRITICAL **: 20:37:17.663: g_variant_type_is_array: assertion 'g_variant_type_check (type)' failed
(process:319024): GLib-CRITICAL **: 20:37:17.663: g_variant_get_type_string: assertion 'value != NULL' failed
(process:319024): GLib-ERROR **: 20:37:17.663: g_variant_new: expected array GVariantBuilder but the built value has type '(null)'
toolbox$ gjs
gjs> new imports.gi.Xdp.Portal().spawn(".", ["echo", "123"], null, null, [], 0, [], [], null, () => console.log("ok"));
(gjs:319291): GLib-CRITICAL **: 20:39:54.697: g_variant_builder_end: assertion 'valid_builder' failed
(gjs:319291): GLib-CRITICAL **: 20:39:54.697: g_variant_get_type: assertion 'value != NULL' failed
(gjs:319291): GLib-CRITICAL **: 20:39:54.697: g_variant_type_is_array: assertion 'g_variant_type_check (type)' failed
(gjs:319291): GLib-CRITICAL **: 20:39:54.697: g_variant_get_type_string: assertion 'value != NULL' failed
(gjs:319291): GLib-ERROR **: 20:39:54.697: g_variant_new: expected array GVariantBuilder but the built value has type '(null)'
Переривання на точці зупину
toolbox$
examples in vala and javascript: