javascript - What is the correct way in GJS to define a GObject property for an Array? -


i see in gjs gobject overrides there definitions types correspond javascript types, how should define property standard array of strings? options have occurred me:

  • use type_object , glist, gjs map array when retrieve it?
  • use type_object , gvariant "as" type , unpack myself
  • use type_boxed , type_array, type_array comparable javascript's array type?

this not possible. subscribe https://bugzilla.gnome.org/show_bug.cgi?id=727787 notified when there progress on it.

i have used second option (gvariant type as) in past. glist option won't work, since gjs doesn't pay attention type of values stored in glist. third option i'm not sure about.

here's minimal example showing how use gvariant option:

const gobject = imports.gi.gobject; const glib = imports.gi.glib;  const myclass = gobject.registerclass({     properties: {         'prop': gobject.param_spec_variant('prop', 'prop', 'prop',             new glib.varianttype('as'), null,             gobject.paramflags.readable),     }, }, class myclass extends gobject.object {     prop() {         return new glib.variant('as', ['one', 'two']);     } });  print(new myclass().prop.deep_unpack()); 

(if you're not using new class syntax, still works in similar way old lang.class.)


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -