-
-
Notifications
You must be signed in to change notification settings - Fork 538
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] closing event working as documented #1180
Conversation
…nfirm_close is False
This merges the close_window and the on_destroy methods of the GTK glue to actually implement the bahavior that is presented in the documentation of the closing event.
This was actually already the behavior in the Cocoa and Windows implementations! |
As tagged in the title, this PR only fixes the GTK backend. Please anyone with either a Windows, a Mac, or a Linux with a working Qt backend test #1181 so I can mark it as ready :). |
Update closing event behavior to match GTK behavior in PR #1180
This is what I view as a complete fix for the closing event beahvior under GTK. I did a separate pull request from a smaller fix because I'm not sure this one is wanted: maybe the documentation is wrong and the code was right.
What this does is to actually run the
events.closing
handlers before the closing confirmation (ifconfirm_close
is set), as explained in the documentation (see issue #1178).It also simplifies the GTK code by merging the
close_window
andon_destroy
functions, in the spirit of how it is done in the Qt code.Maybe the new merged function should rather be called
on_window_close
to match other event handlers. But that's not really for me to decide :).As a bonus, it also looks up the value of the
confirm_close
property on the pywebview window at event time rather than initialization time, so that this can be dynamically changed (see the first comment of issue #1178).This new behavior should be backward compatible with the previous one except if some code exists that changed the value of the
confirm_close
property of their pywebview windows with no effect previously (but why would anyone do that?).However, this new behavior will differ on other backend as is, as I could only test it with GTK so that's the only one I changed in this PR. But note that changing this behavior for other backends as well should be very straightforward since they all have access to the pywebview window.