diff options
| author | Po Lu | 2021-11-10 21:01:40 +0800 |
|---|---|---|
| committer | Po Lu | 2021-11-11 08:31:09 +0800 |
| commit | 3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb (patch) | |
| tree | 31f34c5934124d0ddb85caaf44245e000eef9848 /src | |
| parent | d3ccf0895dbb18ac04e1e2e0c6624af43d467c1b (diff) | |
| download | emacs-3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb.tar.gz emacs-3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb.zip | |
Add `xwidget-webkit-load-html'
* doc/lispref/display.texi (Xwidgets): Document new function.
* etc/NEWS: Announce new function.
* src/xwidget.c (Fxwidget_webkit_load_html): New function.
(syms_of_xwidget): Define new subr.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xwidget.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/xwidget.c b/src/xwidget.c index 2ae635092d6..fc05f4f5709 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -2278,6 +2278,44 @@ using `xwidget-webkit-search'. */) | |||
| 2278 | return Qnil; | 2278 | return Qnil; |
| 2279 | } | 2279 | } |
| 2280 | 2280 | ||
| 2281 | #ifdef USE_GTK | ||
| 2282 | DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html, | ||
| 2283 | Sxwidget_webkit_load_html, 2, 3, 0, | ||
| 2284 | doc: /* Make XWIDGET's WebKit widget render TEXT. | ||
| 2285 | XWIDGET should be a WebKit xwidget, that will receive TEXT. TEXT | ||
| 2286 | should be a string that will be displayed by XWIDGET as HTML markup. | ||
| 2287 | BASE_URI should be a string containing a URI that is used to locate | ||
| 2288 | resources with relative URLs, and if not specified, defaults | ||
| 2289 | to "about:blank". */) | ||
| 2290 | (Lisp_Object xwidget, Lisp_Object text, Lisp_Object base_uri) | ||
| 2291 | { | ||
| 2292 | struct xwidget *xw; | ||
| 2293 | WebKitWebView *webview; | ||
| 2294 | char *data, *uri; | ||
| 2295 | |||
| 2296 | CHECK_XWIDGET (xwidget); | ||
| 2297 | CHECK_STRING (text); | ||
| 2298 | if (NILP (base_uri)) | ||
| 2299 | base_uri = build_string ("about:blank"); | ||
| 2300 | else | ||
| 2301 | CHECK_STRING (base_uri); | ||
| 2302 | |||
| 2303 | base_uri = ENCODE_UTF_8 (base_uri); | ||
| 2304 | text = ENCODE_UTF_8 (text); | ||
| 2305 | xw = XXWIDGET (xwidget); | ||
| 2306 | |||
| 2307 | data = SSDATA (text); | ||
| 2308 | uri = SSDATA (base_uri); | ||
| 2309 | webview = WEBKIT_WEB_VIEW (xw->widget_osr); | ||
| 2310 | |||
| 2311 | block_input (); | ||
| 2312 | webkit_web_view_load_html (webview, data, uri); | ||
| 2313 | unblock_input (); | ||
| 2314 | |||
| 2315 | return Qnil; | ||
| 2316 | } | ||
| 2317 | #endif | ||
| 2318 | |||
| 2281 | void | 2319 | void |
| 2282 | syms_of_xwidget (void) | 2320 | syms_of_xwidget (void) |
| 2283 | { | 2321 | { |
| @@ -2316,6 +2354,9 @@ syms_of_xwidget (void) | |||
| 2316 | defsubr (&Sxwidget_webkit_next_result); | 2354 | defsubr (&Sxwidget_webkit_next_result); |
| 2317 | defsubr (&Sxwidget_webkit_previous_result); | 2355 | defsubr (&Sxwidget_webkit_previous_result); |
| 2318 | defsubr (&Sset_xwidget_buffer); | 2356 | defsubr (&Sset_xwidget_buffer); |
| 2357 | #ifdef USE_GTK | ||
| 2358 | defsubr (&Sxwidget_webkit_load_html); | ||
| 2359 | #endif | ||
| 2319 | 2360 | ||
| 2320 | DEFSYM (QCxwidget, ":xwidget"); | 2361 | DEFSYM (QCxwidget, ":xwidget"); |
| 2321 | DEFSYM (QCtitle, ":title"); | 2362 | DEFSYM (QCtitle, ":title"); |