webkit6/auto/web_view.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::{
7 AuthenticationRequest, AutomationBrowsingContextPresentation, BackForwardList,
8 BackForwardListItem, ColorChooserRequest, ContextMenu, Download, EditorState,
9 FileChooserRequest, FindController, FormSubmissionRequest, HitTestResult, InputMethodContext,
10 InsecureContentEvent, LoadEvent, MediaCaptureState, NavigationAction, NetworkSession,
11 Notification, OptionMenu, PermissionRequest, PermissionStateQuery, PolicyDecision,
12 PolicyDecisionType, PrintOperation, SaveMode, ScriptDialog, Settings, SnapshotOptions,
13 SnapshotRegion, URIRequest, UserContentManager, UserMessage, WebContext, WebExtensionMode,
14 WebInspector, WebProcessTerminationReason, WebResource, WebViewBase, WebViewSessionState,
15 WebsitePolicies, WindowProperties, ffi,
16};
17use glib::{
18 object::ObjectType as _,
19 prelude::*,
20 signal::{SignalHandlerId, connect_raw},
21 translate::*,
22};
23use std::{boxed::Box as Box_, pin::Pin};
24
25glib::wrapper! {
26 /// The central class of the WPE WebKit and WebKitGTK APIs.
27 ///
28 /// [`WebView`][crate::WebView] is the central class of the WPE WebKit and WebKitGTK
29 /// APIs. It is responsible for managing the drawing of the content and
30 /// forwarding of events. You can load any URI into the [`WebView`][crate::WebView] or
31 /// a data string. With [`Settings`][crate::Settings] you can control various aspects
32 /// of the rendering and loading of the content.
33 ///
34 /// Note that in WebKitGTK, [`WebView`][crate::WebView] is scrollable by itself, so
35 /// you don't need to embed it in a `GtkScrolledWindow`.
36 ///
37 /// ## Properties
38 ///
39 ///
40 /// #### `automation-presentation-type`
41 /// The [`AutomationBrowsingContextPresentation`][crate::AutomationBrowsingContextPresentation] of [`WebView`][crate::WebView]. This should only be used when
42 /// creating a new [`WebView`][crate::WebView] as a response to [`create-web-view`][struct@crate::AutomationSession#create-web-view]
43 /// signal request. If the new WebView was added to a new tab of current browsing context window
44 /// [`AutomationBrowsingContextPresentation::Tab`][crate::AutomationBrowsingContextPresentation::Tab] should be used.
45 ///
46 /// Readable | Writeable | Construct Only
47 ///
48 ///
49 /// #### `camera-capture-state`
50 /// Capture state of the camera device. Whenever the user grants a media-request sent by the web
51 /// page, requesting video capture capabilities (`navigator.mediaDevices.getUserMedia({video:
52 /// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
53 ///
54 /// The application can monitor this property and provide a visual indicator allowing to optionally
55 /// deactivate or mute the capture device by setting this property respectively to
56 /// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
57 ///
58 /// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
59 /// can still re-request the permission to the user. Permission desision caching is left to the
60 /// application.
61 ///
62 /// Readable | Writeable
63 ///
64 ///
65 /// #### `default-content-security-policy`
66 /// The default Content-Security-Policy used by the webview as if it were set
67 /// by an HTTP header.
68 ///
69 /// This applies to all content loaded including through navigation or via the various
70 /// webkit_web_view_load_\* APIs. However do note that many WebKit APIs bypass
71 /// Content-Security-Policy in general such as [`UserContentManager`][crate::UserContentManager] and
72 /// `webkit_web_view_run_javascript()`.
73 ///
74 /// Policies are additive so if a website sets its own policy it still applies
75 /// on top of the policy set here.
76 ///
77 /// Readable | Writeable | Construct Only
78 ///
79 ///
80 /// #### `display-capture-state`
81 /// Capture state of the display device. Whenever the user grants a media-request sent by the web
82 /// page, requesting screencasting capabilities (`navigator.mediaDevices.getDisplayMedia() this
83 /// property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
84 ///
85 /// The application can monitor this property and provide a visual indicator allowing to
86 /// optionally deactivate or mute the capture device by setting this property respectively to
87 /// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
88 ///
89 /// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
90 /// can still re-request the permission to the user. Permission desision caching is left to the
91 /// application.
92 ///
93 /// Readable | Writeable
94 ///
95 ///
96 /// #### `editable`
97 /// Whether the pages loaded inside [`WebView`][crate::WebView] are editable. For more
98 /// information see [`WebViewExt::set_editable()`][crate::prelude::WebViewExt::set_editable()].
99 ///
100 /// Readable | Writeable
101 ///
102 ///
103 /// #### `estimated-load-progress`
104 /// An estimate of the percent completion for the current loading operation.
105 /// This value will range from 0.0 to 1.0 and, once a load completes,
106 /// will remain at 1.0 until a new load starts, at which point it
107 /// will be reset to 0.0.
108 /// The value is an estimate based on the total number of bytes expected
109 /// to be received for a document, including all its possible subresources
110 /// and child documents.
111 ///
112 /// Readable
113 ///
114 ///
115 /// #### `favicon`
116 /// The favicon currently associated to the [`WebView`][crate::WebView].
117 /// See [`WebViewExt::favicon()`][crate::prelude::WebViewExt::favicon()] for more details.
118 ///
119 /// Readable
120 ///
121 ///
122 /// #### `is-controlled-by-automation`
123 /// Whether the [`WebView`][crate::WebView] is controlled by automation tools (e.g. WebDriver, Selenium). This is
124 /// required for views returned as a response to [`create-web-view`][struct@crate::AutomationSession#create-web-view] signal,
125 /// alongside any view you want to control during an automation session.
126 ///
127 /// As a `G_PARAM_CONSTRUCT_ONLY`, you need to set it during construction and it can't be modified.
128 ///
129 /// If [`related-view`][struct@crate::WebView#related-view] is also passed during construction, [`is-controlled-by-automation`][struct@crate::WebView#is-controlled-by-automation]
130 /// ignores its own parameter and inherits directly from the related view [`is-controlled-by-automation`][struct@crate::WebView#is-controlled-by-automation]
131 /// property. This is the recommended way when creating new views as a response to the [`create`][struct@crate::WebView#create]
132 /// signal. For example, as response to JavaScript ``window.open()`` calls during an automation session.
133 ///
134 /// Readable | Writeable | Construct Only
135 ///
136 ///
137 /// #### `is-immersive-mode-enabled`
138 /// Whether the [`WebView`][crate::WebView] is in immersive mode.
139 ///
140 /// Readable
141 ///
142 ///
143 /// #### `is-loading`
144 /// Whether the [`WebView`][crate::WebView] is currently loading a page. This property becomes
145 /// [`true`] as soon as a new load operation is requested and before the
146 /// [`load-changed`][struct@crate::WebView#load-changed] signal is emitted with [`LoadEvent::Started`][crate::LoadEvent::Started] and
147 /// at that point the active URI is the requested one.
148 /// When the load operation finishes the property is set to [`false`] before
149 /// [`load-changed`][struct@crate::WebView#load-changed] is emitted with [`LoadEvent::Finished`][crate::LoadEvent::Finished].
150 ///
151 /// Readable
152 ///
153 ///
154 /// #### `is-muted`
155 /// Whether the [`WebView`][crate::WebView] audio is muted. When [`true`], audio is silenced.
156 /// It may still be playing, i.e. [`is-playing-audio`][struct@crate::WebView#is-playing-audio] may be [`true`].
157 ///
158 /// Readable | Writeable
159 ///
160 ///
161 /// #### `is-playing-audio`
162 /// Whether the [`WebView`][crate::WebView] is currently playing audio from a page.
163 /// This property becomes [`true`] as soon as web content starts playing any
164 /// kind of audio. When a page is no longer playing any kind of sound,
165 /// the property is set back to [`false`].
166 ///
167 /// Readable
168 ///
169 ///
170 /// #### `is-web-process-responsive`
171 /// Whether the web process currently associated to the [`WebView`][crate::WebView] is responsive.
172 ///
173 /// Readable
174 ///
175 ///
176 /// #### `microphone-capture-state`
177 /// Capture state of the microphone device. Whenever the user grants a media-request sent by the web
178 /// page, requesting audio capture capabilities (`navigator.mediaDevices.getUserMedia({audio:
179 /// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
180 ///
181 /// The application can monitor this property and provide a visual indicator allowing to
182 /// optionally deactivate or mute the capture device by setting this property respectively to
183 /// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
184 ///
185 /// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
186 /// can still re-request the permission to the user. Permission desision caching is left to the
187 /// application.
188 ///
189 /// Readable | Writeable
190 ///
191 ///
192 /// #### `network-session`
193 /// The [`NetworkSession`][crate::NetworkSession] of the view
194 ///
195 /// Readable | Writeable | Construct Only
196 ///
197 ///
198 /// #### `page-id`
199 /// The identifier of the `WebKitWebPage` corresponding to the [`WebView`][crate::WebView].
200 ///
201 /// Readable
202 ///
203 ///
204 /// #### `related-view`
205 /// The related [`WebView`][crate::WebView] used when creating the view to share the
206 /// same web process and network session. This property is not readable
207 /// because the related web view is only valid during the object construction.
208 ///
209 /// Writeable | Construct Only
210 ///
211 ///
212 /// #### `settings`
213 /// The [`Settings`][crate::Settings] of the view.
214 ///
215 /// Writeable | Construct
216 ///
217 ///
218 /// #### `theme-color`
219 /// The theme color of the WebView's current page.
220 ///
221 /// Readable
222 ///
223 ///
224 /// #### `title`
225 /// The main frame document title of this [`WebView`][crate::WebView]. If
226 /// the title has not been received yet, it will be [`None`].
227 ///
228 /// Readable
229 ///
230 ///
231 /// #### `uri`
232 /// The current active URI of the [`WebView`][crate::WebView].
233 /// See [`WebViewExt::uri()`][crate::prelude::WebViewExt::uri()] for more details.
234 ///
235 /// Readable
236 ///
237 ///
238 /// #### `user-content-manager`
239 /// The [`UserContentManager`][crate::UserContentManager] of the view.
240 ///
241 /// Readable | Writeable | Construct Only
242 ///
243 ///
244 /// #### `web-context`
245 /// The [`WebContext`][crate::WebContext] of the view.
246 ///
247 /// Readable | Writeable | Construct Only
248 ///
249 ///
250 /// #### `web-extension-mode`
251 /// This configures `web_view` to treat the content as a WebExtension.
252 ///
253 /// Note that this refers to the web standard [WebExtensions](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions)
254 /// and not WebKitWebExtensions.
255 ///
256 /// In practice this limits the Content-Security-Policies that are allowed to be set. Some details can be found in
257 /// [Chrome's documentation](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/`content`-security-policy).
258 ///
259 /// Readable | Writeable | Construct Only
260 ///
261 ///
262 /// #### `website-policies`
263 /// The [`WebsitePolicies`][crate::WebsitePolicies] for the view.
264 ///
265 /// Readable | Writeable | Construct Only
266 ///
267 ///
268 /// #### `zoom-level`
269 /// The zoom level of the [`WebView`][crate::WebView] content.
270 /// See [`WebViewExt::set_zoom_level()`][crate::prelude::WebViewExt::set_zoom_level()] for more details.
271 ///
272 /// Readable | Writeable
273 /// <details><summary><h4>Widget</h4></summary>
274 ///
275 ///
276 /// #### `can-focus`
277 /// Whether the widget or any of its descendents can accept
278 /// the input focus.
279 ///
280 /// This property is meant to be set by widget implementations,
281 /// typically in their instance init function.
282 ///
283 /// Readable | Writeable
284 ///
285 ///
286 /// #### `can-target`
287 /// Whether the widget can receive pointer events.
288 ///
289 /// Readable | Writeable
290 ///
291 ///
292 /// #### `css-classes`
293 /// A list of css classes applied to this widget.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `css-name`
299 /// The name of this widget in the CSS tree.
300 ///
301 /// This property is meant to be set by widget implementations,
302 /// typically in their instance init function.
303 ///
304 /// Readable | Writeable | Construct Only
305 ///
306 ///
307 /// #### `cursor`
308 /// The cursor used by `widget`.
309 ///
310 /// Readable | Writeable
311 ///
312 ///
313 /// #### `focus-on-click`
314 /// Whether the widget should grab focus when it is clicked with the mouse.
315 ///
316 /// This property is only relevant for widgets that can take focus.
317 ///
318 /// Readable | Writeable
319 ///
320 ///
321 /// #### `focusable`
322 /// Whether this widget itself will accept the input focus.
323 ///
324 /// Readable | Writeable
325 ///
326 ///
327 /// #### `halign`
328 /// How to distribute horizontal space if widget gets extra space.
329 ///
330 /// Readable | Writeable
331 ///
332 ///
333 /// #### `has-default`
334 /// Whether the widget is the default widget.
335 ///
336 /// Readable
337 ///
338 ///
339 /// #### `has-focus`
340 /// Whether the widget has the input focus.
341 ///
342 /// Readable
343 ///
344 ///
345 /// #### `has-tooltip`
346 /// Enables or disables the emission of the [signal`Gtk`::query-tooltip]
347 /// signal on `widget`.
348 ///
349 /// A true value indicates that `widget` can have a tooltip, in this case
350 /// the widget will be queried using [signal`Gtk`::query-tooltip] to
351 /// determine whether it will provide a tooltip or not.
352 ///
353 /// Readable | Writeable
354 ///
355 ///
356 /// #### `height-request`
357 /// Overrides for height request of the widget.
358 ///
359 /// If this is -1, the natural request will be used.
360 ///
361 /// Readable | Writeable
362 ///
363 ///
364 /// #### `hexpand`
365 /// Whether to expand horizontally.
366 ///
367 /// Readable | Writeable
368 ///
369 ///
370 /// #### `hexpand-set`
371 /// Whether to use the `hexpand` property.
372 ///
373 /// Readable | Writeable
374 ///
375 ///
376 /// #### `layout-manager`
377 /// The [class`Gtk`] instance to use to compute
378 /// the preferred size of the widget, and allocate its children.
379 ///
380 /// This property is meant to be set by widget implementations,
381 /// typically in their instance init function.
382 ///
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `limit-events`
387 /// Makes this widget act like a modal dialog, with respect to
388 /// event delivery.
389 ///
390 /// Global event controllers will not handle events with targets
391 /// inside the widget, unless they are set up to ignore propagation
392 /// limits. See [method`Gtk`.set_propagation_limit].
393 ///
394 /// Readable | Writeable
395 ///
396 ///
397 /// #### `margin-bottom`
398 /// Margin on bottom side of widget.
399 ///
400 /// This property adds margin outside of the widget's normal size
401 /// request, the margin will be added in addition to the size from
402 /// [method`Gtk`.set_size_request] for example.
403 ///
404 /// Readable | Writeable
405 ///
406 ///
407 /// #### `margin-end`
408 /// Margin on end of widget, horizontally.
409 ///
410 /// This property supports left-to-right and right-to-left text
411 /// directions.
412 ///
413 /// This property adds margin outside of the widget's normal size
414 /// request, the margin will be added in addition to the size from
415 /// [method`Gtk`.set_size_request] for example.
416 ///
417 /// Readable | Writeable
418 ///
419 ///
420 /// #### `margin-start`
421 /// Margin on start of widget, horizontally.
422 ///
423 /// This property supports left-to-right and right-to-left text
424 /// directions.
425 ///
426 /// This property adds margin outside of the widget's normal size
427 /// request, the margin will be added in addition to the size from
428 /// [method`Gtk`.set_size_request] for example.
429 ///
430 /// Readable | Writeable
431 ///
432 ///
433 /// #### `margin-top`
434 /// Margin on top side of widget.
435 ///
436 /// This property adds margin outside of the widget's normal size
437 /// request, the margin will be added in addition to the size from
438 /// [method`Gtk`.set_size_request] for example.
439 ///
440 /// Readable | Writeable
441 ///
442 ///
443 /// #### `name`
444 /// The name of the widget.
445 ///
446 /// Readable | Writeable
447 ///
448 ///
449 /// #### `opacity`
450 /// The requested opacity of the widget.
451 ///
452 /// Readable | Writeable
453 ///
454 ///
455 /// #### `overflow`
456 /// How content outside the widget's content area is treated.
457 ///
458 /// This property is meant to be set by widget implementations,
459 /// typically in their instance init function.
460 ///
461 /// Readable | Writeable
462 ///
463 ///
464 /// #### `parent`
465 /// The parent widget of this widget.
466 ///
467 /// Readable
468 ///
469 ///
470 /// #### `receives-default`
471 /// Whether the widget will receive the default action when it is focused.
472 ///
473 /// Readable | Writeable
474 ///
475 ///
476 /// #### `root`
477 /// The `GtkRoot` widget of the widget tree containing this widget.
478 ///
479 /// This will be `NULL` if the widget is not contained in a root widget.
480 ///
481 /// Readable
482 ///
483 ///
484 /// #### `scale-factor`
485 /// The scale factor of the widget.
486 ///
487 /// Readable
488 ///
489 ///
490 /// #### `sensitive`
491 /// Whether the widget responds to input.
492 ///
493 /// Readable | Writeable
494 ///
495 ///
496 /// #### `tooltip-markup`
497 /// Sets the text of tooltip to be the given string, which is marked up
498 /// with Pango markup.
499 ///
500 /// Also see [method`Gtk`.set_markup].
501 ///
502 /// This is a convenience property which will take care of getting the
503 /// tooltip shown if the given string is not `NULL`:
504 /// [property`Gtk`:has-tooltip] will automatically be set to true
505 /// and there will be taken care of [signal`Gtk`::query-tooltip] in
506 /// the default signal handler.
507 ///
508 /// Note that if both [property`Gtk`:tooltip-text] and
509 /// [property`Gtk`:tooltip-markup] are set, the last one wins.
510 ///
511 /// Readable | Writeable
512 ///
513 ///
514 /// #### `tooltip-text`
515 /// Sets the text of tooltip to be the given string.
516 ///
517 /// Also see [method`Gtk`.set_text].
518 ///
519 /// This is a convenience property which will take care of getting the
520 /// tooltip shown if the given string is not `NULL`:
521 /// [property`Gtk`:has-tooltip] will automatically be set to true
522 /// and there will be taken care of [signal`Gtk`::query-tooltip] in
523 /// the default signal handler.
524 ///
525 /// Note that if both [property`Gtk`:tooltip-text] and
526 /// [property`Gtk`:tooltip-markup] are set, the last one wins.
527 ///
528 /// Readable | Writeable
529 ///
530 ///
531 /// #### `valign`
532 /// How to distribute vertical space if widget gets extra space.
533 ///
534 /// Readable | Writeable
535 ///
536 ///
537 /// #### `vexpand`
538 /// Whether to expand vertically.
539 ///
540 /// Readable | Writeable
541 ///
542 ///
543 /// #### `vexpand-set`
544 /// Whether to use the `vexpand` property.
545 ///
546 /// Readable | Writeable
547 ///
548 ///
549 /// #### `visible`
550 /// Whether the widget is visible.
551 ///
552 /// Readable | Writeable
553 ///
554 ///
555 /// #### `width-request`
556 /// Overrides for width request of the widget.
557 ///
558 /// If this is -1, the natural request will be used.
559 ///
560 /// Readable | Writeable
561 /// </details>
562 /// <details><summary><h4>Accessible</h4></summary>
563 ///
564 ///
565 /// #### `accessible-role`
566 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
567 ///
568 /// The accessible role cannot be changed once set.
569 ///
570 /// Readable | Writeable
571 /// </details>
572 ///
573 /// ## Signals
574 ///
575 ///
576 /// #### `authenticate`
577 /// This signal is emitted when the user is challenged with HTTP
578 /// authentication. To let the application access or supply
579 /// the credentials as well as to allow the client application
580 /// to either cancel the request or perform the authentication,
581 /// the signal will pass an instance of the
582 /// [`AuthenticationRequest`][crate::AuthenticationRequest] in the `request` argument.
583 /// To handle this signal asynchronously you should keep a ref
584 /// of the request and return [`true`]. To disable HTTP authentication
585 /// entirely, connect to this signal and simply return [`true`].
586 ///
587 /// The default signal handler will run a default authentication
588 /// dialog asynchronously for the user to interact with.
589 ///
590 ///
591 ///
592 ///
593 /// #### `close`
594 /// Emitted when closing a [`WebView`][crate::WebView] is requested. This occurs when a
595 /// call is made from JavaScript's `<function>`window.close`</function>` function or
596 /// after trying to close the `web_view` with [`WebViewExt::try_close()`][crate::prelude::WebViewExt::try_close()].
597 /// It is the owner's responsibility to handle this signal to hide or
598 /// destroy the [`WebView`][crate::WebView], if necessary.
599 ///
600 ///
601 ///
602 ///
603 /// #### `context-menu`
604 /// Emitted when a context menu is about to be displayed to give the application
605 /// a chance to customize the proposed menu, prevent the menu from being displayed,
606 /// or build its own context menu.
607 /// `<itemizedlist>`
608 /// `<listitem>``<para>`
609 /// To customize the proposed menu you can use [`ContextMenu::prepend()`][crate::ContextMenu::prepend()],
610 /// [`ContextMenu::append()`][crate::ContextMenu::append()] or [`ContextMenu::insert()`][crate::ContextMenu::insert()] to add new
611 /// [`ContextMenuItem`][crate::ContextMenuItem]<!-- -->s to `context_menu`, [`ContextMenu::move_item()`][crate::ContextMenu::move_item()]
612 /// to reorder existing items, or [`ContextMenu::remove()`][crate::ContextMenu::remove()] to remove an
613 /// existing item. The signal handler should return [`false`], and the menu represented
614 /// by `context_menu` will be shown.
615 /// `</para>``</listitem>`
616 /// `<listitem>``<para>`
617 /// To prevent the menu from being displayed you can just connect to this signal
618 /// and return [`true`] so that the proposed menu will not be shown.
619 /// `</para>``</listitem>`
620 /// `<listitem>``<para>`
621 /// To build your own menu, you can remove all items from the proposed menu with
622 /// [`ContextMenu::remove_all()`][crate::ContextMenu::remove_all()], add your own items and return [`false`] so
623 /// that the menu will be shown. You can also ignore the proposed [`ContextMenu`][crate::ContextMenu],
624 /// build your own `GtkMenu` and return [`true`] to prevent the proposed menu from being shown.
625 /// `</para>``</listitem>`
626 /// `<listitem>``<para>`
627 /// If you just want the default menu to be shown always, simply don't connect to this
628 /// signal because showing the proposed context menu is the default behaviour.
629 /// `</para>``</listitem>`
630 /// `</itemizedlist>`
631 ///
632 /// If the signal handler returns [`false`] the context menu represented by `context_menu`
633 /// will be shown, if it return [`true`] the context menu will not be shown.
634 ///
635 /// The proposed [`ContextMenu`][crate::ContextMenu] passed in `context_menu` argument is only valid
636 /// during the signal emission.
637 ///
638 ///
639 ///
640 ///
641 /// #### `context-menu-dismissed`
642 /// Emitted after [`context-menu`][struct@crate::WebView#context-menu] signal, if the context menu is shown,
643 /// to notify that the context menu is dismissed.
644 ///
645 ///
646 ///
647 ///
648 /// #### `create`
649 /// Emitted when the creation of a new [`WebView`][crate::WebView] is requested.
650 /// If this signal is handled the signal handler should return the
651 /// newly created [`WebView`][crate::WebView].
652 ///
653 /// The [`NavigationAction`][crate::NavigationAction] parameter contains information about the
654 /// navigation action that triggered this signal.
655 ///
656 /// The new [`WebView`][crate::WebView] must be related to `web_view`, see
657 /// [`related-view`][struct@crate::WebView#related-view] for more details.
658 ///
659 /// The new [`WebView`][crate::WebView] should not be displayed to the user
660 /// until the [`ready-to-show`][struct@crate::WebView#ready-to-show] signal is emitted.
661 ///
662 /// For creating views as response to automation tools requests, see the
663 /// [`create-web-view`][struct@crate::AutomationSession#create-web-view] signal.
664 ///
665 ///
666 ///
667 ///
668 /// #### `decide-policy`
669 /// This signal is emitted when WebKit is requesting the client to decide a policy
670 /// decision, such as whether to navigate to a page, open a new window or whether or
671 /// not to download a resource. The [`NavigationPolicyDecision`][crate::NavigationPolicyDecision] passed in the
672 /// `decision` argument is a generic type, but should be casted to a more
673 /// specific type when making the decision. For example:
674 ///
675 /// **⚠️ The following code is in c ⚠️**
676 ///
677 /// ```c
678 /// static gboolean
679 /// decide_policy_cb (WebKitWebView *web_view,
680 /// WebKitPolicyDecision *decision,
681 /// WebKitPolicyDecisionType type)
682 /// {
683 /// switch (type) {
684 /// case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
685 /// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
686 /// // Make a policy decision here
687 /// break;
688 /// }
689 /// case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {
690 /// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
691 /// // Make a policy decision here
692 /// break;
693 /// }
694 /// case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
695 /// WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
696 /// // Make a policy decision here
697 /// break;
698 /// default:
699 /// // Making no decision results in webkit_policy_decision_use()
700 /// return FALSE;
701 /// }
702 /// return TRUE;
703 /// }
704 /// ```
705 ///
706 /// It is possible to make policy decision asynchronously, by simply calling `g_object_ref()`
707 /// on the `decision` argument and returning [`true`] to block the default signal handler.
708 /// If the last reference is removed on a [`PolicyDecision`][crate::PolicyDecision] and no decision has been
709 /// made explicitly, [`PolicyDecisionExt::use_()`][crate::prelude::PolicyDecisionExt::use_()] will be the default policy decision. The
710 /// default signal handler will simply call [`PolicyDecisionExt::use_()`][crate::prelude::PolicyDecisionExt::use_()]. Only the first
711 /// policy decision chosen for a given [`PolicyDecision`][crate::PolicyDecision] will have any affect.
712 ///
713 ///
714 ///
715 ///
716 /// #### `enter-fullscreen`
717 /// Emitted when JavaScript code calls
718 /// `<function>`element.webkitRequestFullScreen`</function>`. If the
719 /// signal is not handled the [`WebView`][crate::WebView] will proceed to full screen
720 /// its top level window. This signal can be used by client code to
721 /// request permission to the user prior doing the full screen
722 /// transition and eventually prepare the top-level window
723 /// (e.g. hide some widgets that would otherwise be part of the
724 /// full screen window).
725 ///
726 ///
727 ///
728 ///
729 /// #### `insecure-content-detected`
730 /// Prior to 2.46, this signal was emitted when insecure content was
731 /// loaded in a secure content. Since 2.46, this signal is generally
732 /// no longer emitted.
733 ///
734 ///
735 ///
736 ///
737 /// #### `leave-fullscreen`
738 /// Emitted when the [`WebView`][crate::WebView] is about to restore its top level
739 /// window out of its full screen state. This signal can be used by
740 /// client code to restore widgets hidden during the
741 /// [`enter-fullscreen`][struct@crate::WebView#enter-fullscreen] stage for instance.
742 ///
743 ///
744 ///
745 ///
746 /// #### `load-changed`
747 /// Emitted when a load operation in `web_view` changes.
748 /// The signal is always emitted with [`LoadEvent::Started`][crate::LoadEvent::Started] when a
749 /// new load request is made and [`LoadEvent::Finished`][crate::LoadEvent::Finished] when the load
750 /// finishes successfully or due to an error. When the ongoing load
751 /// operation fails [`load-failed`][struct@crate::WebView#load-failed] signal is emitted
752 /// before [`load-changed`][struct@crate::WebView#load-changed] is emitted with
753 /// [`LoadEvent::Finished`][crate::LoadEvent::Finished].
754 /// If a redirection is received from the server, this signal is emitted
755 /// with [`LoadEvent::Redirected`][crate::LoadEvent::Redirected] after the initial emission with
756 /// [`LoadEvent::Started`][crate::LoadEvent::Started] and before [`LoadEvent::Committed`][crate::LoadEvent::Committed].
757 /// When the page content starts arriving the signal is emitted with
758 /// [`LoadEvent::Committed`][crate::LoadEvent::Committed] event.
759 ///
760 /// You can handle this signal and use a switch to track any ongoing
761 /// load operation.
762 ///
763 /// **⚠️ The following code is in c ⚠️**
764 ///
765 /// ```c
766 /// static void web_view_load_changed (WebKitWebView *web_view,
767 /// WebKitLoadEvent load_event,
768 /// gpointer user_data)
769 /// {
770 /// switch (load_event) {
771 /// case WEBKIT_LOAD_STARTED:
772 /// // New load, we have now a provisional URI
773 /// provisional_uri = webkit_web_view_get_uri (web_view);
774 /// // Here we could start a spinner or update the
775 /// // location bar with the provisional URI
776 /// break;
777 /// case WEBKIT_LOAD_REDIRECTED:
778 /// redirected_uri = webkit_web_view_get_uri (web_view);
779 /// break;
780 /// case WEBKIT_LOAD_COMMITTED:
781 /// // The load is being performed. Current URI is
782 /// // the final one and it won't change unless a new
783 /// // load is requested or a navigation within the
784 /// // same page is performed
785 /// uri = webkit_web_view_get_uri (web_view);
786 /// break;
787 /// case WEBKIT_LOAD_FINISHED:
788 /// // Load finished, we can now stop the spinner
789 /// break;
790 /// }
791 /// }
792 /// ```
793 ///
794 ///
795 ///
796 ///
797 /// #### `load-failed`
798 /// Emitted when an error occurs during a load operation.
799 /// If the error happened when starting to load data for a page
800 /// `load_event` will be [`LoadEvent::Started`][crate::LoadEvent::Started]. If it happened while
801 /// loading a committed data source `load_event` will be [`LoadEvent::Committed`][crate::LoadEvent::Committed].
802 /// Since a load error causes the load operation to finish, the signal
803 /// WebKitWebView::load-changed will always be emitted with
804 /// [`LoadEvent::Finished`][crate::LoadEvent::Finished] event right after this one.
805 ///
806 /// By default, if the signal is not handled, a stock error page will be displayed.
807 /// You need to handle the signal if you want to provide your own error page.
808 ///
809 ///
810 ///
811 ///
812 /// #### `load-failed-with-tls-errors`
813 /// Emitted when a TLS error occurs during a load operation.
814 /// To allow an exception for this `certificate`
815 /// and the host of `failing_uri` use `webkit_web_context_allow_tls_certificate_for_host()`.
816 ///
817 /// To handle this signal asynchronously you should call `g_object_ref()` on `certificate`
818 /// and return [`true`].
819 ///
820 /// If [`false`] is returned, [`load-failed`][struct@crate::WebView#load-failed] will be emitted. The load
821 /// will finish regardless of the returned value.
822 ///
823 ///
824 ///
825 ///
826 /// #### `mouse-target-changed`
827 /// This signal is emitted when the mouse cursor moves over an
828 /// element such as a link, image or a media element. To determine
829 /// what type of element the mouse cursor is over, a Hit Test is performed
830 /// on the current mouse coordinates and the result is passed in the
831 /// `hit_test_result` argument. The `modifiers` argument is a bitmask of
832 /// `GdkModifierType` flags indicating the state of modifier keys.
833 /// The signal is emitted again when the mouse is moved out of the
834 /// current element with a new `hit_test_result`.
835 ///
836 ///
837 ///
838 ///
839 /// #### `permission-request`
840 /// This signal is emitted when WebKit is requesting the client to
841 /// decide about a permission request, such as allowing the browser
842 /// to switch to fullscreen mode, sharing its location or similar
843 /// operations.
844 ///
845 /// A possible way to use this signal could be through a dialog
846 /// allowing the user decide what to do with the request:
847 ///
848 /// **⚠️ The following code is in c ⚠️**
849 ///
850 /// ```c
851 /// static gboolean permission_request_cb (WebKitWebView *web_view,
852 /// WebKitPermissionRequest *request,
853 /// GtkWindow *parent_window)
854 /// {
855 /// GtkWidget *dialog = gtk_message_dialog_new (parent_window,
856 /// GTK_DIALOG_MODAL,
857 /// GTK_MESSAGE_QUESTION,
858 /// GTK_BUTTONS_YES_NO,
859 /// "Allow Permission Request?");
860 /// gtk_widget_show (dialog);
861 /// gint result = gtk_dialog_run (GTK_DIALOG (dialog));
862 ///
863 /// switch (result) {
864 /// case GTK_RESPONSE_YES:
865 /// webkit_permission_request_allow (request);
866 /// break;
867 /// default:
868 /// webkit_permission_request_deny (request);
869 /// break;
870 /// }
871 /// gtk_widget_destroy (dialog);
872 ///
873 /// return TRUE;
874 /// }
875 /// ```
876 ///
877 /// It is possible to handle permission requests asynchronously, by
878 /// simply calling `g_object_ref()` on the `request` argument and
879 /// returning [`true`] to block the default signal handler. If the
880 /// last reference is removed on a [`PermissionRequest`][crate::PermissionRequest] and the
881 /// request has not been handled, [`PermissionRequestExt::deny()`][crate::prelude::PermissionRequestExt::deny()]
882 /// will be the default action.
883 ///
884 /// If the signal is not handled, the `request` will be completed automatically
885 /// by the specific [`PermissionRequest`][crate::PermissionRequest] that could allow or deny it. Check the
886 /// documentation of classes implementing [`PermissionRequest`][crate::PermissionRequest] interface to know
887 /// their default action.
888 ///
889 ///
890 ///
891 ///
892 /// #### `print`
893 /// Emitted when printing is requested on `web_view`, usually by a JavaScript call,
894 /// before the print dialog is shown. This signal can be used to set the initial
895 /// print settings and page setup of `print_operation` to be used as default values in
896 /// the print dialog. You can call [`PrintOperation::set_print_settings()`][crate::PrintOperation::set_print_settings()] and
897 /// [`PrintOperation::set_page_setup()`][crate::PrintOperation::set_page_setup()] and then return [`false`] to propagate the
898 /// event so that the print dialog is shown.
899 ///
900 /// You can connect to this signal and return [`true`] to cancel the print operation
901 /// or implement your own print dialog.
902 ///
903 ///
904 ///
905 ///
906 /// #### `query-permission-state`
907 /// This signal allows the User-Agent to respond to permission requests for powerful features, as
908 /// specified by the [Permissions W3C Specification](https://w3c.github.io/permissions/).
909 /// You can reply to the query using [`PermissionStateQuery::finish()`][crate::PermissionStateQuery::finish()].
910 ///
911 /// You can handle the query asynchronously by calling `webkit_permission_state_query_ref()` on
912 /// `query` and returning [`true`]. If the last reference of `query` is removed and the query has not
913 /// been handled, the query result will be set to `WEBKIT_QUERY_PERMISSION_PROMPT`.
914 ///
915 ///
916 ///
917 ///
918 /// #### `ready-to-show`
919 /// Emitted after [`create`][struct@crate::WebView#create] on the newly created [`WebView`][crate::WebView]
920 /// when it should be displayed to the user. When this signal is emitted
921 /// all the information about how the window should look, including
922 /// size, position, whether the location, status and scrollbars
923 /// should be displayed, is already set on the [`WindowProperties`][crate::WindowProperties]
924 /// of `web_view`. See also [`WebViewExt::window_properties()`][crate::prelude::WebViewExt::window_properties()].
925 ///
926 ///
927 ///
928 ///
929 /// #### `resource-load-started`
930 /// Emitted when a new resource is going to be loaded. The `request` parameter
931 /// contains the [`URIRequest`][crate::URIRequest] that will be sent to the server.
932 /// You can monitor the load operation by connecting to the different signals
933 /// of `resource`.
934 ///
935 ///
936 ///
937 ///
938 /// #### `run-as-modal`
939 /// Emitted after [`ready-to-show`][struct@crate::WebView#ready-to-show] on the newly
940 /// created [`WebView`][crate::WebView] when JavaScript code calls
941 /// `<function>`window.showModalDialog`</function>`. The purpose of
942 /// this signal is to allow the client application to prepare the
943 /// new view to behave as modal. Once the signal is emitted a new
944 /// main loop will be run to block user interaction in the parent
945 /// [`WebView`][crate::WebView] until the new dialog is closed.
946 ///
947 ///
948 ///
949 ///
950 /// #### `run-color-chooser`
951 /// This signal is emitted when the user interacts with a <input
952 /// type='color' /> HTML element, requesting from WebKit to show
953 /// a dialog to select a color. To let the application know the details of
954 /// the color chooser, as well as to allow the client application to either
955 /// cancel the request or perform an actual color selection, the signal will
956 /// pass an instance of the [`ColorChooserRequest`][crate::ColorChooserRequest] in the `request`
957 /// argument.
958 ///
959 /// It is possible to handle this request asynchronously by increasing the
960 /// reference count of the request.
961 ///
962 /// The default signal handler will asynchronously run a regular
963 /// `GtkColorChooser` for the user to interact with.
964 ///
965 ///
966 ///
967 ///
968 /// #### `run-file-chooser`
969 /// This signal is emitted when the user interacts with a <input
970 /// type='file' /> HTML element, requesting from WebKit to show
971 /// a dialog to select one or more files to be uploaded. To let the
972 /// application know the details of the file chooser, as well as to
973 /// allow the client application to either cancel the request or
974 /// perform an actual selection of files, the signal will pass an
975 /// instance of the [`FileChooserRequest`][crate::FileChooserRequest] in the `request`
976 /// argument.
977 ///
978 /// The default signal handler will asynchronously run a regular
979 /// `GtkFileChooserDialog` for the user to interact with.
980 ///
981 ///
982 ///
983 ///
984 /// #### `script-dialog`
985 /// Emitted when JavaScript code calls `<function>`window.alert`</function>`,
986 /// `<function>`window.confirm`</function>` or `<function>`window.prompt`</function>`,
987 /// or when `<function>`onbeforeunload`</function>` event is fired.
988 /// The `dialog` parameter should be used to build the dialog.
989 /// If the signal is not handled a different dialog will be built and shown depending
990 /// on the dialog type:
991 /// `<itemizedlist>`
992 /// `<listitem>``<para>`
993 /// [`ScriptDialogType::Alert`][crate::ScriptDialogType::Alert]: message dialog with a single Close button.
994 /// `</para>``</listitem>`
995 /// `<listitem>``<para>`
996 /// [`ScriptDialogType::Confirm`][crate::ScriptDialogType::Confirm]: message dialog with OK and Cancel buttons.
997 /// `</para>``</listitem>`
998 /// `<listitem>``<para>`
999 /// [`ScriptDialogType::Prompt`][crate::ScriptDialogType::Prompt]: message dialog with OK and Cancel buttons and
1000 /// a text entry with the default text.
1001 /// `</para>``</listitem>`
1002 /// `<listitem>``<para>`
1003 /// [`ScriptDialogType::BeforeUnloadConfirm`][crate::ScriptDialogType::BeforeUnloadConfirm]: message dialog with Stay and Leave buttons.
1004 /// `</para>``</listitem>`
1005 /// `</itemizedlist>`
1006 ///
1007 /// It is possible to handle the script dialog request asynchronously, by simply
1008 /// caling `webkit_script_dialog_ref()` on the `dialog` argument and calling
1009 /// [`ScriptDialog::close()`][crate::ScriptDialog::close()] when done.
1010 /// If the last reference is removed on a [`ScriptDialog`][crate::ScriptDialog] and the dialog has not been
1011 /// closed, [`ScriptDialog::close()`][crate::ScriptDialog::close()] will be called.
1012 ///
1013 ///
1014 ///
1015 ///
1016 /// #### `show-notification`
1017 /// This signal is emitted when a notification should be presented to the
1018 /// user. The `notification` is kept alive until either: 1) the web page cancels it
1019 /// or 2) a navigation happens.
1020 ///
1021 /// The default handler will emit a notification using libnotify, if built with
1022 /// support for it.
1023 ///
1024 ///
1025 ///
1026 ///
1027 /// #### `show-option-menu`
1028 /// This signal is emitted when a select element in `web_view` needs to display a
1029 /// dropdown menu. This signal can be used to show a custom menu, using `menu` to get
1030 /// the details of all items that should be displayed. The area of the element in the
1031 /// [`WebView`][crate::WebView] is given as `rectangle` parameter, it can be used to position the
1032 /// menu.
1033 /// To handle this signal asynchronously you should keep a ref of the `menu`.
1034 ///
1035 /// The default signal handler will pop up a `GtkMenu`.
1036 ///
1037 ///
1038 ///
1039 ///
1040 /// #### `submit-form`
1041 /// This signal is emitted when a form is about to be submitted. The `request`
1042 /// argument passed contains information about the text fields of the form. This
1043 /// is typically used to store login information that can be used later to
1044 /// pre-fill the form.
1045 /// The form will not be submitted until [`FormSubmissionRequest::submit()`][crate::FormSubmissionRequest::submit()] is called.
1046 ///
1047 /// It is possible to handle the form submission request asynchronously, by
1048 /// simply calling `g_object_ref()` on the `request` argument and calling
1049 /// [`FormSubmissionRequest::submit()`][crate::FormSubmissionRequest::submit()] when done to continue with the form submission.
1050 /// If the last reference is removed on a [`FormSubmissionRequest`][crate::FormSubmissionRequest] and the
1051 /// form has not been submitted, [`FormSubmissionRequest::submit()`][crate::FormSubmissionRequest::submit()] will be called.
1052 ///
1053 ///
1054 ///
1055 ///
1056 /// #### `user-message-received`
1057 /// This signal is emitted when a [`UserMessage`][crate::UserMessage] is received from the
1058 /// `WebKitWebPage` corresponding to `web_view`. You can reply to the message
1059 /// using [`UserMessage::send_reply()`][crate::UserMessage::send_reply()].
1060 ///
1061 /// You can handle the user message asynchronously by calling `g_object_ref()` on
1062 /// `message` and returning [`true`]. If the last reference of `message` is removed
1063 /// and the message has not been replied to, the operation in the `WebKitWebPage` will
1064 /// finish with error [`UserMessageError::Message`][crate::UserMessageError::Message].
1065 ///
1066 ///
1067 ///
1068 ///
1069 /// #### `web-process-terminated`
1070 /// This signal is emitted when the web process terminates abnormally due
1071 /// to `reason`.
1072 ///
1073 ///
1074 /// <details><summary><h4>Widget</h4></summary>
1075 ///
1076 ///
1077 /// #### `destroy`
1078 /// Signals that all holders of a reference to the widget should release
1079 /// the reference that they hold.
1080 ///
1081 /// May result in finalization of the widget if all references are released.
1082 ///
1083 /// This signal is not suitable for saving widget state.
1084 ///
1085 ///
1086 ///
1087 ///
1088 /// #### `direction-changed`
1089 /// Emitted when the text direction of a widget changes.
1090 ///
1091 ///
1092 ///
1093 ///
1094 /// #### `hide`
1095 /// Emitted when `widget` is hidden.
1096 ///
1097 ///
1098 ///
1099 ///
1100 /// #### `keynav-failed`
1101 /// Emitted if keyboard navigation fails.
1102 ///
1103 /// See [method`Gtk`.keynav_failed] for details.
1104 ///
1105 ///
1106 ///
1107 ///
1108 /// #### `map`
1109 /// Emitted when `widget` is going to be mapped.
1110 ///
1111 /// A widget is mapped when the widget is visible (which is controlled with
1112 /// [property`Gtk`:visible]) and all its parents up to the toplevel widget
1113 /// are also visible.
1114 ///
1115 /// The `::map` signal can be used to determine whether a widget will be drawn,
1116 /// for instance it can resume an animation that was stopped during the
1117 /// emission of [signal`Gtk`::unmap].
1118 ///
1119 ///
1120 ///
1121 ///
1122 /// #### `mnemonic-activate`
1123 /// Emitted when a widget is activated via a mnemonic.
1124 ///
1125 /// The default handler for this signal activates `widget` if `group_cycling`
1126 /// is false, or just makes `widget` grab focus if `group_cycling` is true.
1127 ///
1128 ///
1129 ///
1130 ///
1131 /// #### `move-focus`
1132 /// Emitted when the focus is moved.
1133 ///
1134 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
1135 ///
1136 /// The default bindings for this signal are `<kbd>`Tab`</kbd>` to move forward,
1137 /// and `<kbd>`Shift`</kbd>`+`<kbd>`Tab`</kbd>` to move backward.
1138 ///
1139 /// Action
1140 ///
1141 ///
1142 /// #### `query-tooltip`
1143 /// Emitted when the widget’s tooltip is about to be shown.
1144 ///
1145 /// This happens when the [property`Gtk`:has-tooltip] property
1146 /// is true and the hover timeout has expired with the cursor hovering
1147 /// above `widget`; or emitted when `widget` got focus in keyboard mode.
1148 ///
1149 /// Using the given coordinates, the signal handler should determine
1150 /// whether a tooltip should be shown for `widget`. If this is the case
1151 /// true should be returned, false otherwise. Note that if `keyboard_mode`
1152 /// is true, the values of `x` and `y` are undefined and should not be used.
1153 ///
1154 /// The signal handler is free to manipulate `tooltip` with the therefore
1155 /// destined function calls.
1156 ///
1157 ///
1158 ///
1159 ///
1160 /// #### `realize`
1161 /// Emitted when `widget` is associated with a `GdkSurface`.
1162 ///
1163 /// This means that [method`Gtk`.realize] has been called
1164 /// or the widget has been mapped (that is, it is going to be drawn).
1165 ///
1166 ///
1167 ///
1168 ///
1169 /// #### `show`
1170 /// Emitted when `widget` is shown.
1171 ///
1172 ///
1173 ///
1174 ///
1175 /// #### `state-flags-changed`
1176 /// Emitted when the widget state changes.
1177 ///
1178 /// See [method`Gtk`.get_state_flags].
1179 ///
1180 ///
1181 ///
1182 ///
1183 /// #### `unmap`
1184 /// Emitted when `widget` is going to be unmapped.
1185 ///
1186 /// A widget is unmapped when either it or any of its parents up to the
1187 /// toplevel widget have been set as hidden.
1188 ///
1189 /// As `::unmap` indicates that a widget will not be shown any longer,
1190 /// it can be used to, for example, stop an animation on the widget.
1191 ///
1192 ///
1193 ///
1194 ///
1195 /// #### `unrealize`
1196 /// Emitted when the `GdkSurface` associated with `widget` is destroyed.
1197 ///
1198 /// This means that [method`Gtk`.unrealize] has been called
1199 /// or the widget has been unmapped (that is, it is going to be hidden).
1200 ///
1201 ///
1202 /// </details>
1203 ///
1204 /// # Implements
1205 ///
1206 /// [`WebViewExt`][trait@crate::prelude::WebViewExt], [`WebViewBaseExt`][trait@crate::prelude::WebViewBaseExt], [`trait@gtk::prelude::WidgetExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`]
1207 #[doc(alias = "WebKitWebView")]
1208 pub struct WebView(Object<ffi::WebKitWebView, ffi::WebKitWebViewClass>) @extends WebViewBase, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
1209
1210 match fn {
1211 type_ => || ffi::webkit_web_view_get_type(),
1212 }
1213}
1214
1215impl WebView {
1216 pub const NONE: Option<&'static WebView> = None;
1217
1218 /// Creates a new [`WebView`][crate::WebView] with the default [`WebContext`][crate::WebContext].
1219 ///
1220 /// Creates a new [`WebView`][crate::WebView] with the default [`WebContext`][crate::WebContext] and
1221 /// no [`UserContentManager`][crate::UserContentManager] associated with it.
1222 /// See also `webkit_web_view_new_with_context()`,
1223 /// `webkit_web_view_new_with_user_content_manager()`, and
1224 /// `webkit_web_view_new_with_settings()`.
1225 ///
1226 /// # Returns
1227 ///
1228 /// The newly created [`WebView`][crate::WebView] widget
1229 #[doc(alias = "webkit_web_view_new")]
1230 pub fn new() -> WebView {
1231 assert_initialized_main_thread!();
1232 unsafe { gtk::Widget::from_glib_none(ffi::webkit_web_view_new()).unsafe_cast() }
1233 }
1234
1235 // rustdoc-stripper-ignore-next
1236 /// Creates a new builder-pattern struct instance to construct [`WebView`] objects.
1237 ///
1238 /// This method returns an instance of [`WebViewBuilder`](crate::builders::WebViewBuilder) which can be used to create [`WebView`] objects.
1239 pub fn builder() -> WebViewBuilder {
1240 WebViewBuilder::new()
1241 }
1242}
1243
1244impl Default for WebView {
1245 fn default() -> Self {
1246 Self::new()
1247 }
1248}
1249
1250// rustdoc-stripper-ignore-next
1251/// A [builder-pattern] type to construct [`WebView`] objects.
1252///
1253/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1254#[must_use = "The builder must be built to be used"]
1255pub struct WebViewBuilder {
1256 builder: glib::object::ObjectBuilder<'static, WebView>,
1257}
1258
1259impl WebViewBuilder {
1260 fn new() -> Self {
1261 Self {
1262 builder: glib::object::Object::builder(),
1263 }
1264 }
1265
1266 /// The [`AutomationBrowsingContextPresentation`][crate::AutomationBrowsingContextPresentation] of [`WebView`][crate::WebView]. This should only be used when
1267 /// creating a new [`WebView`][crate::WebView] as a response to [`create-web-view`][struct@crate::AutomationSession#create-web-view]
1268 /// signal request. If the new WebView was added to a new tab of current browsing context window
1269 /// [`AutomationBrowsingContextPresentation::Tab`][crate::AutomationBrowsingContextPresentation::Tab] should be used.
1270 pub fn automation_presentation_type(
1271 self,
1272 automation_presentation_type: AutomationBrowsingContextPresentation,
1273 ) -> Self {
1274 Self {
1275 builder: self
1276 .builder
1277 .property("automation-presentation-type", automation_presentation_type),
1278 }
1279 }
1280
1281 /// Capture state of the camera device. Whenever the user grants a media-request sent by the web
1282 /// page, requesting video capture capabilities (`navigator.mediaDevices.getUserMedia({video:
1283 /// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
1284 ///
1285 /// The application can monitor this property and provide a visual indicator allowing to optionally
1286 /// deactivate or mute the capture device by setting this property respectively to
1287 /// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
1288 ///
1289 /// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
1290 /// can still re-request the permission to the user. Permission desision caching is left to the
1291 /// application.
1292 pub fn camera_capture_state(self, camera_capture_state: MediaCaptureState) -> Self {
1293 Self {
1294 builder: self
1295 .builder
1296 .property("camera-capture-state", camera_capture_state),
1297 }
1298 }
1299
1300 /// The default Content-Security-Policy used by the webview as if it were set
1301 /// by an HTTP header.
1302 ///
1303 /// This applies to all content loaded including through navigation or via the various
1304 /// webkit_web_view_load_\* APIs. However do note that many WebKit APIs bypass
1305 /// Content-Security-Policy in general such as [`UserContentManager`][crate::UserContentManager] and
1306 /// `webkit_web_view_run_javascript()`.
1307 ///
1308 /// Policies are additive so if a website sets its own policy it still applies
1309 /// on top of the policy set here.
1310 pub fn default_content_security_policy(
1311 self,
1312 default_content_security_policy: impl Into<glib::GString>,
1313 ) -> Self {
1314 Self {
1315 builder: self.builder.property(
1316 "default-content-security-policy",
1317 default_content_security_policy.into(),
1318 ),
1319 }
1320 }
1321
1322 /// Capture state of the display device. Whenever the user grants a media-request sent by the web
1323 /// page, requesting screencasting capabilities (`navigator.mediaDevices.getDisplayMedia() this
1324 /// property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
1325 ///
1326 /// The application can monitor this property and provide a visual indicator allowing to
1327 /// optionally deactivate or mute the capture device by setting this property respectively to
1328 /// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
1329 ///
1330 /// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
1331 /// can still re-request the permission to the user. Permission desision caching is left to the
1332 /// application.
1333 pub fn display_capture_state(self, display_capture_state: MediaCaptureState) -> Self {
1334 Self {
1335 builder: self
1336 .builder
1337 .property("display-capture-state", display_capture_state),
1338 }
1339 }
1340
1341 /// Whether the pages loaded inside [`WebView`][crate::WebView] are editable. For more
1342 /// information see [`WebViewExt::set_editable()`][crate::prelude::WebViewExt::set_editable()].
1343 pub fn editable(self, editable: bool) -> Self {
1344 Self {
1345 builder: self.builder.property("editable", editable),
1346 }
1347 }
1348
1349 /// Whether the [`WebView`][crate::WebView] is controlled by automation tools (e.g. WebDriver, Selenium). This is
1350 /// required for views returned as a response to [`create-web-view`][struct@crate::AutomationSession#create-web-view] signal,
1351 /// alongside any view you want to control during an automation session.
1352 ///
1353 /// As a `G_PARAM_CONSTRUCT_ONLY`, you need to set it during construction and it can't be modified.
1354 ///
1355 /// If [`related-view`][struct@crate::WebView#related-view] is also passed during construction, [`is-controlled-by-automation`][struct@crate::WebView#is-controlled-by-automation]
1356 /// ignores its own parameter and inherits directly from the related view [`is-controlled-by-automation`][struct@crate::WebView#is-controlled-by-automation]
1357 /// property. This is the recommended way when creating new views as a response to the [`create`][struct@crate::WebView#create]
1358 /// signal. For example, as response to JavaScript ``window.open()`` calls during an automation session.
1359 pub fn is_controlled_by_automation(self, is_controlled_by_automation: bool) -> Self {
1360 Self {
1361 builder: self
1362 .builder
1363 .property("is-controlled-by-automation", is_controlled_by_automation),
1364 }
1365 }
1366
1367 /// Whether the [`WebView`][crate::WebView] audio is muted. When [`true`], audio is silenced.
1368 /// It may still be playing, i.e. [`is-playing-audio`][struct@crate::WebView#is-playing-audio] may be [`true`].
1369 pub fn is_muted(self, is_muted: bool) -> Self {
1370 Self {
1371 builder: self.builder.property("is-muted", is_muted),
1372 }
1373 }
1374
1375 /// Capture state of the microphone device. Whenever the user grants a media-request sent by the web
1376 /// page, requesting audio capture capabilities (`navigator.mediaDevices.getUserMedia({audio:
1377 /// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
1378 ///
1379 /// The application can monitor this property and provide a visual indicator allowing to
1380 /// optionally deactivate or mute the capture device by setting this property respectively to
1381 /// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
1382 ///
1383 /// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
1384 /// can still re-request the permission to the user. Permission desision caching is left to the
1385 /// application.
1386 pub fn microphone_capture_state(self, microphone_capture_state: MediaCaptureState) -> Self {
1387 Self {
1388 builder: self
1389 .builder
1390 .property("microphone-capture-state", microphone_capture_state),
1391 }
1392 }
1393
1394 /// The [`NetworkSession`][crate::NetworkSession] of the view
1395 pub fn network_session(self, network_session: &NetworkSession) -> Self {
1396 Self {
1397 builder: self
1398 .builder
1399 .property("network-session", network_session.clone()),
1400 }
1401 }
1402
1403 /// The related [`WebView`][crate::WebView] used when creating the view to share the
1404 /// same web process and network session. This property is not readable
1405 /// because the related web view is only valid during the object construction.
1406 pub fn related_view(self, related_view: &impl IsA<WebView>) -> Self {
1407 Self {
1408 builder: self
1409 .builder
1410 .property("related-view", related_view.clone().upcast()),
1411 }
1412 }
1413
1414 /// The [`Settings`][crate::Settings] of the view.
1415 pub fn settings(self, settings: &Settings) -> Self {
1416 Self {
1417 builder: self.builder.property("settings", settings.clone()),
1418 }
1419 }
1420
1421 /// The [`UserContentManager`][crate::UserContentManager] of the view.
1422 pub fn user_content_manager(self, user_content_manager: &UserContentManager) -> Self {
1423 Self {
1424 builder: self
1425 .builder
1426 .property("user-content-manager", user_content_manager.clone()),
1427 }
1428 }
1429
1430 /// The [`WebContext`][crate::WebContext] of the view.
1431 pub fn web_context(self, web_context: &WebContext) -> Self {
1432 Self {
1433 builder: self.builder.property("web-context", web_context.clone()),
1434 }
1435 }
1436
1437 /// This configures `web_view` to treat the content as a WebExtension.
1438 ///
1439 /// Note that this refers to the web standard [WebExtensions](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions)
1440 /// and not WebKitWebExtensions.
1441 ///
1442 /// In practice this limits the Content-Security-Policies that are allowed to be set. Some details can be found in
1443 /// [Chrome's documentation](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/`content`-security-policy).
1444 pub fn web_extension_mode(self, web_extension_mode: WebExtensionMode) -> Self {
1445 Self {
1446 builder: self
1447 .builder
1448 .property("web-extension-mode", web_extension_mode),
1449 }
1450 }
1451
1452 /// The [`WebsitePolicies`][crate::WebsitePolicies] for the view.
1453 pub fn website_policies(self, website_policies: &WebsitePolicies) -> Self {
1454 Self {
1455 builder: self
1456 .builder
1457 .property("website-policies", website_policies.clone()),
1458 }
1459 }
1460
1461 /// The zoom level of the [`WebView`][crate::WebView] content.
1462 /// See [`WebViewExt::set_zoom_level()`][crate::prelude::WebViewExt::set_zoom_level()] for more details.
1463 pub fn zoom_level(self, zoom_level: f64) -> Self {
1464 Self {
1465 builder: self.builder.property("zoom-level", zoom_level),
1466 }
1467 }
1468
1469 /// Whether the widget or any of its descendents can accept
1470 /// the input focus.
1471 ///
1472 /// This property is meant to be set by widget implementations,
1473 /// typically in their instance init function.
1474 pub fn can_focus(self, can_focus: bool) -> Self {
1475 Self {
1476 builder: self.builder.property("can-focus", can_focus),
1477 }
1478 }
1479
1480 /// Whether the widget can receive pointer events.
1481 pub fn can_target(self, can_target: bool) -> Self {
1482 Self {
1483 builder: self.builder.property("can-target", can_target),
1484 }
1485 }
1486
1487 /// A list of css classes applied to this widget.
1488 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1489 Self {
1490 builder: self.builder.property("css-classes", css_classes.into()),
1491 }
1492 }
1493
1494 /// The name of this widget in the CSS tree.
1495 ///
1496 /// This property is meant to be set by widget implementations,
1497 /// typically in their instance init function.
1498 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1499 Self {
1500 builder: self.builder.property("css-name", css_name.into()),
1501 }
1502 }
1503
1504 //pub fn cursor(self, cursor: /*Ignored*/&gdk::Cursor) -> Self {
1505 // Self { builder: self.builder.property("cursor", cursor), }
1506 //}
1507
1508 /// Whether the widget should grab focus when it is clicked with the mouse.
1509 ///
1510 /// This property is only relevant for widgets that can take focus.
1511 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1512 Self {
1513 builder: self.builder.property("focus-on-click", focus_on_click),
1514 }
1515 }
1516
1517 /// Whether this widget itself will accept the input focus.
1518 pub fn focusable(self, focusable: bool) -> Self {
1519 Self {
1520 builder: self.builder.property("focusable", focusable),
1521 }
1522 }
1523
1524 //pub fn halign(self, halign: /*Ignored*/gtk::Align) -> Self {
1525 // Self { builder: self.builder.property("halign", halign), }
1526 //}
1527
1528 /// Enables or disables the emission of the [signal`Gtk`::query-tooltip]
1529 /// signal on `widget`.
1530 ///
1531 /// A true value indicates that `widget` can have a tooltip, in this case
1532 /// the widget will be queried using [signal`Gtk`::query-tooltip] to
1533 /// determine whether it will provide a tooltip or not.
1534 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1535 Self {
1536 builder: self.builder.property("has-tooltip", has_tooltip),
1537 }
1538 }
1539
1540 /// Overrides for height request of the widget.
1541 ///
1542 /// If this is -1, the natural request will be used.
1543 pub fn height_request(self, height_request: i32) -> Self {
1544 Self {
1545 builder: self.builder.property("height-request", height_request),
1546 }
1547 }
1548
1549 /// Whether to expand horizontally.
1550 pub fn hexpand(self, hexpand: bool) -> Self {
1551 Self {
1552 builder: self.builder.property("hexpand", hexpand),
1553 }
1554 }
1555
1556 /// Whether to use the `hexpand` property.
1557 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1558 Self {
1559 builder: self.builder.property("hexpand-set", hexpand_set),
1560 }
1561 }
1562
1563 //pub fn layout_manager(self, layout_manager: &impl IsA</*Ignored*/gtk::LayoutManager>) -> Self {
1564 // Self { builder: self.builder.property("layout-manager", layout_manager.clone().upcast()), }
1565 //}
1566
1567 /// Makes this widget act like a modal dialog, with respect to
1568 /// event delivery.
1569 ///
1570 /// Global event controllers will not handle events with targets
1571 /// inside the widget, unless they are set up to ignore propagation
1572 /// limits. See [method`Gtk`.set_propagation_limit].
1573 #[cfg(feature = "gtk_v4_18")]
1574 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
1575 pub fn limit_events(self, limit_events: bool) -> Self {
1576 Self {
1577 builder: self.builder.property("limit-events", limit_events),
1578 }
1579 }
1580
1581 /// Margin on bottom side of widget.
1582 ///
1583 /// This property adds margin outside of the widget's normal size
1584 /// request, the margin will be added in addition to the size from
1585 /// [method`Gtk`.set_size_request] for example.
1586 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1587 Self {
1588 builder: self.builder.property("margin-bottom", margin_bottom),
1589 }
1590 }
1591
1592 /// Margin on end of widget, horizontally.
1593 ///
1594 /// This property supports left-to-right and right-to-left text
1595 /// directions.
1596 ///
1597 /// This property adds margin outside of the widget's normal size
1598 /// request, the margin will be added in addition to the size from
1599 /// [method`Gtk`.set_size_request] for example.
1600 pub fn margin_end(self, margin_end: i32) -> Self {
1601 Self {
1602 builder: self.builder.property("margin-end", margin_end),
1603 }
1604 }
1605
1606 /// Margin on start of widget, horizontally.
1607 ///
1608 /// This property supports left-to-right and right-to-left text
1609 /// directions.
1610 ///
1611 /// This property adds margin outside of the widget's normal size
1612 /// request, the margin will be added in addition to the size from
1613 /// [method`Gtk`.set_size_request] for example.
1614 pub fn margin_start(self, margin_start: i32) -> Self {
1615 Self {
1616 builder: self.builder.property("margin-start", margin_start),
1617 }
1618 }
1619
1620 /// Margin on top side of widget.
1621 ///
1622 /// This property adds margin outside of the widget's normal size
1623 /// request, the margin will be added in addition to the size from
1624 /// [method`Gtk`.set_size_request] for example.
1625 pub fn margin_top(self, margin_top: i32) -> Self {
1626 Self {
1627 builder: self.builder.property("margin-top", margin_top),
1628 }
1629 }
1630
1631 /// The name of the widget.
1632 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1633 Self {
1634 builder: self.builder.property("name", name.into()),
1635 }
1636 }
1637
1638 /// The requested opacity of the widget.
1639 pub fn opacity(self, opacity: f64) -> Self {
1640 Self {
1641 builder: self.builder.property("opacity", opacity),
1642 }
1643 }
1644
1645 //pub fn overflow(self, overflow: /*Ignored*/gtk::Overflow) -> Self {
1646 // Self { builder: self.builder.property("overflow", overflow), }
1647 //}
1648
1649 /// Whether the widget will receive the default action when it is focused.
1650 pub fn receives_default(self, receives_default: bool) -> Self {
1651 Self {
1652 builder: self.builder.property("receives-default", receives_default),
1653 }
1654 }
1655
1656 /// Whether the widget responds to input.
1657 pub fn sensitive(self, sensitive: bool) -> Self {
1658 Self {
1659 builder: self.builder.property("sensitive", sensitive),
1660 }
1661 }
1662
1663 /// Sets the text of tooltip to be the given string, which is marked up
1664 /// with Pango markup.
1665 ///
1666 /// Also see [method`Gtk`.set_markup].
1667 ///
1668 /// This is a convenience property which will take care of getting the
1669 /// tooltip shown if the given string is not `NULL`:
1670 /// [property`Gtk`:has-tooltip] will automatically be set to true
1671 /// and there will be taken care of [signal`Gtk`::query-tooltip] in
1672 /// the default signal handler.
1673 ///
1674 /// Note that if both [property`Gtk`:tooltip-text] and
1675 /// [property`Gtk`:tooltip-markup] are set, the last one wins.
1676 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1677 Self {
1678 builder: self
1679 .builder
1680 .property("tooltip-markup", tooltip_markup.into()),
1681 }
1682 }
1683
1684 /// Sets the text of tooltip to be the given string.
1685 ///
1686 /// Also see [method`Gtk`.set_text].
1687 ///
1688 /// This is a convenience property which will take care of getting the
1689 /// tooltip shown if the given string is not `NULL`:
1690 /// [property`Gtk`:has-tooltip] will automatically be set to true
1691 /// and there will be taken care of [signal`Gtk`::query-tooltip] in
1692 /// the default signal handler.
1693 ///
1694 /// Note that if both [property`Gtk`:tooltip-text] and
1695 /// [property`Gtk`:tooltip-markup] are set, the last one wins.
1696 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1697 Self {
1698 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1699 }
1700 }
1701
1702 //pub fn valign(self, valign: /*Ignored*/gtk::Align) -> Self {
1703 // Self { builder: self.builder.property("valign", valign), }
1704 //}
1705
1706 /// Whether to expand vertically.
1707 pub fn vexpand(self, vexpand: bool) -> Self {
1708 Self {
1709 builder: self.builder.property("vexpand", vexpand),
1710 }
1711 }
1712
1713 /// Whether to use the `vexpand` property.
1714 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1715 Self {
1716 builder: self.builder.property("vexpand-set", vexpand_set),
1717 }
1718 }
1719
1720 /// Whether the widget is visible.
1721 pub fn visible(self, visible: bool) -> Self {
1722 Self {
1723 builder: self.builder.property("visible", visible),
1724 }
1725 }
1726
1727 /// Overrides for width request of the widget.
1728 ///
1729 /// If this is -1, the natural request will be used.
1730 pub fn width_request(self, width_request: i32) -> Self {
1731 Self {
1732 builder: self.builder.property("width-request", width_request),
1733 }
1734 }
1735
1736 //pub fn accessible_role(self, accessible_role: /*Ignored*/gtk::AccessibleRole) -> Self {
1737 // Self { builder: self.builder.property("accessible-role", accessible_role), }
1738 //}
1739
1740 // rustdoc-stripper-ignore-next
1741 /// Build the [`WebView`].
1742 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1743 pub fn build(self) -> WebView {
1744 assert_initialized_main_thread!();
1745 self.builder.build()
1746 }
1747}
1748
1749/// Trait containing all [`struct@WebView`] methods.
1750///
1751/// # Implementors
1752///
1753/// [`WebView`][struct@crate::WebView]
1754pub trait WebViewExt: IsA<WebView> + 'static {
1755 /// Asynchronously call `body` with `arguments` in the script world with name `world_name` of the main frame current context in `self`.
1756 /// The `arguments` values must be one of the following types, or contain only the following GVariant types: number, string and dictionary.
1757 /// The result of the operation can be a Promise that will be properly passed to the callback.
1758 /// If `world_name` is [`None`], the default world is used. Any value that is not [`None`] is a distin ct world.
1759 /// The `source_uri` will be shown in exceptions and doesn't affect the behavior of the script.
1760 /// When not provided, the document URL is used.
1761 ///
1762 /// Note that if [`enable-javascript`][struct@crate::Settings#enable-javascript] is [`false`], this method will do nothing.
1763 /// If you want to use this method but still prevent web content from executing its own
1764 /// JavaScript, then use [`enable-javascript-markup`][struct@crate::Settings#enable-javascript-markup].
1765 ///
1766 /// When the operation is finished, `callback` will be called. You can then call
1767 /// `webkit_web_view_call_async_javascript_function_finish()` to get the result of the operation.
1768 ///
1769 /// This is an example that shows how to pass arguments to a JS function that returns a Promise
1770 /// that resolves with the passed argument:
1771 ///
1772 /// **⚠️ The following code is in c ⚠️**
1773 ///
1774 /// ```c
1775 /// static void
1776 /// web_view_javascript_finished (GObject *object,
1777 /// GAsyncResult *result,
1778 /// gpointer user_data)
1779 /// {
1780 /// JSCValue *value;
1781 /// GError *error = NULL;
1782 ///
1783 /// value = webkit_web_view_call_async_javascript_function_finish (WEBKIT_WEB_VIEW (object), result, &error);
1784 /// if (!value) {
1785 /// g_warning ("Error running javascript: %s", error->message);
1786 /// g_error_free (error);
1787 /// return;
1788 /// }
1789 ///
1790 /// if (jsc_value_is_number (value)) {
1791 /// gint32 int_value = jsc_value_to_string (value);
1792 /// JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
1793 /// if (exception)
1794 /// g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
1795 /// else
1796 /// g_print ("Script result: %d\n", int_value);
1797 /// g_free (str_value);
1798 /// } else {
1799 /// g_warning ("Error running javascript: unexpected return value");
1800 /// }
1801 /// g_object_unref (value);
1802 /// }
1803 ///
1804 /// static void
1805 /// web_view_evaluate_promise (WebKitWebView *web_view)
1806 /// {
1807 /// GVariantDict dict;
1808 /// g_variant_dict_init (&dict, NULL);
1809 /// g_variant_dict_insert (&dict, "count", "u", 42);
1810 /// GVariant *args = g_variant_dict_end (&dict);
1811 /// const gchar *body = "return new Promise((resolve) => { resolve(count); });";
1812 /// webkit_web_view_call_async_javascript_function (web_view, body, -1, arguments, NULL, NULL, NULL, web_view_javascript_finished, NULL);
1813 /// }
1814 /// ```
1815 /// ## `body`
1816 /// the function body
1817 /// ## `length`
1818 /// length of `body`, or -1 if `body` is a nul-terminated string
1819 /// ## `arguments`
1820 /// a [`glib::Variant`][struct@crate::glib::Variant] with format `a{sv}` storing the function arguments, or [`None`]
1821 /// ## `world_name`
1822 /// the name of a `WebKitScriptWorld` or [`None`] to use the default
1823 /// ## `source_uri`
1824 /// the source URI
1825 /// ## `cancellable`
1826 /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`] to ignore
1827 /// ## `callback`
1828 /// a `GAsyncReadyCallback` to call when the script finished
1829 #[doc(alias = "webkit_web_view_call_async_javascript_function")]
1830 fn call_async_javascript_function<
1831 P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static,
1832 >(
1833 &self,
1834 body: &str,
1835 arguments: Option<&glib::Variant>,
1836 world_name: Option<&str>,
1837 source_uri: Option<&str>,
1838 cancellable: Option<&impl IsA<gio::Cancellable>>,
1839 callback: P,
1840 ) {
1841 let length = body.len() as _;
1842
1843 let main_context = glib::MainContext::ref_thread_default();
1844 let is_main_context_owner = main_context.is_owner();
1845 let has_acquired_main_context = (!is_main_context_owner)
1846 .then(|| main_context.acquire().ok())
1847 .flatten();
1848 assert!(
1849 is_main_context_owner || has_acquired_main_context.is_some(),
1850 "Async operations only allowed if the thread is owning the MainContext"
1851 );
1852
1853 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1854 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1855 unsafe extern "C" fn call_async_javascript_function_trampoline<
1856 P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static,
1857 >(
1858 _source_object: *mut glib::gobject_ffi::GObject,
1859 res: *mut gio::ffi::GAsyncResult,
1860 user_data: glib::ffi::gpointer,
1861 ) {
1862 unsafe {
1863 let mut error = std::ptr::null_mut();
1864 let ret = ffi::webkit_web_view_call_async_javascript_function_finish(
1865 _source_object as *mut _,
1866 res,
1867 &mut error,
1868 );
1869 let result = if error.is_null() {
1870 Ok(from_glib_full(ret))
1871 } else {
1872 Err(from_glib_full(error))
1873 };
1874 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1875 Box_::from_raw(user_data as *mut _);
1876 let callback: P = callback.into_inner();
1877 callback(result);
1878 }
1879 }
1880 let callback = call_async_javascript_function_trampoline::<P>;
1881 unsafe {
1882 ffi::webkit_web_view_call_async_javascript_function(
1883 self.as_ref().to_glib_none().0,
1884 body.to_glib_none().0,
1885 length,
1886 arguments.to_glib_none().0,
1887 world_name.to_glib_none().0,
1888 source_uri.to_glib_none().0,
1889 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1890 Some(callback),
1891 Box_::into_raw(user_data) as *mut _,
1892 );
1893 }
1894 }
1895
1896 fn call_async_javascript_function_future(
1897 &self,
1898 body: &str,
1899 arguments: Option<&glib::Variant>,
1900 world_name: Option<&str>,
1901 source_uri: Option<&str>,
1902 ) -> Pin<
1903 Box_<
1904 dyn std::future::Future<Output = Result<javascriptcore::Value, glib::Error>> + 'static,
1905 >,
1906 > {
1907 let body = String::from(body);
1908 let arguments = arguments.map(ToOwned::to_owned);
1909 let world_name = world_name.map(ToOwned::to_owned);
1910 let source_uri = source_uri.map(ToOwned::to_owned);
1911 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1912 obj.call_async_javascript_function(
1913 &body,
1914 arguments.as_ref().map(::std::borrow::Borrow::borrow),
1915 world_name.as_ref().map(::std::borrow::Borrow::borrow),
1916 source_uri.as_ref().map(::std::borrow::Borrow::borrow),
1917 Some(cancellable),
1918 move |res| {
1919 send.resolve(res);
1920 },
1921 );
1922 }))
1923 }
1924
1925 /// Asynchronously check if it is possible to execute the given editing command.
1926 ///
1927 /// When the operation is finished, `callback` will be called. You can then call
1928 /// `webkit_web_view_can_execute_editing_command_finish()` to get the result of the operation.
1929 /// ## `command`
1930 /// the command to check
1931 /// ## `cancellable`
1932 /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`] to ignore
1933 /// ## `callback`
1934 /// a `GAsyncReadyCallback` to call when the request is satisfied
1935 #[doc(alias = "webkit_web_view_can_execute_editing_command")]
1936 fn can_execute_editing_command<P: FnOnce(Result<(), glib::Error>) + 'static>(
1937 &self,
1938 command: &str,
1939 cancellable: Option<&impl IsA<gio::Cancellable>>,
1940 callback: P,
1941 ) {
1942 let main_context = glib::MainContext::ref_thread_default();
1943 let is_main_context_owner = main_context.is_owner();
1944 let has_acquired_main_context = (!is_main_context_owner)
1945 .then(|| main_context.acquire().ok())
1946 .flatten();
1947 assert!(
1948 is_main_context_owner || has_acquired_main_context.is_some(),
1949 "Async operations only allowed if the thread is owning the MainContext"
1950 );
1951
1952 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1953 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1954 unsafe extern "C" fn can_execute_editing_command_trampoline<
1955 P: FnOnce(Result<(), glib::Error>) + 'static,
1956 >(
1957 _source_object: *mut glib::gobject_ffi::GObject,
1958 res: *mut gio::ffi::GAsyncResult,
1959 user_data: glib::ffi::gpointer,
1960 ) {
1961 unsafe {
1962 let mut error = std::ptr::null_mut();
1963 ffi::webkit_web_view_can_execute_editing_command_finish(
1964 _source_object as *mut _,
1965 res,
1966 &mut error,
1967 );
1968 let result = if error.is_null() {
1969 Ok(())
1970 } else {
1971 Err(from_glib_full(error))
1972 };
1973 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1974 Box_::from_raw(user_data as *mut _);
1975 let callback: P = callback.into_inner();
1976 callback(result);
1977 }
1978 }
1979 let callback = can_execute_editing_command_trampoline::<P>;
1980 unsafe {
1981 ffi::webkit_web_view_can_execute_editing_command(
1982 self.as_ref().to_glib_none().0,
1983 command.to_glib_none().0,
1984 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1985 Some(callback),
1986 Box_::into_raw(user_data) as *mut _,
1987 );
1988 }
1989 }
1990
1991 fn can_execute_editing_command_future(
1992 &self,
1993 command: &str,
1994 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1995 let command = String::from(command);
1996 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1997 obj.can_execute_editing_command(&command, Some(cancellable), move |res| {
1998 send.resolve(res);
1999 });
2000 }))
2001 }
2002
2003 /// Determines whether `self` has a previous history item.
2004 ///
2005 /// # Returns
2006 ///
2007 /// [`true`] if able to move back or [`false`] otherwise.
2008 #[doc(alias = "webkit_web_view_can_go_back")]
2009 fn can_go_back(&self) -> bool {
2010 unsafe {
2011 from_glib(ffi::webkit_web_view_can_go_back(
2012 self.as_ref().to_glib_none().0,
2013 ))
2014 }
2015 }
2016
2017 /// Determines whether `self` has a next history item.
2018 ///
2019 /// # Returns
2020 ///
2021 /// [`true`] if able to move forward or [`false`] otherwise.
2022 #[doc(alias = "webkit_web_view_can_go_forward")]
2023 fn can_go_forward(&self) -> bool {
2024 unsafe {
2025 from_glib(ffi::webkit_web_view_can_go_forward(
2026 self.as_ref().to_glib_none().0,
2027 ))
2028 }
2029 }
2030
2031 /// Whether or not a MIME type can be displayed in `self`.
2032 /// ## `mime_type`
2033 /// a MIME type
2034 ///
2035 /// # Returns
2036 ///
2037 /// [`true`] if the MIME type `mime_type` can be displayed or [`false`] otherwise
2038 #[doc(alias = "webkit_web_view_can_show_mime_type")]
2039 fn can_show_mime_type(&self, mime_type: &str) -> bool {
2040 unsafe {
2041 from_glib(ffi::webkit_web_view_can_show_mime_type(
2042 self.as_ref().to_glib_none().0,
2043 mime_type.to_glib_none().0,
2044 ))
2045 }
2046 }
2047
2048 /// Requests downloading of the specified URI string for `self`.
2049 /// ## `uri`
2050 /// the URI to download
2051 ///
2052 /// # Returns
2053 ///
2054 /// a new [`Download`][crate::Download] representing
2055 /// the download operation.
2056 #[doc(alias = "webkit_web_view_download_uri")]
2057 fn download_uri(&self, uri: &str) -> Option<Download> {
2058 unsafe {
2059 from_glib_full(ffi::webkit_web_view_download_uri(
2060 self.as_ref().to_glib_none().0,
2061 uri.to_glib_none().0,
2062 ))
2063 }
2064 }
2065
2066 /// Asynchronously evaluate `script` in the script world with name `world_name` of the main frame current context in `self`.
2067 /// If `world_name` is [`None`], the default world is used. Any value that is not [`None`] is a distinct world.
2068 /// The `source_uri` will be shown in exceptions and doesn't affect the behavior of the script.
2069 /// When not provided, the document URL is used.
2070 ///
2071 /// Note that if [`enable-javascript`][struct@crate::Settings#enable-javascript] is [`false`], this method will do nothing.
2072 /// If you want to use this method but still prevent web content from executing its own
2073 /// JavaScript, then use [`enable-javascript-markup`][struct@crate::Settings#enable-javascript-markup].
2074 ///
2075 /// When the operation is finished, `callback` will be called. You can then call
2076 /// `webkit_web_view_evaluate_javascript_finish()` to get the result of the operation.
2077 ///
2078 /// This is an example of using [`evaluate_javascript()`][Self::evaluate_javascript()] with a script returning
2079 /// a string:
2080 ///
2081 /// **⚠️ The following code is in c ⚠️**
2082 ///
2083 /// ```c
2084 /// static void
2085 /// web_view_javascript_finished (GObject *object,
2086 /// GAsyncResult *result,
2087 /// gpointer user_data)
2088 /// {
2089 /// JSCValue *value;
2090 /// GError *error = NULL;
2091 ///
2092 /// value = webkit_web_view_evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error);
2093 /// if (!value) {
2094 /// g_warning ("Error running javascript: %s", error->message);
2095 /// g_error_free (error);
2096 /// return;
2097 /// }
2098 ///
2099 /// if (jsc_value_is_string (value)) {
2100 /// gchar *str_value = jsc_value_to_string (value);
2101 /// JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
2102 /// if (exception)
2103 /// g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
2104 /// else
2105 /// g_print ("Script result: %s\n", str_value);
2106 /// g_free (str_value);
2107 /// } else {
2108 /// g_warning ("Error running javascript: unexpected return value");
2109 /// }
2110 /// g_object_unref (value);
2111 /// }
2112 ///
2113 /// static void
2114 /// web_view_get_link_url (WebKitWebView *web_view,
2115 /// const gchar *link_id)
2116 /// {
2117 /// gchar *script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id);
2118 /// webkit_web_view_evaluate_javascript (web_view, script, -1, NULL, NULL, NULL, web_view_javascript_finished, NULL);
2119 /// g_free (script);
2120 /// }
2121 /// ```
2122 /// ## `script`
2123 /// the script to evaluate
2124 /// ## `length`
2125 /// length of `script`, or -1 if `script` is a nul-terminated string
2126 /// ## `world_name`
2127 /// the name of a `WebKitScriptWorld` or [`None`] to use the default
2128 /// ## `source_uri`
2129 /// the source URI
2130 /// ## `cancellable`
2131 /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`] to ignore
2132 /// ## `callback`
2133 /// a `GAsyncReadyCallback` to call when the script finished
2134 #[doc(alias = "webkit_web_view_evaluate_javascript")]
2135 fn evaluate_javascript<P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static>(
2136 &self,
2137 script: &str,
2138 world_name: Option<&str>,
2139 source_uri: Option<&str>,
2140 cancellable: Option<&impl IsA<gio::Cancellable>>,
2141 callback: P,
2142 ) {
2143 let length = script.len() as _;
2144
2145 let main_context = glib::MainContext::ref_thread_default();
2146 let is_main_context_owner = main_context.is_owner();
2147 let has_acquired_main_context = (!is_main_context_owner)
2148 .then(|| main_context.acquire().ok())
2149 .flatten();
2150 assert!(
2151 is_main_context_owner || has_acquired_main_context.is_some(),
2152 "Async operations only allowed if the thread is owning the MainContext"
2153 );
2154
2155 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2156 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2157 unsafe extern "C" fn evaluate_javascript_trampoline<
2158 P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static,
2159 >(
2160 _source_object: *mut glib::gobject_ffi::GObject,
2161 res: *mut gio::ffi::GAsyncResult,
2162 user_data: glib::ffi::gpointer,
2163 ) {
2164 unsafe {
2165 let mut error = std::ptr::null_mut();
2166 let ret = ffi::webkit_web_view_evaluate_javascript_finish(
2167 _source_object as *mut _,
2168 res,
2169 &mut error,
2170 );
2171 let result = if error.is_null() {
2172 Ok(from_glib_full(ret))
2173 } else {
2174 Err(from_glib_full(error))
2175 };
2176 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2177 Box_::from_raw(user_data as *mut _);
2178 let callback: P = callback.into_inner();
2179 callback(result);
2180 }
2181 }
2182 let callback = evaluate_javascript_trampoline::<P>;
2183 unsafe {
2184 ffi::webkit_web_view_evaluate_javascript(
2185 self.as_ref().to_glib_none().0,
2186 script.to_glib_none().0,
2187 length,
2188 world_name.to_glib_none().0,
2189 source_uri.to_glib_none().0,
2190 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2191 Some(callback),
2192 Box_::into_raw(user_data) as *mut _,
2193 );
2194 }
2195 }
2196
2197 fn evaluate_javascript_future(
2198 &self,
2199 script: &str,
2200 world_name: Option<&str>,
2201 source_uri: Option<&str>,
2202 ) -> Pin<
2203 Box_<
2204 dyn std::future::Future<Output = Result<javascriptcore::Value, glib::Error>> + 'static,
2205 >,
2206 > {
2207 let script = String::from(script);
2208 let world_name = world_name.map(ToOwned::to_owned);
2209 let source_uri = source_uri.map(ToOwned::to_owned);
2210 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2211 obj.evaluate_javascript(
2212 &script,
2213 world_name.as_ref().map(::std::borrow::Borrow::borrow),
2214 source_uri.as_ref().map(::std::borrow::Borrow::borrow),
2215 Some(cancellable),
2216 move |res| {
2217 send.resolve(res);
2218 },
2219 );
2220 }))
2221 }
2222
2223 /// Request to execute the given `command` for `self`.
2224 ///
2225 /// You can use [`can_execute_editing_command()`][Self::can_execute_editing_command()] to check whether
2226 /// it's possible to execute the command.
2227 /// ## `command`
2228 /// the command to execute
2229 #[doc(alias = "webkit_web_view_execute_editing_command")]
2230 fn execute_editing_command(&self, command: &str) {
2231 unsafe {
2232 ffi::webkit_web_view_execute_editing_command(
2233 self.as_ref().to_glib_none().0,
2234 command.to_glib_none().0,
2235 );
2236 }
2237 }
2238
2239 /// Request to execute the given `command` with `argument` for `self`.
2240 ///
2241 /// You can use
2242 /// [`can_execute_editing_command()`][Self::can_execute_editing_command()] to check whether
2243 /// it's possible to execute the command.
2244 /// ## `command`
2245 /// the command to execute
2246 /// ## `argument`
2247 /// the command argument
2248 #[doc(alias = "webkit_web_view_execute_editing_command_with_argument")]
2249 fn execute_editing_command_with_argument(&self, command: &str, argument: &str) {
2250 unsafe {
2251 ffi::webkit_web_view_execute_editing_command_with_argument(
2252 self.as_ref().to_glib_none().0,
2253 command.to_glib_none().0,
2254 argument.to_glib_none().0,
2255 );
2256 }
2257 }
2258
2259 /// Get the presentation type of [`WebView`][crate::WebView] when created for automation.
2260 ///
2261 /// # Returns
2262 ///
2263 /// a [`AutomationBrowsingContextPresentation`][crate::AutomationBrowsingContextPresentation].
2264 #[doc(alias = "webkit_web_view_get_automation_presentation_type")]
2265 #[doc(alias = "get_automation_presentation_type")]
2266 #[doc(alias = "automation-presentation-type")]
2267 fn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation {
2268 unsafe {
2269 from_glib(ffi::webkit_web_view_get_automation_presentation_type(
2270 self.as_ref().to_glib_none().0,
2271 ))
2272 }
2273 }
2274
2275 /// Obtains the [`BackForwardList`][crate::BackForwardList] associated with the given [`WebView`][crate::WebView].
2276 ///
2277 /// The [`BackForwardList`][crate::BackForwardList] is owned by the [`WebView`][crate::WebView].
2278 ///
2279 /// # Returns
2280 ///
2281 /// the [`BackForwardList`][crate::BackForwardList]
2282 #[doc(alias = "webkit_web_view_get_back_forward_list")]
2283 #[doc(alias = "get_back_forward_list")]
2284 fn back_forward_list(&self) -> Option<BackForwardList> {
2285 unsafe {
2286 from_glib_none(ffi::webkit_web_view_get_back_forward_list(
2287 self.as_ref().to_glib_none().0,
2288 ))
2289 }
2290 }
2291
2292 /// Gets the color that is used to draw the `self` background.
2293 ///
2294 /// Gets the color that is used to draw the `self` background before
2295 /// the actual contents are rendered.
2296 /// For more information see also [`set_background_color()`][Self::set_background_color()]
2297 ///
2298 /// # Returns
2299 ///
2300 ///
2301 /// ## `rgba`
2302 /// a [`gdk::RGBA`][crate::gdk::RGBA] to fill in with the background color
2303 #[doc(alias = "webkit_web_view_get_background_color")]
2304 #[doc(alias = "get_background_color")]
2305 fn background_color(&self) -> gdk::RGBA {
2306 unsafe {
2307 let mut rgba = gdk::RGBA::uninitialized();
2308 ffi::webkit_web_view_get_background_color(
2309 self.as_ref().to_glib_none().0,
2310 rgba.to_glib_none_mut().0,
2311 );
2312 rgba
2313 }
2314 }
2315
2316 /// Get the camera capture state of a [`WebView`][crate::WebView].
2317 ///
2318 /// # Returns
2319 ///
2320 /// The [`MediaCaptureState`][crate::MediaCaptureState] of the camera device. If [`enable-mediastream`][struct@crate::Settings#enable-mediastream]
2321 /// is [`false`], this method will return [`MediaCaptureState::None`][crate::MediaCaptureState::None].
2322 #[doc(alias = "webkit_web_view_get_camera_capture_state")]
2323 #[doc(alias = "get_camera_capture_state")]
2324 #[doc(alias = "camera-capture-state")]
2325 fn camera_capture_state(&self) -> MediaCaptureState {
2326 unsafe {
2327 from_glib(ffi::webkit_web_view_get_camera_capture_state(
2328 self.as_ref().to_glib_none().0,
2329 ))
2330 }
2331 }
2332
2333 /// Gets the web context of `self`.
2334 ///
2335 /// # Returns
2336 ///
2337 /// the [`WebContext`][crate::WebContext] of the view
2338 #[doc(alias = "webkit_web_view_get_context")]
2339 #[doc(alias = "get_context")]
2340 fn context(&self) -> Option<WebContext> {
2341 unsafe {
2342 from_glib_none(ffi::webkit_web_view_get_context(
2343 self.as_ref().to_glib_none().0,
2344 ))
2345 }
2346 }
2347
2348 /// Returns the current custom character encoding name of `self`.
2349 ///
2350 /// # Returns
2351 ///
2352 /// the current custom character encoding name or [`None`] if no
2353 /// custom character encoding has been set.
2354 #[doc(alias = "webkit_web_view_get_custom_charset")]
2355 #[doc(alias = "get_custom_charset")]
2356 fn custom_charset(&self) -> Option<glib::GString> {
2357 unsafe {
2358 from_glib_none(ffi::webkit_web_view_get_custom_charset(
2359 self.as_ref().to_glib_none().0,
2360 ))
2361 }
2362 }
2363
2364 /// Gets the configured default Content-Security-Policy.
2365 ///
2366 /// # Returns
2367 ///
2368 /// The default policy or [`None`]
2369 #[doc(alias = "webkit_web_view_get_default_content_security_policy")]
2370 #[doc(alias = "get_default_content_security_policy")]
2371 #[doc(alias = "default-content-security-policy")]
2372 fn default_content_security_policy(&self) -> Option<glib::GString> {
2373 unsafe {
2374 from_glib_none(ffi::webkit_web_view_get_default_content_security_policy(
2375 self.as_ref().to_glib_none().0,
2376 ))
2377 }
2378 }
2379
2380 /// Get the display capture state of a [`WebView`][crate::WebView].
2381 ///
2382 /// # Returns
2383 ///
2384 /// The [`MediaCaptureState`][crate::MediaCaptureState] of the display device. If [`enable-mediastream`][struct@crate::Settings#enable-mediastream]
2385 /// is [`false`], this method will return [`MediaCaptureState::None`][crate::MediaCaptureState::None].
2386 #[doc(alias = "webkit_web_view_get_display_capture_state")]
2387 #[doc(alias = "get_display_capture_state")]
2388 #[doc(alias = "display-capture-state")]
2389 fn display_capture_state(&self) -> MediaCaptureState {
2390 unsafe {
2391 from_glib(ffi::webkit_web_view_get_display_capture_state(
2392 self.as_ref().to_glib_none().0,
2393 ))
2394 }
2395 }
2396
2397 /// Gets the web editor state of `self`.
2398 ///
2399 /// # Returns
2400 ///
2401 /// the [`EditorState`][crate::EditorState] of the view
2402 #[doc(alias = "webkit_web_view_get_editor_state")]
2403 #[doc(alias = "get_editor_state")]
2404 fn editor_state(&self) -> Option<EditorState> {
2405 unsafe {
2406 from_glib_none(ffi::webkit_web_view_get_editor_state(
2407 self.as_ref().to_glib_none().0,
2408 ))
2409 }
2410 }
2411
2412 /// Gets the value of the [`estimated-load-progress`][struct@crate::WebView#estimated-load-progress] property.
2413 ///
2414 /// You can monitor the estimated progress of a load operation by
2415 /// connecting to the notify::estimated-load-progress signal of `self`.
2416 ///
2417 /// # Returns
2418 ///
2419 /// an estimate of the of the percent complete for a document
2420 /// load as a range from 0.0 to 1.0.
2421 #[doc(alias = "webkit_web_view_get_estimated_load_progress")]
2422 #[doc(alias = "get_estimated_load_progress")]
2423 #[doc(alias = "estimated-load-progress")]
2424 fn estimated_load_progress(&self) -> f64 {
2425 unsafe { ffi::webkit_web_view_get_estimated_load_progress(self.as_ref().to_glib_none().0) }
2426 }
2427
2428 /// Returns favicon currently associated to `self`.
2429 ///
2430 /// Returns favicon currently associated to `self`, if any. You can
2431 /// connect to notify::favicon signal of `self` to be notified when
2432 /// the favicon is available.
2433 ///
2434 /// # Returns
2435 ///
2436 /// the favicon image or [`None`] if there's no
2437 /// icon associated with `self`.
2438 #[doc(alias = "webkit_web_view_get_favicon")]
2439 #[doc(alias = "get_favicon")]
2440 fn favicon(&self) -> Option<gdk::Texture> {
2441 unsafe {
2442 from_glib_none(ffi::webkit_web_view_get_favicon(
2443 self.as_ref().to_glib_none().0,
2444 ))
2445 }
2446 }
2447
2448 /// Gets the [`FindController`][crate::FindController].
2449 ///
2450 /// Gets the [`FindController`][crate::FindController] that will allow the caller to query
2451 /// the [`WebView`][crate::WebView] for the text to look for.
2452 ///
2453 /// # Returns
2454 ///
2455 /// the [`FindController`][crate::FindController] associated to
2456 /// this particular [`WebView`][crate::WebView].
2457 #[doc(alias = "webkit_web_view_get_find_controller")]
2458 #[doc(alias = "get_find_controller")]
2459 fn find_controller(&self) -> Option<FindController> {
2460 unsafe {
2461 from_glib_none(ffi::webkit_web_view_get_find_controller(
2462 self.as_ref().to_glib_none().0,
2463 ))
2464 }
2465 }
2466
2467 /// Get the [`InputMethodContext`][crate::InputMethodContext] currently in use by `self`.
2468 ///
2469 /// Get the [`InputMethodContext`][crate::InputMethodContext] currently in use by `self`, or [`None`] if no input method is being used.
2470 ///
2471 /// # Returns
2472 ///
2473 /// a [`InputMethodContext`][crate::InputMethodContext], or [`None`]
2474 #[doc(alias = "webkit_web_view_get_input_method_context")]
2475 #[doc(alias = "get_input_method_context")]
2476 fn input_method_context(&self) -> Option<InputMethodContext> {
2477 unsafe {
2478 from_glib_none(ffi::webkit_web_view_get_input_method_context(
2479 self.as_ref().to_glib_none().0,
2480 ))
2481 }
2482 }
2483
2484 /// Get the [`WebInspector`][crate::WebInspector] associated to `self`
2485 ///
2486 /// # Returns
2487 ///
2488 /// the [`WebInspector`][crate::WebInspector] of `self`
2489 #[doc(alias = "webkit_web_view_get_inspector")]
2490 #[doc(alias = "get_inspector")]
2491 fn inspector(&self) -> Option<WebInspector> {
2492 unsafe {
2493 from_glib_none(ffi::webkit_web_view_get_inspector(
2494 self.as_ref().to_glib_none().0,
2495 ))
2496 }
2497 }
2498
2499 /// Gets the mute state of `self`.
2500 ///
2501 /// # Returns
2502 ///
2503 /// [`true`] if `self` audio is muted or [`false`] is audio is not muted.
2504 #[doc(alias = "webkit_web_view_get_is_muted")]
2505 #[doc(alias = "get_is_muted")]
2506 #[doc(alias = "is-muted")]
2507 fn is_muted(&self) -> bool {
2508 unsafe {
2509 from_glib(ffi::webkit_web_view_get_is_muted(
2510 self.as_ref().to_glib_none().0,
2511 ))
2512 }
2513 }
2514
2515 /// Get whether the current web process of a [`WebView`][crate::WebView] is responsive.
2516 ///
2517 /// # Returns
2518 ///
2519 /// [`true`] if the web process attached to `self` is responsive, or [`false`] otherwise.
2520 #[doc(alias = "webkit_web_view_get_is_web_process_responsive")]
2521 #[doc(alias = "get_is_web_process_responsive")]
2522 #[doc(alias = "is-web-process-responsive")]
2523 fn is_web_process_responsive(&self) -> bool {
2524 unsafe {
2525 from_glib(ffi::webkit_web_view_get_is_web_process_responsive(
2526 self.as_ref().to_glib_none().0,
2527 ))
2528 }
2529 }
2530
2531 /// Return the main resource of `self`.
2532 ///
2533 /// # Returns
2534 ///
2535 /// the main [`WebResource`][crate::WebResource] of the view
2536 /// or [`None`] if nothing has been loaded.
2537 #[doc(alias = "webkit_web_view_get_main_resource")]
2538 #[doc(alias = "get_main_resource")]
2539 fn main_resource(&self) -> Option<WebResource> {
2540 unsafe {
2541 from_glib_none(ffi::webkit_web_view_get_main_resource(
2542 self.as_ref().to_glib_none().0,
2543 ))
2544 }
2545 }
2546
2547 /// Get the microphone capture state of a [`WebView`][crate::WebView].
2548 ///
2549 /// # Returns
2550 ///
2551 /// The [`MediaCaptureState`][crate::MediaCaptureState] of the microphone device. If [`enable-mediastream`][struct@crate::Settings#enable-mediastream]
2552 /// is [`false`], this method will return [`MediaCaptureState::None`][crate::MediaCaptureState::None].
2553 #[doc(alias = "webkit_web_view_get_microphone_capture_state")]
2554 #[doc(alias = "get_microphone_capture_state")]
2555 #[doc(alias = "microphone-capture-state")]
2556 fn microphone_capture_state(&self) -> MediaCaptureState {
2557 unsafe {
2558 from_glib(ffi::webkit_web_view_get_microphone_capture_state(
2559 self.as_ref().to_glib_none().0,
2560 ))
2561 }
2562 }
2563
2564 /// Get the [`NetworkSession`][crate::NetworkSession] associated to `self`.
2565 ///
2566 /// # Returns
2567 ///
2568 /// a [`NetworkSession`][crate::NetworkSession]
2569 #[doc(alias = "webkit_web_view_get_network_session")]
2570 #[doc(alias = "get_network_session")]
2571 #[doc(alias = "network-session")]
2572 fn network_session(&self) -> Option<NetworkSession> {
2573 unsafe {
2574 from_glib_none(ffi::webkit_web_view_get_network_session(
2575 self.as_ref().to_glib_none().0,
2576 ))
2577 }
2578 }
2579
2580 /// Get the identifier of the `WebKitWebPage` corresponding to
2581 /// the [`WebView`][crate::WebView]
2582 ///
2583 /// # Returns
2584 ///
2585 /// the page ID of `self`.
2586 #[doc(alias = "webkit_web_view_get_page_id")]
2587 #[doc(alias = "get_page_id")]
2588 #[doc(alias = "page-id")]
2589 fn page_id(&self) -> u64 {
2590 unsafe { ffi::webkit_web_view_get_page_id(self.as_ref().to_glib_none().0) }
2591 }
2592
2593 /// Gets the current session state of `self`
2594 ///
2595 /// # Returns
2596 ///
2597 /// a [`WebViewSessionState`][crate::WebViewSessionState]
2598 #[doc(alias = "webkit_web_view_get_session_state")]
2599 #[doc(alias = "get_session_state")]
2600 fn session_state(&self) -> Option<WebViewSessionState> {
2601 unsafe {
2602 from_glib_full(ffi::webkit_web_view_get_session_state(
2603 self.as_ref().to_glib_none().0,
2604 ))
2605 }
2606 }
2607
2608 /// Gets the [`Settings`][crate::Settings] currently applied to `self`.
2609 ///
2610 /// If no other [`Settings`][crate::Settings] have been explicitly applied to
2611 /// `self` with [`set_settings()`][Self::set_settings()], the default
2612 /// [`Settings`][crate::Settings] will be returned. This method always returns
2613 /// a valid [`Settings`][crate::Settings] object.
2614 /// To modify any of the `self` settings, you can either create
2615 /// a new [`Settings`][crate::Settings] object with [`Settings::new()`][crate::Settings::new()], setting
2616 /// the desired preferences, and then replace the existing `self`
2617 /// settings with [`set_settings()`][Self::set_settings()] or get the existing
2618 /// `self` settings and update it directly. [`Settings`][crate::Settings] objects
2619 /// can be shared by multiple [`WebView`][crate::WebView]<!-- -->s, so modifying
2620 /// the settings of a [`WebView`][crate::WebView] would affect other
2621 /// [`WebView`][crate::WebView]<!-- -->s using the same [`Settings`][crate::Settings].
2622 ///
2623 /// # Returns
2624 ///
2625 /// the [`Settings`][crate::Settings] attached to `self`
2626 #[doc(alias = "webkit_web_view_get_settings")]
2627 #[doc(alias = "get_settings")]
2628 fn settings(&self) -> Option<Settings> {
2629 unsafe {
2630 from_glib_none(ffi::webkit_web_view_get_settings(
2631 self.as_ref().to_glib_none().0,
2632 ))
2633 }
2634 }
2635
2636 /// Asynchronously retrieves a snapshot of `self` for `region`.
2637 ///
2638 /// `options` specifies how the snapshot should be rendered.
2639 ///
2640 /// When the operation is finished, `callback` will be called. You must
2641 /// call `webkit_web_view_get_snapshot_finish()` to get the result of the
2642 /// operation.
2643 /// ## `region`
2644 /// the [`SnapshotRegion`][crate::SnapshotRegion] for this snapshot
2645 /// ## `options`
2646 /// [`SnapshotOptions`][crate::SnapshotOptions] for the snapshot
2647 /// ## `cancellable`
2648 /// a [`gio::Cancellable`][crate::gio::Cancellable]
2649 /// ## `callback`
2650 /// a `GAsyncReadyCallback`
2651 #[doc(alias = "webkit_web_view_get_snapshot")]
2652 #[doc(alias = "get_snapshot")]
2653 fn snapshot<P: FnOnce(Result<gdk::Texture, glib::Error>) + 'static>(
2654 &self,
2655 region: SnapshotRegion,
2656 options: SnapshotOptions,
2657 cancellable: Option<&impl IsA<gio::Cancellable>>,
2658 callback: P,
2659 ) {
2660 let main_context = glib::MainContext::ref_thread_default();
2661 let is_main_context_owner = main_context.is_owner();
2662 let has_acquired_main_context = (!is_main_context_owner)
2663 .then(|| main_context.acquire().ok())
2664 .flatten();
2665 assert!(
2666 is_main_context_owner || has_acquired_main_context.is_some(),
2667 "Async operations only allowed if the thread is owning the MainContext"
2668 );
2669
2670 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2671 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2672 unsafe extern "C" fn snapshot_trampoline<
2673 P: FnOnce(Result<gdk::Texture, glib::Error>) + 'static,
2674 >(
2675 _source_object: *mut glib::gobject_ffi::GObject,
2676 res: *mut gio::ffi::GAsyncResult,
2677 user_data: glib::ffi::gpointer,
2678 ) {
2679 unsafe {
2680 let mut error = std::ptr::null_mut();
2681 let ret = ffi::webkit_web_view_get_snapshot_finish(
2682 _source_object as *mut _,
2683 res,
2684 &mut error,
2685 );
2686 let result = if error.is_null() {
2687 Ok(from_glib_full(ret))
2688 } else {
2689 Err(from_glib_full(error))
2690 };
2691 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2692 Box_::from_raw(user_data as *mut _);
2693 let callback: P = callback.into_inner();
2694 callback(result);
2695 }
2696 }
2697 let callback = snapshot_trampoline::<P>;
2698 unsafe {
2699 ffi::webkit_web_view_get_snapshot(
2700 self.as_ref().to_glib_none().0,
2701 region.into_glib(),
2702 options.into_glib(),
2703 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2704 Some(callback),
2705 Box_::into_raw(user_data) as *mut _,
2706 );
2707 }
2708 }
2709
2710 fn snapshot_future(
2711 &self,
2712 region: SnapshotRegion,
2713 options: SnapshotOptions,
2714 ) -> Pin<Box_<dyn std::future::Future<Output = Result<gdk::Texture, glib::Error>> + 'static>>
2715 {
2716 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2717 obj.snapshot(region, options, Some(cancellable), move |res| {
2718 send.resolve(res);
2719 });
2720 }))
2721 }
2722
2723 /// Gets the theme color that is specified by the content in the `self`.
2724 /// If the `self` doesn't have a theme color it will fill the `rgba`
2725 /// with transparent black content.
2726 ///
2727 /// # Returns
2728 ///
2729 /// Whether the currently loaded page defines a theme color.
2730 ///
2731 /// ## `rgba`
2732 /// a [`gdk::RGBA`][crate::gdk::RGBA] to fill in with the theme color
2733 #[cfg(feature = "v2_50")]
2734 #[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
2735 #[doc(alias = "webkit_web_view_get_theme_color")]
2736 #[doc(alias = "get_theme_color")]
2737 #[doc(alias = "theme-color")]
2738 fn theme_color(&self) -> Option<gdk::RGBA> {
2739 unsafe {
2740 let mut rgba = gdk::RGBA::uninitialized();
2741 let ret = from_glib(ffi::webkit_web_view_get_theme_color(
2742 self.as_ref().to_glib_none().0,
2743 rgba.to_glib_none_mut().0,
2744 ));
2745 if ret { Some(rgba) } else { None }
2746 }
2747 }
2748
2749 /// Gets the value of the [`title`][struct@crate::WebView#title] property.
2750 ///
2751 /// You can connect to notify::title signal of `self` to
2752 /// be notified when the title has been received.
2753 ///
2754 /// # Returns
2755 ///
2756 /// The main frame document title of `self`.
2757 #[doc(alias = "webkit_web_view_get_title")]
2758 #[doc(alias = "get_title")]
2759 fn title(&self) -> Option<glib::GString> {
2760 unsafe {
2761 from_glib_none(ffi::webkit_web_view_get_title(
2762 self.as_ref().to_glib_none().0,
2763 ))
2764 }
2765 }
2766
2767 /// Retrieves the [`gio::TlsCertificate`][crate::gio::TlsCertificate] associated with the main resource of `self`.
2768 ///
2769 /// Retrieves the [`gio::TlsCertificate`][crate::gio::TlsCertificate] associated with the main resource of `self`,
2770 /// and the [`gio::TlsCertificateFlags`][crate::gio::TlsCertificateFlags] showing what problems, if any, have been found
2771 /// with that certificate.
2772 /// If the connection is not HTTPS, this function returns [`false`].
2773 /// This function should be called after a response has been received from the
2774 /// server, so you can connect to [`load-changed`][struct@crate::WebView#load-changed] and call this function
2775 /// when it's emitted with [`LoadEvent::Committed`][crate::LoadEvent::Committed] event.
2776 ///
2777 /// Note that this function provides no information about the security of the web
2778 /// page if the current [`TLSErrorsPolicy`][crate::TLSErrorsPolicy] is [`TLSErrorsPolicy::Ignore`][crate::TLSErrorsPolicy::Ignore],
2779 /// as subresources of the page may be controlled by an attacker. This function
2780 /// may safely be used to determine the security status of the current page only
2781 /// if the current [`TLSErrorsPolicy`][crate::TLSErrorsPolicy] is [`TLSErrorsPolicy::Fail`][crate::TLSErrorsPolicy::Fail], in
2782 /// which case subresources that fail certificate verification will be blocked.
2783 ///
2784 /// # Returns
2785 ///
2786 /// [`true`] if the `self` connection uses HTTPS and a response has been received
2787 /// from the server, or [`false`] otherwise.
2788 ///
2789 /// ## `certificate`
2790 /// return location for a [`gio::TlsCertificate`][crate::gio::TlsCertificate]
2791 ///
2792 /// ## `errors`
2793 /// return location for a [`gio::TlsCertificateFlags`][crate::gio::TlsCertificateFlags] the verification status of `certificate`
2794 #[doc(alias = "webkit_web_view_get_tls_info")]
2795 #[doc(alias = "get_tls_info")]
2796 fn tls_info(&self) -> Option<(gio::TlsCertificate, gio::TlsCertificateFlags)> {
2797 unsafe {
2798 let mut certificate = std::ptr::null_mut();
2799 let mut errors = std::mem::MaybeUninit::uninit();
2800 let ret = from_glib(ffi::webkit_web_view_get_tls_info(
2801 self.as_ref().to_glib_none().0,
2802 &mut certificate,
2803 errors.as_mut_ptr(),
2804 ));
2805 if ret {
2806 Some((from_glib_none(certificate), from_glib(errors.assume_init())))
2807 } else {
2808 None
2809 }
2810 }
2811 }
2812
2813 /// Returns the current active URI of `self`.
2814 ///
2815 /// The active URI might change during
2816 /// a load operation:
2817 ///
2818 /// `<orderedlist>`
2819 /// `<listitem>``<para>`
2820 /// When nothing has been loaded yet on `self` the active URI is [`None`].
2821 /// `</para>``</listitem>`
2822 /// `<listitem>``<para>`
2823 /// When a new load operation starts the active URI is the requested URI:
2824 /// `<itemizedlist>`
2825 /// `<listitem>``<para>`
2826 /// If the load operation was started by [`load_uri()`][Self::load_uri()],
2827 /// the requested URI is the given one.
2828 /// `</para>``</listitem>`
2829 /// `<listitem>``<para>`
2830 /// If the load operation was started by [`load_html()`][Self::load_html()],
2831 /// the requested URI is "about:blank".
2832 /// `</para>``</listitem>`
2833 /// `<listitem>``<para>`
2834 /// If the load operation was started by [`load_alternate_html()`][Self::load_alternate_html()],
2835 /// the requested URI is content URI provided.
2836 /// `</para>``</listitem>`
2837 /// `<listitem>``<para>`
2838 /// If the load operation was started by [`go_back()`][Self::go_back()] or
2839 /// [`go_forward()`][Self::go_forward()], the requested URI is the original URI
2840 /// of the previous/next item in the [`BackForwardList`][crate::BackForwardList] of `self`.
2841 /// `</para>``</listitem>`
2842 /// `<listitem>``<para>`
2843 /// If the load operation was started by
2844 /// [`go_to_back_forward_list_item()`][Self::go_to_back_forward_list_item()], the requested URI
2845 /// is the opriginal URI of the given [`BackForwardListItem`][crate::BackForwardListItem].
2846 /// `</para>``</listitem>`
2847 /// `</itemizedlist>`
2848 /// `</para>``</listitem>`
2849 /// `<listitem>``<para>`
2850 /// If there is a server redirection during the load operation,
2851 /// the active URI is the redirected URI. When the signal
2852 /// [`load-changed`][struct@crate::WebView#load-changed] is emitted with [`LoadEvent::Redirected`][crate::LoadEvent::Redirected]
2853 /// event, the active URI is already updated to the redirected URI.
2854 /// `</para>``</listitem>`
2855 /// `<listitem>``<para>`
2856 /// When the signal [`load-changed`][struct@crate::WebView#load-changed] is emitted
2857 /// with [`LoadEvent::Committed`][crate::LoadEvent::Committed] event, the active URI is the final
2858 /// one and it will not change unless a new load operation is started
2859 /// or a navigation action within the same page is performed.
2860 /// `</para>``</listitem>`
2861 /// `</orderedlist>`
2862 ///
2863 /// You can monitor the active URI by connecting to the notify::uri
2864 /// signal of `self`.
2865 ///
2866 /// # Returns
2867 ///
2868 /// the current active URI of `self` or [`None`]
2869 /// if nothing has been loaded yet.
2870 #[doc(alias = "webkit_web_view_get_uri")]
2871 #[doc(alias = "get_uri")]
2872 fn uri(&self) -> Option<glib::GString> {
2873 unsafe { from_glib_none(ffi::webkit_web_view_get_uri(self.as_ref().to_glib_none().0)) }
2874 }
2875
2876 /// Gets the user content manager associated to `self`.
2877 ///
2878 /// # Returns
2879 ///
2880 /// the [`UserContentManager`][crate::UserContentManager] associated with the view
2881 #[doc(alias = "webkit_web_view_get_user_content_manager")]
2882 #[doc(alias = "get_user_content_manager")]
2883 #[doc(alias = "user-content-manager")]
2884 fn user_content_manager(&self) -> Option<UserContentManager> {
2885 unsafe {
2886 from_glib_none(ffi::webkit_web_view_get_user_content_manager(
2887 self.as_ref().to_glib_none().0,
2888 ))
2889 }
2890 }
2891
2892 /// Get the view's [`WebExtensionMode`][crate::WebExtensionMode].
2893 ///
2894 /// # Returns
2895 ///
2896 /// the [`WebExtensionMode`][crate::WebExtensionMode]
2897 #[doc(alias = "webkit_web_view_get_web_extension_mode")]
2898 #[doc(alias = "get_web_extension_mode")]
2899 #[doc(alias = "web-extension-mode")]
2900 fn web_extension_mode(&self) -> WebExtensionMode {
2901 unsafe {
2902 from_glib(ffi::webkit_web_view_get_web_extension_mode(
2903 self.as_ref().to_glib_none().0,
2904 ))
2905 }
2906 }
2907
2908 /// Gets the default website policies.
2909 ///
2910 /// Gets the default website policies set on construction in the
2911 /// `self`. These can be overridden on a per-origin basis via the
2912 /// [`decide-policy`][struct@crate::WebView#decide-policy] signal handler.
2913 ///
2914 /// See also [`PolicyDecisionExt::use_with_policies()`][crate::prelude::PolicyDecisionExt::use_with_policies()].
2915 ///
2916 /// # Returns
2917 ///
2918 /// the default [`WebsitePolicies`][crate::WebsitePolicies]
2919 /// associated with the view.
2920 #[doc(alias = "webkit_web_view_get_website_policies")]
2921 #[doc(alias = "get_website_policies")]
2922 #[doc(alias = "website-policies")]
2923 fn website_policies(&self) -> Option<WebsitePolicies> {
2924 unsafe {
2925 from_glib_none(ffi::webkit_web_view_get_website_policies(
2926 self.as_ref().to_glib_none().0,
2927 ))
2928 }
2929 }
2930
2931 /// Get the [`WindowProperties`][crate::WindowProperties] object.
2932 ///
2933 /// Get the [`WindowProperties`][crate::WindowProperties] object containing the properties
2934 /// that the window containing `self` should have.
2935 ///
2936 /// # Returns
2937 ///
2938 /// the [`WindowProperties`][crate::WindowProperties] of `self`
2939 #[doc(alias = "webkit_web_view_get_window_properties")]
2940 #[doc(alias = "get_window_properties")]
2941 fn window_properties(&self) -> Option<WindowProperties> {
2942 unsafe {
2943 from_glib_none(ffi::webkit_web_view_get_window_properties(
2944 self.as_ref().to_glib_none().0,
2945 ))
2946 }
2947 }
2948
2949 /// Set the zoom level of `self`.
2950 ///
2951 /// Get the zoom level of `self`, i.e. the factor by which the
2952 /// view contents are scaled with respect to their original size.
2953 ///
2954 /// # Returns
2955 ///
2956 /// the current zoom level of `self`
2957 #[doc(alias = "webkit_web_view_get_zoom_level")]
2958 #[doc(alias = "get_zoom_level")]
2959 #[doc(alias = "zoom-level")]
2960 fn zoom_level(&self) -> f64 {
2961 unsafe { ffi::webkit_web_view_get_zoom_level(self.as_ref().to_glib_none().0) }
2962 }
2963
2964 /// Loads the previous history item.
2965 ///
2966 /// You can monitor the load operation by connecting to
2967 /// [`load-changed`][struct@crate::WebView#load-changed] signal.
2968 #[doc(alias = "webkit_web_view_go_back")]
2969 fn go_back(&self) {
2970 unsafe {
2971 ffi::webkit_web_view_go_back(self.as_ref().to_glib_none().0);
2972 }
2973 }
2974
2975 /// Loads the next history item.
2976 ///
2977 /// You can monitor the load operation by connecting to
2978 /// [`load-changed`][struct@crate::WebView#load-changed] signal.
2979 #[doc(alias = "webkit_web_view_go_forward")]
2980 fn go_forward(&self) {
2981 unsafe {
2982 ffi::webkit_web_view_go_forward(self.as_ref().to_glib_none().0);
2983 }
2984 }
2985
2986 /// Loads the specific history item `list_item`.
2987 ///
2988 /// You can monitor the load operation by connecting to
2989 /// [`load-changed`][struct@crate::WebView#load-changed] signal.
2990 /// ## `list_item`
2991 /// a [`BackForwardListItem`][crate::BackForwardListItem]
2992 #[doc(alias = "webkit_web_view_go_to_back_forward_list_item")]
2993 fn go_to_back_forward_list_item(&self, list_item: &BackForwardListItem) {
2994 unsafe {
2995 ffi::webkit_web_view_go_to_back_forward_list_item(
2996 self.as_ref().to_glib_none().0,
2997 list_item.to_glib_none().0,
2998 );
2999 }
3000 }
3001
3002 /// Get whether a [`WebView`][crate::WebView] was created with [`is-controlled-by-automation`][struct@crate::WebView#is-controlled-by-automation]
3003 /// property enabled.
3004 ///
3005 /// Only [`WebView`][crate::WebView]<!-- -->s controlled by automation can be used in an
3006 /// automation session.
3007 ///
3008 /// # Returns
3009 ///
3010 /// [`true`] if `self` is controlled by automation, or [`false`] otherwise.
3011 #[doc(alias = "webkit_web_view_is_controlled_by_automation")]
3012 fn is_controlled_by_automation(&self) -> bool {
3013 unsafe {
3014 from_glib(ffi::webkit_web_view_is_controlled_by_automation(
3015 self.as_ref().to_glib_none().0,
3016 ))
3017 }
3018 }
3019
3020 /// Gets whether the user is allowed to edit the HTML document.
3021 ///
3022 /// When `self` is not editable an element in the HTML document can only be edited if the
3023 /// CONTENTEDITABLE attribute has been set on the element or one of its parent
3024 /// elements. By default a [`WebView`][crate::WebView] is not editable.
3025 ///
3026 /// # Returns
3027 ///
3028 /// [`true`] if the user is allowed to edit the HTML document, or [`false`] otherwise.
3029 #[doc(alias = "webkit_web_view_is_editable")]
3030 #[doc(alias = "editable")]
3031 fn is_editable(&self) -> bool {
3032 unsafe {
3033 from_glib(ffi::webkit_web_view_is_editable(
3034 self.as_ref().to_glib_none().0,
3035 ))
3036 }
3037 }
3038
3039 /// Gets whether `self` is in immersive mode.
3040 ///
3041 /// An immersive session is a mode in which the user is presented with a fully immersive XR experience
3042 /// (such as VR or AR), typically rendered via a headset.
3043 ///
3044 /// Note that if WebXR is disabled or OPENXR is not used, this API always returns [`false`].
3045 ///
3046 /// # Returns
3047 ///
3048 /// [`true`] if the `self` is in immersive mode, or [`false`] otherwise.
3049 #[cfg(feature = "v2_52")]
3050 #[cfg_attr(docsrs, doc(cfg(feature = "v2_52")))]
3051 #[doc(alias = "webkit_web_view_is_immersive_mode_enabled")]
3052 #[doc(alias = "is-immersive-mode-enabled")]
3053 fn is_immersive_mode_enabled(&self) -> bool {
3054 unsafe {
3055 from_glib(ffi::webkit_web_view_is_immersive_mode_enabled(
3056 self.as_ref().to_glib_none().0,
3057 ))
3058 }
3059 }
3060
3061 /// Gets the value of the [`is-loading`][struct@crate::WebView#is-loading] property.
3062 ///
3063 /// You can monitor when a [`WebView`][crate::WebView] is loading a page by connecting to
3064 /// notify::is-loading signal of `self`. This is useful when you are
3065 /// interesting in knowing when the view is loading something but not in the
3066 /// details about the status of the load operation, for example to start a spinner
3067 /// when the view is loading a page and stop it when it finishes.
3068 ///
3069 /// # Returns
3070 ///
3071 /// [`true`] if `self` is loading a page or [`false`] otherwise.
3072 #[doc(alias = "webkit_web_view_is_loading")]
3073 #[doc(alias = "is-loading")]
3074 fn is_loading(&self) -> bool {
3075 unsafe {
3076 from_glib(ffi::webkit_web_view_is_loading(
3077 self.as_ref().to_glib_none().0,
3078 ))
3079 }
3080 }
3081
3082 /// Gets the value of the [`is-playing-audio`][struct@crate::WebView#is-playing-audio] property.
3083 ///
3084 /// You can monitor when a page in a [`WebView`][crate::WebView] is playing audio by
3085 /// connecting to the notify::is-playing-audio signal of `self`. This
3086 /// is useful when the application wants to provide visual feedback when a
3087 /// page is producing sound.
3088 ///
3089 /// # Returns
3090 ///
3091 /// [`true`] if a page in `self` is playing audio or [`false`] otherwise.
3092 #[doc(alias = "webkit_web_view_is_playing_audio")]
3093 #[doc(alias = "is-playing-audio")]
3094 fn is_playing_audio(&self) -> bool {
3095 unsafe {
3096 from_glib(ffi::webkit_web_view_is_playing_audio(
3097 self.as_ref().to_glib_none().0,
3098 ))
3099 }
3100 }
3101
3102 /// Requests to leave the immersive mode this [`WebView`][crate::WebView] is in.
3103 ///
3104 /// Users interact with web content to start XR sessions, and can typically
3105 /// end the sessions themselves, but applications might need to end a session on their
3106 /// own based on application or platform logic.
3107 ///
3108 /// Note that if WebXR is disabled, or if it is enabled but the `self` is not in
3109 /// immersive mode, this API does nothing. See also [`is_immersive_mode_enabled()`][Self::is_immersive_mode_enabled()].
3110 #[cfg(feature = "v2_52")]
3111 #[cfg_attr(docsrs, doc(cfg(feature = "v2_52")))]
3112 #[doc(alias = "webkit_web_view_leave_immersive_mode")]
3113 fn leave_immersive_mode(&self) {
3114 unsafe {
3115 ffi::webkit_web_view_leave_immersive_mode(self.as_ref().to_glib_none().0);
3116 }
3117 }
3118
3119 /// Load the given `content` string for the URI `content_uri`.
3120 ///
3121 /// This allows clients to display page-loading errors in the [`WebView`][crate::WebView] itself.
3122 /// When this method is called from [`load-failed`][struct@crate::WebView#load-failed] signal to show an
3123 /// error page, then the back-forward list is maintained appropriately.
3124 /// For everything else this method works the same way as [`load_html()`][Self::load_html()].
3125 /// ## `content`
3126 /// the new content to display as the main page of the `self`
3127 /// ## `content_uri`
3128 /// the URI for the alternate page content
3129 /// ## `base_uri`
3130 /// the base URI for relative locations or [`None`]
3131 #[doc(alias = "webkit_web_view_load_alternate_html")]
3132 fn load_alternate_html(&self, content: &str, content_uri: &str, base_uri: Option<&str>) {
3133 unsafe {
3134 ffi::webkit_web_view_load_alternate_html(
3135 self.as_ref().to_glib_none().0,
3136 content.to_glib_none().0,
3137 content_uri.to_glib_none().0,
3138 base_uri.to_glib_none().0,
3139 );
3140 }
3141 }
3142
3143 /// Load the specified `bytes` into `self` using the given `mime_type` and `encoding`.
3144 ///
3145 /// When `mime_type` is [`None`], it defaults to "text/html".
3146 /// When `encoding` is [`None`], it defaults to "UTF-8".
3147 /// When `base_uri` is [`None`], it defaults to "about:blank".
3148 /// You can monitor the load operation by connecting to [`load-changed`][struct@crate::WebView#load-changed] signal.
3149 /// ## `bytes`
3150 /// input data to load
3151 /// ## `mime_type`
3152 /// the MIME type of `bytes`, or [`None`]
3153 /// ## `encoding`
3154 /// the character encoding of `bytes`, or [`None`]
3155 /// ## `base_uri`
3156 /// the base URI for relative locations or [`None`]
3157 #[doc(alias = "webkit_web_view_load_bytes")]
3158 fn load_bytes(
3159 &self,
3160 bytes: &glib::Bytes,
3161 mime_type: Option<&str>,
3162 encoding: Option<&str>,
3163 base_uri: Option<&str>,
3164 ) {
3165 unsafe {
3166 ffi::webkit_web_view_load_bytes(
3167 self.as_ref().to_glib_none().0,
3168 bytes.to_glib_none().0,
3169 mime_type.to_glib_none().0,
3170 encoding.to_glib_none().0,
3171 base_uri.to_glib_none().0,
3172 );
3173 }
3174 }
3175
3176 /// Load the given `content` string with the specified `base_uri`.
3177 ///
3178 /// If `base_uri` is not [`None`], relative URLs in the `content` will be
3179 /// resolved against `base_uri` and absolute local paths must be children of the `base_uri`.
3180 /// For security reasons absolute local paths that are not children of `base_uri`
3181 /// will cause the web process to terminate.
3182 /// If you need to include URLs in `content` that are local paths in a different
3183 /// directory than `base_uri` you can build a data URI for them. When `base_uri` is [`None`],
3184 /// it defaults to "about:blank". The mime type of the document will be "text/html".
3185 /// You can monitor the load operation by connecting to [`load-changed`][struct@crate::WebView#load-changed] signal.
3186 /// ## `content`
3187 /// The HTML string to load
3188 /// ## `base_uri`
3189 /// The base URI for relative locations or [`None`]
3190 #[doc(alias = "webkit_web_view_load_html")]
3191 fn load_html(&self, content: &str, base_uri: Option<&str>) {
3192 unsafe {
3193 ffi::webkit_web_view_load_html(
3194 self.as_ref().to_glib_none().0,
3195 content.to_glib_none().0,
3196 base_uri.to_glib_none().0,
3197 );
3198 }
3199 }
3200
3201 /// Load the specified `plain_text` string into `self`.
3202 ///
3203 /// The mime type of document will be "text/plain". You can monitor the load
3204 /// operation by connecting to [`load-changed`][struct@crate::WebView#load-changed] signal.
3205 /// ## `plain_text`
3206 /// The plain text to load
3207 #[doc(alias = "webkit_web_view_load_plain_text")]
3208 fn load_plain_text(&self, plain_text: &str) {
3209 unsafe {
3210 ffi::webkit_web_view_load_plain_text(
3211 self.as_ref().to_glib_none().0,
3212 plain_text.to_glib_none().0,
3213 );
3214 }
3215 }
3216
3217 /// Requests loading of the specified [`URIRequest`][crate::URIRequest].
3218 ///
3219 /// You can monitor the load operation by connecting to
3220 /// [`load-changed`][struct@crate::WebView#load-changed] signal.
3221 /// ## `request`
3222 /// a [`URIRequest`][crate::URIRequest] to load
3223 #[doc(alias = "webkit_web_view_load_request")]
3224 fn load_request(&self, request: &URIRequest) {
3225 unsafe {
3226 ffi::webkit_web_view_load_request(
3227 self.as_ref().to_glib_none().0,
3228 request.to_glib_none().0,
3229 );
3230 }
3231 }
3232
3233 /// Requests loading of the specified URI string.
3234 ///
3235 /// You can monitor the load operation by connecting to
3236 /// [`load-changed`][struct@crate::WebView#load-changed] signal.
3237 /// ## `uri`
3238 /// an URI string
3239 #[doc(alias = "webkit_web_view_load_uri")]
3240 fn load_uri(&self, uri: &str) {
3241 unsafe {
3242 ffi::webkit_web_view_load_uri(self.as_ref().to_glib_none().0, uri.to_glib_none().0);
3243 }
3244 }
3245
3246 /// Reloads the current contents of `self`.
3247 ///
3248 /// See also [`reload_bypass_cache()`][Self::reload_bypass_cache()].
3249 #[doc(alias = "webkit_web_view_reload")]
3250 fn reload(&self) {
3251 unsafe {
3252 ffi::webkit_web_view_reload(self.as_ref().to_glib_none().0);
3253 }
3254 }
3255
3256 /// Reloads the current contents of `self` without
3257 /// using any cached data.
3258 #[doc(alias = "webkit_web_view_reload_bypass_cache")]
3259 fn reload_bypass_cache(&self) {
3260 unsafe {
3261 ffi::webkit_web_view_reload_bypass_cache(self.as_ref().to_glib_none().0);
3262 }
3263 }
3264
3265 /// Restore the `self` session state from `state`
3266 /// ## `state`
3267 /// a [`WebViewSessionState`][crate::WebViewSessionState]
3268 #[doc(alias = "webkit_web_view_restore_session_state")]
3269 fn restore_session_state(&self, state: &WebViewSessionState) {
3270 unsafe {
3271 ffi::webkit_web_view_restore_session_state(
3272 self.as_ref().to_glib_none().0,
3273 state.to_glib_none().0,
3274 );
3275 }
3276 }
3277
3278 /// Asynchronously save the current web page.
3279 ///
3280 /// Asynchronously save the current web page associated to the
3281 /// [`WebView`][crate::WebView] into a self-contained format using the mode
3282 /// specified in `save_mode`.
3283 ///
3284 /// When the operation is finished, `callback` will be called. You can
3285 /// then call `webkit_web_view_save_finish()` to get the result of the
3286 /// operation.
3287 /// ## `save_mode`
3288 /// the [`SaveMode`][crate::SaveMode] specifying how the web page should be saved.
3289 /// ## `cancellable`
3290 /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`] to ignore
3291 /// ## `callback`
3292 /// a `GAsyncReadyCallback` to call when the request is satisfied
3293 #[doc(alias = "webkit_web_view_save")]
3294 fn save<P: FnOnce(Result<gio::InputStream, glib::Error>) + 'static>(
3295 &self,
3296 save_mode: SaveMode,
3297 cancellable: Option<&impl IsA<gio::Cancellable>>,
3298 callback: P,
3299 ) {
3300 let main_context = glib::MainContext::ref_thread_default();
3301 let is_main_context_owner = main_context.is_owner();
3302 let has_acquired_main_context = (!is_main_context_owner)
3303 .then(|| main_context.acquire().ok())
3304 .flatten();
3305 assert!(
3306 is_main_context_owner || has_acquired_main_context.is_some(),
3307 "Async operations only allowed if the thread is owning the MainContext"
3308 );
3309
3310 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
3311 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
3312 unsafe extern "C" fn save_trampoline<
3313 P: FnOnce(Result<gio::InputStream, glib::Error>) + 'static,
3314 >(
3315 _source_object: *mut glib::gobject_ffi::GObject,
3316 res: *mut gio::ffi::GAsyncResult,
3317 user_data: glib::ffi::gpointer,
3318 ) {
3319 unsafe {
3320 let mut error = std::ptr::null_mut();
3321 let ret =
3322 ffi::webkit_web_view_save_finish(_source_object as *mut _, res, &mut error);
3323 let result = if error.is_null() {
3324 Ok(from_glib_full(ret))
3325 } else {
3326 Err(from_glib_full(error))
3327 };
3328 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
3329 Box_::from_raw(user_data as *mut _);
3330 let callback: P = callback.into_inner();
3331 callback(result);
3332 }
3333 }
3334 let callback = save_trampoline::<P>;
3335 unsafe {
3336 ffi::webkit_web_view_save(
3337 self.as_ref().to_glib_none().0,
3338 save_mode.into_glib(),
3339 cancellable.map(|p| p.as_ref()).to_glib_none().0,
3340 Some(callback),
3341 Box_::into_raw(user_data) as *mut _,
3342 );
3343 }
3344 }
3345
3346 fn save_future(
3347 &self,
3348 save_mode: SaveMode,
3349 ) -> Pin<Box_<dyn std::future::Future<Output = Result<gio::InputStream, glib::Error>> + 'static>>
3350 {
3351 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
3352 obj.save(save_mode, Some(cancellable), move |res| {
3353 send.resolve(res);
3354 });
3355 }))
3356 }
3357
3358 /// Asynchronously save the current web page.
3359 ///
3360 /// Asynchronously save the current web page associated to the
3361 /// [`WebView`][crate::WebView] into a self-contained format using the mode
3362 /// specified in `save_mode` and writing it to `file`.
3363 ///
3364 /// When the operation is finished, `callback` will be called. You can
3365 /// then call `webkit_web_view_save_to_file_finish()` to get the result of the
3366 /// operation.
3367 /// ## `file`
3368 /// the [`gio::File`][crate::gio::File] where the current web page should be saved to.
3369 /// ## `save_mode`
3370 /// the [`SaveMode`][crate::SaveMode] specifying how the web page should be saved.
3371 /// ## `cancellable`
3372 /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`] to ignore
3373 /// ## `callback`
3374 /// a `GAsyncReadyCallback` to call when the request is satisfied
3375 #[doc(alias = "webkit_web_view_save_to_file")]
3376 fn save_to_file<P: FnOnce(Result<(), glib::Error>) + 'static>(
3377 &self,
3378 file: &impl IsA<gio::File>,
3379 save_mode: SaveMode,
3380 cancellable: Option<&impl IsA<gio::Cancellable>>,
3381 callback: P,
3382 ) {
3383 let main_context = glib::MainContext::ref_thread_default();
3384 let is_main_context_owner = main_context.is_owner();
3385 let has_acquired_main_context = (!is_main_context_owner)
3386 .then(|| main_context.acquire().ok())
3387 .flatten();
3388 assert!(
3389 is_main_context_owner || has_acquired_main_context.is_some(),
3390 "Async operations only allowed if the thread is owning the MainContext"
3391 );
3392
3393 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
3394 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
3395 unsafe extern "C" fn save_to_file_trampoline<
3396 P: FnOnce(Result<(), glib::Error>) + 'static,
3397 >(
3398 _source_object: *mut glib::gobject_ffi::GObject,
3399 res: *mut gio::ffi::GAsyncResult,
3400 user_data: glib::ffi::gpointer,
3401 ) {
3402 unsafe {
3403 let mut error = std::ptr::null_mut();
3404 ffi::webkit_web_view_save_to_file_finish(_source_object as *mut _, res, &mut error);
3405 let result = if error.is_null() {
3406 Ok(())
3407 } else {
3408 Err(from_glib_full(error))
3409 };
3410 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
3411 Box_::from_raw(user_data as *mut _);
3412 let callback: P = callback.into_inner();
3413 callback(result);
3414 }
3415 }
3416 let callback = save_to_file_trampoline::<P>;
3417 unsafe {
3418 ffi::webkit_web_view_save_to_file(
3419 self.as_ref().to_glib_none().0,
3420 file.as_ref().to_glib_none().0,
3421 save_mode.into_glib(),
3422 cancellable.map(|p| p.as_ref()).to_glib_none().0,
3423 Some(callback),
3424 Box_::into_raw(user_data) as *mut _,
3425 );
3426 }
3427 }
3428
3429 fn save_to_file_future(
3430 &self,
3431 file: &(impl IsA<gio::File> + Clone + 'static),
3432 save_mode: SaveMode,
3433 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
3434 let file = file.clone();
3435 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
3436 obj.save_to_file(&file, save_mode, Some(cancellable), move |res| {
3437 send.resolve(res);
3438 });
3439 }))
3440 }
3441
3442 /// Send `message` to the `WebKitWebPage` corresponding to `self`.
3443 ///
3444 /// If `message` is floating, it's consumed.
3445 /// If you don't expect any reply, or you simply want to ignore it, you can pass [`None`] as `callback`.
3446 /// When the operation is finished, `callback` will be called. You can then call
3447 /// `webkit_web_view_send_message_to_page_finish()` to get the message reply.
3448 /// ## `message`
3449 /// a [`UserMessage`][crate::UserMessage]
3450 /// ## `cancellable`
3451 /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`] to ignore
3452 /// ## `callback`
3453 /// (nullable): A `GAsyncReadyCallback` to call when the request is satisfied or [`None`]
3454 #[doc(alias = "webkit_web_view_send_message_to_page")]
3455 fn send_message_to_page<P: FnOnce(Result<UserMessage, glib::Error>) + 'static>(
3456 &self,
3457 message: &UserMessage,
3458 cancellable: Option<&impl IsA<gio::Cancellable>>,
3459 callback: P,
3460 ) {
3461 let main_context = glib::MainContext::ref_thread_default();
3462 let is_main_context_owner = main_context.is_owner();
3463 let has_acquired_main_context = (!is_main_context_owner)
3464 .then(|| main_context.acquire().ok())
3465 .flatten();
3466 assert!(
3467 is_main_context_owner || has_acquired_main_context.is_some(),
3468 "Async operations only allowed if the thread is owning the MainContext"
3469 );
3470
3471 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
3472 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
3473 unsafe extern "C" fn send_message_to_page_trampoline<
3474 P: FnOnce(Result<UserMessage, glib::Error>) + 'static,
3475 >(
3476 _source_object: *mut glib::gobject_ffi::GObject,
3477 res: *mut gio::ffi::GAsyncResult,
3478 user_data: glib::ffi::gpointer,
3479 ) {
3480 unsafe {
3481 let mut error = std::ptr::null_mut();
3482 let ret = ffi::webkit_web_view_send_message_to_page_finish(
3483 _source_object as *mut _,
3484 res,
3485 &mut error,
3486 );
3487 let result = if error.is_null() {
3488 Ok(from_glib_full(ret))
3489 } else {
3490 Err(from_glib_full(error))
3491 };
3492 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
3493 Box_::from_raw(user_data as *mut _);
3494 let callback: P = callback.into_inner();
3495 callback(result);
3496 }
3497 }
3498 let callback = send_message_to_page_trampoline::<P>;
3499 unsafe {
3500 ffi::webkit_web_view_send_message_to_page(
3501 self.as_ref().to_glib_none().0,
3502 message.to_glib_none().0,
3503 cancellable.map(|p| p.as_ref()).to_glib_none().0,
3504 Some(callback),
3505 Box_::into_raw(user_data) as *mut _,
3506 );
3507 }
3508 }
3509
3510 fn send_message_to_page_future(
3511 &self,
3512 message: &UserMessage,
3513 ) -> Pin<Box_<dyn std::future::Future<Output = Result<UserMessage, glib::Error>> + 'static>>
3514 {
3515 let message = message.clone();
3516 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
3517 obj.send_message_to_page(&message, Some(cancellable), move |res| {
3518 send.resolve(res);
3519 });
3520 }))
3521 }
3522
3523 /// Sets the color that will be used to draw the `self` background.
3524 ///
3525 /// Sets the color that will be used to draw the `self` background before
3526 /// the actual contents are rendered. Note that if the web page loaded in `self`
3527 /// specifies a background color, it will take precedence over the `rgba` color.
3528 /// By default the `self` background color is opaque white.
3529 /// ## `rgba`
3530 /// a [`gdk::RGBA`][crate::gdk::RGBA]
3531 #[doc(alias = "webkit_web_view_set_background_color")]
3532 fn set_background_color(&self, rgba: &gdk::RGBA) {
3533 unsafe {
3534 ffi::webkit_web_view_set_background_color(
3535 self.as_ref().to_glib_none().0,
3536 rgba.to_glib_none().0,
3537 );
3538 }
3539 }
3540
3541 /// Set the camera capture state of a [`WebView`][crate::WebView].
3542 ///
3543 /// If [`enable-mediastream`][struct@crate::Settings#enable-mediastream] is [`false`], this method will have no visible effect. Once the
3544 /// state of the device has been set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] it cannot be changed
3545 /// anymore. The page can however request capture again using the mediaDevices API.
3546 /// ## `state`
3547 /// a [`MediaCaptureState`][crate::MediaCaptureState]
3548 #[doc(alias = "webkit_web_view_set_camera_capture_state")]
3549 #[doc(alias = "camera-capture-state")]
3550 fn set_camera_capture_state(&self, state: MediaCaptureState) {
3551 unsafe {
3552 ffi::webkit_web_view_set_camera_capture_state(
3553 self.as_ref().to_glib_none().0,
3554 state.into_glib(),
3555 );
3556 }
3557 }
3558
3559 /// Sets the `allowlist` for CORS.
3560 ///
3561 /// Sets the `allowlist` for which
3562 /// [Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
3563 /// checks are disabled in `self`. URI patterns must be of the form
3564 /// `[protocol]://[host]/[path]`, each component may contain the wildcard
3565 /// character (`*`) to represent zero or more other characters. All three
3566 /// components are required and must not be omitted from the URI
3567 /// patterns.
3568 ///
3569 /// Disabling CORS checks permits resources from other origins to load
3570 /// allowlisted resources. It does not permit the allowlisted resources
3571 /// to load resources from other origins.
3572 ///
3573 /// If this function is called multiple times, only the allowlist set by
3574 /// the most recent call will be effective.
3575 /// ## `allowlist`
3576 /// an allowlist of URI patterns, or [`None`]
3577 #[doc(alias = "webkit_web_view_set_cors_allowlist")]
3578 fn set_cors_allowlist(&self, allowlist: &[&str]) {
3579 unsafe {
3580 ffi::webkit_web_view_set_cors_allowlist(
3581 self.as_ref().to_glib_none().0,
3582 allowlist.to_glib_none().0,
3583 );
3584 }
3585 }
3586
3587 /// Sets the current custom character encoding override of `self`.
3588 ///
3589 /// The custom character encoding will override any text encoding detected via HTTP headers or
3590 /// META tags. Calling this method will stop any current load operation and reload the
3591 /// current page. Setting the custom character encoding to [`None`] removes the character
3592 /// encoding override.
3593 /// ## `charset`
3594 /// a character encoding name or [`None`]
3595 #[doc(alias = "webkit_web_view_set_custom_charset")]
3596 fn set_custom_charset(&self, charset: Option<&str>) {
3597 unsafe {
3598 ffi::webkit_web_view_set_custom_charset(
3599 self.as_ref().to_glib_none().0,
3600 charset.to_glib_none().0,
3601 );
3602 }
3603 }
3604
3605 /// Set the display capture state of a [`WebView`][crate::WebView].
3606 ///
3607 /// If [`enable-mediastream`][struct@crate::Settings#enable-mediastream] is [`false`], this method will have no visible effect. Once the
3608 /// state of the device has been set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] it cannot be changed
3609 /// anymore. The page can however request capture again using the mediaDevices API.
3610 /// ## `state`
3611 /// a [`MediaCaptureState`][crate::MediaCaptureState]
3612 #[doc(alias = "webkit_web_view_set_display_capture_state")]
3613 #[doc(alias = "display-capture-state")]
3614 fn set_display_capture_state(&self, state: MediaCaptureState) {
3615 unsafe {
3616 ffi::webkit_web_view_set_display_capture_state(
3617 self.as_ref().to_glib_none().0,
3618 state.into_glib(),
3619 );
3620 }
3621 }
3622
3623 /// Sets whether the user is allowed to edit the HTML document.
3624 ///
3625 /// If `editable` is [`true`], `self` allows the user to edit the HTML document. If
3626 /// `editable` is [`false`], an element in `self`'s document can only be edited if the
3627 /// CONTENTEDITABLE attribute has been set on the element or one of its parent
3628 /// elements. By default a [`WebView`][crate::WebView] is not editable.
3629 ///
3630 /// Normally, a HTML document is not editable unless the elements within the
3631 /// document are editable. This function provides a way to make the contents
3632 /// of a [`WebView`][crate::WebView] editable without altering the document or DOM structure.
3633 /// ## `editable`
3634 /// a `gboolean` indicating the editable state
3635 #[doc(alias = "webkit_web_view_set_editable")]
3636 #[doc(alias = "editable")]
3637 fn set_editable(&self, editable: bool) {
3638 unsafe {
3639 ffi::webkit_web_view_set_editable(self.as_ref().to_glib_none().0, editable.into_glib());
3640 }
3641 }
3642
3643 /// Set the [`InputMethodContext`][crate::InputMethodContext] to be used by `self`.
3644 ///
3645 /// Set the [`InputMethodContext`][crate::InputMethodContext] to be used by `self`, or [`None`] to not use any input method.
3646 /// Note that the same [`InputMethodContext`][crate::InputMethodContext] can't be set on more than one [`WebView`][crate::WebView] at the same time.
3647 /// ## `context`
3648 /// the [`InputMethodContext`][crate::InputMethodContext] to set, or [`None`]
3649 #[doc(alias = "webkit_web_view_set_input_method_context")]
3650 fn set_input_method_context(&self, context: Option<&impl IsA<InputMethodContext>>) {
3651 unsafe {
3652 ffi::webkit_web_view_set_input_method_context(
3653 self.as_ref().to_glib_none().0,
3654 context.map(|p| p.as_ref()).to_glib_none().0,
3655 );
3656 }
3657 }
3658
3659 /// Sets the mute state of `self`.
3660 /// ## `muted`
3661 /// mute flag
3662 #[doc(alias = "webkit_web_view_set_is_muted")]
3663 #[doc(alias = "is-muted")]
3664 fn set_is_muted(&self, muted: bool) {
3665 unsafe {
3666 ffi::webkit_web_view_set_is_muted(self.as_ref().to_glib_none().0, muted.into_glib());
3667 }
3668 }
3669
3670 /// Set the microphone capture state of a [`WebView`][crate::WebView].
3671 ///
3672 /// If [`enable-mediastream`][struct@crate::Settings#enable-mediastream] is [`false`], this method will have no visible effect. Once the
3673 /// state of the device has been set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] it cannot be changed
3674 /// anymore. The page can however request capture again using the mediaDevices API.
3675 /// ## `state`
3676 /// a [`MediaCaptureState`][crate::MediaCaptureState]
3677 #[doc(alias = "webkit_web_view_set_microphone_capture_state")]
3678 #[doc(alias = "microphone-capture-state")]
3679 fn set_microphone_capture_state(&self, state: MediaCaptureState) {
3680 unsafe {
3681 ffi::webkit_web_view_set_microphone_capture_state(
3682 self.as_ref().to_glib_none().0,
3683 state.into_glib(),
3684 );
3685 }
3686 }
3687
3688 /// Sets the [`Settings`][crate::Settings] to be applied to `self`.
3689 ///
3690 /// The
3691 /// existing [`Settings`][crate::Settings] of `self` will be replaced by
3692 /// `settings`. New settings are applied immediately on `self`.
3693 /// The same [`Settings`][crate::Settings] object can be shared
3694 /// by multiple [`WebView`][crate::WebView]<!-- -->s.
3695 /// ## `settings`
3696 /// a [`Settings`][crate::Settings]
3697 #[doc(alias = "webkit_web_view_set_settings")]
3698 #[doc(alias = "settings")]
3699 fn set_settings(&self, settings: &Settings) {
3700 unsafe {
3701 ffi::webkit_web_view_set_settings(
3702 self.as_ref().to_glib_none().0,
3703 settings.to_glib_none().0,
3704 );
3705 }
3706 }
3707
3708 /// Set the zoom level of `self`.
3709 ///
3710 /// Set the zoom level of `self`, i.e. the factor by which the
3711 /// view contents are scaled with respect to their original size.
3712 /// ## `zoom_level`
3713 /// the zoom level
3714 #[doc(alias = "webkit_web_view_set_zoom_level")]
3715 #[doc(alias = "zoom-level")]
3716 fn set_zoom_level(&self, zoom_level: f64) {
3717 unsafe {
3718 ffi::webkit_web_view_set_zoom_level(self.as_ref().to_glib_none().0, zoom_level);
3719 }
3720 }
3721
3722 /// Stops any ongoing loading operation in `self`.
3723 ///
3724 /// This method does nothing if no content is being loaded.
3725 /// If there is a loading operation in progress, it will be cancelled and
3726 /// [`load-failed`][struct@crate::WebView#load-failed] signal will be emitted with
3727 /// [`NetworkError::Cancelled`][crate::NetworkError::Cancelled] error.
3728 #[doc(alias = "webkit_web_view_stop_loading")]
3729 fn stop_loading(&self) {
3730 unsafe {
3731 ffi::webkit_web_view_stop_loading(self.as_ref().to_glib_none().0);
3732 }
3733 }
3734
3735 /// Terminates the web process associated to `self`.
3736 ///
3737 /// When the web process gets terminated
3738 /// using this method, the [`web-process-terminated`][struct@crate::WebView#web-process-terminated] signal is emitted with
3739 /// [`WebProcessTerminationReason::TerminatedByApi`][crate::WebProcessTerminationReason::TerminatedByApi] as the reason for termination.
3740 #[doc(alias = "webkit_web_view_terminate_web_process")]
3741 fn terminate_web_process(&self) {
3742 unsafe {
3743 ffi::webkit_web_view_terminate_web_process(self.as_ref().to_glib_none().0);
3744 }
3745 }
3746
3747 /// Tries to close the `self`.
3748 ///
3749 /// This will fire the onbeforeunload event
3750 /// to ask the user for confirmation to close the page. If there isn't an
3751 /// onbeforeunload event handler or the user confirms to close the page,
3752 /// the [`close`][struct@crate::WebView#close] signal is emitted, otherwise nothing happens.
3753 #[doc(alias = "webkit_web_view_try_close")]
3754 fn try_close(&self) {
3755 unsafe {
3756 ffi::webkit_web_view_try_close(self.as_ref().to_glib_none().0);
3757 }
3758 }
3759
3760 /// The [`WebContext`][crate::WebContext] of the view.
3761 #[doc(alias = "web-context")]
3762 fn web_context(&self) -> Option<WebContext> {
3763 ObjectExt::property(self.as_ref(), "web-context")
3764 }
3765
3766 /// This signal is emitted when the user is challenged with HTTP
3767 /// authentication. To let the application access or supply
3768 /// the credentials as well as to allow the client application
3769 /// to either cancel the request or perform the authentication,
3770 /// the signal will pass an instance of the
3771 /// [`AuthenticationRequest`][crate::AuthenticationRequest] in the `request` argument.
3772 /// To handle this signal asynchronously you should keep a ref
3773 /// of the request and return [`true`]. To disable HTTP authentication
3774 /// entirely, connect to this signal and simply return [`true`].
3775 ///
3776 /// The default signal handler will run a default authentication
3777 /// dialog asynchronously for the user to interact with.
3778 /// ## `request`
3779 /// a [`AuthenticationRequest`][crate::AuthenticationRequest]
3780 ///
3781 /// # Returns
3782 ///
3783 /// [`true`] to stop other handlers from being invoked for the event.
3784 /// [`false`] to propagate the event further.
3785 #[doc(alias = "authenticate")]
3786 fn connect_authenticate<F: Fn(&Self, &AuthenticationRequest) -> bool + 'static>(
3787 &self,
3788 f: F,
3789 ) -> SignalHandlerId {
3790 unsafe extern "C" fn authenticate_trampoline<
3791 P: IsA<WebView>,
3792 F: Fn(&P, &AuthenticationRequest) -> bool + 'static,
3793 >(
3794 this: *mut ffi::WebKitWebView,
3795 request: *mut ffi::WebKitAuthenticationRequest,
3796 f: glib::ffi::gpointer,
3797 ) -> glib::ffi::gboolean {
3798 unsafe {
3799 let f: &F = &*(f as *const F);
3800 f(
3801 WebView::from_glib_borrow(this).unsafe_cast_ref(),
3802 &from_glib_borrow(request),
3803 )
3804 .into_glib()
3805 }
3806 }
3807 unsafe {
3808 let f: Box_<F> = Box_::new(f);
3809 connect_raw(
3810 self.as_ptr() as *mut _,
3811 c"authenticate".as_ptr(),
3812 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3813 authenticate_trampoline::<Self, F> as *const (),
3814 )),
3815 Box_::into_raw(f),
3816 )
3817 }
3818 }
3819
3820 /// Emitted when closing a [`WebView`][crate::WebView] is requested. This occurs when a
3821 /// call is made from JavaScript's `<function>`window.close`</function>` function or
3822 /// after trying to close the `web_view` with [`try_close()`][Self::try_close()].
3823 /// It is the owner's responsibility to handle this signal to hide or
3824 /// destroy the [`WebView`][crate::WebView], if necessary.
3825 #[doc(alias = "close")]
3826 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3827 unsafe extern "C" fn close_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3828 this: *mut ffi::WebKitWebView,
3829 f: glib::ffi::gpointer,
3830 ) {
3831 unsafe {
3832 let f: &F = &*(f as *const F);
3833 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3834 }
3835 }
3836 unsafe {
3837 let f: Box_<F> = Box_::new(f);
3838 connect_raw(
3839 self.as_ptr() as *mut _,
3840 c"close".as_ptr(),
3841 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3842 close_trampoline::<Self, F> as *const (),
3843 )),
3844 Box_::into_raw(f),
3845 )
3846 }
3847 }
3848
3849 /// Emitted when a context menu is about to be displayed to give the application
3850 /// a chance to customize the proposed menu, prevent the menu from being displayed,
3851 /// or build its own context menu.
3852 /// `<itemizedlist>`
3853 /// `<listitem>``<para>`
3854 /// To customize the proposed menu you can use [`ContextMenu::prepend()`][crate::ContextMenu::prepend()],
3855 /// [`ContextMenu::append()`][crate::ContextMenu::append()] or [`ContextMenu::insert()`][crate::ContextMenu::insert()] to add new
3856 /// [`ContextMenuItem`][crate::ContextMenuItem]<!-- -->s to `context_menu`, [`ContextMenu::move_item()`][crate::ContextMenu::move_item()]
3857 /// to reorder existing items, or [`ContextMenu::remove()`][crate::ContextMenu::remove()] to remove an
3858 /// existing item. The signal handler should return [`false`], and the menu represented
3859 /// by `context_menu` will be shown.
3860 /// `</para>``</listitem>`
3861 /// `<listitem>``<para>`
3862 /// To prevent the menu from being displayed you can just connect to this signal
3863 /// and return [`true`] so that the proposed menu will not be shown.
3864 /// `</para>``</listitem>`
3865 /// `<listitem>``<para>`
3866 /// To build your own menu, you can remove all items from the proposed menu with
3867 /// [`ContextMenu::remove_all()`][crate::ContextMenu::remove_all()], add your own items and return [`false`] so
3868 /// that the menu will be shown. You can also ignore the proposed [`ContextMenu`][crate::ContextMenu],
3869 /// build your own `GtkMenu` and return [`true`] to prevent the proposed menu from being shown.
3870 /// `</para>``</listitem>`
3871 /// `<listitem>``<para>`
3872 /// If you just want the default menu to be shown always, simply don't connect to this
3873 /// signal because showing the proposed context menu is the default behaviour.
3874 /// `</para>``</listitem>`
3875 /// `</itemizedlist>`
3876 ///
3877 /// If the signal handler returns [`false`] the context menu represented by `context_menu`
3878 /// will be shown, if it return [`true`] the context menu will not be shown.
3879 ///
3880 /// The proposed [`ContextMenu`][crate::ContextMenu] passed in `context_menu` argument is only valid
3881 /// during the signal emission.
3882 /// ## `context_menu`
3883 /// the proposed [`ContextMenu`][crate::ContextMenu]
3884 /// ## `hit_test_result`
3885 /// a [`HitTestResult`][crate::HitTestResult]
3886 ///
3887 /// # Returns
3888 ///
3889 /// [`true`] to stop other handlers from being invoked for the event.
3890 /// [`false`] to propagate the event further.
3891 #[doc(alias = "context-menu")]
3892 fn connect_context_menu<F: Fn(&Self, &ContextMenu, &HitTestResult) -> bool + 'static>(
3893 &self,
3894 f: F,
3895 ) -> SignalHandlerId {
3896 unsafe extern "C" fn context_menu_trampoline<
3897 P: IsA<WebView>,
3898 F: Fn(&P, &ContextMenu, &HitTestResult) -> bool + 'static,
3899 >(
3900 this: *mut ffi::WebKitWebView,
3901 context_menu: *mut ffi::WebKitContextMenu,
3902 hit_test_result: *mut ffi::WebKitHitTestResult,
3903 f: glib::ffi::gpointer,
3904 ) -> glib::ffi::gboolean {
3905 unsafe {
3906 let f: &F = &*(f as *const F);
3907 f(
3908 WebView::from_glib_borrow(this).unsafe_cast_ref(),
3909 &from_glib_borrow(context_menu),
3910 &from_glib_borrow(hit_test_result),
3911 )
3912 .into_glib()
3913 }
3914 }
3915 unsafe {
3916 let f: Box_<F> = Box_::new(f);
3917 connect_raw(
3918 self.as_ptr() as *mut _,
3919 c"context-menu".as_ptr(),
3920 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3921 context_menu_trampoline::<Self, F> as *const (),
3922 )),
3923 Box_::into_raw(f),
3924 )
3925 }
3926 }
3927
3928 /// Emitted after [`context-menu`][struct@crate::WebView#context-menu] signal, if the context menu is shown,
3929 /// to notify that the context menu is dismissed.
3930 #[doc(alias = "context-menu-dismissed")]
3931 fn connect_context_menu_dismissed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3932 unsafe extern "C" fn context_menu_dismissed_trampoline<
3933 P: IsA<WebView>,
3934 F: Fn(&P) + 'static,
3935 >(
3936 this: *mut ffi::WebKitWebView,
3937 f: glib::ffi::gpointer,
3938 ) {
3939 unsafe {
3940 let f: &F = &*(f as *const F);
3941 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3942 }
3943 }
3944 unsafe {
3945 let f: Box_<F> = Box_::new(f);
3946 connect_raw(
3947 self.as_ptr() as *mut _,
3948 c"context-menu-dismissed".as_ptr(),
3949 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3950 context_menu_dismissed_trampoline::<Self, F> as *const (),
3951 )),
3952 Box_::into_raw(f),
3953 )
3954 }
3955 }
3956
3957 /// Emitted when the creation of a new [`WebView`][crate::WebView] is requested.
3958 /// If this signal is handled the signal handler should return the
3959 /// newly created [`WebView`][crate::WebView].
3960 ///
3961 /// The [`NavigationAction`][crate::NavigationAction] parameter contains information about the
3962 /// navigation action that triggered this signal.
3963 ///
3964 /// The new [`WebView`][crate::WebView] must be related to `web_view`, see
3965 /// [`related-view`][struct@crate::WebView#related-view] for more details.
3966 ///
3967 /// The new [`WebView`][crate::WebView] should not be displayed to the user
3968 /// until the [`ready-to-show`][struct@crate::WebView#ready-to-show] signal is emitted.
3969 ///
3970 /// For creating views as response to automation tools requests, see the
3971 /// [`create-web-view`][struct@crate::AutomationSession#create-web-view] signal.
3972 /// ## `navigation_action`
3973 /// a [`NavigationAction`][crate::NavigationAction]
3974 ///
3975 /// # Returns
3976 ///
3977 /// a newly allocated [`WebView`][crate::WebView] widget
3978 /// or [`None`] to propagate the event further.
3979 #[doc(alias = "create")]
3980 fn connect_create<F: Fn(&Self, &NavigationAction) -> Option<gtk::Widget> + 'static>(
3981 &self,
3982 f: F,
3983 ) -> SignalHandlerId {
3984 unsafe extern "C" fn create_trampoline<
3985 P: IsA<WebView>,
3986 F: Fn(&P, &NavigationAction) -> Option<gtk::Widget> + 'static,
3987 >(
3988 this: *mut ffi::WebKitWebView,
3989 navigation_action: *mut ffi::WebKitNavigationAction,
3990 f: glib::ffi::gpointer,
3991 ) -> *mut gtk::ffi::GtkWidget {
3992 unsafe {
3993 let f: &F = &*(f as *const F);
3994 f(
3995 WebView::from_glib_borrow(this).unsafe_cast_ref(),
3996 &from_glib_borrow(navigation_action),
3997 )
3998 .to_glib_full()
3999 }
4000 }
4001 unsafe {
4002 let f: Box_<F> = Box_::new(f);
4003 connect_raw(
4004 self.as_ptr() as *mut _,
4005 c"create".as_ptr(),
4006 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4007 create_trampoline::<Self, F> as *const (),
4008 )),
4009 Box_::into_raw(f),
4010 )
4011 }
4012 }
4013
4014 /// This signal is emitted when WebKit is requesting the client to decide a policy
4015 /// decision, such as whether to navigate to a page, open a new window or whether or
4016 /// not to download a resource. The [`NavigationPolicyDecision`][crate::NavigationPolicyDecision] passed in the
4017 /// `decision` argument is a generic type, but should be casted to a more
4018 /// specific type when making the decision. For example:
4019 ///
4020 /// **⚠️ The following code is in c ⚠️**
4021 ///
4022 /// ```c
4023 /// static gboolean
4024 /// decide_policy_cb (WebKitWebView *web_view,
4025 /// WebKitPolicyDecision *decision,
4026 /// WebKitPolicyDecisionType type)
4027 /// {
4028 /// switch (type) {
4029 /// case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
4030 /// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
4031 /// // Make a policy decision here
4032 /// break;
4033 /// }
4034 /// case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {
4035 /// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
4036 /// // Make a policy decision here
4037 /// break;
4038 /// }
4039 /// case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
4040 /// WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
4041 /// // Make a policy decision here
4042 /// break;
4043 /// default:
4044 /// // Making no decision results in webkit_policy_decision_use()
4045 /// return FALSE;
4046 /// }
4047 /// return TRUE;
4048 /// }
4049 /// ```
4050 ///
4051 /// It is possible to make policy decision asynchronously, by simply calling `g_object_ref()`
4052 /// on the `decision` argument and returning [`true`] to block the default signal handler.
4053 /// If the last reference is removed on a [`PolicyDecision`][crate::PolicyDecision] and no decision has been
4054 /// made explicitly, [`PolicyDecisionExt::use_()`][crate::prelude::PolicyDecisionExt::use_()] will be the default policy decision. The
4055 /// default signal handler will simply call [`PolicyDecisionExt::use_()`][crate::prelude::PolicyDecisionExt::use_()]. Only the first
4056 /// policy decision chosen for a given [`PolicyDecision`][crate::PolicyDecision] will have any affect.
4057 /// ## `decision`
4058 /// the [`PolicyDecision`][crate::PolicyDecision]
4059 /// ## `decision_type`
4060 /// a [`PolicyDecisionType`][crate::PolicyDecisionType] denoting the type of `decision`
4061 ///
4062 /// # Returns
4063 ///
4064 /// [`true`] to stop other handlers from being invoked for the event.
4065 /// [`false`] to propagate the event further.
4066 #[doc(alias = "decide-policy")]
4067 fn connect_decide_policy<
4068 F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static,
4069 >(
4070 &self,
4071 f: F,
4072 ) -> SignalHandlerId {
4073 unsafe extern "C" fn decide_policy_trampoline<
4074 P: IsA<WebView>,
4075 F: Fn(&P, &PolicyDecision, PolicyDecisionType) -> bool + 'static,
4076 >(
4077 this: *mut ffi::WebKitWebView,
4078 decision: *mut ffi::WebKitPolicyDecision,
4079 decision_type: ffi::WebKitPolicyDecisionType,
4080 f: glib::ffi::gpointer,
4081 ) -> glib::ffi::gboolean {
4082 unsafe {
4083 let f: &F = &*(f as *const F);
4084 f(
4085 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4086 &from_glib_borrow(decision),
4087 from_glib(decision_type),
4088 )
4089 .into_glib()
4090 }
4091 }
4092 unsafe {
4093 let f: Box_<F> = Box_::new(f);
4094 connect_raw(
4095 self.as_ptr() as *mut _,
4096 c"decide-policy".as_ptr(),
4097 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4098 decide_policy_trampoline::<Self, F> as *const (),
4099 )),
4100 Box_::into_raw(f),
4101 )
4102 }
4103 }
4104
4105 /// Emitted when JavaScript code calls
4106 /// `<function>`element.webkitRequestFullScreen`</function>`. If the
4107 /// signal is not handled the [`WebView`][crate::WebView] will proceed to full screen
4108 /// its top level window. This signal can be used by client code to
4109 /// request permission to the user prior doing the full screen
4110 /// transition and eventually prepare the top-level window
4111 /// (e.g. hide some widgets that would otherwise be part of the
4112 /// full screen window).
4113 ///
4114 /// # Returns
4115 ///
4116 /// [`true`] to stop other handlers from being invoked for the event.
4117 /// [`false`] to continue emission of the event.
4118 #[doc(alias = "enter-fullscreen")]
4119 fn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
4120 unsafe extern "C" fn enter_fullscreen_trampoline<
4121 P: IsA<WebView>,
4122 F: Fn(&P) -> bool + 'static,
4123 >(
4124 this: *mut ffi::WebKitWebView,
4125 f: glib::ffi::gpointer,
4126 ) -> glib::ffi::gboolean {
4127 unsafe {
4128 let f: &F = &*(f as *const F);
4129 f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
4130 }
4131 }
4132 unsafe {
4133 let f: Box_<F> = Box_::new(f);
4134 connect_raw(
4135 self.as_ptr() as *mut _,
4136 c"enter-fullscreen".as_ptr(),
4137 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4138 enter_fullscreen_trampoline::<Self, F> as *const (),
4139 )),
4140 Box_::into_raw(f),
4141 )
4142 }
4143 }
4144
4145 /// Prior to 2.46, this signal was emitted when insecure content was
4146 /// loaded in a secure content. Since 2.46, this signal is generally
4147 /// no longer emitted.
4148 ///
4149 /// # Deprecated since 2.46
4150 ///
4151 /// ## `event`
4152 /// the [`InsecureContentEvent`][crate::InsecureContentEvent]
4153 #[cfg_attr(feature = "v2_46", deprecated = "Since 2.46")]
4154 #[doc(alias = "insecure-content-detected")]
4155 fn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>(
4156 &self,
4157 f: F,
4158 ) -> SignalHandlerId {
4159 unsafe extern "C" fn insecure_content_detected_trampoline<
4160 P: IsA<WebView>,
4161 F: Fn(&P, InsecureContentEvent) + 'static,
4162 >(
4163 this: *mut ffi::WebKitWebView,
4164 event: ffi::WebKitInsecureContentEvent,
4165 f: glib::ffi::gpointer,
4166 ) {
4167 unsafe {
4168 let f: &F = &*(f as *const F);
4169 f(
4170 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4171 from_glib(event),
4172 )
4173 }
4174 }
4175 unsafe {
4176 let f: Box_<F> = Box_::new(f);
4177 connect_raw(
4178 self.as_ptr() as *mut _,
4179 c"insecure-content-detected".as_ptr(),
4180 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4181 insecure_content_detected_trampoline::<Self, F> as *const (),
4182 )),
4183 Box_::into_raw(f),
4184 )
4185 }
4186 }
4187
4188 /// Emitted when the [`WebView`][crate::WebView] is about to restore its top level
4189 /// window out of its full screen state. This signal can be used by
4190 /// client code to restore widgets hidden during the
4191 /// [`enter-fullscreen`][struct@crate::WebView#enter-fullscreen] stage for instance.
4192 ///
4193 /// # Returns
4194 ///
4195 /// [`true`] to stop other handlers from being invoked for the event.
4196 /// [`false`] to continue emission of the event.
4197 #[doc(alias = "leave-fullscreen")]
4198 fn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
4199 unsafe extern "C" fn leave_fullscreen_trampoline<
4200 P: IsA<WebView>,
4201 F: Fn(&P) -> bool + 'static,
4202 >(
4203 this: *mut ffi::WebKitWebView,
4204 f: glib::ffi::gpointer,
4205 ) -> glib::ffi::gboolean {
4206 unsafe {
4207 let f: &F = &*(f as *const F);
4208 f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
4209 }
4210 }
4211 unsafe {
4212 let f: Box_<F> = Box_::new(f);
4213 connect_raw(
4214 self.as_ptr() as *mut _,
4215 c"leave-fullscreen".as_ptr(),
4216 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4217 leave_fullscreen_trampoline::<Self, F> as *const (),
4218 )),
4219 Box_::into_raw(f),
4220 )
4221 }
4222 }
4223
4224 /// Emitted when a load operation in `web_view` changes.
4225 /// The signal is always emitted with [`LoadEvent::Started`][crate::LoadEvent::Started] when a
4226 /// new load request is made and [`LoadEvent::Finished`][crate::LoadEvent::Finished] when the load
4227 /// finishes successfully or due to an error. When the ongoing load
4228 /// operation fails [`load-failed`][struct@crate::WebView#load-failed] signal is emitted
4229 /// before [`load-changed`][struct@crate::WebView#load-changed] is emitted with
4230 /// [`LoadEvent::Finished`][crate::LoadEvent::Finished].
4231 /// If a redirection is received from the server, this signal is emitted
4232 /// with [`LoadEvent::Redirected`][crate::LoadEvent::Redirected] after the initial emission with
4233 /// [`LoadEvent::Started`][crate::LoadEvent::Started] and before [`LoadEvent::Committed`][crate::LoadEvent::Committed].
4234 /// When the page content starts arriving the signal is emitted with
4235 /// [`LoadEvent::Committed`][crate::LoadEvent::Committed] event.
4236 ///
4237 /// You can handle this signal and use a switch to track any ongoing
4238 /// load operation.
4239 ///
4240 /// **⚠️ The following code is in c ⚠️**
4241 ///
4242 /// ```c
4243 /// static void web_view_load_changed (WebKitWebView *web_view,
4244 /// WebKitLoadEvent load_event,
4245 /// gpointer user_data)
4246 /// {
4247 /// switch (load_event) {
4248 /// case WEBKIT_LOAD_STARTED:
4249 /// // New load, we have now a provisional URI
4250 /// provisional_uri = webkit_web_view_get_uri (web_view);
4251 /// // Here we could start a spinner or update the
4252 /// // location bar with the provisional URI
4253 /// break;
4254 /// case WEBKIT_LOAD_REDIRECTED:
4255 /// redirected_uri = webkit_web_view_get_uri (web_view);
4256 /// break;
4257 /// case WEBKIT_LOAD_COMMITTED:
4258 /// // The load is being performed. Current URI is
4259 /// // the final one and it won't change unless a new
4260 /// // load is requested or a navigation within the
4261 /// // same page is performed
4262 /// uri = webkit_web_view_get_uri (web_view);
4263 /// break;
4264 /// case WEBKIT_LOAD_FINISHED:
4265 /// // Load finished, we can now stop the spinner
4266 /// break;
4267 /// }
4268 /// }
4269 /// ```
4270 /// ## `load_event`
4271 /// the [`LoadEvent`][crate::LoadEvent]
4272 #[doc(alias = "load-changed")]
4273 fn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>(&self, f: F) -> SignalHandlerId {
4274 unsafe extern "C" fn load_changed_trampoline<
4275 P: IsA<WebView>,
4276 F: Fn(&P, LoadEvent) + 'static,
4277 >(
4278 this: *mut ffi::WebKitWebView,
4279 load_event: ffi::WebKitLoadEvent,
4280 f: glib::ffi::gpointer,
4281 ) {
4282 unsafe {
4283 let f: &F = &*(f as *const F);
4284 f(
4285 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4286 from_glib(load_event),
4287 )
4288 }
4289 }
4290 unsafe {
4291 let f: Box_<F> = Box_::new(f);
4292 connect_raw(
4293 self.as_ptr() as *mut _,
4294 c"load-changed".as_ptr(),
4295 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4296 load_changed_trampoline::<Self, F> as *const (),
4297 )),
4298 Box_::into_raw(f),
4299 )
4300 }
4301 }
4302
4303 /// Emitted when an error occurs during a load operation.
4304 /// If the error happened when starting to load data for a page
4305 /// `load_event` will be [`LoadEvent::Started`][crate::LoadEvent::Started]. If it happened while
4306 /// loading a committed data source `load_event` will be [`LoadEvent::Committed`][crate::LoadEvent::Committed].
4307 /// Since a load error causes the load operation to finish, the signal
4308 /// WebKitWebView::load-changed will always be emitted with
4309 /// [`LoadEvent::Finished`][crate::LoadEvent::Finished] event right after this one.
4310 ///
4311 /// By default, if the signal is not handled, a stock error page will be displayed.
4312 /// You need to handle the signal if you want to provide your own error page.
4313 /// ## `load_event`
4314 /// the [`LoadEvent`][crate::LoadEvent] of the load operation
4315 /// ## `failing_uri`
4316 /// the URI that failed to load
4317 /// ## `error`
4318 /// the [`glib::Error`][crate::glib::Error] that was triggered
4319 ///
4320 /// # Returns
4321 ///
4322 /// [`true`] to stop other handlers from being invoked for the event.
4323 /// [`false`] to propagate the event further.
4324 #[doc(alias = "load-failed")]
4325 fn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &glib::Error) -> bool + 'static>(
4326 &self,
4327 f: F,
4328 ) -> SignalHandlerId {
4329 unsafe extern "C" fn load_failed_trampoline<
4330 P: IsA<WebView>,
4331 F: Fn(&P, LoadEvent, &str, &glib::Error) -> bool + 'static,
4332 >(
4333 this: *mut ffi::WebKitWebView,
4334 load_event: ffi::WebKitLoadEvent,
4335 failing_uri: *mut std::ffi::c_char,
4336 error: *mut glib::ffi::GError,
4337 f: glib::ffi::gpointer,
4338 ) -> glib::ffi::gboolean {
4339 unsafe {
4340 let f: &F = &*(f as *const F);
4341 f(
4342 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4343 from_glib(load_event),
4344 &glib::GString::from_glib_borrow(failing_uri),
4345 &from_glib_borrow(error),
4346 )
4347 .into_glib()
4348 }
4349 }
4350 unsafe {
4351 let f: Box_<F> = Box_::new(f);
4352 connect_raw(
4353 self.as_ptr() as *mut _,
4354 c"load-failed".as_ptr(),
4355 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4356 load_failed_trampoline::<Self, F> as *const (),
4357 )),
4358 Box_::into_raw(f),
4359 )
4360 }
4361 }
4362
4363 /// Emitted when a TLS error occurs during a load operation.
4364 /// To allow an exception for this `certificate`
4365 /// and the host of `failing_uri` use `webkit_web_context_allow_tls_certificate_for_host()`.
4366 ///
4367 /// To handle this signal asynchronously you should call `g_object_ref()` on `certificate`
4368 /// and return [`true`].
4369 ///
4370 /// If [`false`] is returned, [`load-failed`][struct@crate::WebView#load-failed] will be emitted. The load
4371 /// will finish regardless of the returned value.
4372 /// ## `failing_uri`
4373 /// the URI that failed to load
4374 /// ## `certificate`
4375 /// a [`gio::TlsCertificate`][crate::gio::TlsCertificate]
4376 /// ## `errors`
4377 /// a [`gio::TlsCertificateFlags`][crate::gio::TlsCertificateFlags] with the verification status of `certificate`
4378 ///
4379 /// # Returns
4380 ///
4381 /// [`true`] to stop other handlers from being invoked for the event.
4382 /// [`false`] to propagate the event further.
4383 #[doc(alias = "load-failed-with-tls-errors")]
4384 fn connect_load_failed_with_tls_errors<
4385 F: Fn(&Self, &str, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
4386 >(
4387 &self,
4388 f: F,
4389 ) -> SignalHandlerId {
4390 unsafe extern "C" fn load_failed_with_tls_errors_trampoline<
4391 P: IsA<WebView>,
4392 F: Fn(&P, &str, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
4393 >(
4394 this: *mut ffi::WebKitWebView,
4395 failing_uri: *mut std::ffi::c_char,
4396 certificate: *mut gio::ffi::GTlsCertificate,
4397 errors: gio::ffi::GTlsCertificateFlags,
4398 f: glib::ffi::gpointer,
4399 ) -> glib::ffi::gboolean {
4400 unsafe {
4401 let f: &F = &*(f as *const F);
4402 f(
4403 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4404 &glib::GString::from_glib_borrow(failing_uri),
4405 &from_glib_borrow(certificate),
4406 from_glib(errors),
4407 )
4408 .into_glib()
4409 }
4410 }
4411 unsafe {
4412 let f: Box_<F> = Box_::new(f);
4413 connect_raw(
4414 self.as_ptr() as *mut _,
4415 c"load-failed-with-tls-errors".as_ptr(),
4416 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4417 load_failed_with_tls_errors_trampoline::<Self, F> as *const (),
4418 )),
4419 Box_::into_raw(f),
4420 )
4421 }
4422 }
4423
4424 /// This signal is emitted when the mouse cursor moves over an
4425 /// element such as a link, image or a media element. To determine
4426 /// what type of element the mouse cursor is over, a Hit Test is performed
4427 /// on the current mouse coordinates and the result is passed in the
4428 /// `hit_test_result` argument. The `modifiers` argument is a bitmask of
4429 /// `GdkModifierType` flags indicating the state of modifier keys.
4430 /// The signal is emitted again when the mouse is moved out of the
4431 /// current element with a new `hit_test_result`.
4432 /// ## `hit_test_result`
4433 /// a [`HitTestResult`][crate::HitTestResult]
4434 /// ## `modifiers`
4435 /// a bitmask of `GdkModifierType`
4436 #[doc(alias = "mouse-target-changed")]
4437 fn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>(
4438 &self,
4439 f: F,
4440 ) -> SignalHandlerId {
4441 unsafe extern "C" fn mouse_target_changed_trampoline<
4442 P: IsA<WebView>,
4443 F: Fn(&P, &HitTestResult, u32) + 'static,
4444 >(
4445 this: *mut ffi::WebKitWebView,
4446 hit_test_result: *mut ffi::WebKitHitTestResult,
4447 modifiers: std::ffi::c_uint,
4448 f: glib::ffi::gpointer,
4449 ) {
4450 unsafe {
4451 let f: &F = &*(f as *const F);
4452 f(
4453 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4454 &from_glib_borrow(hit_test_result),
4455 modifiers,
4456 )
4457 }
4458 }
4459 unsafe {
4460 let f: Box_<F> = Box_::new(f);
4461 connect_raw(
4462 self.as_ptr() as *mut _,
4463 c"mouse-target-changed".as_ptr(),
4464 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4465 mouse_target_changed_trampoline::<Self, F> as *const (),
4466 )),
4467 Box_::into_raw(f),
4468 )
4469 }
4470 }
4471
4472 /// This signal is emitted when WebKit is requesting the client to
4473 /// decide about a permission request, such as allowing the browser
4474 /// to switch to fullscreen mode, sharing its location or similar
4475 /// operations.
4476 ///
4477 /// A possible way to use this signal could be through a dialog
4478 /// allowing the user decide what to do with the request:
4479 ///
4480 /// **⚠️ The following code is in c ⚠️**
4481 ///
4482 /// ```c
4483 /// static gboolean permission_request_cb (WebKitWebView *web_view,
4484 /// WebKitPermissionRequest *request,
4485 /// GtkWindow *parent_window)
4486 /// {
4487 /// GtkWidget *dialog = gtk_message_dialog_new (parent_window,
4488 /// GTK_DIALOG_MODAL,
4489 /// GTK_MESSAGE_QUESTION,
4490 /// GTK_BUTTONS_YES_NO,
4491 /// "Allow Permission Request?");
4492 /// gtk_widget_show (dialog);
4493 /// gint result = gtk_dialog_run (GTK_DIALOG (dialog));
4494 ///
4495 /// switch (result) {
4496 /// case GTK_RESPONSE_YES:
4497 /// webkit_permission_request_allow (request);
4498 /// break;
4499 /// default:
4500 /// webkit_permission_request_deny (request);
4501 /// break;
4502 /// }
4503 /// gtk_widget_destroy (dialog);
4504 ///
4505 /// return TRUE;
4506 /// }
4507 /// ```
4508 ///
4509 /// It is possible to handle permission requests asynchronously, by
4510 /// simply calling `g_object_ref()` on the `request` argument and
4511 /// returning [`true`] to block the default signal handler. If the
4512 /// last reference is removed on a [`PermissionRequest`][crate::PermissionRequest] and the
4513 /// request has not been handled, [`PermissionRequestExt::deny()`][crate::prelude::PermissionRequestExt::deny()]
4514 /// will be the default action.
4515 ///
4516 /// If the signal is not handled, the `request` will be completed automatically
4517 /// by the specific [`PermissionRequest`][crate::PermissionRequest] that could allow or deny it. Check the
4518 /// documentation of classes implementing [`PermissionRequest`][crate::PermissionRequest] interface to know
4519 /// their default action.
4520 /// ## `request`
4521 /// the [`PermissionRequest`][crate::PermissionRequest]
4522 ///
4523 /// # Returns
4524 ///
4525 /// [`true`] to stop other handlers from being invoked for the event.
4526 /// [`false`] to propagate the event further.
4527 #[doc(alias = "permission-request")]
4528 fn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>(
4529 &self,
4530 f: F,
4531 ) -> SignalHandlerId {
4532 unsafe extern "C" fn permission_request_trampoline<
4533 P: IsA<WebView>,
4534 F: Fn(&P, &PermissionRequest) -> bool + 'static,
4535 >(
4536 this: *mut ffi::WebKitWebView,
4537 request: *mut ffi::WebKitPermissionRequest,
4538 f: glib::ffi::gpointer,
4539 ) -> glib::ffi::gboolean {
4540 unsafe {
4541 let f: &F = &*(f as *const F);
4542 f(
4543 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4544 &from_glib_borrow(request),
4545 )
4546 .into_glib()
4547 }
4548 }
4549 unsafe {
4550 let f: Box_<F> = Box_::new(f);
4551 connect_raw(
4552 self.as_ptr() as *mut _,
4553 c"permission-request".as_ptr(),
4554 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4555 permission_request_trampoline::<Self, F> as *const (),
4556 )),
4557 Box_::into_raw(f),
4558 )
4559 }
4560 }
4561
4562 /// Emitted when printing is requested on `web_view`, usually by a JavaScript call,
4563 /// before the print dialog is shown. This signal can be used to set the initial
4564 /// print settings and page setup of `print_operation` to be used as default values in
4565 /// the print dialog. You can call [`PrintOperation::set_print_settings()`][crate::PrintOperation::set_print_settings()] and
4566 /// [`PrintOperation::set_page_setup()`][crate::PrintOperation::set_page_setup()] and then return [`false`] to propagate the
4567 /// event so that the print dialog is shown.
4568 ///
4569 /// You can connect to this signal and return [`true`] to cancel the print operation
4570 /// or implement your own print dialog.
4571 /// ## `print_operation`
4572 /// the [`PrintOperation`][crate::PrintOperation] that will handle the print request
4573 ///
4574 /// # Returns
4575 ///
4576 /// [`true`] to stop other handlers from being invoked for the event.
4577 /// [`false`] to propagate the event further.
4578 #[doc(alias = "print")]
4579 fn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>(
4580 &self,
4581 f: F,
4582 ) -> SignalHandlerId {
4583 unsafe extern "C" fn print_trampoline<
4584 P: IsA<WebView>,
4585 F: Fn(&P, &PrintOperation) -> bool + 'static,
4586 >(
4587 this: *mut ffi::WebKitWebView,
4588 print_operation: *mut ffi::WebKitPrintOperation,
4589 f: glib::ffi::gpointer,
4590 ) -> glib::ffi::gboolean {
4591 unsafe {
4592 let f: &F = &*(f as *const F);
4593 f(
4594 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4595 &from_glib_borrow(print_operation),
4596 )
4597 .into_glib()
4598 }
4599 }
4600 unsafe {
4601 let f: Box_<F> = Box_::new(f);
4602 connect_raw(
4603 self.as_ptr() as *mut _,
4604 c"print".as_ptr(),
4605 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4606 print_trampoline::<Self, F> as *const (),
4607 )),
4608 Box_::into_raw(f),
4609 )
4610 }
4611 }
4612
4613 /// This signal allows the User-Agent to respond to permission requests for powerful features, as
4614 /// specified by the [Permissions W3C Specification](https://w3c.github.io/permissions/).
4615 /// You can reply to the query using [`PermissionStateQuery::finish()`][crate::PermissionStateQuery::finish()].
4616 ///
4617 /// You can handle the query asynchronously by calling `webkit_permission_state_query_ref()` on
4618 /// `query` and returning [`true`]. If the last reference of `query` is removed and the query has not
4619 /// been handled, the query result will be set to `WEBKIT_QUERY_PERMISSION_PROMPT`.
4620 /// ## `query`
4621 /// the [`PermissionStateQuery`][crate::PermissionStateQuery]
4622 ///
4623 /// # Returns
4624 ///
4625 /// [`true`] if the message was handled, or [`false`] otherwise.
4626 #[doc(alias = "query-permission-state")]
4627 fn connect_query_permission_state<F: Fn(&Self, &PermissionStateQuery) -> bool + 'static>(
4628 &self,
4629 f: F,
4630 ) -> SignalHandlerId {
4631 unsafe extern "C" fn query_permission_state_trampoline<
4632 P: IsA<WebView>,
4633 F: Fn(&P, &PermissionStateQuery) -> bool + 'static,
4634 >(
4635 this: *mut ffi::WebKitWebView,
4636 query: *mut ffi::WebKitPermissionStateQuery,
4637 f: glib::ffi::gpointer,
4638 ) -> glib::ffi::gboolean {
4639 unsafe {
4640 let f: &F = &*(f as *const F);
4641 f(
4642 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4643 &from_glib_borrow(query),
4644 )
4645 .into_glib()
4646 }
4647 }
4648 unsafe {
4649 let f: Box_<F> = Box_::new(f);
4650 connect_raw(
4651 self.as_ptr() as *mut _,
4652 c"query-permission-state".as_ptr(),
4653 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4654 query_permission_state_trampoline::<Self, F> as *const (),
4655 )),
4656 Box_::into_raw(f),
4657 )
4658 }
4659 }
4660
4661 /// Emitted after [`create`][struct@crate::WebView#create] on the newly created [`WebView`][crate::WebView]
4662 /// when it should be displayed to the user. When this signal is emitted
4663 /// all the information about how the window should look, including
4664 /// size, position, whether the location, status and scrollbars
4665 /// should be displayed, is already set on the [`WindowProperties`][crate::WindowProperties]
4666 /// of `web_view`. See also [`window_properties()`][Self::window_properties()].
4667 #[doc(alias = "ready-to-show")]
4668 fn connect_ready_to_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4669 unsafe extern "C" fn ready_to_show_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
4670 this: *mut ffi::WebKitWebView,
4671 f: glib::ffi::gpointer,
4672 ) {
4673 unsafe {
4674 let f: &F = &*(f as *const F);
4675 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
4676 }
4677 }
4678 unsafe {
4679 let f: Box_<F> = Box_::new(f);
4680 connect_raw(
4681 self.as_ptr() as *mut _,
4682 c"ready-to-show".as_ptr(),
4683 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4684 ready_to_show_trampoline::<Self, F> as *const (),
4685 )),
4686 Box_::into_raw(f),
4687 )
4688 }
4689 }
4690
4691 /// Emitted when a new resource is going to be loaded. The `request` parameter
4692 /// contains the [`URIRequest`][crate::URIRequest] that will be sent to the server.
4693 /// You can monitor the load operation by connecting to the different signals
4694 /// of `resource`.
4695 /// ## `resource`
4696 /// a [`WebResource`][crate::WebResource]
4697 /// ## `request`
4698 /// a [`URIRequest`][crate::URIRequest]
4699 #[doc(alias = "resource-load-started")]
4700 fn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>(
4701 &self,
4702 f: F,
4703 ) -> SignalHandlerId {
4704 unsafe extern "C" fn resource_load_started_trampoline<
4705 P: IsA<WebView>,
4706 F: Fn(&P, &WebResource, &URIRequest) + 'static,
4707 >(
4708 this: *mut ffi::WebKitWebView,
4709 resource: *mut ffi::WebKitWebResource,
4710 request: *mut ffi::WebKitURIRequest,
4711 f: glib::ffi::gpointer,
4712 ) {
4713 unsafe {
4714 let f: &F = &*(f as *const F);
4715 f(
4716 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4717 &from_glib_borrow(resource),
4718 &from_glib_borrow(request),
4719 )
4720 }
4721 }
4722 unsafe {
4723 let f: Box_<F> = Box_::new(f);
4724 connect_raw(
4725 self.as_ptr() as *mut _,
4726 c"resource-load-started".as_ptr(),
4727 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4728 resource_load_started_trampoline::<Self, F> as *const (),
4729 )),
4730 Box_::into_raw(f),
4731 )
4732 }
4733 }
4734
4735 /// Emitted after [`ready-to-show`][struct@crate::WebView#ready-to-show] on the newly
4736 /// created [`WebView`][crate::WebView] when JavaScript code calls
4737 /// `<function>`window.showModalDialog`</function>`. The purpose of
4738 /// this signal is to allow the client application to prepare the
4739 /// new view to behave as modal. Once the signal is emitted a new
4740 /// main loop will be run to block user interaction in the parent
4741 /// [`WebView`][crate::WebView] until the new dialog is closed.
4742 #[doc(alias = "run-as-modal")]
4743 fn connect_run_as_modal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4744 unsafe extern "C" fn run_as_modal_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
4745 this: *mut ffi::WebKitWebView,
4746 f: glib::ffi::gpointer,
4747 ) {
4748 unsafe {
4749 let f: &F = &*(f as *const F);
4750 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
4751 }
4752 }
4753 unsafe {
4754 let f: Box_<F> = Box_::new(f);
4755 connect_raw(
4756 self.as_ptr() as *mut _,
4757 c"run-as-modal".as_ptr(),
4758 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4759 run_as_modal_trampoline::<Self, F> as *const (),
4760 )),
4761 Box_::into_raw(f),
4762 )
4763 }
4764 }
4765
4766 /// This signal is emitted when the user interacts with a <input
4767 /// type='color' /> HTML element, requesting from WebKit to show
4768 /// a dialog to select a color. To let the application know the details of
4769 /// the color chooser, as well as to allow the client application to either
4770 /// cancel the request or perform an actual color selection, the signal will
4771 /// pass an instance of the [`ColorChooserRequest`][crate::ColorChooserRequest] in the `request`
4772 /// argument.
4773 ///
4774 /// It is possible to handle this request asynchronously by increasing the
4775 /// reference count of the request.
4776 ///
4777 /// The default signal handler will asynchronously run a regular
4778 /// `GtkColorChooser` for the user to interact with.
4779 /// ## `request`
4780 /// a [`ColorChooserRequest`][crate::ColorChooserRequest]
4781 ///
4782 /// # Returns
4783 ///
4784 /// [`true`] to stop other handlers from being invoked for the event.
4785 /// [`false`] to propagate the event further.
4786 #[doc(alias = "run-color-chooser")]
4787 fn connect_run_color_chooser<F: Fn(&Self, &ColorChooserRequest) -> bool + 'static>(
4788 &self,
4789 f: F,
4790 ) -> SignalHandlerId {
4791 unsafe extern "C" fn run_color_chooser_trampoline<
4792 P: IsA<WebView>,
4793 F: Fn(&P, &ColorChooserRequest) -> bool + 'static,
4794 >(
4795 this: *mut ffi::WebKitWebView,
4796 request: *mut ffi::WebKitColorChooserRequest,
4797 f: glib::ffi::gpointer,
4798 ) -> glib::ffi::gboolean {
4799 unsafe {
4800 let f: &F = &*(f as *const F);
4801 f(
4802 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4803 &from_glib_borrow(request),
4804 )
4805 .into_glib()
4806 }
4807 }
4808 unsafe {
4809 let f: Box_<F> = Box_::new(f);
4810 connect_raw(
4811 self.as_ptr() as *mut _,
4812 c"run-color-chooser".as_ptr(),
4813 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4814 run_color_chooser_trampoline::<Self, F> as *const (),
4815 )),
4816 Box_::into_raw(f),
4817 )
4818 }
4819 }
4820
4821 /// This signal is emitted when the user interacts with a <input
4822 /// type='file' /> HTML element, requesting from WebKit to show
4823 /// a dialog to select one or more files to be uploaded. To let the
4824 /// application know the details of the file chooser, as well as to
4825 /// allow the client application to either cancel the request or
4826 /// perform an actual selection of files, the signal will pass an
4827 /// instance of the [`FileChooserRequest`][crate::FileChooserRequest] in the `request`
4828 /// argument.
4829 ///
4830 /// The default signal handler will asynchronously run a regular
4831 /// `GtkFileChooserDialog` for the user to interact with.
4832 /// ## `request`
4833 /// a [`FileChooserRequest`][crate::FileChooserRequest]
4834 ///
4835 /// # Returns
4836 ///
4837 /// [`true`] to stop other handlers from being invoked for the event.
4838 /// [`false`] to propagate the event further.
4839 #[doc(alias = "run-file-chooser")]
4840 fn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>(
4841 &self,
4842 f: F,
4843 ) -> SignalHandlerId {
4844 unsafe extern "C" fn run_file_chooser_trampoline<
4845 P: IsA<WebView>,
4846 F: Fn(&P, &FileChooserRequest) -> bool + 'static,
4847 >(
4848 this: *mut ffi::WebKitWebView,
4849 request: *mut ffi::WebKitFileChooserRequest,
4850 f: glib::ffi::gpointer,
4851 ) -> glib::ffi::gboolean {
4852 unsafe {
4853 let f: &F = &*(f as *const F);
4854 f(
4855 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4856 &from_glib_borrow(request),
4857 )
4858 .into_glib()
4859 }
4860 }
4861 unsafe {
4862 let f: Box_<F> = Box_::new(f);
4863 connect_raw(
4864 self.as_ptr() as *mut _,
4865 c"run-file-chooser".as_ptr(),
4866 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4867 run_file_chooser_trampoline::<Self, F> as *const (),
4868 )),
4869 Box_::into_raw(f),
4870 )
4871 }
4872 }
4873
4874 /// Emitted when JavaScript code calls `<function>`window.alert`</function>`,
4875 /// `<function>`window.confirm`</function>` or `<function>`window.prompt`</function>`,
4876 /// or when `<function>`onbeforeunload`</function>` event is fired.
4877 /// The `dialog` parameter should be used to build the dialog.
4878 /// If the signal is not handled a different dialog will be built and shown depending
4879 /// on the dialog type:
4880 /// `<itemizedlist>`
4881 /// `<listitem>``<para>`
4882 /// [`ScriptDialogType::Alert`][crate::ScriptDialogType::Alert]: message dialog with a single Close button.
4883 /// `</para>``</listitem>`
4884 /// `<listitem>``<para>`
4885 /// [`ScriptDialogType::Confirm`][crate::ScriptDialogType::Confirm]: message dialog with OK and Cancel buttons.
4886 /// `</para>``</listitem>`
4887 /// `<listitem>``<para>`
4888 /// [`ScriptDialogType::Prompt`][crate::ScriptDialogType::Prompt]: message dialog with OK and Cancel buttons and
4889 /// a text entry with the default text.
4890 /// `</para>``</listitem>`
4891 /// `<listitem>``<para>`
4892 /// [`ScriptDialogType::BeforeUnloadConfirm`][crate::ScriptDialogType::BeforeUnloadConfirm]: message dialog with Stay and Leave buttons.
4893 /// `</para>``</listitem>`
4894 /// `</itemizedlist>`
4895 ///
4896 /// It is possible to handle the script dialog request asynchronously, by simply
4897 /// caling `webkit_script_dialog_ref()` on the `dialog` argument and calling
4898 /// [`ScriptDialog::close()`][crate::ScriptDialog::close()] when done.
4899 /// If the last reference is removed on a [`ScriptDialog`][crate::ScriptDialog] and the dialog has not been
4900 /// closed, [`ScriptDialog::close()`][crate::ScriptDialog::close()] will be called.
4901 /// ## `dialog`
4902 /// the [`ScriptDialog`][crate::ScriptDialog] to show
4903 ///
4904 /// # Returns
4905 ///
4906 /// [`true`] to stop other handlers from being invoked for the event.
4907 /// [`false`] to propagate the event further.
4908 #[doc(alias = "script-dialog")]
4909 fn connect_script_dialog<F: Fn(&Self, &ScriptDialog) -> bool + 'static>(
4910 &self,
4911 f: F,
4912 ) -> SignalHandlerId {
4913 unsafe extern "C" fn script_dialog_trampoline<
4914 P: IsA<WebView>,
4915 F: Fn(&P, &ScriptDialog) -> bool + 'static,
4916 >(
4917 this: *mut ffi::WebKitWebView,
4918 dialog: *mut ffi::WebKitScriptDialog,
4919 f: glib::ffi::gpointer,
4920 ) -> glib::ffi::gboolean {
4921 unsafe {
4922 let f: &F = &*(f as *const F);
4923 f(
4924 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4925 &from_glib_borrow(dialog),
4926 )
4927 .into_glib()
4928 }
4929 }
4930 unsafe {
4931 let f: Box_<F> = Box_::new(f);
4932 connect_raw(
4933 self.as_ptr() as *mut _,
4934 c"script-dialog".as_ptr(),
4935 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4936 script_dialog_trampoline::<Self, F> as *const (),
4937 )),
4938 Box_::into_raw(f),
4939 )
4940 }
4941 }
4942
4943 /// This signal is emitted when a notification should be presented to the
4944 /// user. The `notification` is kept alive until either: 1) the web page cancels it
4945 /// or 2) a navigation happens.
4946 ///
4947 /// The default handler will emit a notification using libnotify, if built with
4948 /// support for it.
4949 /// ## `notification`
4950 /// a [`Notification`][crate::Notification]
4951 ///
4952 /// # Returns
4953 ///
4954 /// [`true`] to stop other handlers from being invoked. [`false`] otherwise.
4955 #[doc(alias = "show-notification")]
4956 fn connect_show_notification<F: Fn(&Self, &Notification) -> bool + 'static>(
4957 &self,
4958 f: F,
4959 ) -> SignalHandlerId {
4960 unsafe extern "C" fn show_notification_trampoline<
4961 P: IsA<WebView>,
4962 F: Fn(&P, &Notification) -> bool + 'static,
4963 >(
4964 this: *mut ffi::WebKitWebView,
4965 notification: *mut ffi::WebKitNotification,
4966 f: glib::ffi::gpointer,
4967 ) -> glib::ffi::gboolean {
4968 unsafe {
4969 let f: &F = &*(f as *const F);
4970 f(
4971 WebView::from_glib_borrow(this).unsafe_cast_ref(),
4972 &from_glib_borrow(notification),
4973 )
4974 .into_glib()
4975 }
4976 }
4977 unsafe {
4978 let f: Box_<F> = Box_::new(f);
4979 connect_raw(
4980 self.as_ptr() as *mut _,
4981 c"show-notification".as_ptr(),
4982 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4983 show_notification_trampoline::<Self, F> as *const (),
4984 )),
4985 Box_::into_raw(f),
4986 )
4987 }
4988 }
4989
4990 /// This signal is emitted when a select element in `web_view` needs to display a
4991 /// dropdown menu. This signal can be used to show a custom menu, using `menu` to get
4992 /// the details of all items that should be displayed. The area of the element in the
4993 /// [`WebView`][crate::WebView] is given as `rectangle` parameter, it can be used to position the
4994 /// menu.
4995 /// To handle this signal asynchronously you should keep a ref of the `menu`.
4996 ///
4997 /// The default signal handler will pop up a `GtkMenu`.
4998 /// ## `menu`
4999 /// the [`OptionMenu`][crate::OptionMenu]
5000 /// ## `rectangle`
5001 /// the option element area
5002 ///
5003 /// # Returns
5004 ///
5005 /// [`true`] to stop other handlers from being invoked for the event.
5006 /// [`false`] to propagate the event further.
5007 #[doc(alias = "show-option-menu")]
5008 fn connect_show_option_menu<F: Fn(&Self, &OptionMenu, &gdk::Rectangle) -> bool + 'static>(
5009 &self,
5010 f: F,
5011 ) -> SignalHandlerId {
5012 unsafe extern "C" fn show_option_menu_trampoline<
5013 P: IsA<WebView>,
5014 F: Fn(&P, &OptionMenu, &gdk::Rectangle) -> bool + 'static,
5015 >(
5016 this: *mut ffi::WebKitWebView,
5017 menu: *mut ffi::WebKitOptionMenu,
5018 rectangle: *mut gdk::ffi::GdkRectangle,
5019 f: glib::ffi::gpointer,
5020 ) -> glib::ffi::gboolean {
5021 unsafe {
5022 let f: &F = &*(f as *const F);
5023 f(
5024 WebView::from_glib_borrow(this).unsafe_cast_ref(),
5025 &from_glib_borrow(menu),
5026 &from_glib_borrow(rectangle),
5027 )
5028 .into_glib()
5029 }
5030 }
5031 unsafe {
5032 let f: Box_<F> = Box_::new(f);
5033 connect_raw(
5034 self.as_ptr() as *mut _,
5035 c"show-option-menu".as_ptr(),
5036 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5037 show_option_menu_trampoline::<Self, F> as *const (),
5038 )),
5039 Box_::into_raw(f),
5040 )
5041 }
5042 }
5043
5044 /// This signal is emitted when a form is about to be submitted. The `request`
5045 /// argument passed contains information about the text fields of the form. This
5046 /// is typically used to store login information that can be used later to
5047 /// pre-fill the form.
5048 /// The form will not be submitted until [`FormSubmissionRequest::submit()`][crate::FormSubmissionRequest::submit()] is called.
5049 ///
5050 /// It is possible to handle the form submission request asynchronously, by
5051 /// simply calling `g_object_ref()` on the `request` argument and calling
5052 /// [`FormSubmissionRequest::submit()`][crate::FormSubmissionRequest::submit()] when done to continue with the form submission.
5053 /// If the last reference is removed on a [`FormSubmissionRequest`][crate::FormSubmissionRequest] and the
5054 /// form has not been submitted, [`FormSubmissionRequest::submit()`][crate::FormSubmissionRequest::submit()] will be called.
5055 /// ## `request`
5056 /// a [`FormSubmissionRequest`][crate::FormSubmissionRequest]
5057 #[doc(alias = "submit-form")]
5058 fn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>(
5059 &self,
5060 f: F,
5061 ) -> SignalHandlerId {
5062 unsafe extern "C" fn submit_form_trampoline<
5063 P: IsA<WebView>,
5064 F: Fn(&P, &FormSubmissionRequest) + 'static,
5065 >(
5066 this: *mut ffi::WebKitWebView,
5067 request: *mut ffi::WebKitFormSubmissionRequest,
5068 f: glib::ffi::gpointer,
5069 ) {
5070 unsafe {
5071 let f: &F = &*(f as *const F);
5072 f(
5073 WebView::from_glib_borrow(this).unsafe_cast_ref(),
5074 &from_glib_borrow(request),
5075 )
5076 }
5077 }
5078 unsafe {
5079 let f: Box_<F> = Box_::new(f);
5080 connect_raw(
5081 self.as_ptr() as *mut _,
5082 c"submit-form".as_ptr(),
5083 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5084 submit_form_trampoline::<Self, F> as *const (),
5085 )),
5086 Box_::into_raw(f),
5087 )
5088 }
5089 }
5090
5091 /// This signal is emitted when a [`UserMessage`][crate::UserMessage] is received from the
5092 /// `WebKitWebPage` corresponding to `web_view`. You can reply to the message
5093 /// using [`UserMessage::send_reply()`][crate::UserMessage::send_reply()].
5094 ///
5095 /// You can handle the user message asynchronously by calling `g_object_ref()` on
5096 /// `message` and returning [`true`]. If the last reference of `message` is removed
5097 /// and the message has not been replied to, the operation in the `WebKitWebPage` will
5098 /// finish with error [`UserMessageError::Message`][crate::UserMessageError::Message].
5099 /// ## `message`
5100 /// the [`UserMessage`][crate::UserMessage] received
5101 ///
5102 /// # Returns
5103 ///
5104 /// [`true`] if the message was handled, or [`false`] otherwise.
5105 #[doc(alias = "user-message-received")]
5106 fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
5107 &self,
5108 f: F,
5109 ) -> SignalHandlerId {
5110 unsafe extern "C" fn user_message_received_trampoline<
5111 P: IsA<WebView>,
5112 F: Fn(&P, &UserMessage) -> bool + 'static,
5113 >(
5114 this: *mut ffi::WebKitWebView,
5115 message: *mut ffi::WebKitUserMessage,
5116 f: glib::ffi::gpointer,
5117 ) -> glib::ffi::gboolean {
5118 unsafe {
5119 let f: &F = &*(f as *const F);
5120 f(
5121 WebView::from_glib_borrow(this).unsafe_cast_ref(),
5122 &from_glib_borrow(message),
5123 )
5124 .into_glib()
5125 }
5126 }
5127 unsafe {
5128 let f: Box_<F> = Box_::new(f);
5129 connect_raw(
5130 self.as_ptr() as *mut _,
5131 c"user-message-received".as_ptr(),
5132 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5133 user_message_received_trampoline::<Self, F> as *const (),
5134 )),
5135 Box_::into_raw(f),
5136 )
5137 }
5138 }
5139
5140 /// This signal is emitted when the web process terminates abnormally due
5141 /// to `reason`.
5142 /// ## `reason`
5143 /// the a [`WebProcessTerminationReason`][crate::WebProcessTerminationReason]
5144 #[doc(alias = "web-process-terminated")]
5145 fn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>(
5146 &self,
5147 f: F,
5148 ) -> SignalHandlerId {
5149 unsafe extern "C" fn web_process_terminated_trampoline<
5150 P: IsA<WebView>,
5151 F: Fn(&P, WebProcessTerminationReason) + 'static,
5152 >(
5153 this: *mut ffi::WebKitWebView,
5154 reason: ffi::WebKitWebProcessTerminationReason,
5155 f: glib::ffi::gpointer,
5156 ) {
5157 unsafe {
5158 let f: &F = &*(f as *const F);
5159 f(
5160 WebView::from_glib_borrow(this).unsafe_cast_ref(),
5161 from_glib(reason),
5162 )
5163 }
5164 }
5165 unsafe {
5166 let f: Box_<F> = Box_::new(f);
5167 connect_raw(
5168 self.as_ptr() as *mut _,
5169 c"web-process-terminated".as_ptr(),
5170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5171 web_process_terminated_trampoline::<Self, F> as *const (),
5172 )),
5173 Box_::into_raw(f),
5174 )
5175 }
5176 }
5177
5178 #[doc(alias = "camera-capture-state")]
5179 fn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5180 unsafe extern "C" fn notify_camera_capture_state_trampoline<
5181 P: IsA<WebView>,
5182 F: Fn(&P) + 'static,
5183 >(
5184 this: *mut ffi::WebKitWebView,
5185 _param_spec: glib::ffi::gpointer,
5186 f: glib::ffi::gpointer,
5187 ) {
5188 unsafe {
5189 let f: &F = &*(f as *const F);
5190 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5191 }
5192 }
5193 unsafe {
5194 let f: Box_<F> = Box_::new(f);
5195 connect_raw(
5196 self.as_ptr() as *mut _,
5197 c"notify::camera-capture-state".as_ptr(),
5198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5199 notify_camera_capture_state_trampoline::<Self, F> as *const (),
5200 )),
5201 Box_::into_raw(f),
5202 )
5203 }
5204 }
5205
5206 #[doc(alias = "display-capture-state")]
5207 fn connect_display_capture_state_notify<F: Fn(&Self) + 'static>(
5208 &self,
5209 f: F,
5210 ) -> SignalHandlerId {
5211 unsafe extern "C" fn notify_display_capture_state_trampoline<
5212 P: IsA<WebView>,
5213 F: Fn(&P) + 'static,
5214 >(
5215 this: *mut ffi::WebKitWebView,
5216 _param_spec: glib::ffi::gpointer,
5217 f: glib::ffi::gpointer,
5218 ) {
5219 unsafe {
5220 let f: &F = &*(f as *const F);
5221 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5222 }
5223 }
5224 unsafe {
5225 let f: Box_<F> = Box_::new(f);
5226 connect_raw(
5227 self.as_ptr() as *mut _,
5228 c"notify::display-capture-state".as_ptr(),
5229 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5230 notify_display_capture_state_trampoline::<Self, F> as *const (),
5231 )),
5232 Box_::into_raw(f),
5233 )
5234 }
5235 }
5236
5237 #[doc(alias = "editable")]
5238 fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5239 unsafe extern "C" fn notify_editable_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5240 this: *mut ffi::WebKitWebView,
5241 _param_spec: glib::ffi::gpointer,
5242 f: glib::ffi::gpointer,
5243 ) {
5244 unsafe {
5245 let f: &F = &*(f as *const F);
5246 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5247 }
5248 }
5249 unsafe {
5250 let f: Box_<F> = Box_::new(f);
5251 connect_raw(
5252 self.as_ptr() as *mut _,
5253 c"notify::editable".as_ptr(),
5254 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5255 notify_editable_trampoline::<Self, F> as *const (),
5256 )),
5257 Box_::into_raw(f),
5258 )
5259 }
5260 }
5261
5262 #[doc(alias = "estimated-load-progress")]
5263 fn connect_estimated_load_progress_notify<F: Fn(&Self) + 'static>(
5264 &self,
5265 f: F,
5266 ) -> SignalHandlerId {
5267 unsafe extern "C" fn notify_estimated_load_progress_trampoline<
5268 P: IsA<WebView>,
5269 F: Fn(&P) + 'static,
5270 >(
5271 this: *mut ffi::WebKitWebView,
5272 _param_spec: glib::ffi::gpointer,
5273 f: glib::ffi::gpointer,
5274 ) {
5275 unsafe {
5276 let f: &F = &*(f as *const F);
5277 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5278 }
5279 }
5280 unsafe {
5281 let f: Box_<F> = Box_::new(f);
5282 connect_raw(
5283 self.as_ptr() as *mut _,
5284 c"notify::estimated-load-progress".as_ptr(),
5285 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5286 notify_estimated_load_progress_trampoline::<Self, F> as *const (),
5287 )),
5288 Box_::into_raw(f),
5289 )
5290 }
5291 }
5292
5293 #[doc(alias = "favicon")]
5294 fn connect_favicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5295 unsafe extern "C" fn notify_favicon_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5296 this: *mut ffi::WebKitWebView,
5297 _param_spec: glib::ffi::gpointer,
5298 f: glib::ffi::gpointer,
5299 ) {
5300 unsafe {
5301 let f: &F = &*(f as *const F);
5302 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5303 }
5304 }
5305 unsafe {
5306 let f: Box_<F> = Box_::new(f);
5307 connect_raw(
5308 self.as_ptr() as *mut _,
5309 c"notify::favicon".as_ptr(),
5310 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5311 notify_favicon_trampoline::<Self, F> as *const (),
5312 )),
5313 Box_::into_raw(f),
5314 )
5315 }
5316 }
5317
5318 #[cfg(feature = "v2_52")]
5319 #[cfg_attr(docsrs, doc(cfg(feature = "v2_52")))]
5320 #[doc(alias = "is-immersive-mode-enabled")]
5321 fn connect_is_immersive_mode_enabled_notify<F: Fn(&Self) + 'static>(
5322 &self,
5323 f: F,
5324 ) -> SignalHandlerId {
5325 unsafe extern "C" fn notify_is_immersive_mode_enabled_trampoline<
5326 P: IsA<WebView>,
5327 F: Fn(&P) + 'static,
5328 >(
5329 this: *mut ffi::WebKitWebView,
5330 _param_spec: glib::ffi::gpointer,
5331 f: glib::ffi::gpointer,
5332 ) {
5333 unsafe {
5334 let f: &F = &*(f as *const F);
5335 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5336 }
5337 }
5338 unsafe {
5339 let f: Box_<F> = Box_::new(f);
5340 connect_raw(
5341 self.as_ptr() as *mut _,
5342 c"notify::is-immersive-mode-enabled".as_ptr(),
5343 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5344 notify_is_immersive_mode_enabled_trampoline::<Self, F> as *const (),
5345 )),
5346 Box_::into_raw(f),
5347 )
5348 }
5349 }
5350
5351 #[doc(alias = "is-loading")]
5352 fn connect_is_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5353 unsafe extern "C" fn notify_is_loading_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5354 this: *mut ffi::WebKitWebView,
5355 _param_spec: glib::ffi::gpointer,
5356 f: glib::ffi::gpointer,
5357 ) {
5358 unsafe {
5359 let f: &F = &*(f as *const F);
5360 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5361 }
5362 }
5363 unsafe {
5364 let f: Box_<F> = Box_::new(f);
5365 connect_raw(
5366 self.as_ptr() as *mut _,
5367 c"notify::is-loading".as_ptr(),
5368 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5369 notify_is_loading_trampoline::<Self, F> as *const (),
5370 )),
5371 Box_::into_raw(f),
5372 )
5373 }
5374 }
5375
5376 #[doc(alias = "is-muted")]
5377 fn connect_is_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5378 unsafe extern "C" fn notify_is_muted_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5379 this: *mut ffi::WebKitWebView,
5380 _param_spec: glib::ffi::gpointer,
5381 f: glib::ffi::gpointer,
5382 ) {
5383 unsafe {
5384 let f: &F = &*(f as *const F);
5385 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5386 }
5387 }
5388 unsafe {
5389 let f: Box_<F> = Box_::new(f);
5390 connect_raw(
5391 self.as_ptr() as *mut _,
5392 c"notify::is-muted".as_ptr(),
5393 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5394 notify_is_muted_trampoline::<Self, F> as *const (),
5395 )),
5396 Box_::into_raw(f),
5397 )
5398 }
5399 }
5400
5401 #[doc(alias = "is-playing-audio")]
5402 fn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5403 unsafe extern "C" fn notify_is_playing_audio_trampoline<
5404 P: IsA<WebView>,
5405 F: Fn(&P) + 'static,
5406 >(
5407 this: *mut ffi::WebKitWebView,
5408 _param_spec: glib::ffi::gpointer,
5409 f: glib::ffi::gpointer,
5410 ) {
5411 unsafe {
5412 let f: &F = &*(f as *const F);
5413 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5414 }
5415 }
5416 unsafe {
5417 let f: Box_<F> = Box_::new(f);
5418 connect_raw(
5419 self.as_ptr() as *mut _,
5420 c"notify::is-playing-audio".as_ptr(),
5421 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5422 notify_is_playing_audio_trampoline::<Self, F> as *const (),
5423 )),
5424 Box_::into_raw(f),
5425 )
5426 }
5427 }
5428
5429 #[doc(alias = "is-web-process-responsive")]
5430 fn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>(
5431 &self,
5432 f: F,
5433 ) -> SignalHandlerId {
5434 unsafe extern "C" fn notify_is_web_process_responsive_trampoline<
5435 P: IsA<WebView>,
5436 F: Fn(&P) + 'static,
5437 >(
5438 this: *mut ffi::WebKitWebView,
5439 _param_spec: glib::ffi::gpointer,
5440 f: glib::ffi::gpointer,
5441 ) {
5442 unsafe {
5443 let f: &F = &*(f as *const F);
5444 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5445 }
5446 }
5447 unsafe {
5448 let f: Box_<F> = Box_::new(f);
5449 connect_raw(
5450 self.as_ptr() as *mut _,
5451 c"notify::is-web-process-responsive".as_ptr(),
5452 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5453 notify_is_web_process_responsive_trampoline::<Self, F> as *const (),
5454 )),
5455 Box_::into_raw(f),
5456 )
5457 }
5458 }
5459
5460 #[doc(alias = "microphone-capture-state")]
5461 fn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>(
5462 &self,
5463 f: F,
5464 ) -> SignalHandlerId {
5465 unsafe extern "C" fn notify_microphone_capture_state_trampoline<
5466 P: IsA<WebView>,
5467 F: Fn(&P) + 'static,
5468 >(
5469 this: *mut ffi::WebKitWebView,
5470 _param_spec: glib::ffi::gpointer,
5471 f: glib::ffi::gpointer,
5472 ) {
5473 unsafe {
5474 let f: &F = &*(f as *const F);
5475 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5476 }
5477 }
5478 unsafe {
5479 let f: Box_<F> = Box_::new(f);
5480 connect_raw(
5481 self.as_ptr() as *mut _,
5482 c"notify::microphone-capture-state".as_ptr(),
5483 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5484 notify_microphone_capture_state_trampoline::<Self, F> as *const (),
5485 )),
5486 Box_::into_raw(f),
5487 )
5488 }
5489 }
5490
5491 #[doc(alias = "page-id")]
5492 fn connect_page_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5493 unsafe extern "C" fn notify_page_id_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5494 this: *mut ffi::WebKitWebView,
5495 _param_spec: glib::ffi::gpointer,
5496 f: glib::ffi::gpointer,
5497 ) {
5498 unsafe {
5499 let f: &F = &*(f as *const F);
5500 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5501 }
5502 }
5503 unsafe {
5504 let f: Box_<F> = Box_::new(f);
5505 connect_raw(
5506 self.as_ptr() as *mut _,
5507 c"notify::page-id".as_ptr(),
5508 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5509 notify_page_id_trampoline::<Self, F> as *const (),
5510 )),
5511 Box_::into_raw(f),
5512 )
5513 }
5514 }
5515
5516 #[doc(alias = "settings")]
5517 fn connect_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5518 unsafe extern "C" fn notify_settings_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5519 this: *mut ffi::WebKitWebView,
5520 _param_spec: glib::ffi::gpointer,
5521 f: glib::ffi::gpointer,
5522 ) {
5523 unsafe {
5524 let f: &F = &*(f as *const F);
5525 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5526 }
5527 }
5528 unsafe {
5529 let f: Box_<F> = Box_::new(f);
5530 connect_raw(
5531 self.as_ptr() as *mut _,
5532 c"notify::settings".as_ptr(),
5533 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5534 notify_settings_trampoline::<Self, F> as *const (),
5535 )),
5536 Box_::into_raw(f),
5537 )
5538 }
5539 }
5540
5541 #[cfg(feature = "v2_50")]
5542 #[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
5543 #[doc(alias = "theme-color")]
5544 fn connect_theme_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5545 unsafe extern "C" fn notify_theme_color_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5546 this: *mut ffi::WebKitWebView,
5547 _param_spec: glib::ffi::gpointer,
5548 f: glib::ffi::gpointer,
5549 ) {
5550 unsafe {
5551 let f: &F = &*(f as *const F);
5552 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5553 }
5554 }
5555 unsafe {
5556 let f: Box_<F> = Box_::new(f);
5557 connect_raw(
5558 self.as_ptr() as *mut _,
5559 c"notify::theme-color".as_ptr(),
5560 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5561 notify_theme_color_trampoline::<Self, F> as *const (),
5562 )),
5563 Box_::into_raw(f),
5564 )
5565 }
5566 }
5567
5568 #[doc(alias = "title")]
5569 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5570 unsafe extern "C" fn notify_title_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5571 this: *mut ffi::WebKitWebView,
5572 _param_spec: glib::ffi::gpointer,
5573 f: glib::ffi::gpointer,
5574 ) {
5575 unsafe {
5576 let f: &F = &*(f as *const F);
5577 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5578 }
5579 }
5580 unsafe {
5581 let f: Box_<F> = Box_::new(f);
5582 connect_raw(
5583 self.as_ptr() as *mut _,
5584 c"notify::title".as_ptr(),
5585 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5586 notify_title_trampoline::<Self, F> as *const (),
5587 )),
5588 Box_::into_raw(f),
5589 )
5590 }
5591 }
5592
5593 #[doc(alias = "uri")]
5594 fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5595 unsafe extern "C" fn notify_uri_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5596 this: *mut ffi::WebKitWebView,
5597 _param_spec: glib::ffi::gpointer,
5598 f: glib::ffi::gpointer,
5599 ) {
5600 unsafe {
5601 let f: &F = &*(f as *const F);
5602 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5603 }
5604 }
5605 unsafe {
5606 let f: Box_<F> = Box_::new(f);
5607 connect_raw(
5608 self.as_ptr() as *mut _,
5609 c"notify::uri".as_ptr(),
5610 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5611 notify_uri_trampoline::<Self, F> as *const (),
5612 )),
5613 Box_::into_raw(f),
5614 )
5615 }
5616 }
5617
5618 #[doc(alias = "zoom-level")]
5619 fn connect_zoom_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5620 unsafe extern "C" fn notify_zoom_level_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
5621 this: *mut ffi::WebKitWebView,
5622 _param_spec: glib::ffi::gpointer,
5623 f: glib::ffi::gpointer,
5624 ) {
5625 unsafe {
5626 let f: &F = &*(f as *const F);
5627 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
5628 }
5629 }
5630 unsafe {
5631 let f: Box_<F> = Box_::new(f);
5632 connect_raw(
5633 self.as_ptr() as *mut _,
5634 c"notify::zoom-level".as_ptr(),
5635 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5636 notify_zoom_level_trampoline::<Self, F> as *const (),
5637 )),
5638 Box_::into_raw(f),
5639 )
5640 }
5641 }
5642}
5643
5644impl<O: IsA<WebView>> WebViewExt for O {}