1#![allow(deprecated)]
5
6#[cfg(feature = "v2_2")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v2_2")))]
8use crate::AuthenticationRequest;
9#[cfg(feature = "v2_10")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v2_10")))]
11use crate::EditorState;
12#[cfg(feature = "v2_34")]
13#[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
14use crate::MediaCaptureState;
15#[cfg(feature = "v2_18")]
16#[cfg_attr(docsrs, doc(cfg(feature = "v2_18")))]
17use crate::OptionMenu;
18#[cfg(feature = "v2_24")]
19#[cfg_attr(docsrs, doc(cfg(feature = "v2_24")))]
20use crate::ScriptDialog;
21#[cfg(feature = "v2_20")]
22#[cfg_attr(docsrs, doc(cfg(feature = "v2_20")))]
23use crate::WebProcessTerminationReason;
24#[cfg(feature = "v2_12")]
25#[cfg_attr(docsrs, doc(cfg(feature = "v2_12")))]
26use crate::WebViewSessionState;
27#[cfg(feature = "v2_16")]
28#[cfg_attr(docsrs, doc(cfg(feature = "v2_16")))]
29use crate::WebsiteDataManager;
30#[cfg(feature = "v2_30")]
31#[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
32use crate::WebsitePolicies;
33#[cfg(feature = "v2_28")]
34#[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
35use crate::{AutomationBrowsingContextPresentation, InputMethodContext, UserMessage};
36use crate::{
37 BackForwardList, BackForwardListItem, ContextMenu, Download, FileChooserRequest, FindController,
38 FormSubmissionRequest, HitTestResult, InsecureContentEvent, JavascriptResult, LoadEvent,
39 PermissionRequest, PolicyDecision, PolicyDecisionType, PrintOperation, SaveMode, Settings,
40 SnapshotOptions, SnapshotRegion, URIRequest, WebContext, WebInspector, WebResource, WebViewBase,
41 WindowProperties,
42};
43#[cfg(feature = "v2_8")]
44#[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
45use crate::{ColorChooserRequest, Notification};
46#[cfg(feature = "v2_6")]
47#[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
48use crate::{NavigationAction, UserContentManager};
49use glib::{
50 prelude::*,
51 signal::{connect_raw, SignalHandlerId},
52 translate::*,
53};
54use std::{boxed::Box as Box_, pin::Pin};
55
56glib::wrapper! {
57 #[doc(alias = "WebKitWebView")]
58 pub struct WebView(Object<ffi::WebKitWebView, ffi::WebKitWebViewClass>) @extends WebViewBase, gtk::Container, gtk::Widget, @implements gtk::Buildable;
59
60 match fn {
61 type_ => || ffi::webkit_web_view_get_type(),
62 }
63}
64
65impl WebView {
66 pub const NONE: Option<&'static WebView> = None;
67
68 #[doc(alias = "webkit_web_view_new")]
69 pub fn new() -> WebView {
70 assert_initialized_main_thread!();
71 unsafe { gtk::Widget::from_glib_none(ffi::webkit_web_view_new()).unsafe_cast() }
72 }
73
74 #[doc(alias = "webkit_web_view_new_with_context")]
75 #[doc(alias = "new_with_context")]
76 pub fn with_context(context: &impl IsA<WebContext>) -> WebView {
77 skip_assert_initialized!();
78 unsafe {
79 gtk::Widget::from_glib_none(ffi::webkit_web_view_new_with_context(
80 context.as_ref().to_glib_none().0,
81 ))
82 .unsafe_cast()
83 }
84 }
85
86 #[cfg(feature = "v2_4")]
87 #[cfg_attr(docsrs, doc(cfg(feature = "v2_4")))]
88 #[doc(alias = "webkit_web_view_new_with_related_view")]
89 #[doc(alias = "new_with_related_view")]
90 pub fn with_related_view(web_view: &impl IsA<WebView>) -> WebView {
91 skip_assert_initialized!();
92 unsafe {
93 gtk::Widget::from_glib_full(ffi::webkit_web_view_new_with_related_view(
94 web_view.as_ref().to_glib_none().0,
95 ))
96 .unsafe_cast()
97 }
98 }
99
100 #[cfg(feature = "v2_6")]
101 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
102 #[doc(alias = "webkit_web_view_new_with_settings")]
103 #[doc(alias = "new_with_settings")]
104 pub fn with_settings(settings: &impl IsA<Settings>) -> WebView {
105 skip_assert_initialized!();
106 unsafe {
107 gtk::Widget::from_glib_none(ffi::webkit_web_view_new_with_settings(
108 settings.as_ref().to_glib_none().0,
109 ))
110 .unsafe_cast()
111 }
112 }
113
114 #[cfg(feature = "v2_6")]
115 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
116 #[doc(alias = "webkit_web_view_new_with_user_content_manager")]
117 #[doc(alias = "new_with_user_content_manager")]
118 pub fn with_user_content_manager(user_content_manager: &impl IsA<UserContentManager>) -> WebView {
119 skip_assert_initialized!();
120 unsafe {
121 gtk::Widget::from_glib_none(ffi::webkit_web_view_new_with_user_content_manager(
122 user_content_manager.as_ref().to_glib_none().0,
123 ))
124 .unsafe_cast()
125 }
126 }
127
128 pub fn builder() -> WebViewBuilder {
133 WebViewBuilder::new()
134 }
135}
136
137impl Default for WebView {
138 fn default() -> Self {
139 Self::new()
140 }
141}
142
143#[must_use = "The builder must be built to be used"]
148pub struct WebViewBuilder {
149 builder: glib::object::ObjectBuilder<'static, WebView>,
150}
151
152impl WebViewBuilder {
153 fn new() -> Self {
154 Self {
155 builder: glib::object::Object::builder(),
156 }
157 }
158
159 #[cfg(feature = "v2_28")]
160 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
161 pub fn automation_presentation_type(
162 self,
163 automation_presentation_type: AutomationBrowsingContextPresentation,
164 ) -> Self {
165 Self {
166 builder: self
167 .builder
168 .property("automation-presentation-type", automation_presentation_type),
169 }
170 }
171
172 #[cfg(feature = "v2_34")]
173 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
174 pub fn camera_capture_state(self, camera_capture_state: MediaCaptureState) -> Self {
175 Self {
176 builder: self
177 .builder
178 .property("camera-capture-state", camera_capture_state),
179 }
180 }
181
182 #[cfg(feature = "v2_38")]
183 #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))]
184 pub fn default_content_security_policy(
185 self,
186 default_content_security_policy: impl Into<glib::GString>,
187 ) -> Self {
188 Self {
189 builder: self.builder.property(
190 "default-content-security-policy",
191 default_content_security_policy.into(),
192 ),
193 }
194 }
195
196 #[cfg(feature = "v2_34")]
197 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
198 pub fn display_capture_state(self, display_capture_state: MediaCaptureState) -> Self {
199 Self {
200 builder: self
201 .builder
202 .property("display-capture-state", display_capture_state),
203 }
204 }
205
206 #[cfg(feature = "v2_8")]
207 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
208 pub fn editable(self, editable: bool) -> Self {
209 Self {
210 builder: self.builder.property("editable", editable),
211 }
212 }
213
214 #[cfg(feature = "v2_18")]
215 #[cfg_attr(docsrs, doc(cfg(feature = "v2_18")))]
216 pub fn is_controlled_by_automation(self, is_controlled_by_automation: bool) -> Self {
217 Self {
218 builder: self
219 .builder
220 .property("is-controlled-by-automation", is_controlled_by_automation),
221 }
222 }
223
224 #[cfg(feature = "v2_16")]
225 #[cfg_attr(docsrs, doc(cfg(feature = "v2_16")))]
226 pub fn is_ephemeral(self, is_ephemeral: bool) -> Self {
227 Self {
228 builder: self.builder.property("is-ephemeral", is_ephemeral),
229 }
230 }
231
232 #[cfg(feature = "v2_30")]
233 #[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
234 pub fn is_muted(self, is_muted: bool) -> Self {
235 Self {
236 builder: self.builder.property("is-muted", is_muted),
237 }
238 }
239
240 #[cfg(feature = "v2_34")]
241 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
242 pub fn microphone_capture_state(self, microphone_capture_state: MediaCaptureState) -> Self {
243 Self {
244 builder: self
245 .builder
246 .property("microphone-capture-state", microphone_capture_state),
247 }
248 }
249
250 #[cfg(feature = "v2_4")]
251 #[cfg_attr(docsrs, doc(cfg(feature = "v2_4")))]
252 pub fn related_view(self, related_view: &impl IsA<WebView>) -> Self {
253 Self {
254 builder: self
255 .builder
256 .property("related-view", related_view.clone().upcast()),
257 }
258 }
259
260 #[cfg(feature = "v2_6")]
261 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
262 pub fn settings(self, settings: &impl IsA<Settings>) -> Self {
263 Self {
264 builder: self.builder.property("settings", settings.clone().upcast()),
265 }
266 }
267
268 #[cfg(feature = "v2_6")]
269 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
270 pub fn user_content_manager(self, user_content_manager: &impl IsA<UserContentManager>) -> Self {
271 Self {
272 builder: self.builder.property(
273 "user-content-manager",
274 user_content_manager.clone().upcast(),
275 ),
276 }
277 }
278
279 pub fn web_context(self, web_context: &impl IsA<WebContext>) -> Self {
280 Self {
281 builder: self
282 .builder
283 .property("web-context", web_context.clone().upcast()),
284 }
285 }
286
287 #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))]
289 #[cfg(feature = "v2_30")]
293 #[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
294 pub fn website_policies(self, website_policies: &impl IsA<WebsitePolicies>) -> Self {
295 Self {
296 builder: self
297 .builder
298 .property("website-policies", website_policies.clone().upcast()),
299 }
300 }
301
302 pub fn zoom_level(self, zoom_level: f64) -> Self {
303 Self {
304 builder: self.builder.property("zoom-level", zoom_level),
305 }
306 }
307
308 pub fn border_width(self, border_width: u32) -> Self {
309 Self {
310 builder: self.builder.property("border-width", border_width),
311 }
312 }
313
314 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
315 Self {
316 builder: self.builder.property("child", child.clone().upcast()),
317 }
318 }
319
320 pub fn app_paintable(self, app_paintable: bool) -> Self {
325 Self {
326 builder: self.builder.property("app-paintable", app_paintable),
327 }
328 }
329
330 pub fn can_default(self, can_default: bool) -> Self {
331 Self {
332 builder: self.builder.property("can-default", can_default),
333 }
334 }
335
336 pub fn can_focus(self, can_focus: bool) -> Self {
337 Self {
338 builder: self.builder.property("can-focus", can_focus),
339 }
340 }
341
342 #[cfg(feature = "gtk_v2_18")]
343 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_18")))]
344 #[cfg_attr(feature = "v3_14", deprecated = "Since 3.14")]
345 pub fn double_buffered(self, double_buffered: bool) -> Self {
346 Self {
347 builder: self.builder.property("double-buffered", double_buffered),
348 }
349 }
350
351 #[cfg(feature = "gtk_v3")]
356 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
357 pub fn expand(self, expand: bool) -> Self {
358 Self {
359 builder: self.builder.property("expand", expand),
360 }
361 }
362
363 #[cfg(feature = "gtk_v3_20")]
364 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_20")))]
365 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
366 Self {
367 builder: self.builder.property("focus-on-click", focus_on_click),
368 }
369 }
370
371 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
373 pub fn has_default(self, has_default: bool) -> Self {
378 Self {
379 builder: self.builder.property("has-default", has_default),
380 }
381 }
382
383 pub fn has_focus(self, has_focus: bool) -> Self {
384 Self {
385 builder: self.builder.property("has-focus", has_focus),
386 }
387 }
388
389 #[cfg(feature = "gtk_v2_12")]
390 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_12")))]
391 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
392 Self {
393 builder: self.builder.property("has-tooltip", has_tooltip),
394 }
395 }
396
397 pub fn height_request(self, height_request: i32) -> Self {
398 Self {
399 builder: self.builder.property("height-request", height_request),
400 }
401 }
402
403 #[cfg(feature = "gtk_v3")]
404 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
405 pub fn hexpand(self, hexpand: bool) -> Self {
406 Self {
407 builder: self.builder.property("hexpand", hexpand),
408 }
409 }
410
411 #[cfg(feature = "gtk_v3")]
412 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
413 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
414 Self {
415 builder: self.builder.property("hexpand-set", hexpand_set),
416 }
417 }
418
419 pub fn is_focus(self, is_focus: bool) -> Self {
420 Self {
421 builder: self.builder.property("is-focus", is_focus),
422 }
423 }
424
425 #[cfg(feature = "gtk_v3")]
426 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
427 pub fn margin(self, margin: i32) -> Self {
428 Self {
429 builder: self.builder.property("margin", margin),
430 }
431 }
432
433 #[cfg(feature = "gtk_v3")]
434 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
435 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
436 Self {
437 builder: self.builder.property("margin-bottom", margin_bottom),
438 }
439 }
440
441 #[cfg(feature = "gtk_v3_12")]
442 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_12")))]
443 pub fn margin_end(self, margin_end: i32) -> Self {
444 Self {
445 builder: self.builder.property("margin-end", margin_end),
446 }
447 }
448
449 #[cfg(feature = "gtk_v3")]
450 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
451 #[cfg_attr(feature = "v3_12", deprecated = "Since 3.12")]
452 pub fn margin_left(self, margin_left: i32) -> Self {
453 Self {
454 builder: self.builder.property("margin-left", margin_left),
455 }
456 }
457
458 #[cfg(feature = "gtk_v3")]
459 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
460 #[cfg_attr(feature = "v3_12", deprecated = "Since 3.12")]
461 pub fn margin_right(self, margin_right: i32) -> Self {
462 Self {
463 builder: self.builder.property("margin-right", margin_right),
464 }
465 }
466
467 #[cfg(feature = "gtk_v3_12")]
468 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_12")))]
469 pub fn margin_start(self, margin_start: i32) -> Self {
470 Self {
471 builder: self.builder.property("margin-start", margin_start),
472 }
473 }
474
475 #[cfg(feature = "gtk_v3")]
476 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
477 pub fn margin_top(self, margin_top: i32) -> Self {
478 Self {
479 builder: self.builder.property("margin-top", margin_top),
480 }
481 }
482
483 pub fn name(self, name: impl Into<glib::GString>) -> Self {
484 Self {
485 builder: self.builder.property("name", name.into()),
486 }
487 }
488
489 pub fn no_show_all(self, no_show_all: bool) -> Self {
490 Self {
491 builder: self.builder.property("no-show-all", no_show_all),
492 }
493 }
494
495 #[cfg(feature = "gtk_v3_8")]
496 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_8")))]
497 pub fn opacity(self, opacity: f64) -> Self {
498 Self {
499 builder: self.builder.property("opacity", opacity),
500 }
501 }
502
503 pub fn parent(self, parent: &impl IsA<gtk::Container>) -> Self {
504 Self {
505 builder: self.builder.property("parent", parent.clone().upcast()),
506 }
507 }
508
509 pub fn receives_default(self, receives_default: bool) -> Self {
510 Self {
511 builder: self.builder.property("receives-default", receives_default),
512 }
513 }
514
515 pub fn sensitive(self, sensitive: bool) -> Self {
516 Self {
517 builder: self.builder.property("sensitive", sensitive),
518 }
519 }
520
521 #[cfg(feature = "gtk_v2_12")]
526 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_12")))]
527 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
528 Self {
529 builder: self
530 .builder
531 .property("tooltip-markup", tooltip_markup.into()),
532 }
533 }
534
535 #[cfg(feature = "gtk_v2_12")]
536 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_12")))]
537 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
538 Self {
539 builder: self.builder.property("tooltip-text", tooltip_text.into()),
540 }
541 }
542
543 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
545 #[cfg(feature = "gtk_v3")]
549 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
550 pub fn vexpand(self, vexpand: bool) -> Self {
551 Self {
552 builder: self.builder.property("vexpand", vexpand),
553 }
554 }
555
556 #[cfg(feature = "gtk_v3")]
557 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
558 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
559 Self {
560 builder: self.builder.property("vexpand-set", vexpand_set),
561 }
562 }
563
564 pub fn visible(self, visible: bool) -> Self {
565 Self {
566 builder: self.builder.property("visible", visible),
567 }
568 }
569
570 pub fn width_request(self, width_request: i32) -> Self {
571 Self {
572 builder: self.builder.property("width-request", width_request),
573 }
574 }
575
576 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
579 pub fn build(self) -> WebView {
580 self.builder.build()
581 }
582}
583
584mod sealed {
585 pub trait Sealed {}
586 impl<T: super::IsA<super::WebView>> Sealed for T {}
587}
588
589pub trait WebViewExt: IsA<WebView> + sealed::Sealed + 'static {
590 #[cfg(feature = "v2_40")]
591 #[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))]
592 #[doc(alias = "webkit_web_view_call_async_javascript_function")]
593 fn call_async_javascript_function<
594 P: FnOnce(Result<java_script_core::Value, glib::Error>) + 'static,
595 >(
596 &self,
597 body: &str,
598 arguments: Option<&glib::Variant>,
599 world_name: Option<&str>,
600 source_uri: Option<&str>,
601 cancellable: Option<&impl IsA<gio::Cancellable>>,
602 callback: P,
603 ) {
604 let length = body.len() as _;
605
606 let main_context = glib::MainContext::ref_thread_default();
607 let is_main_context_owner = main_context.is_owner();
608 let has_acquired_main_context = (!is_main_context_owner)
609 .then(|| main_context.acquire().ok())
610 .flatten();
611 assert!(
612 is_main_context_owner || has_acquired_main_context.is_some(),
613 "Async operations only allowed if the thread is owning the MainContext"
614 );
615
616 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
617 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
618 unsafe extern "C" fn call_async_javascript_function_trampoline<
619 P: FnOnce(Result<java_script_core::Value, glib::Error>) + 'static,
620 >(
621 _source_object: *mut glib::gobject_ffi::GObject,
622 res: *mut gio::ffi::GAsyncResult,
623 user_data: glib::ffi::gpointer,
624 ) {
625 let mut error = std::ptr::null_mut();
626 let ret = ffi::webkit_web_view_call_async_javascript_function_finish(
627 _source_object as *mut _,
628 res,
629 &mut error,
630 );
631 let result = if error.is_null() {
632 Ok(from_glib_full(ret))
633 } else {
634 Err(from_glib_full(error))
635 };
636 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
637 let callback: P = callback.into_inner();
638 callback(result);
639 }
640 let callback = call_async_javascript_function_trampoline::<P>;
641 unsafe {
642 ffi::webkit_web_view_call_async_javascript_function(
643 self.as_ref().to_glib_none().0,
644 body.to_glib_none().0,
645 length,
646 arguments.to_glib_none().0,
647 world_name.to_glib_none().0,
648 source_uri.to_glib_none().0,
649 cancellable.map(|p| p.as_ref()).to_glib_none().0,
650 Some(callback),
651 Box_::into_raw(user_data) as *mut _,
652 );
653 }
654 }
655
656 #[cfg(feature = "v2_40")]
657 #[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))]
658 fn call_async_javascript_function_future(
659 &self,
660 body: &str,
661 arguments: Option<&glib::Variant>,
662 world_name: Option<&str>,
663 source_uri: Option<&str>,
664 ) -> Pin<
665 Box_<dyn std::future::Future<Output = Result<java_script_core::Value, glib::Error>> + 'static>,
666 > {
667 let body = String::from(body);
668 let arguments = arguments.map(ToOwned::to_owned);
669 let world_name = world_name.map(ToOwned::to_owned);
670 let source_uri = source_uri.map(ToOwned::to_owned);
671 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
672 obj.call_async_javascript_function(
673 &body,
674 arguments.as_ref().map(::std::borrow::Borrow::borrow),
675 world_name.as_ref().map(::std::borrow::Borrow::borrow),
676 source_uri.as_ref().map(::std::borrow::Borrow::borrow),
677 Some(cancellable),
678 move |res| {
679 send.resolve(res);
680 },
681 );
682 }))
683 }
684
685 #[doc(alias = "webkit_web_view_can_execute_editing_command")]
686 fn can_execute_editing_command<P: FnOnce(Result<(), glib::Error>) + 'static>(
687 &self,
688 command: &str,
689 cancellable: Option<&impl IsA<gio::Cancellable>>,
690 callback: P,
691 ) {
692 let main_context = glib::MainContext::ref_thread_default();
693 let is_main_context_owner = main_context.is_owner();
694 let has_acquired_main_context = (!is_main_context_owner)
695 .then(|| main_context.acquire().ok())
696 .flatten();
697 assert!(
698 is_main_context_owner || has_acquired_main_context.is_some(),
699 "Async operations only allowed if the thread is owning the MainContext"
700 );
701
702 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
703 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
704 unsafe extern "C" fn can_execute_editing_command_trampoline<
705 P: FnOnce(Result<(), glib::Error>) + 'static,
706 >(
707 _source_object: *mut glib::gobject_ffi::GObject,
708 res: *mut gio::ffi::GAsyncResult,
709 user_data: glib::ffi::gpointer,
710 ) {
711 let mut error = std::ptr::null_mut();
712 let _ = ffi::webkit_web_view_can_execute_editing_command_finish(
713 _source_object as *mut _,
714 res,
715 &mut error,
716 );
717 let result = if error.is_null() {
718 Ok(())
719 } else {
720 Err(from_glib_full(error))
721 };
722 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
723 let callback: P = callback.into_inner();
724 callback(result);
725 }
726 let callback = can_execute_editing_command_trampoline::<P>;
727 unsafe {
728 ffi::webkit_web_view_can_execute_editing_command(
729 self.as_ref().to_glib_none().0,
730 command.to_glib_none().0,
731 cancellable.map(|p| p.as_ref()).to_glib_none().0,
732 Some(callback),
733 Box_::into_raw(user_data) as *mut _,
734 );
735 }
736 }
737
738 fn can_execute_editing_command_future(
739 &self,
740 command: &str,
741 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
742 let command = String::from(command);
743 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
744 obj.can_execute_editing_command(&command, Some(cancellable), move |res| {
745 send.resolve(res);
746 });
747 }))
748 }
749
750 #[doc(alias = "webkit_web_view_can_go_back")]
751 fn can_go_back(&self) -> bool {
752 unsafe {
753 from_glib(ffi::webkit_web_view_can_go_back(
754 self.as_ref().to_glib_none().0,
755 ))
756 }
757 }
758
759 #[doc(alias = "webkit_web_view_can_go_forward")]
760 fn can_go_forward(&self) -> bool {
761 unsafe {
762 from_glib(ffi::webkit_web_view_can_go_forward(
763 self.as_ref().to_glib_none().0,
764 ))
765 }
766 }
767
768 #[doc(alias = "webkit_web_view_can_show_mime_type")]
769 fn can_show_mime_type(&self, mime_type: &str) -> bool {
770 unsafe {
771 from_glib(ffi::webkit_web_view_can_show_mime_type(
772 self.as_ref().to_glib_none().0,
773 mime_type.to_glib_none().0,
774 ))
775 }
776 }
777
778 #[doc(alias = "webkit_web_view_download_uri")]
779 fn download_uri(&self, uri: &str) -> Option<Download> {
780 unsafe {
781 from_glib_full(ffi::webkit_web_view_download_uri(
782 self.as_ref().to_glib_none().0,
783 uri.to_glib_none().0,
784 ))
785 }
786 }
787
788 #[cfg(feature = "v2_40")]
789 #[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))]
790 #[doc(alias = "webkit_web_view_evaluate_javascript")]
791 fn evaluate_javascript<P: FnOnce(Result<java_script_core::Value, glib::Error>) + 'static>(
792 &self,
793 script: &str,
794 world_name: Option<&str>,
795 source_uri: Option<&str>,
796 cancellable: Option<&impl IsA<gio::Cancellable>>,
797 callback: P,
798 ) {
799 let length = script.len() as _;
800
801 let main_context = glib::MainContext::ref_thread_default();
802 let is_main_context_owner = main_context.is_owner();
803 let has_acquired_main_context = (!is_main_context_owner)
804 .then(|| main_context.acquire().ok())
805 .flatten();
806 assert!(
807 is_main_context_owner || has_acquired_main_context.is_some(),
808 "Async operations only allowed if the thread is owning the MainContext"
809 );
810
811 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
812 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
813 unsafe extern "C" fn evaluate_javascript_trampoline<
814 P: FnOnce(Result<java_script_core::Value, glib::Error>) + 'static,
815 >(
816 _source_object: *mut glib::gobject_ffi::GObject,
817 res: *mut gio::ffi::GAsyncResult,
818 user_data: glib::ffi::gpointer,
819 ) {
820 let mut error = std::ptr::null_mut();
821 let ret =
822 ffi::webkit_web_view_evaluate_javascript_finish(_source_object as *mut _, res, &mut error);
823 let result = if error.is_null() {
824 Ok(from_glib_full(ret))
825 } else {
826 Err(from_glib_full(error))
827 };
828 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
829 let callback: P = callback.into_inner();
830 callback(result);
831 }
832 let callback = evaluate_javascript_trampoline::<P>;
833 unsafe {
834 ffi::webkit_web_view_evaluate_javascript(
835 self.as_ref().to_glib_none().0,
836 script.to_glib_none().0,
837 length,
838 world_name.to_glib_none().0,
839 source_uri.to_glib_none().0,
840 cancellable.map(|p| p.as_ref()).to_glib_none().0,
841 Some(callback),
842 Box_::into_raw(user_data) as *mut _,
843 );
844 }
845 }
846
847 #[cfg(feature = "v2_40")]
848 #[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))]
849 fn evaluate_javascript_future(
850 &self,
851 script: &str,
852 world_name: Option<&str>,
853 source_uri: Option<&str>,
854 ) -> Pin<
855 Box_<dyn std::future::Future<Output = Result<java_script_core::Value, glib::Error>> + 'static>,
856 > {
857 let script = String::from(script);
858 let world_name = world_name.map(ToOwned::to_owned);
859 let source_uri = source_uri.map(ToOwned::to_owned);
860 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
861 obj.evaluate_javascript(
862 &script,
863 world_name.as_ref().map(::std::borrow::Borrow::borrow),
864 source_uri.as_ref().map(::std::borrow::Borrow::borrow),
865 Some(cancellable),
866 move |res| {
867 send.resolve(res);
868 },
869 );
870 }))
871 }
872
873 #[doc(alias = "webkit_web_view_execute_editing_command")]
874 fn execute_editing_command(&self, command: &str) {
875 unsafe {
876 ffi::webkit_web_view_execute_editing_command(
877 self.as_ref().to_glib_none().0,
878 command.to_glib_none().0,
879 );
880 }
881 }
882
883 #[cfg(feature = "v2_10")]
884 #[cfg_attr(docsrs, doc(cfg(feature = "v2_10")))]
885 #[doc(alias = "webkit_web_view_execute_editing_command_with_argument")]
886 fn execute_editing_command_with_argument(&self, command: &str, argument: &str) {
887 unsafe {
888 ffi::webkit_web_view_execute_editing_command_with_argument(
889 self.as_ref().to_glib_none().0,
890 command.to_glib_none().0,
891 argument.to_glib_none().0,
892 );
893 }
894 }
895
896 #[cfg(feature = "v2_28")]
897 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
898 #[doc(alias = "webkit_web_view_get_automation_presentation_type")]
899 #[doc(alias = "get_automation_presentation_type")]
900 fn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation {
901 unsafe {
902 from_glib(ffi::webkit_web_view_get_automation_presentation_type(
903 self.as_ref().to_glib_none().0,
904 ))
905 }
906 }
907
908 #[doc(alias = "webkit_web_view_get_back_forward_list")]
909 #[doc(alias = "get_back_forward_list")]
910 fn back_forward_list(&self) -> Option<BackForwardList> {
911 unsafe {
912 from_glib_none(ffi::webkit_web_view_get_back_forward_list(
913 self.as_ref().to_glib_none().0,
914 ))
915 }
916 }
917
918 #[cfg(feature = "v2_8")]
919 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
920 #[doc(alias = "webkit_web_view_get_background_color")]
921 #[doc(alias = "get_background_color")]
922 fn background_color(&self) -> gdk::RGBA {
923 unsafe {
924 let mut rgba = gdk::RGBA::uninitialized();
925 ffi::webkit_web_view_get_background_color(
926 self.as_ref().to_glib_none().0,
927 rgba.to_glib_none_mut().0,
928 );
929 rgba
930 }
931 }
932
933 #[cfg(feature = "v2_34")]
934 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
935 #[doc(alias = "webkit_web_view_get_camera_capture_state")]
936 #[doc(alias = "get_camera_capture_state")]
937 fn camera_capture_state(&self) -> MediaCaptureState {
938 unsafe {
939 from_glib(ffi::webkit_web_view_get_camera_capture_state(
940 self.as_ref().to_glib_none().0,
941 ))
942 }
943 }
944
945 #[doc(alias = "webkit_web_view_get_context")]
946 #[doc(alias = "get_context")]
947 fn context(&self) -> Option<WebContext> {
948 unsafe {
949 from_glib_none(ffi::webkit_web_view_get_context(
950 self.as_ref().to_glib_none().0,
951 ))
952 }
953 }
954
955 #[doc(alias = "webkit_web_view_get_custom_charset")]
956 #[doc(alias = "get_custom_charset")]
957 fn custom_charset(&self) -> Option<glib::GString> {
958 unsafe {
959 from_glib_none(ffi::webkit_web_view_get_custom_charset(
960 self.as_ref().to_glib_none().0,
961 ))
962 }
963 }
964
965 #[cfg(feature = "v2_38")]
966 #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))]
967 #[doc(alias = "webkit_web_view_get_default_content_security_policy")]
968 #[doc(alias = "get_default_content_security_policy")]
969 fn default_content_security_policy(&self) -> Option<glib::GString> {
970 unsafe {
971 from_glib_none(ffi::webkit_web_view_get_default_content_security_policy(
972 self.as_ref().to_glib_none().0,
973 ))
974 }
975 }
976
977 #[cfg(feature = "v2_34")]
978 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
979 #[doc(alias = "webkit_web_view_get_display_capture_state")]
980 #[doc(alias = "get_display_capture_state")]
981 fn display_capture_state(&self) -> MediaCaptureState {
982 unsafe {
983 from_glib(ffi::webkit_web_view_get_display_capture_state(
984 self.as_ref().to_glib_none().0,
985 ))
986 }
987 }
988
989 #[cfg(feature = "v2_10")]
990 #[cfg_attr(docsrs, doc(cfg(feature = "v2_10")))]
991 #[doc(alias = "webkit_web_view_get_editor_state")]
992 #[doc(alias = "get_editor_state")]
993 fn editor_state(&self) -> Option<EditorState> {
994 unsafe {
995 from_glib_none(ffi::webkit_web_view_get_editor_state(
996 self.as_ref().to_glib_none().0,
997 ))
998 }
999 }
1000
1001 #[doc(alias = "webkit_web_view_get_estimated_load_progress")]
1002 #[doc(alias = "get_estimated_load_progress")]
1003 fn estimated_load_progress(&self) -> f64 {
1004 unsafe { ffi::webkit_web_view_get_estimated_load_progress(self.as_ref().to_glib_none().0) }
1005 }
1006
1007 #[doc(alias = "webkit_web_view_get_favicon")]
1008 #[doc(alias = "get_favicon")]
1009 fn favicon(&self) -> Option<cairo::Surface> {
1010 unsafe {
1011 from_glib_none(ffi::webkit_web_view_get_favicon(
1012 self.as_ref().to_glib_none().0,
1013 ))
1014 }
1015 }
1016
1017 #[doc(alias = "webkit_web_view_get_find_controller")]
1018 #[doc(alias = "get_find_controller")]
1019 fn find_controller(&self) -> Option<FindController> {
1020 unsafe {
1021 from_glib_none(ffi::webkit_web_view_get_find_controller(
1022 self.as_ref().to_glib_none().0,
1023 ))
1024 }
1025 }
1026
1027 #[cfg(feature = "v2_28")]
1028 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
1029 #[doc(alias = "webkit_web_view_get_input_method_context")]
1030 #[doc(alias = "get_input_method_context")]
1031 fn input_method_context(&self) -> Option<InputMethodContext> {
1032 unsafe {
1033 from_glib_none(ffi::webkit_web_view_get_input_method_context(
1034 self.as_ref().to_glib_none().0,
1035 ))
1036 }
1037 }
1038
1039 #[doc(alias = "webkit_web_view_get_inspector")]
1040 #[doc(alias = "get_inspector")]
1041 fn inspector(&self) -> Option<WebInspector> {
1042 unsafe {
1043 from_glib_none(ffi::webkit_web_view_get_inspector(
1044 self.as_ref().to_glib_none().0,
1045 ))
1046 }
1047 }
1048
1049 #[cfg(feature = "v2_30")]
1050 #[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
1051 #[doc(alias = "webkit_web_view_get_is_muted")]
1052 #[doc(alias = "get_is_muted")]
1053 fn is_muted(&self) -> bool {
1054 unsafe {
1055 from_glib(ffi::webkit_web_view_get_is_muted(
1056 self.as_ref().to_glib_none().0,
1057 ))
1058 }
1059 }
1060
1061 #[cfg(feature = "v2_34")]
1062 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1063 #[doc(alias = "webkit_web_view_get_is_web_process_responsive")]
1064 #[doc(alias = "get_is_web_process_responsive")]
1065 fn is_web_process_responsive(&self) -> bool {
1066 unsafe {
1067 from_glib(ffi::webkit_web_view_get_is_web_process_responsive(
1068 self.as_ref().to_glib_none().0,
1069 ))
1070 }
1071 }
1072
1073 #[doc(alias = "webkit_web_view_get_main_resource")]
1074 #[doc(alias = "get_main_resource")]
1075 fn main_resource(&self) -> Option<WebResource> {
1076 unsafe {
1077 from_glib_none(ffi::webkit_web_view_get_main_resource(
1078 self.as_ref().to_glib_none().0,
1079 ))
1080 }
1081 }
1082
1083 #[cfg(feature = "v2_34")]
1084 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1085 #[doc(alias = "webkit_web_view_get_microphone_capture_state")]
1086 #[doc(alias = "get_microphone_capture_state")]
1087 fn microphone_capture_state(&self) -> MediaCaptureState {
1088 unsafe {
1089 from_glib(ffi::webkit_web_view_get_microphone_capture_state(
1090 self.as_ref().to_glib_none().0,
1091 ))
1092 }
1093 }
1094
1095 #[doc(alias = "webkit_web_view_get_page_id")]
1096 #[doc(alias = "get_page_id")]
1097 fn page_id(&self) -> u64 {
1098 unsafe { ffi::webkit_web_view_get_page_id(self.as_ref().to_glib_none().0) }
1099 }
1100
1101 #[cfg(feature = "v2_12")]
1102 #[cfg_attr(docsrs, doc(cfg(feature = "v2_12")))]
1103 #[doc(alias = "webkit_web_view_get_session_state")]
1104 #[doc(alias = "get_session_state")]
1105 fn session_state(&self) -> Option<WebViewSessionState> {
1106 unsafe {
1107 from_glib_full(ffi::webkit_web_view_get_session_state(
1108 self.as_ref().to_glib_none().0,
1109 ))
1110 }
1111 }
1112
1113 #[doc(alias = "webkit_web_view_get_settings")]
1114 #[doc(alias = "get_settings")]
1115 fn settings(&self) -> Option<Settings> {
1116 unsafe {
1117 from_glib_none(ffi::webkit_web_view_get_settings(
1118 self.as_ref().to_glib_none().0,
1119 ))
1120 }
1121 }
1122
1123 #[doc(alias = "webkit_web_view_get_snapshot")]
1124 #[doc(alias = "get_snapshot")]
1125 fn snapshot<P: FnOnce(Result<cairo::Surface, glib::Error>) + 'static>(
1126 &self,
1127 region: SnapshotRegion,
1128 options: SnapshotOptions,
1129 cancellable: Option<&impl IsA<gio::Cancellable>>,
1130 callback: P,
1131 ) {
1132 let main_context = glib::MainContext::ref_thread_default();
1133 let is_main_context_owner = main_context.is_owner();
1134 let has_acquired_main_context = (!is_main_context_owner)
1135 .then(|| main_context.acquire().ok())
1136 .flatten();
1137 assert!(
1138 is_main_context_owner || has_acquired_main_context.is_some(),
1139 "Async operations only allowed if the thread is owning the MainContext"
1140 );
1141
1142 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1143 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1144 unsafe extern "C" fn snapshot_trampoline<
1145 P: FnOnce(Result<cairo::Surface, glib::Error>) + 'static,
1146 >(
1147 _source_object: *mut glib::gobject_ffi::GObject,
1148 res: *mut gio::ffi::GAsyncResult,
1149 user_data: glib::ffi::gpointer,
1150 ) {
1151 let mut error = std::ptr::null_mut();
1152 let ret = ffi::webkit_web_view_get_snapshot_finish(_source_object as *mut _, res, &mut error);
1153 let result = if error.is_null() {
1154 Ok(from_glib_full(ret))
1155 } else {
1156 Err(from_glib_full(error))
1157 };
1158 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1159 let callback: P = callback.into_inner();
1160 callback(result);
1161 }
1162 let callback = snapshot_trampoline::<P>;
1163 unsafe {
1164 ffi::webkit_web_view_get_snapshot(
1165 self.as_ref().to_glib_none().0,
1166 region.into_glib(),
1167 options.into_glib(),
1168 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1169 Some(callback),
1170 Box_::into_raw(user_data) as *mut _,
1171 );
1172 }
1173 }
1174
1175 fn snapshot_future(
1176 &self,
1177 region: SnapshotRegion,
1178 options: SnapshotOptions,
1179 ) -> Pin<Box_<dyn std::future::Future<Output = Result<cairo::Surface, glib::Error>> + 'static>>
1180 {
1181 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1182 obj.snapshot(region, options, Some(cancellable), move |res| {
1183 send.resolve(res);
1184 });
1185 }))
1186 }
1187
1188 #[doc(alias = "webkit_web_view_get_title")]
1189 #[doc(alias = "get_title")]
1190 fn title(&self) -> Option<glib::GString> {
1191 unsafe {
1192 from_glib_none(ffi::webkit_web_view_get_title(
1193 self.as_ref().to_glib_none().0,
1194 ))
1195 }
1196 }
1197
1198 #[doc(alias = "webkit_web_view_get_tls_info")]
1199 #[doc(alias = "get_tls_info")]
1200 fn tls_info(&self) -> Option<(gio::TlsCertificate, gio::TlsCertificateFlags)> {
1201 unsafe {
1202 let mut certificate = std::ptr::null_mut();
1203 let mut errors = std::mem::MaybeUninit::uninit();
1204 let ret = from_glib(ffi::webkit_web_view_get_tls_info(
1205 self.as_ref().to_glib_none().0,
1206 &mut certificate,
1207 errors.as_mut_ptr(),
1208 ));
1209 if ret {
1210 Some((from_glib_none(certificate), from_glib(errors.assume_init())))
1211 } else {
1212 None
1213 }
1214 }
1215 }
1216
1217 #[doc(alias = "webkit_web_view_get_uri")]
1218 #[doc(alias = "get_uri")]
1219 fn uri(&self) -> Option<glib::GString> {
1220 unsafe { from_glib_none(ffi::webkit_web_view_get_uri(self.as_ref().to_glib_none().0)) }
1221 }
1222
1223 #[cfg(feature = "v2_6")]
1224 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
1225 #[doc(alias = "webkit_web_view_get_user_content_manager")]
1226 #[doc(alias = "get_user_content_manager")]
1227 fn user_content_manager(&self) -> Option<UserContentManager> {
1228 unsafe {
1229 from_glib_none(ffi::webkit_web_view_get_user_content_manager(
1230 self.as_ref().to_glib_none().0,
1231 ))
1232 }
1233 }
1234
1235 #[cfg(feature = "v2_16")]
1244 #[cfg_attr(docsrs, doc(cfg(feature = "v2_16")))]
1245 #[doc(alias = "webkit_web_view_get_website_data_manager")]
1246 #[doc(alias = "get_website_data_manager")]
1247 fn website_data_manager(&self) -> Option<WebsiteDataManager> {
1248 unsafe {
1249 from_glib_none(ffi::webkit_web_view_get_website_data_manager(
1250 self.as_ref().to_glib_none().0,
1251 ))
1252 }
1253 }
1254
1255 #[cfg(feature = "v2_30")]
1256 #[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
1257 #[doc(alias = "webkit_web_view_get_website_policies")]
1258 #[doc(alias = "get_website_policies")]
1259 fn website_policies(&self) -> Option<WebsitePolicies> {
1260 unsafe {
1261 from_glib_none(ffi::webkit_web_view_get_website_policies(
1262 self.as_ref().to_glib_none().0,
1263 ))
1264 }
1265 }
1266
1267 #[doc(alias = "webkit_web_view_get_window_properties")]
1268 #[doc(alias = "get_window_properties")]
1269 fn window_properties(&self) -> Option<WindowProperties> {
1270 unsafe {
1271 from_glib_none(ffi::webkit_web_view_get_window_properties(
1272 self.as_ref().to_glib_none().0,
1273 ))
1274 }
1275 }
1276
1277 #[doc(alias = "webkit_web_view_get_zoom_level")]
1278 #[doc(alias = "get_zoom_level")]
1279 fn zoom_level(&self) -> f64 {
1280 unsafe { ffi::webkit_web_view_get_zoom_level(self.as_ref().to_glib_none().0) }
1281 }
1282
1283 #[doc(alias = "webkit_web_view_go_back")]
1284 fn go_back(&self) {
1285 unsafe {
1286 ffi::webkit_web_view_go_back(self.as_ref().to_glib_none().0);
1287 }
1288 }
1289
1290 #[doc(alias = "webkit_web_view_go_forward")]
1291 fn go_forward(&self) {
1292 unsafe {
1293 ffi::webkit_web_view_go_forward(self.as_ref().to_glib_none().0);
1294 }
1295 }
1296
1297 #[doc(alias = "webkit_web_view_go_to_back_forward_list_item")]
1298 fn go_to_back_forward_list_item(&self, list_item: &impl IsA<BackForwardListItem>) {
1299 unsafe {
1300 ffi::webkit_web_view_go_to_back_forward_list_item(
1301 self.as_ref().to_glib_none().0,
1302 list_item.as_ref().to_glib_none().0,
1303 );
1304 }
1305 }
1306
1307 #[cfg(feature = "v2_18")]
1308 #[cfg_attr(docsrs, doc(cfg(feature = "v2_18")))]
1309 #[doc(alias = "webkit_web_view_is_controlled_by_automation")]
1310 fn is_controlled_by_automation(&self) -> bool {
1311 unsafe {
1312 from_glib(ffi::webkit_web_view_is_controlled_by_automation(
1313 self.as_ref().to_glib_none().0,
1314 ))
1315 }
1316 }
1317
1318 #[cfg(feature = "v2_8")]
1319 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
1320 #[doc(alias = "webkit_web_view_is_editable")]
1321 fn is_editable(&self) -> bool {
1322 unsafe {
1323 from_glib(ffi::webkit_web_view_is_editable(
1324 self.as_ref().to_glib_none().0,
1325 ))
1326 }
1327 }
1328
1329 #[cfg(feature = "v2_16")]
1330 #[cfg_attr(docsrs, doc(cfg(feature = "v2_16")))]
1331 #[doc(alias = "webkit_web_view_is_ephemeral")]
1332 fn is_ephemeral(&self) -> bool {
1333 unsafe {
1334 from_glib(ffi::webkit_web_view_is_ephemeral(
1335 self.as_ref().to_glib_none().0,
1336 ))
1337 }
1338 }
1339
1340 #[doc(alias = "webkit_web_view_is_loading")]
1341 fn is_loading(&self) -> bool {
1342 unsafe {
1343 from_glib(ffi::webkit_web_view_is_loading(
1344 self.as_ref().to_glib_none().0,
1345 ))
1346 }
1347 }
1348
1349 #[cfg(feature = "v2_8")]
1350 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
1351 #[doc(alias = "webkit_web_view_is_playing_audio")]
1352 fn is_playing_audio(&self) -> bool {
1353 unsafe {
1354 from_glib(ffi::webkit_web_view_is_playing_audio(
1355 self.as_ref().to_glib_none().0,
1356 ))
1357 }
1358 }
1359
1360 #[doc(alias = "webkit_web_view_load_alternate_html")]
1361 fn load_alternate_html(&self, content: &str, content_uri: &str, base_uri: Option<&str>) {
1362 unsafe {
1363 ffi::webkit_web_view_load_alternate_html(
1364 self.as_ref().to_glib_none().0,
1365 content.to_glib_none().0,
1366 content_uri.to_glib_none().0,
1367 base_uri.to_glib_none().0,
1368 );
1369 }
1370 }
1371
1372 #[cfg(feature = "v2_6")]
1373 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
1374 #[doc(alias = "webkit_web_view_load_bytes")]
1375 fn load_bytes(
1376 &self,
1377 bytes: &glib::Bytes,
1378 mime_type: Option<&str>,
1379 encoding: Option<&str>,
1380 base_uri: Option<&str>,
1381 ) {
1382 unsafe {
1383 ffi::webkit_web_view_load_bytes(
1384 self.as_ref().to_glib_none().0,
1385 bytes.to_glib_none().0,
1386 mime_type.to_glib_none().0,
1387 encoding.to_glib_none().0,
1388 base_uri.to_glib_none().0,
1389 );
1390 }
1391 }
1392
1393 #[doc(alias = "webkit_web_view_load_html")]
1394 fn load_html(&self, content: &str, base_uri: Option<&str>) {
1395 unsafe {
1396 ffi::webkit_web_view_load_html(
1397 self.as_ref().to_glib_none().0,
1398 content.to_glib_none().0,
1399 base_uri.to_glib_none().0,
1400 );
1401 }
1402 }
1403
1404 #[doc(alias = "webkit_web_view_load_plain_text")]
1405 fn load_plain_text(&self, plain_text: &str) {
1406 unsafe {
1407 ffi::webkit_web_view_load_plain_text(
1408 self.as_ref().to_glib_none().0,
1409 plain_text.to_glib_none().0,
1410 );
1411 }
1412 }
1413
1414 #[doc(alias = "webkit_web_view_load_request")]
1415 fn load_request(&self, request: &impl IsA<URIRequest>) {
1416 unsafe {
1417 ffi::webkit_web_view_load_request(
1418 self.as_ref().to_glib_none().0,
1419 request.as_ref().to_glib_none().0,
1420 );
1421 }
1422 }
1423
1424 #[doc(alias = "webkit_web_view_load_uri")]
1425 fn load_uri(&self, uri: &str) {
1426 unsafe {
1427 ffi::webkit_web_view_load_uri(self.as_ref().to_glib_none().0, uri.to_glib_none().0);
1428 }
1429 }
1430
1431 #[doc(alias = "webkit_web_view_reload")]
1432 fn reload(&self) {
1433 unsafe {
1434 ffi::webkit_web_view_reload(self.as_ref().to_glib_none().0);
1435 }
1436 }
1437
1438 #[doc(alias = "webkit_web_view_reload_bypass_cache")]
1439 fn reload_bypass_cache(&self) {
1440 unsafe {
1441 ffi::webkit_web_view_reload_bypass_cache(self.as_ref().to_glib_none().0);
1442 }
1443 }
1444
1445 #[cfg(feature = "v2_12")]
1446 #[cfg_attr(docsrs, doc(cfg(feature = "v2_12")))]
1447 #[doc(alias = "webkit_web_view_restore_session_state")]
1448 fn restore_session_state(&self, state: &WebViewSessionState) {
1449 unsafe {
1450 ffi::webkit_web_view_restore_session_state(
1451 self.as_ref().to_glib_none().0,
1452 state.to_glib_none().0,
1453 );
1454 }
1455 }
1456
1457 #[cfg_attr(feature = "v2_40", deprecated = "Since 2.40")]
1467 #[allow(deprecated)]
1468 #[doc(alias = "webkit_web_view_run_javascript")]
1469 fn run_javascript<P: FnOnce(Result<JavascriptResult, glib::Error>) + 'static>(
1470 &self,
1471 script: &str,
1472 cancellable: Option<&impl IsA<gio::Cancellable>>,
1473 callback: P,
1474 ) {
1475 let main_context = glib::MainContext::ref_thread_default();
1476 let is_main_context_owner = main_context.is_owner();
1477 let has_acquired_main_context = (!is_main_context_owner)
1478 .then(|| main_context.acquire().ok())
1479 .flatten();
1480 assert!(
1481 is_main_context_owner || has_acquired_main_context.is_some(),
1482 "Async operations only allowed if the thread is owning the MainContext"
1483 );
1484
1485 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1486 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1487 unsafe extern "C" fn run_javascript_trampoline<
1488 P: FnOnce(Result<JavascriptResult, glib::Error>) + 'static,
1489 >(
1490 _source_object: *mut glib::gobject_ffi::GObject,
1491 res: *mut gio::ffi::GAsyncResult,
1492 user_data: glib::ffi::gpointer,
1493 ) {
1494 let mut error = std::ptr::null_mut();
1495 let ret =
1496 ffi::webkit_web_view_run_javascript_finish(_source_object as *mut _, res, &mut error);
1497 let result = if error.is_null() {
1498 Ok(from_glib_full(ret))
1499 } else {
1500 Err(from_glib_full(error))
1501 };
1502 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1503 let callback: P = callback.into_inner();
1504 callback(result);
1505 }
1506 let callback = run_javascript_trampoline::<P>;
1507 unsafe {
1508 ffi::webkit_web_view_run_javascript(
1509 self.as_ref().to_glib_none().0,
1510 script.to_glib_none().0,
1511 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1512 Some(callback),
1513 Box_::into_raw(user_data) as *mut _,
1514 );
1515 }
1516 }
1517
1518 #[cfg_attr(feature = "v2_40", deprecated = "Since 2.40")]
1519
1520 fn run_javascript_future(
1521 &self,
1522 script: &str,
1523 ) -> Pin<Box_<dyn std::future::Future<Output = Result<JavascriptResult, glib::Error>> + 'static>>
1524 {
1525 let script = String::from(script);
1526 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1527 obj.run_javascript(&script, Some(cancellable), move |res| {
1528 send.resolve(res);
1529 });
1530 }))
1531 }
1532
1533 #[cfg_attr(feature = "v2_40", deprecated = "Since 2.40")]
1534 #[allow(deprecated)]
1535 #[doc(alias = "webkit_web_view_run_javascript_from_gresource")]
1536 fn run_javascript_from_gresource<P: FnOnce(Result<JavascriptResult, glib::Error>) + 'static>(
1537 &self,
1538 resource: &str,
1539 cancellable: Option<&impl IsA<gio::Cancellable>>,
1540 callback: P,
1541 ) {
1542 let main_context = glib::MainContext::ref_thread_default();
1543 let is_main_context_owner = main_context.is_owner();
1544 let has_acquired_main_context = (!is_main_context_owner)
1545 .then(|| main_context.acquire().ok())
1546 .flatten();
1547 assert!(
1548 is_main_context_owner || has_acquired_main_context.is_some(),
1549 "Async operations only allowed if the thread is owning the MainContext"
1550 );
1551
1552 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1553 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1554 unsafe extern "C" fn run_javascript_from_gresource_trampoline<
1555 P: FnOnce(Result<JavascriptResult, glib::Error>) + 'static,
1556 >(
1557 _source_object: *mut glib::gobject_ffi::GObject,
1558 res: *mut gio::ffi::GAsyncResult,
1559 user_data: glib::ffi::gpointer,
1560 ) {
1561 let mut error = std::ptr::null_mut();
1562 let ret = ffi::webkit_web_view_run_javascript_from_gresource_finish(
1563 _source_object as *mut _,
1564 res,
1565 &mut error,
1566 );
1567 let result = if error.is_null() {
1568 Ok(from_glib_full(ret))
1569 } else {
1570 Err(from_glib_full(error))
1571 };
1572 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1573 let callback: P = callback.into_inner();
1574 callback(result);
1575 }
1576 let callback = run_javascript_from_gresource_trampoline::<P>;
1577 unsafe {
1578 ffi::webkit_web_view_run_javascript_from_gresource(
1579 self.as_ref().to_glib_none().0,
1580 resource.to_glib_none().0,
1581 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1582 Some(callback),
1583 Box_::into_raw(user_data) as *mut _,
1584 );
1585 }
1586 }
1587
1588 #[cfg_attr(feature = "v2_40", deprecated = "Since 2.40")]
1589
1590 fn run_javascript_from_gresource_future(
1591 &self,
1592 resource: &str,
1593 ) -> Pin<Box_<dyn std::future::Future<Output = Result<JavascriptResult, glib::Error>> + 'static>>
1594 {
1595 let resource = String::from(resource);
1596 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1597 obj.run_javascript_from_gresource(&resource, Some(cancellable), move |res| {
1598 send.resolve(res);
1599 });
1600 }))
1601 }
1602
1603 #[cfg_attr(feature = "v2_40", deprecated = "Since 2.40")]
1604 #[cfg(feature = "v2_22")]
1605 #[cfg_attr(docsrs, doc(cfg(feature = "v2_22")))]
1606 #[allow(deprecated)]
1607 #[doc(alias = "webkit_web_view_run_javascript_in_world")]
1608 fn run_javascript_in_world<P: FnOnce(Result<JavascriptResult, glib::Error>) + 'static>(
1609 &self,
1610 script: &str,
1611 world_name: &str,
1612 cancellable: Option<&impl IsA<gio::Cancellable>>,
1613 callback: P,
1614 ) {
1615 let main_context = glib::MainContext::ref_thread_default();
1616 let is_main_context_owner = main_context.is_owner();
1617 let has_acquired_main_context = (!is_main_context_owner)
1618 .then(|| main_context.acquire().ok())
1619 .flatten();
1620 assert!(
1621 is_main_context_owner || has_acquired_main_context.is_some(),
1622 "Async operations only allowed if the thread is owning the MainContext"
1623 );
1624
1625 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1626 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1627 unsafe extern "C" fn run_javascript_in_world_trampoline<
1628 P: FnOnce(Result<JavascriptResult, glib::Error>) + 'static,
1629 >(
1630 _source_object: *mut glib::gobject_ffi::GObject,
1631 res: *mut gio::ffi::GAsyncResult,
1632 user_data: glib::ffi::gpointer,
1633 ) {
1634 let mut error = std::ptr::null_mut();
1635 let ret = ffi::webkit_web_view_run_javascript_in_world_finish(
1636 _source_object as *mut _,
1637 res,
1638 &mut error,
1639 );
1640 let result = if error.is_null() {
1641 Ok(from_glib_full(ret))
1642 } else {
1643 Err(from_glib_full(error))
1644 };
1645 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1646 let callback: P = callback.into_inner();
1647 callback(result);
1648 }
1649 let callback = run_javascript_in_world_trampoline::<P>;
1650 unsafe {
1651 ffi::webkit_web_view_run_javascript_in_world(
1652 self.as_ref().to_glib_none().0,
1653 script.to_glib_none().0,
1654 world_name.to_glib_none().0,
1655 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1656 Some(callback),
1657 Box_::into_raw(user_data) as *mut _,
1658 );
1659 }
1660 }
1661
1662 #[cfg_attr(feature = "v2_40", deprecated = "Since 2.40")]
1663 #[cfg(feature = "v2_22")]
1664 #[cfg_attr(docsrs, doc(cfg(feature = "v2_22")))]
1665 fn run_javascript_in_world_future(
1666 &self,
1667 script: &str,
1668 world_name: &str,
1669 ) -> Pin<Box_<dyn std::future::Future<Output = Result<JavascriptResult, glib::Error>> + 'static>>
1670 {
1671 let script = String::from(script);
1672 let world_name = String::from(world_name);
1673 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1674 obj.run_javascript_in_world(&script, &world_name, Some(cancellable), move |res| {
1675 send.resolve(res);
1676 });
1677 }))
1678 }
1679
1680 #[doc(alias = "webkit_web_view_save")]
1681 fn save<P: FnOnce(Result<gio::InputStream, glib::Error>) + 'static>(
1682 &self,
1683 save_mode: SaveMode,
1684 cancellable: Option<&impl IsA<gio::Cancellable>>,
1685 callback: P,
1686 ) {
1687 let main_context = glib::MainContext::ref_thread_default();
1688 let is_main_context_owner = main_context.is_owner();
1689 let has_acquired_main_context = (!is_main_context_owner)
1690 .then(|| main_context.acquire().ok())
1691 .flatten();
1692 assert!(
1693 is_main_context_owner || has_acquired_main_context.is_some(),
1694 "Async operations only allowed if the thread is owning the MainContext"
1695 );
1696
1697 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1698 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1699 unsafe extern "C" fn save_trampoline<
1700 P: FnOnce(Result<gio::InputStream, glib::Error>) + 'static,
1701 >(
1702 _source_object: *mut glib::gobject_ffi::GObject,
1703 res: *mut gio::ffi::GAsyncResult,
1704 user_data: glib::ffi::gpointer,
1705 ) {
1706 let mut error = std::ptr::null_mut();
1707 let ret = ffi::webkit_web_view_save_finish(_source_object as *mut _, res, &mut error);
1708 let result = if error.is_null() {
1709 Ok(from_glib_full(ret))
1710 } else {
1711 Err(from_glib_full(error))
1712 };
1713 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1714 let callback: P = callback.into_inner();
1715 callback(result);
1716 }
1717 let callback = save_trampoline::<P>;
1718 unsafe {
1719 ffi::webkit_web_view_save(
1720 self.as_ref().to_glib_none().0,
1721 save_mode.into_glib(),
1722 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1723 Some(callback),
1724 Box_::into_raw(user_data) as *mut _,
1725 );
1726 }
1727 }
1728
1729 fn save_future(
1730 &self,
1731 save_mode: SaveMode,
1732 ) -> Pin<Box_<dyn std::future::Future<Output = Result<gio::InputStream, glib::Error>> + 'static>>
1733 {
1734 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1735 obj.save(save_mode, Some(cancellable), move |res| {
1736 send.resolve(res);
1737 });
1738 }))
1739 }
1740
1741 #[doc(alias = "webkit_web_view_save_to_file")]
1742 fn save_to_file<P: FnOnce(Result<(), glib::Error>) + 'static>(
1743 &self,
1744 file: &impl IsA<gio::File>,
1745 save_mode: SaveMode,
1746 cancellable: Option<&impl IsA<gio::Cancellable>>,
1747 callback: P,
1748 ) {
1749 let main_context = glib::MainContext::ref_thread_default();
1750 let is_main_context_owner = main_context.is_owner();
1751 let has_acquired_main_context = (!is_main_context_owner)
1752 .then(|| main_context.acquire().ok())
1753 .flatten();
1754 assert!(
1755 is_main_context_owner || has_acquired_main_context.is_some(),
1756 "Async operations only allowed if the thread is owning the MainContext"
1757 );
1758
1759 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1760 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1761 unsafe extern "C" fn save_to_file_trampoline<P: FnOnce(Result<(), glib::Error>) + 'static>(
1762 _source_object: *mut glib::gobject_ffi::GObject,
1763 res: *mut gio::ffi::GAsyncResult,
1764 user_data: glib::ffi::gpointer,
1765 ) {
1766 let mut error = std::ptr::null_mut();
1767 let _ = ffi::webkit_web_view_save_to_file_finish(_source_object as *mut _, res, &mut error);
1768 let result = if error.is_null() {
1769 Ok(())
1770 } else {
1771 Err(from_glib_full(error))
1772 };
1773 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1774 let callback: P = callback.into_inner();
1775 callback(result);
1776 }
1777 let callback = save_to_file_trampoline::<P>;
1778 unsafe {
1779 ffi::webkit_web_view_save_to_file(
1780 self.as_ref().to_glib_none().0,
1781 file.as_ref().to_glib_none().0,
1782 save_mode.into_glib(),
1783 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1784 Some(callback),
1785 Box_::into_raw(user_data) as *mut _,
1786 );
1787 }
1788 }
1789
1790 fn save_to_file_future(
1791 &self,
1792 file: &(impl IsA<gio::File> + Clone + 'static),
1793 save_mode: SaveMode,
1794 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1795 let file = file.clone();
1796 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1797 obj.save_to_file(&file, save_mode, Some(cancellable), move |res| {
1798 send.resolve(res);
1799 });
1800 }))
1801 }
1802
1803 #[cfg(feature = "v2_28")]
1804 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
1805 #[doc(alias = "webkit_web_view_send_message_to_page")]
1806 fn send_message_to_page<P: FnOnce(Result<UserMessage, glib::Error>) + 'static>(
1807 &self,
1808 message: &impl IsA<UserMessage>,
1809 cancellable: Option<&impl IsA<gio::Cancellable>>,
1810 callback: P,
1811 ) {
1812 let main_context = glib::MainContext::ref_thread_default();
1813 let is_main_context_owner = main_context.is_owner();
1814 let has_acquired_main_context = (!is_main_context_owner)
1815 .then(|| main_context.acquire().ok())
1816 .flatten();
1817 assert!(
1818 is_main_context_owner || has_acquired_main_context.is_some(),
1819 "Async operations only allowed if the thread is owning the MainContext"
1820 );
1821
1822 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1823 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1824 unsafe extern "C" fn send_message_to_page_trampoline<
1825 P: FnOnce(Result<UserMessage, glib::Error>) + 'static,
1826 >(
1827 _source_object: *mut glib::gobject_ffi::GObject,
1828 res: *mut gio::ffi::GAsyncResult,
1829 user_data: glib::ffi::gpointer,
1830 ) {
1831 let mut error = std::ptr::null_mut();
1832 let ret =
1833 ffi::webkit_web_view_send_message_to_page_finish(_source_object as *mut _, res, &mut error);
1834 let result = if error.is_null() {
1835 Ok(from_glib_full(ret))
1836 } else {
1837 Err(from_glib_full(error))
1838 };
1839 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
1840 let callback: P = callback.into_inner();
1841 callback(result);
1842 }
1843 let callback = send_message_to_page_trampoline::<P>;
1844 unsafe {
1845 ffi::webkit_web_view_send_message_to_page(
1846 self.as_ref().to_glib_none().0,
1847 message.as_ref().to_glib_none().0,
1848 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1849 Some(callback),
1850 Box_::into_raw(user_data) as *mut _,
1851 );
1852 }
1853 }
1854
1855 #[cfg(feature = "v2_28")]
1856 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
1857 fn send_message_to_page_future(
1858 &self,
1859 message: &(impl IsA<UserMessage> + Clone + 'static),
1860 ) -> Pin<Box_<dyn std::future::Future<Output = Result<UserMessage, glib::Error>> + 'static>> {
1861 let message = message.clone();
1862 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1863 obj.send_message_to_page(&message, Some(cancellable), move |res| {
1864 send.resolve(res);
1865 });
1866 }))
1867 }
1868
1869 #[cfg(feature = "v2_8")]
1870 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
1871 #[doc(alias = "webkit_web_view_set_background_color")]
1872 fn set_background_color(&self, rgba: &gdk::RGBA) {
1873 unsafe {
1874 ffi::webkit_web_view_set_background_color(
1875 self.as_ref().to_glib_none().0,
1876 rgba.to_glib_none().0,
1877 );
1878 }
1879 }
1880
1881 #[cfg(feature = "v2_34")]
1882 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1883 #[doc(alias = "webkit_web_view_set_camera_capture_state")]
1884 fn set_camera_capture_state(&self, state: MediaCaptureState) {
1885 unsafe {
1886 ffi::webkit_web_view_set_camera_capture_state(
1887 self.as_ref().to_glib_none().0,
1888 state.into_glib(),
1889 );
1890 }
1891 }
1892
1893 #[cfg(feature = "v2_34")]
1894 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1895 #[doc(alias = "webkit_web_view_set_cors_allowlist")]
1896 fn set_cors_allowlist(&self, allowlist: &[&str]) {
1897 unsafe {
1898 ffi::webkit_web_view_set_cors_allowlist(
1899 self.as_ref().to_glib_none().0,
1900 allowlist.to_glib_none().0,
1901 );
1902 }
1903 }
1904
1905 #[doc(alias = "webkit_web_view_set_custom_charset")]
1906 fn set_custom_charset(&self, charset: Option<&str>) {
1907 unsafe {
1908 ffi::webkit_web_view_set_custom_charset(
1909 self.as_ref().to_glib_none().0,
1910 charset.to_glib_none().0,
1911 );
1912 }
1913 }
1914
1915 #[cfg(feature = "v2_34")]
1916 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1917 #[doc(alias = "webkit_web_view_set_display_capture_state")]
1918 fn set_display_capture_state(&self, state: MediaCaptureState) {
1919 unsafe {
1920 ffi::webkit_web_view_set_display_capture_state(
1921 self.as_ref().to_glib_none().0,
1922 state.into_glib(),
1923 );
1924 }
1925 }
1926
1927 #[cfg(feature = "v2_8")]
1928 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
1929 #[doc(alias = "webkit_web_view_set_editable")]
1930 fn set_editable(&self, editable: bool) {
1931 unsafe {
1932 ffi::webkit_web_view_set_editable(self.as_ref().to_glib_none().0, editable.into_glib());
1933 }
1934 }
1935
1936 #[cfg(feature = "v2_28")]
1937 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
1938 #[doc(alias = "webkit_web_view_set_input_method_context")]
1939 fn set_input_method_context(&self, context: Option<&impl IsA<InputMethodContext>>) {
1940 unsafe {
1941 ffi::webkit_web_view_set_input_method_context(
1942 self.as_ref().to_glib_none().0,
1943 context.map(|p| p.as_ref()).to_glib_none().0,
1944 );
1945 }
1946 }
1947
1948 #[cfg(feature = "v2_30")]
1949 #[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
1950 #[doc(alias = "webkit_web_view_set_is_muted")]
1951 fn set_is_muted(&self, muted: bool) {
1952 unsafe {
1953 ffi::webkit_web_view_set_is_muted(self.as_ref().to_glib_none().0, muted.into_glib());
1954 }
1955 }
1956
1957 #[cfg(feature = "v2_34")]
1958 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1959 #[doc(alias = "webkit_web_view_set_microphone_capture_state")]
1960 fn set_microphone_capture_state(&self, state: MediaCaptureState) {
1961 unsafe {
1962 ffi::webkit_web_view_set_microphone_capture_state(
1963 self.as_ref().to_glib_none().0,
1964 state.into_glib(),
1965 );
1966 }
1967 }
1968
1969 #[doc(alias = "webkit_web_view_set_settings")]
1970 fn set_settings(&self, settings: &impl IsA<Settings>) {
1971 unsafe {
1972 ffi::webkit_web_view_set_settings(
1973 self.as_ref().to_glib_none().0,
1974 settings.as_ref().to_glib_none().0,
1975 );
1976 }
1977 }
1978
1979 #[doc(alias = "webkit_web_view_set_zoom_level")]
1980 fn set_zoom_level(&self, zoom_level: f64) {
1981 unsafe {
1982 ffi::webkit_web_view_set_zoom_level(self.as_ref().to_glib_none().0, zoom_level);
1983 }
1984 }
1985
1986 #[doc(alias = "webkit_web_view_stop_loading")]
1987 fn stop_loading(&self) {
1988 unsafe {
1989 ffi::webkit_web_view_stop_loading(self.as_ref().to_glib_none().0);
1990 }
1991 }
1992
1993 #[cfg(feature = "v2_34")]
1994 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
1995 #[doc(alias = "webkit_web_view_terminate_web_process")]
1996 fn terminate_web_process(&self) {
1997 unsafe {
1998 ffi::webkit_web_view_terminate_web_process(self.as_ref().to_glib_none().0);
1999 }
2000 }
2001
2002 #[cfg(feature = "v2_12")]
2003 #[cfg_attr(docsrs, doc(cfg(feature = "v2_12")))]
2004 #[doc(alias = "webkit_web_view_try_close")]
2005 fn try_close(&self) {
2006 unsafe {
2007 ffi::webkit_web_view_try_close(self.as_ref().to_glib_none().0);
2008 }
2009 }
2010
2011 #[doc(alias = "web-context")]
2012 fn web_context(&self) -> Option<WebContext> {
2013 ObjectExt::property(self.as_ref(), "web-context")
2014 }
2015
2016 #[cfg(feature = "v2_2")]
2017 #[cfg_attr(docsrs, doc(cfg(feature = "v2_2")))]
2018 #[doc(alias = "authenticate")]
2019 fn connect_authenticate<F: Fn(&Self, &AuthenticationRequest) -> bool + 'static>(
2020 &self,
2021 f: F,
2022 ) -> SignalHandlerId {
2023 unsafe extern "C" fn authenticate_trampoline<
2024 P: IsA<WebView>,
2025 F: Fn(&P, &AuthenticationRequest) -> bool + 'static,
2026 >(
2027 this: *mut ffi::WebKitWebView,
2028 request: *mut ffi::WebKitAuthenticationRequest,
2029 f: glib::ffi::gpointer,
2030 ) -> glib::ffi::gboolean {
2031 let f: &F = &*(f as *const F);
2032 f(
2033 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2034 &from_glib_borrow(request),
2035 )
2036 .into_glib()
2037 }
2038 unsafe {
2039 let f: Box_<F> = Box_::new(f);
2040 connect_raw(
2041 self.as_ptr() as *mut _,
2042 b"authenticate\0".as_ptr() as *const _,
2043 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2044 authenticate_trampoline::<Self, F> as *const (),
2045 )),
2046 Box_::into_raw(f),
2047 )
2048 }
2049 }
2050
2051 #[doc(alias = "close")]
2052 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2053 unsafe extern "C" fn close_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
2054 this: *mut ffi::WebKitWebView,
2055 f: glib::ffi::gpointer,
2056 ) {
2057 let f: &F = &*(f as *const F);
2058 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2059 }
2060 unsafe {
2061 let f: Box_<F> = Box_::new(f);
2062 connect_raw(
2063 self.as_ptr() as *mut _,
2064 b"close\0".as_ptr() as *const _,
2065 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2066 close_trampoline::<Self, F> as *const (),
2067 )),
2068 Box_::into_raw(f),
2069 )
2070 }
2071 }
2072
2073 #[doc(alias = "context-menu")]
2074 fn connect_context_menu<
2075 F: Fn(&Self, &ContextMenu, &gdk::Event, &HitTestResult) -> bool + 'static,
2076 >(
2077 &self,
2078 f: F,
2079 ) -> SignalHandlerId {
2080 unsafe extern "C" fn context_menu_trampoline<
2081 P: IsA<WebView>,
2082 F: Fn(&P, &ContextMenu, &gdk::Event, &HitTestResult) -> bool + 'static,
2083 >(
2084 this: *mut ffi::WebKitWebView,
2085 context_menu: *mut ffi::WebKitContextMenu,
2086 event: *mut gdk::ffi::GdkEvent,
2087 hit_test_result: *mut ffi::WebKitHitTestResult,
2088 f: glib::ffi::gpointer,
2089 ) -> glib::ffi::gboolean {
2090 let f: &F = &*(f as *const F);
2091 f(
2092 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2093 &from_glib_borrow(context_menu),
2094 &from_glib_none(event),
2095 &from_glib_borrow(hit_test_result),
2096 )
2097 .into_glib()
2098 }
2099 unsafe {
2100 let f: Box_<F> = Box_::new(f);
2101 connect_raw(
2102 self.as_ptr() as *mut _,
2103 b"context-menu\0".as_ptr() as *const _,
2104 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2105 context_menu_trampoline::<Self, F> as *const (),
2106 )),
2107 Box_::into_raw(f),
2108 )
2109 }
2110 }
2111
2112 #[doc(alias = "context-menu-dismissed")]
2113 fn connect_context_menu_dismissed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2114 unsafe extern "C" fn context_menu_dismissed_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
2115 this: *mut ffi::WebKitWebView,
2116 f: glib::ffi::gpointer,
2117 ) {
2118 let f: &F = &*(f as *const F);
2119 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2120 }
2121 unsafe {
2122 let f: Box_<F> = Box_::new(f);
2123 connect_raw(
2124 self.as_ptr() as *mut _,
2125 b"context-menu-dismissed\0".as_ptr() as *const _,
2126 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2127 context_menu_dismissed_trampoline::<Self, F> as *const (),
2128 )),
2129 Box_::into_raw(f),
2130 )
2131 }
2132 }
2133
2134 #[cfg(feature = "v2_6")]
2135 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
2136 #[doc(alias = "create")]
2137 fn connect_create<F: Fn(&Self, &NavigationAction) -> Option<gtk::Widget> + 'static>(
2138 &self,
2139 f: F,
2140 ) -> SignalHandlerId {
2141 unsafe extern "C" fn create_trampoline<
2142 P: IsA<WebView>,
2143 F: Fn(&P, &NavigationAction) -> Option<gtk::Widget> + 'static,
2144 >(
2145 this: *mut ffi::WebKitWebView,
2146 navigation_action: *mut ffi::WebKitNavigationAction,
2147 f: glib::ffi::gpointer,
2148 ) -> *mut gtk::ffi::GtkWidget {
2149 let f: &F = &*(f as *const F);
2150 f(
2151 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2152 &from_glib_borrow(navigation_action),
2153 )
2154 .to_glib_full()
2155 }
2156 unsafe {
2157 let f: Box_<F> = Box_::new(f);
2158 connect_raw(
2159 self.as_ptr() as *mut _,
2160 b"create\0".as_ptr() as *const _,
2161 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2162 create_trampoline::<Self, F> as *const (),
2163 )),
2164 Box_::into_raw(f),
2165 )
2166 }
2167 }
2168
2169 #[doc(alias = "decide-policy")]
2170 fn connect_decide_policy<F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static>(
2171 &self,
2172 f: F,
2173 ) -> SignalHandlerId {
2174 unsafe extern "C" fn decide_policy_trampoline<
2175 P: IsA<WebView>,
2176 F: Fn(&P, &PolicyDecision, PolicyDecisionType) -> bool + 'static,
2177 >(
2178 this: *mut ffi::WebKitWebView,
2179 decision: *mut ffi::WebKitPolicyDecision,
2180 decision_type: ffi::WebKitPolicyDecisionType,
2181 f: glib::ffi::gpointer,
2182 ) -> glib::ffi::gboolean {
2183 let f: &F = &*(f as *const F);
2184 f(
2185 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2186 &from_glib_borrow(decision),
2187 from_glib(decision_type),
2188 )
2189 .into_glib()
2190 }
2191 unsafe {
2192 let f: Box_<F> = Box_::new(f);
2193 connect_raw(
2194 self.as_ptr() as *mut _,
2195 b"decide-policy\0".as_ptr() as *const _,
2196 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2197 decide_policy_trampoline::<Self, F> as *const (),
2198 )),
2199 Box_::into_raw(f),
2200 )
2201 }
2202 }
2203
2204 #[doc(alias = "enter-fullscreen")]
2205 fn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
2206 unsafe extern "C" fn enter_fullscreen_trampoline<
2207 P: IsA<WebView>,
2208 F: Fn(&P) -> bool + 'static,
2209 >(
2210 this: *mut ffi::WebKitWebView,
2211 f: glib::ffi::gpointer,
2212 ) -> glib::ffi::gboolean {
2213 let f: &F = &*(f as *const F);
2214 f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
2215 }
2216 unsafe {
2217 let f: Box_<F> = Box_::new(f);
2218 connect_raw(
2219 self.as_ptr() as *mut _,
2220 b"enter-fullscreen\0".as_ptr() as *const _,
2221 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2222 enter_fullscreen_trampoline::<Self, F> as *const (),
2223 )),
2224 Box_::into_raw(f),
2225 )
2226 }
2227 }
2228
2229 #[doc(alias = "insecure-content-detected")]
2230 fn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>(
2231 &self,
2232 f: F,
2233 ) -> SignalHandlerId {
2234 unsafe extern "C" fn insecure_content_detected_trampoline<
2235 P: IsA<WebView>,
2236 F: Fn(&P, InsecureContentEvent) + 'static,
2237 >(
2238 this: *mut ffi::WebKitWebView,
2239 event: ffi::WebKitInsecureContentEvent,
2240 f: glib::ffi::gpointer,
2241 ) {
2242 let f: &F = &*(f as *const F);
2243 f(
2244 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2245 from_glib(event),
2246 )
2247 }
2248 unsafe {
2249 let f: Box_<F> = Box_::new(f);
2250 connect_raw(
2251 self.as_ptr() as *mut _,
2252 b"insecure-content-detected\0".as_ptr() as *const _,
2253 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2254 insecure_content_detected_trampoline::<Self, F> as *const (),
2255 )),
2256 Box_::into_raw(f),
2257 )
2258 }
2259 }
2260
2261 #[doc(alias = "leave-fullscreen")]
2262 fn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
2263 unsafe extern "C" fn leave_fullscreen_trampoline<
2264 P: IsA<WebView>,
2265 F: Fn(&P) -> bool + 'static,
2266 >(
2267 this: *mut ffi::WebKitWebView,
2268 f: glib::ffi::gpointer,
2269 ) -> glib::ffi::gboolean {
2270 let f: &F = &*(f as *const F);
2271 f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
2272 }
2273 unsafe {
2274 let f: Box_<F> = Box_::new(f);
2275 connect_raw(
2276 self.as_ptr() as *mut _,
2277 b"leave-fullscreen\0".as_ptr() as *const _,
2278 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2279 leave_fullscreen_trampoline::<Self, F> as *const (),
2280 )),
2281 Box_::into_raw(f),
2282 )
2283 }
2284 }
2285
2286 #[doc(alias = "load-changed")]
2287 fn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>(&self, f: F) -> SignalHandlerId {
2288 unsafe extern "C" fn load_changed_trampoline<
2289 P: IsA<WebView>,
2290 F: Fn(&P, LoadEvent) + 'static,
2291 >(
2292 this: *mut ffi::WebKitWebView,
2293 load_event: ffi::WebKitLoadEvent,
2294 f: glib::ffi::gpointer,
2295 ) {
2296 let f: &F = &*(f as *const F);
2297 f(
2298 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2299 from_glib(load_event),
2300 )
2301 }
2302 unsafe {
2303 let f: Box_<F> = Box_::new(f);
2304 connect_raw(
2305 self.as_ptr() as *mut _,
2306 b"load-changed\0".as_ptr() as *const _,
2307 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2308 load_changed_trampoline::<Self, F> as *const (),
2309 )),
2310 Box_::into_raw(f),
2311 )
2312 }
2313 }
2314
2315 #[doc(alias = "load-failed")]
2316 fn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &glib::Error) -> bool + 'static>(
2317 &self,
2318 f: F,
2319 ) -> SignalHandlerId {
2320 unsafe extern "C" fn load_failed_trampoline<
2321 P: IsA<WebView>,
2322 F: Fn(&P, LoadEvent, &str, &glib::Error) -> bool + 'static,
2323 >(
2324 this: *mut ffi::WebKitWebView,
2325 load_event: ffi::WebKitLoadEvent,
2326 failing_uri: *mut libc::c_char,
2327 error: *mut glib::ffi::GError,
2328 f: glib::ffi::gpointer,
2329 ) -> glib::ffi::gboolean {
2330 let f: &F = &*(f as *const F);
2331 f(
2332 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2333 from_glib(load_event),
2334 &glib::GString::from_glib_borrow(failing_uri),
2335 &from_glib_borrow(error),
2336 )
2337 .into_glib()
2338 }
2339 unsafe {
2340 let f: Box_<F> = Box_::new(f);
2341 connect_raw(
2342 self.as_ptr() as *mut _,
2343 b"load-failed\0".as_ptr() as *const _,
2344 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2345 load_failed_trampoline::<Self, F> as *const (),
2346 )),
2347 Box_::into_raw(f),
2348 )
2349 }
2350 }
2351
2352 #[cfg(feature = "v2_6")]
2353 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
2354 #[doc(alias = "load-failed-with-tls-errors")]
2355 fn connect_load_failed_with_tls_errors<
2356 F: Fn(&Self, &str, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
2357 >(
2358 &self,
2359 f: F,
2360 ) -> SignalHandlerId {
2361 unsafe extern "C" fn load_failed_with_tls_errors_trampoline<
2362 P: IsA<WebView>,
2363 F: Fn(&P, &str, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
2364 >(
2365 this: *mut ffi::WebKitWebView,
2366 failing_uri: *mut libc::c_char,
2367 certificate: *mut gio::ffi::GTlsCertificate,
2368 errors: gio::ffi::GTlsCertificateFlags,
2369 f: glib::ffi::gpointer,
2370 ) -> glib::ffi::gboolean {
2371 let f: &F = &*(f as *const F);
2372 f(
2373 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2374 &glib::GString::from_glib_borrow(failing_uri),
2375 &from_glib_borrow(certificate),
2376 from_glib(errors),
2377 )
2378 .into_glib()
2379 }
2380 unsafe {
2381 let f: Box_<F> = Box_::new(f);
2382 connect_raw(
2383 self.as_ptr() as *mut _,
2384 b"load-failed-with-tls-errors\0".as_ptr() as *const _,
2385 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2386 load_failed_with_tls_errors_trampoline::<Self, F> as *const (),
2387 )),
2388 Box_::into_raw(f),
2389 )
2390 }
2391 }
2392
2393 #[doc(alias = "mouse-target-changed")]
2394 fn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>(
2395 &self,
2396 f: F,
2397 ) -> SignalHandlerId {
2398 unsafe extern "C" fn mouse_target_changed_trampoline<
2399 P: IsA<WebView>,
2400 F: Fn(&P, &HitTestResult, u32) + 'static,
2401 >(
2402 this: *mut ffi::WebKitWebView,
2403 hit_test_result: *mut ffi::WebKitHitTestResult,
2404 modifiers: libc::c_uint,
2405 f: glib::ffi::gpointer,
2406 ) {
2407 let f: &F = &*(f as *const F);
2408 f(
2409 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2410 &from_glib_borrow(hit_test_result),
2411 modifiers,
2412 )
2413 }
2414 unsafe {
2415 let f: Box_<F> = Box_::new(f);
2416 connect_raw(
2417 self.as_ptr() as *mut _,
2418 b"mouse-target-changed\0".as_ptr() as *const _,
2419 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2420 mouse_target_changed_trampoline::<Self, F> as *const (),
2421 )),
2422 Box_::into_raw(f),
2423 )
2424 }
2425 }
2426
2427 #[doc(alias = "permission-request")]
2428 fn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>(
2429 &self,
2430 f: F,
2431 ) -> SignalHandlerId {
2432 unsafe extern "C" fn permission_request_trampoline<
2433 P: IsA<WebView>,
2434 F: Fn(&P, &PermissionRequest) -> bool + 'static,
2435 >(
2436 this: *mut ffi::WebKitWebView,
2437 request: *mut ffi::WebKitPermissionRequest,
2438 f: glib::ffi::gpointer,
2439 ) -> glib::ffi::gboolean {
2440 let f: &F = &*(f as *const F);
2441 f(
2442 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2443 &from_glib_borrow(request),
2444 )
2445 .into_glib()
2446 }
2447 unsafe {
2448 let f: Box_<F> = Box_::new(f);
2449 connect_raw(
2450 self.as_ptr() as *mut _,
2451 b"permission-request\0".as_ptr() as *const _,
2452 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2453 permission_request_trampoline::<Self, F> as *const (),
2454 )),
2455 Box_::into_raw(f),
2456 )
2457 }
2458 }
2459
2460 #[doc(alias = "print")]
2461 fn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>(
2462 &self,
2463 f: F,
2464 ) -> SignalHandlerId {
2465 unsafe extern "C" fn print_trampoline<
2466 P: IsA<WebView>,
2467 F: Fn(&P, &PrintOperation) -> bool + 'static,
2468 >(
2469 this: *mut ffi::WebKitWebView,
2470 print_operation: *mut ffi::WebKitPrintOperation,
2471 f: glib::ffi::gpointer,
2472 ) -> glib::ffi::gboolean {
2473 let f: &F = &*(f as *const F);
2474 f(
2475 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2476 &from_glib_borrow(print_operation),
2477 )
2478 .into_glib()
2479 }
2480 unsafe {
2481 let f: Box_<F> = Box_::new(f);
2482 connect_raw(
2483 self.as_ptr() as *mut _,
2484 b"print\0".as_ptr() as *const _,
2485 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2486 print_trampoline::<Self, F> as *const (),
2487 )),
2488 Box_::into_raw(f),
2489 )
2490 }
2491 }
2492
2493 #[doc(alias = "ready-to-show")]
2501 fn connect_ready_to_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2502 unsafe extern "C" fn ready_to_show_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
2503 this: *mut ffi::WebKitWebView,
2504 f: glib::ffi::gpointer,
2505 ) {
2506 let f: &F = &*(f as *const F);
2507 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2508 }
2509 unsafe {
2510 let f: Box_<F> = Box_::new(f);
2511 connect_raw(
2512 self.as_ptr() as *mut _,
2513 b"ready-to-show\0".as_ptr() as *const _,
2514 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2515 ready_to_show_trampoline::<Self, F> as *const (),
2516 )),
2517 Box_::into_raw(f),
2518 )
2519 }
2520 }
2521
2522 #[doc(alias = "resource-load-started")]
2523 fn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>(
2524 &self,
2525 f: F,
2526 ) -> SignalHandlerId {
2527 unsafe extern "C" fn resource_load_started_trampoline<
2528 P: IsA<WebView>,
2529 F: Fn(&P, &WebResource, &URIRequest) + 'static,
2530 >(
2531 this: *mut ffi::WebKitWebView,
2532 resource: *mut ffi::WebKitWebResource,
2533 request: *mut ffi::WebKitURIRequest,
2534 f: glib::ffi::gpointer,
2535 ) {
2536 let f: &F = &*(f as *const F);
2537 f(
2538 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2539 &from_glib_borrow(resource),
2540 &from_glib_borrow(request),
2541 )
2542 }
2543 unsafe {
2544 let f: Box_<F> = Box_::new(f);
2545 connect_raw(
2546 self.as_ptr() as *mut _,
2547 b"resource-load-started\0".as_ptr() as *const _,
2548 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2549 resource_load_started_trampoline::<Self, F> as *const (),
2550 )),
2551 Box_::into_raw(f),
2552 )
2553 }
2554 }
2555
2556 #[doc(alias = "run-as-modal")]
2557 fn connect_run_as_modal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2558 unsafe extern "C" fn run_as_modal_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
2559 this: *mut ffi::WebKitWebView,
2560 f: glib::ffi::gpointer,
2561 ) {
2562 let f: &F = &*(f as *const F);
2563 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2564 }
2565 unsafe {
2566 let f: Box_<F> = Box_::new(f);
2567 connect_raw(
2568 self.as_ptr() as *mut _,
2569 b"run-as-modal\0".as_ptr() as *const _,
2570 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2571 run_as_modal_trampoline::<Self, F> as *const (),
2572 )),
2573 Box_::into_raw(f),
2574 )
2575 }
2576 }
2577
2578 #[cfg(feature = "v2_8")]
2579 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
2580 #[doc(alias = "run-color-chooser")]
2581 fn connect_run_color_chooser<F: Fn(&Self, &ColorChooserRequest) -> bool + 'static>(
2582 &self,
2583 f: F,
2584 ) -> SignalHandlerId {
2585 unsafe extern "C" fn run_color_chooser_trampoline<
2586 P: IsA<WebView>,
2587 F: Fn(&P, &ColorChooserRequest) -> bool + 'static,
2588 >(
2589 this: *mut ffi::WebKitWebView,
2590 request: *mut ffi::WebKitColorChooserRequest,
2591 f: glib::ffi::gpointer,
2592 ) -> glib::ffi::gboolean {
2593 let f: &F = &*(f as *const F);
2594 f(
2595 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2596 &from_glib_borrow(request),
2597 )
2598 .into_glib()
2599 }
2600 unsafe {
2601 let f: Box_<F> = Box_::new(f);
2602 connect_raw(
2603 self.as_ptr() as *mut _,
2604 b"run-color-chooser\0".as_ptr() as *const _,
2605 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2606 run_color_chooser_trampoline::<Self, F> as *const (),
2607 )),
2608 Box_::into_raw(f),
2609 )
2610 }
2611 }
2612
2613 #[doc(alias = "run-file-chooser")]
2614 fn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>(
2615 &self,
2616 f: F,
2617 ) -> SignalHandlerId {
2618 unsafe extern "C" fn run_file_chooser_trampoline<
2619 P: IsA<WebView>,
2620 F: Fn(&P, &FileChooserRequest) -> bool + 'static,
2621 >(
2622 this: *mut ffi::WebKitWebView,
2623 request: *mut ffi::WebKitFileChooserRequest,
2624 f: glib::ffi::gpointer,
2625 ) -> glib::ffi::gboolean {
2626 let f: &F = &*(f as *const F);
2627 f(
2628 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2629 &from_glib_borrow(request),
2630 )
2631 .into_glib()
2632 }
2633 unsafe {
2634 let f: Box_<F> = Box_::new(f);
2635 connect_raw(
2636 self.as_ptr() as *mut _,
2637 b"run-file-chooser\0".as_ptr() as *const _,
2638 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2639 run_file_chooser_trampoline::<Self, F> as *const (),
2640 )),
2641 Box_::into_raw(f),
2642 )
2643 }
2644 }
2645
2646 #[cfg(feature = "v2_24")]
2647 #[cfg_attr(docsrs, doc(cfg(feature = "v2_24")))]
2648 #[doc(alias = "script-dialog")]
2649 fn connect_script_dialog<F: Fn(&Self, &ScriptDialog) -> bool + 'static>(
2650 &self,
2651 f: F,
2652 ) -> SignalHandlerId {
2653 unsafe extern "C" fn script_dialog_trampoline<
2654 P: IsA<WebView>,
2655 F: Fn(&P, &ScriptDialog) -> bool + 'static,
2656 >(
2657 this: *mut ffi::WebKitWebView,
2658 dialog: *mut ffi::WebKitScriptDialog,
2659 f: glib::ffi::gpointer,
2660 ) -> glib::ffi::gboolean {
2661 let f: &F = &*(f as *const F);
2662 f(
2663 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2664 &from_glib_borrow(dialog),
2665 )
2666 .into_glib()
2667 }
2668 unsafe {
2669 let f: Box_<F> = Box_::new(f);
2670 connect_raw(
2671 self.as_ptr() as *mut _,
2672 b"script-dialog\0".as_ptr() as *const _,
2673 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2674 script_dialog_trampoline::<Self, F> as *const (),
2675 )),
2676 Box_::into_raw(f),
2677 )
2678 }
2679 }
2680
2681 #[cfg(feature = "v2_8")]
2682 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
2683 #[doc(alias = "show-notification")]
2684 fn connect_show_notification<F: Fn(&Self, &Notification) -> bool + 'static>(
2685 &self,
2686 f: F,
2687 ) -> SignalHandlerId {
2688 unsafe extern "C" fn show_notification_trampoline<
2689 P: IsA<WebView>,
2690 F: Fn(&P, &Notification) -> bool + 'static,
2691 >(
2692 this: *mut ffi::WebKitWebView,
2693 notification: *mut ffi::WebKitNotification,
2694 f: glib::ffi::gpointer,
2695 ) -> glib::ffi::gboolean {
2696 let f: &F = &*(f as *const F);
2697 f(
2698 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2699 &from_glib_borrow(notification),
2700 )
2701 .into_glib()
2702 }
2703 unsafe {
2704 let f: Box_<F> = Box_::new(f);
2705 connect_raw(
2706 self.as_ptr() as *mut _,
2707 b"show-notification\0".as_ptr() as *const _,
2708 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2709 show_notification_trampoline::<Self, F> as *const (),
2710 )),
2711 Box_::into_raw(f),
2712 )
2713 }
2714 }
2715
2716 #[cfg(feature = "v2_18")]
2717 #[cfg_attr(docsrs, doc(cfg(feature = "v2_18")))]
2718 #[doc(alias = "show-option-menu")]
2719 fn connect_show_option_menu<
2720 F: Fn(&Self, &OptionMenu, &gdk::Event, &gdk::Rectangle) -> bool + 'static,
2721 >(
2722 &self,
2723 f: F,
2724 ) -> SignalHandlerId {
2725 unsafe extern "C" fn show_option_menu_trampoline<
2726 P: IsA<WebView>,
2727 F: Fn(&P, &OptionMenu, &gdk::Event, &gdk::Rectangle) -> bool + 'static,
2728 >(
2729 this: *mut ffi::WebKitWebView,
2730 menu: *mut ffi::WebKitOptionMenu,
2731 event: *mut gdk::ffi::GdkEvent,
2732 rectangle: *mut gdk::ffi::GdkRectangle,
2733 f: glib::ffi::gpointer,
2734 ) -> glib::ffi::gboolean {
2735 let f: &F = &*(f as *const F);
2736 f(
2737 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2738 &from_glib_borrow(menu),
2739 &from_glib_none(event),
2740 &from_glib_borrow(rectangle),
2741 )
2742 .into_glib()
2743 }
2744 unsafe {
2745 let f: Box_<F> = Box_::new(f);
2746 connect_raw(
2747 self.as_ptr() as *mut _,
2748 b"show-option-menu\0".as_ptr() as *const _,
2749 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2750 show_option_menu_trampoline::<Self, F> as *const (),
2751 )),
2752 Box_::into_raw(f),
2753 )
2754 }
2755 }
2756
2757 #[doc(alias = "submit-form")]
2758 fn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>(
2759 &self,
2760 f: F,
2761 ) -> SignalHandlerId {
2762 unsafe extern "C" fn submit_form_trampoline<
2763 P: IsA<WebView>,
2764 F: Fn(&P, &FormSubmissionRequest) + 'static,
2765 >(
2766 this: *mut ffi::WebKitWebView,
2767 request: *mut ffi::WebKitFormSubmissionRequest,
2768 f: glib::ffi::gpointer,
2769 ) {
2770 let f: &F = &*(f as *const F);
2771 f(
2772 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2773 &from_glib_borrow(request),
2774 )
2775 }
2776 unsafe {
2777 let f: Box_<F> = Box_::new(f);
2778 connect_raw(
2779 self.as_ptr() as *mut _,
2780 b"submit-form\0".as_ptr() as *const _,
2781 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2782 submit_form_trampoline::<Self, F> as *const (),
2783 )),
2784 Box_::into_raw(f),
2785 )
2786 }
2787 }
2788
2789 #[cfg(feature = "v2_28")]
2790 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
2791 #[doc(alias = "user-message-received")]
2792 fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
2793 &self,
2794 f: F,
2795 ) -> SignalHandlerId {
2796 unsafe extern "C" fn user_message_received_trampoline<
2797 P: IsA<WebView>,
2798 F: Fn(&P, &UserMessage) -> bool + 'static,
2799 >(
2800 this: *mut ffi::WebKitWebView,
2801 message: *mut ffi::WebKitUserMessage,
2802 f: glib::ffi::gpointer,
2803 ) -> glib::ffi::gboolean {
2804 let f: &F = &*(f as *const F);
2805 f(
2806 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2807 &from_glib_borrow(message),
2808 )
2809 .into_glib()
2810 }
2811 unsafe {
2812 let f: Box_<F> = Box_::new(f);
2813 connect_raw(
2814 self.as_ptr() as *mut _,
2815 b"user-message-received\0".as_ptr() as *const _,
2816 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2817 user_message_received_trampoline::<Self, F> as *const (),
2818 )),
2819 Box_::into_raw(f),
2820 )
2821 }
2822 }
2823
2824 #[cfg_attr(feature = "v2_20", deprecated = "Since 2.20")]
2825 #[doc(alias = "web-process-crashed")]
2826 fn connect_web_process_crashed<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
2827 unsafe extern "C" fn web_process_crashed_trampoline<
2828 P: IsA<WebView>,
2829 F: Fn(&P) -> bool + 'static,
2830 >(
2831 this: *mut ffi::WebKitWebView,
2832 f: glib::ffi::gpointer,
2833 ) -> glib::ffi::gboolean {
2834 let f: &F = &*(f as *const F);
2835 f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
2836 }
2837 unsafe {
2838 let f: Box_<F> = Box_::new(f);
2839 connect_raw(
2840 self.as_ptr() as *mut _,
2841 b"web-process-crashed\0".as_ptr() as *const _,
2842 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2843 web_process_crashed_trampoline::<Self, F> as *const (),
2844 )),
2845 Box_::into_raw(f),
2846 )
2847 }
2848 }
2849
2850 #[cfg(feature = "v2_20")]
2851 #[cfg_attr(docsrs, doc(cfg(feature = "v2_20")))]
2852 #[doc(alias = "web-process-terminated")]
2853 fn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>(
2854 &self,
2855 f: F,
2856 ) -> SignalHandlerId {
2857 unsafe extern "C" fn web_process_terminated_trampoline<
2858 P: IsA<WebView>,
2859 F: Fn(&P, WebProcessTerminationReason) + 'static,
2860 >(
2861 this: *mut ffi::WebKitWebView,
2862 reason: ffi::WebKitWebProcessTerminationReason,
2863 f: glib::ffi::gpointer,
2864 ) {
2865 let f: &F = &*(f as *const F);
2866 f(
2867 WebView::from_glib_borrow(this).unsafe_cast_ref(),
2868 from_glib(reason),
2869 )
2870 }
2871 unsafe {
2872 let f: Box_<F> = Box_::new(f);
2873 connect_raw(
2874 self.as_ptr() as *mut _,
2875 b"web-process-terminated\0".as_ptr() as *const _,
2876 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2877 web_process_terminated_trampoline::<Self, F> as *const (),
2878 )),
2879 Box_::into_raw(f),
2880 )
2881 }
2882 }
2883
2884 #[cfg(feature = "v2_34")]
2885 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
2886 #[doc(alias = "camera-capture-state")]
2887 fn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2888 unsafe extern "C" fn notify_camera_capture_state_trampoline<
2889 P: IsA<WebView>,
2890 F: Fn(&P) + 'static,
2891 >(
2892 this: *mut ffi::WebKitWebView,
2893 _param_spec: glib::ffi::gpointer,
2894 f: glib::ffi::gpointer,
2895 ) {
2896 let f: &F = &*(f as *const F);
2897 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2898 }
2899 unsafe {
2900 let f: Box_<F> = Box_::new(f);
2901 connect_raw(
2902 self.as_ptr() as *mut _,
2903 b"notify::camera-capture-state\0".as_ptr() as *const _,
2904 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2905 notify_camera_capture_state_trampoline::<Self, F> as *const (),
2906 )),
2907 Box_::into_raw(f),
2908 )
2909 }
2910 }
2911
2912 #[cfg(feature = "v2_34")]
2913 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
2914 #[doc(alias = "display-capture-state")]
2915 fn connect_display_capture_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2916 unsafe extern "C" fn notify_display_capture_state_trampoline<
2917 P: IsA<WebView>,
2918 F: Fn(&P) + 'static,
2919 >(
2920 this: *mut ffi::WebKitWebView,
2921 _param_spec: glib::ffi::gpointer,
2922 f: glib::ffi::gpointer,
2923 ) {
2924 let f: &F = &*(f as *const F);
2925 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2926 }
2927 unsafe {
2928 let f: Box_<F> = Box_::new(f);
2929 connect_raw(
2930 self.as_ptr() as *mut _,
2931 b"notify::display-capture-state\0".as_ptr() as *const _,
2932 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2933 notify_display_capture_state_trampoline::<Self, F> as *const (),
2934 )),
2935 Box_::into_raw(f),
2936 )
2937 }
2938 }
2939
2940 #[cfg(feature = "v2_8")]
2941 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
2942 #[doc(alias = "editable")]
2943 fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2944 unsafe extern "C" fn notify_editable_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
2945 this: *mut ffi::WebKitWebView,
2946 _param_spec: glib::ffi::gpointer,
2947 f: glib::ffi::gpointer,
2948 ) {
2949 let f: &F = &*(f as *const F);
2950 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2951 }
2952 unsafe {
2953 let f: Box_<F> = Box_::new(f);
2954 connect_raw(
2955 self.as_ptr() as *mut _,
2956 b"notify::editable\0".as_ptr() as *const _,
2957 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2958 notify_editable_trampoline::<Self, F> as *const (),
2959 )),
2960 Box_::into_raw(f),
2961 )
2962 }
2963 }
2964
2965 #[doc(alias = "estimated-load-progress")]
2966 fn connect_estimated_load_progress_notify<F: Fn(&Self) + 'static>(
2967 &self,
2968 f: F,
2969 ) -> SignalHandlerId {
2970 unsafe extern "C" fn notify_estimated_load_progress_trampoline<
2971 P: IsA<WebView>,
2972 F: Fn(&P) + 'static,
2973 >(
2974 this: *mut ffi::WebKitWebView,
2975 _param_spec: glib::ffi::gpointer,
2976 f: glib::ffi::gpointer,
2977 ) {
2978 let f: &F = &*(f as *const F);
2979 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
2980 }
2981 unsafe {
2982 let f: Box_<F> = Box_::new(f);
2983 connect_raw(
2984 self.as_ptr() as *mut _,
2985 b"notify::estimated-load-progress\0".as_ptr() as *const _,
2986 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
2987 notify_estimated_load_progress_trampoline::<Self, F> as *const (),
2988 )),
2989 Box_::into_raw(f),
2990 )
2991 }
2992 }
2993
2994 #[doc(alias = "favicon")]
2995 fn connect_favicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2996 unsafe extern "C" fn notify_favicon_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
2997 this: *mut ffi::WebKitWebView,
2998 _param_spec: glib::ffi::gpointer,
2999 f: glib::ffi::gpointer,
3000 ) {
3001 let f: &F = &*(f as *const F);
3002 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3003 }
3004 unsafe {
3005 let f: Box_<F> = Box_::new(f);
3006 connect_raw(
3007 self.as_ptr() as *mut _,
3008 b"notify::favicon\0".as_ptr() as *const _,
3009 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3010 notify_favicon_trampoline::<Self, F> as *const (),
3011 )),
3012 Box_::into_raw(f),
3013 )
3014 }
3015 }
3016
3017 #[doc(alias = "is-loading")]
3018 fn connect_is_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3019 unsafe extern "C" fn notify_is_loading_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3020 this: *mut ffi::WebKitWebView,
3021 _param_spec: glib::ffi::gpointer,
3022 f: glib::ffi::gpointer,
3023 ) {
3024 let f: &F = &*(f as *const F);
3025 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3026 }
3027 unsafe {
3028 let f: Box_<F> = Box_::new(f);
3029 connect_raw(
3030 self.as_ptr() as *mut _,
3031 b"notify::is-loading\0".as_ptr() as *const _,
3032 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3033 notify_is_loading_trampoline::<Self, F> as *const (),
3034 )),
3035 Box_::into_raw(f),
3036 )
3037 }
3038 }
3039
3040 #[cfg(feature = "v2_30")]
3041 #[cfg_attr(docsrs, doc(cfg(feature = "v2_30")))]
3042 #[doc(alias = "is-muted")]
3043 fn connect_is_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3044 unsafe extern "C" fn notify_is_muted_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3045 this: *mut ffi::WebKitWebView,
3046 _param_spec: glib::ffi::gpointer,
3047 f: glib::ffi::gpointer,
3048 ) {
3049 let f: &F = &*(f as *const F);
3050 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3051 }
3052 unsafe {
3053 let f: Box_<F> = Box_::new(f);
3054 connect_raw(
3055 self.as_ptr() as *mut _,
3056 b"notify::is-muted\0".as_ptr() as *const _,
3057 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3058 notify_is_muted_trampoline::<Self, F> as *const (),
3059 )),
3060 Box_::into_raw(f),
3061 )
3062 }
3063 }
3064
3065 #[cfg(feature = "v2_8")]
3066 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
3067 #[doc(alias = "is-playing-audio")]
3068 fn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3069 unsafe extern "C" fn notify_is_playing_audio_trampoline<
3070 P: IsA<WebView>,
3071 F: Fn(&P) + 'static,
3072 >(
3073 this: *mut ffi::WebKitWebView,
3074 _param_spec: glib::ffi::gpointer,
3075 f: glib::ffi::gpointer,
3076 ) {
3077 let f: &F = &*(f as *const F);
3078 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3079 }
3080 unsafe {
3081 let f: Box_<F> = Box_::new(f);
3082 connect_raw(
3083 self.as_ptr() as *mut _,
3084 b"notify::is-playing-audio\0".as_ptr() as *const _,
3085 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3086 notify_is_playing_audio_trampoline::<Self, F> as *const (),
3087 )),
3088 Box_::into_raw(f),
3089 )
3090 }
3091 }
3092
3093 #[cfg(feature = "v2_34")]
3094 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
3095 #[doc(alias = "is-web-process-responsive")]
3096 fn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>(
3097 &self,
3098 f: F,
3099 ) -> SignalHandlerId {
3100 unsafe extern "C" fn notify_is_web_process_responsive_trampoline<
3101 P: IsA<WebView>,
3102 F: Fn(&P) + 'static,
3103 >(
3104 this: *mut ffi::WebKitWebView,
3105 _param_spec: glib::ffi::gpointer,
3106 f: glib::ffi::gpointer,
3107 ) {
3108 let f: &F = &*(f as *const F);
3109 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3110 }
3111 unsafe {
3112 let f: Box_<F> = Box_::new(f);
3113 connect_raw(
3114 self.as_ptr() as *mut _,
3115 b"notify::is-web-process-responsive\0".as_ptr() as *const _,
3116 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3117 notify_is_web_process_responsive_trampoline::<Self, F> as *const (),
3118 )),
3119 Box_::into_raw(f),
3120 )
3121 }
3122 }
3123
3124 #[cfg(feature = "v2_34")]
3125 #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
3126 #[doc(alias = "microphone-capture-state")]
3127 fn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>(
3128 &self,
3129 f: F,
3130 ) -> SignalHandlerId {
3131 unsafe extern "C" fn notify_microphone_capture_state_trampoline<
3132 P: IsA<WebView>,
3133 F: Fn(&P) + 'static,
3134 >(
3135 this: *mut ffi::WebKitWebView,
3136 _param_spec: glib::ffi::gpointer,
3137 f: glib::ffi::gpointer,
3138 ) {
3139 let f: &F = &*(f as *const F);
3140 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3141 }
3142 unsafe {
3143 let f: Box_<F> = Box_::new(f);
3144 connect_raw(
3145 self.as_ptr() as *mut _,
3146 b"notify::microphone-capture-state\0".as_ptr() as *const _,
3147 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3148 notify_microphone_capture_state_trampoline::<Self, F> as *const (),
3149 )),
3150 Box_::into_raw(f),
3151 )
3152 }
3153 }
3154
3155 #[cfg(feature = "v2_28")]
3156 #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))]
3157 #[doc(alias = "page-id")]
3158 fn connect_page_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3159 unsafe extern "C" fn notify_page_id_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3160 this: *mut ffi::WebKitWebView,
3161 _param_spec: glib::ffi::gpointer,
3162 f: glib::ffi::gpointer,
3163 ) {
3164 let f: &F = &*(f as *const F);
3165 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3166 }
3167 unsafe {
3168 let f: Box_<F> = Box_::new(f);
3169 connect_raw(
3170 self.as_ptr() as *mut _,
3171 b"notify::page-id\0".as_ptr() as *const _,
3172 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3173 notify_page_id_trampoline::<Self, F> as *const (),
3174 )),
3175 Box_::into_raw(f),
3176 )
3177 }
3178 }
3179
3180 #[cfg(feature = "v2_6")]
3181 #[cfg_attr(docsrs, doc(cfg(feature = "v2_6")))]
3182 #[doc(alias = "settings")]
3183 fn connect_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3184 unsafe extern "C" fn notify_settings_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3185 this: *mut ffi::WebKitWebView,
3186 _param_spec: glib::ffi::gpointer,
3187 f: glib::ffi::gpointer,
3188 ) {
3189 let f: &F = &*(f as *const F);
3190 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3191 }
3192 unsafe {
3193 let f: Box_<F> = Box_::new(f);
3194 connect_raw(
3195 self.as_ptr() as *mut _,
3196 b"notify::settings\0".as_ptr() as *const _,
3197 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3198 notify_settings_trampoline::<Self, F> as *const (),
3199 )),
3200 Box_::into_raw(f),
3201 )
3202 }
3203 }
3204
3205 #[doc(alias = "title")]
3206 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3207 unsafe extern "C" fn notify_title_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3208 this: *mut ffi::WebKitWebView,
3209 _param_spec: glib::ffi::gpointer,
3210 f: glib::ffi::gpointer,
3211 ) {
3212 let f: &F = &*(f as *const F);
3213 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3214 }
3215 unsafe {
3216 let f: Box_<F> = Box_::new(f);
3217 connect_raw(
3218 self.as_ptr() as *mut _,
3219 b"notify::title\0".as_ptr() as *const _,
3220 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3221 notify_title_trampoline::<Self, F> as *const (),
3222 )),
3223 Box_::into_raw(f),
3224 )
3225 }
3226 }
3227
3228 #[doc(alias = "uri")]
3229 fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3230 unsafe extern "C" fn notify_uri_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3231 this: *mut ffi::WebKitWebView,
3232 _param_spec: glib::ffi::gpointer,
3233 f: glib::ffi::gpointer,
3234 ) {
3235 let f: &F = &*(f as *const F);
3236 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3237 }
3238 unsafe {
3239 let f: Box_<F> = Box_::new(f);
3240 connect_raw(
3241 self.as_ptr() as *mut _,
3242 b"notify::uri\0".as_ptr() as *const _,
3243 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3244 notify_uri_trampoline::<Self, F> as *const (),
3245 )),
3246 Box_::into_raw(f),
3247 )
3248 }
3249 }
3250
3251 #[doc(alias = "zoom-level")]
3252 fn connect_zoom_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3253 unsafe extern "C" fn notify_zoom_level_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
3254 this: *mut ffi::WebKitWebView,
3255 _param_spec: glib::ffi::gpointer,
3256 f: glib::ffi::gpointer,
3257 ) {
3258 let f: &F = &*(f as *const F);
3259 f(WebView::from_glib_borrow(this).unsafe_cast_ref())
3260 }
3261 unsafe {
3262 let f: Box_<F> = Box_::new(f);
3263 connect_raw(
3264 self.as_ptr() as *mut _,
3265 b"notify::zoom-level\0".as_ptr() as *const _,
3266 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
3267 notify_zoom_level_trampoline::<Self, F> as *const (),
3268 )),
3269 Box_::into_raw(f),
3270 )
3271 }
3272 }
3273}
3274
3275impl<O: IsA<WebView>> WebViewExt for O {}