-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gtk.Builder.connectSignals does not bind "this" to object #305
Comments
I reply to my own issue. I started out in GTK 4 and got it working.
|
For GTK3 vs GTK4: I'd suggest GTK4. For connectSignals: see https://github.com/romgrk/node-gtk/blob/master/examples/builder-auto-connect-signals.js Your issue seems resolved, I'll close but you can re-open if something is unclear. |
Your example uses GTK 3, however the GTK documentation clearly states that this function no longer exists: https://docs.gtk.org/gtk4/migrating-3to4.html Somehow, I have the feeling that there should be a language-specific implementation of Gtk.BuilderScope. Since Gtk.BuilderCScope is the C/C++ implementation, naming it Gtk.BuilderJSScope would make sense. |
First of all: I think you are into something great. IMHO, the entire Gnome Infrastructure could rely on node-gtk rather than on GJS, since GJS is an interpreter on its own and hence introduces useless hassle.
From the very early days when I learnt JS, I trained the habit of using classes rather than plain functions or objects. When programming a web application and connecting an event listener to the click event of a button, I use something like this:
button_go.addEventListener("click", this.button_go_click.bind(this))
Note the bind at the end. In this way, the variable "this" points to the object within the event handler.
I expected something like this when using Gtk.Builder.connectSignals() too, but unfortunately, "this" seems to refer to the static function context.
Just to outline what I mean, here is a rough sketch:
On the other hand: Is it viable in the year 2021 to start writing a GTK 3 app and porting it in a few years, or should I start out with GTK 4 immediately?
The text was updated successfully, but these errors were encountered: