GNOME Bugzilla – Bug 595387
x.set_property
Last modified: 2021-05-25 17:32:16 UTC
I across some gstreamer code i wanted to port to seed and i found that example.set_property() doesn't work. The same code on gjs works as expected.
ping ?
If you have a little chunk of example code, I can take a peek.
Example code, this works with gjs (adapted of course). Gtk = imports.gi.Gtk; Gst = imports.gi.Gst; GLib = imports.gi.GLib; Gtk.init(Seed.argv); Gst.init(Seed.argv); url = Seed.argv[2]; var pipeline = new Gst.Pipeline({name: "AudioTest"}); var player = Gst.ElementFactory.make("playbin2", "player"); //player.set_property("uri", "file:///home/metalgod/Projects/javascript/audio.mp3") player.set_property("uri", url) pipeline.add(player); pipeline.set_state(Gst.State.PLAYING); Gtk.main();
Going through the code, Gobject methods are not natively exposed via introspection, but set/get properties are implemented by the JS getter/setter calls hence: player.set_property("uri", url) is written as player.uri = url; It appears to work OK internally, g_object_set_property appears to return success..
needs changing to NOTABUG - I do not have privalliges to do this.. ;)
I think we should keep this one open, i don't think "the seed-way" to do this is correct. Yes indeed .set_property works fine like x.set_property("something", whatever) as x.something = whatever But it's too much confusing and it gets away from GTK+ and bindings (even gjs itself which do it on the right way). I would like to ear more opinions on this before closing the bug.
As I am not involved as a developer of the project, it is not my place to say what direction it will take but I have to ask is it wise to deviate from the Gnome bindings as the reference manuals and code derived from it are the primary sources of documentation to be used when coding JS stuff? While Alan's solution does work, I think this buf should be kept open until x.set_property function is fixed.
This is solution for one word properties. But what about properties in WebKit.WebSettings, where words are separated by dash like "default-font-size"? This gives syntax error: settings = new WebKit.WebSettings(); settings.default-font-size = 10; By replacing dashes with underscores doesn't seem to work either.
http://devel.akbkhome.com/seed/WebKit.WebSettings.html Convert dashes to underscore. use settings.default_font_size = 10;
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new enhancement request ticket at https://gitlab.gnome.org/GNOME/seed/-/issues/ Thank you for your understanding and your help.