emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5bab113: Add `xwidget-webkit-estimated-load-progress'


From: Po Lu
Subject: master 5bab113: Add `xwidget-webkit-estimated-load-progress'
Date: Fri, 19 Nov 2021 04:51:21 -0500 (EST)

branch: master
commit 5bab11348602b7f5281d3dd76cc7f93f48b18696
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Add `xwidget-webkit-estimated-load-progress'
    
    * doc/lispref/display.texi (Xwidgets): Document new function.
    * etc/NEWS: Announce new function.
    
    * src/xwidget.c (Fxwidget_webkit_estimated_load_progress): New
    function.
    (syms_of_xwidget): Define new subr.
---
 doc/lispref/display.texi |  8 ++++++++
 etc/NEWS                 |  5 +++++
 src/xwidget.c            | 24 ++++++++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 8decff6..e9b5070 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -7004,6 +7004,14 @@ manually to reach a specific history item.  Instead, 
@var{idx} should
 be passed as an index to @code{xwidget-webkit-goto-history}.
 @end defun
 
+@defun xwidget-webkit-estimated-load-progress xwidget
+Return an estimate of how much data is remaining to be transferred
+before the page displayed by the WebKit widget @var{xwidget} is fully
+loaded.
+
+The value returned is a float ranging between 0.0 and 1.0.
+@end defun
+
 @node Buttons
 @section Buttons
 @cindex buttons in buffers
diff --git a/etc/NEWS b/etc/NEWS
index cee2844..ad31b23 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -864,6 +864,11 @@ This function is used to obtain the history of page-loads 
in a given
 WebKit xwidget.
 
 +++
+*** New function 'xwidget-webkit-estimated-load-progress'.
+This function is used to obtain the estimated progress of page loading
+in a given WebKit xwidget.
+
++++
 *** 'load-changed' xwidget events are now more detailed.
 In particular, they can now have different arguments based on the
 state of the WebKit widget.  'load-finished' is sent when a load has
diff --git a/src/xwidget.c b/src/xwidget.c
index e1bf40e..62b01b7 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -2555,6 +2555,29 @@ LIMIT is not specified or nil, it is treated as `50'.  
*/)
 
   return list3 (back, here, forward);
 }
+
+DEFUN ("xwidget-webkit-estimated-load-progress",
+       Fxwidget_webkit_estimated_load_progress, 
Sxwidget_webkit_estimated_load_progress,
+       1, 1, 0, doc: /* Get the estimated load progress of XWIDGET, a WebKit 
widget.
+Return a value ranging from 0.0 to 1.0, based on how close XWIDGET
+is to completely loading its page.  */)
+  (Lisp_Object xwidget)
+{
+  struct xwidget *xw;
+  WebKitWebView *webview;
+  double value;
+
+  CHECK_XWIDGET (xwidget);
+  xw = XXWIDGET (xwidget);
+  CHECK_WEBKIT_WIDGET (xw);
+
+  block_input ();
+  webview = WEBKIT_WEB_VIEW (xw->widget_osr);
+  value = webkit_web_view_get_estimated_load_progress (webview);
+  unblock_input ();
+
+  return make_float (value);
+}
 #endif
 
 void
@@ -2600,6 +2623,7 @@ syms_of_xwidget (void)
 #ifdef USE_GTK
   defsubr (&Sxwidget_webkit_load_html);
   defsubr (&Sxwidget_webkit_back_forward_list);
+  defsubr (&Sxwidget_webkit_estimated_load_progress);
 #endif
   defsubr (&Skill_xwidget);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]