Allow terminating page loading operations in webkit xwidgets

* doc/lispref/display.texi (Xwidgets): Document new function.
* etc/NEWS: Announce `xwidget-webkit-stop-loading'.
* src/xwidget.c (Fxwidget_webkit_stop_loading): New function.
(syms_of_xwidget): Define new subr.
This commit is contained in:
Po Lu 2021-11-20 18:23:02 +08:00
parent 2ba7d1e84e
commit fbf361f593
3 changed files with 36 additions and 0 deletions

View file

@ -7025,6 +7025,12 @@ If this function is not called at least once on @var{xwidget} or a
related widget, @var{xwidget} will not store cookies on disk at all.
@end defun
@defun xwidget-webkit-stop-loading xwidget
Terminate any data transfer still in progress in the WebKit widget
@var{xwidget} as part of a page-loading operation. If a page is not
being loaded, this function does nothing.
@end defun
@node Buttons
@section Buttons
@cindex buttons in buffers

View file

@ -873,6 +873,11 @@ WebKit xwidget.
This function is used to obtain the estimated progress of page loading
in a given WebKit xwidget.
+++
*** New function 'xwidget-webkit-stop-loading'.
This function is used to terminate all data transfer during page loads
in a given WebKit xwidget.
+++
*** 'load-changed' xwidget events are now more detailed.
In particular, they can now have different arguments based on the

View file

@ -2615,6 +2615,30 @@ store cookies in FILE and load them from there. */)
return Qnil;
}
DEFUN ("xwidget-webkit-stop-loading", Fxwidget_webkit_stop_loading,
Sxwidget_webkit_stop_loading,
1, 1, 0, doc: /* Stop loading data in the WebKit widget XWIDGET.
This will stop any data transfer that may still be in progress inside
XWIDGET as part of loading a page. */)
(Lisp_Object xwidget)
{
#ifdef USE_GTK
struct xwidget *xw;
WebKitWebView *webview;
CHECK_LIVE_XWIDGET (xwidget);
xw = XXWIDGET (xwidget);
CHECK_WEBKIT_WIDGET (xw);
block_input ();
webview = WEBKIT_WEB_VIEW (xw->widget_osr);
webkit_web_view_stop_loading (webview);
unblock_input ();
#endif
return Qnil;
}
void
syms_of_xwidget (void)
{
@ -2656,6 +2680,7 @@ syms_of_xwidget (void)
defsubr (&Sxwidget_webkit_previous_result);
defsubr (&Sset_xwidget_buffer);
defsubr (&Sxwidget_webkit_set_cookie_storage_file);
defsubr (&Sxwidget_webkit_stop_loading);
#ifdef USE_GTK
defsubr (&Sxwidget_webkit_load_html);
defsubr (&Sxwidget_webkit_back_forward_list);