1use crate::WebViewBase;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "WebKitWebInspector")]
15 pub struct WebInspector(Object<ffi::WebKitWebInspector, ffi::WebKitWebInspectorClass>);
16
17 match fn {
18 type_ => || ffi::webkit_web_inspector_get_type(),
19 }
20}
21
22impl WebInspector {
23 pub const NONE: Option<&'static WebInspector> = None;
24}
25
26mod sealed {
27 pub trait Sealed {}
28 impl<T: super::IsA<super::WebInspector>> Sealed for T {}
29}
30
31pub trait WebInspectorExt: IsA<WebInspector> + sealed::Sealed + 'static {
32 #[doc(alias = "webkit_web_inspector_attach")]
33 fn attach(&self) {
34 unsafe {
35 ffi::webkit_web_inspector_attach(self.as_ref().to_glib_none().0);
36 }
37 }
38
39 #[doc(alias = "webkit_web_inspector_close")]
40 fn close(&self) {
41 unsafe {
42 ffi::webkit_web_inspector_close(self.as_ref().to_glib_none().0);
43 }
44 }
45
46 #[doc(alias = "webkit_web_inspector_detach")]
47 fn detach(&self) {
48 unsafe {
49 ffi::webkit_web_inspector_detach(self.as_ref().to_glib_none().0);
50 }
51 }
52
53 #[doc(alias = "webkit_web_inspector_get_attached_height")]
54 #[doc(alias = "get_attached_height")]
55 fn attached_height(&self) -> u32 {
56 unsafe { ffi::webkit_web_inspector_get_attached_height(self.as_ref().to_glib_none().0) }
57 }
58
59 #[cfg(feature = "v2_8")]
60 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
61 #[doc(alias = "webkit_web_inspector_get_can_attach")]
62 #[doc(alias = "get_can_attach")]
63 fn can_attach(&self) -> bool {
64 unsafe {
65 from_glib(ffi::webkit_web_inspector_get_can_attach(
66 self.as_ref().to_glib_none().0,
67 ))
68 }
69 }
70
71 #[doc(alias = "webkit_web_inspector_get_inspected_uri")]
72 #[doc(alias = "get_inspected_uri")]
73 fn inspected_uri(&self) -> Option<glib::GString> {
74 unsafe {
75 from_glib_none(ffi::webkit_web_inspector_get_inspected_uri(
76 self.as_ref().to_glib_none().0,
77 ))
78 }
79 }
80
81 #[doc(alias = "webkit_web_inspector_get_web_view")]
82 #[doc(alias = "get_web_view")]
83 fn web_view(&self) -> Option<WebViewBase> {
84 unsafe {
85 from_glib_none(ffi::webkit_web_inspector_get_web_view(
86 self.as_ref().to_glib_none().0,
87 ))
88 }
89 }
90
91 #[doc(alias = "webkit_web_inspector_is_attached")]
92 fn is_attached(&self) -> bool {
93 unsafe {
94 from_glib(ffi::webkit_web_inspector_is_attached(
95 self.as_ref().to_glib_none().0,
96 ))
97 }
98 }
99
100 #[doc(alias = "webkit_web_inspector_show")]
101 fn show(&self) {
102 unsafe {
103 ffi::webkit_web_inspector_show(self.as_ref().to_glib_none().0);
104 }
105 }
106
107 #[doc(alias = "attach")]
108 fn connect_attach<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
109 unsafe extern "C" fn attach_trampoline<P: IsA<WebInspector>, F: Fn(&P) -> bool + 'static>(
110 this: *mut ffi::WebKitWebInspector,
111 f: glib::ffi::gpointer,
112 ) -> glib::ffi::gboolean {
113 let f: &F = &*(f as *const F);
114 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
115 }
116 unsafe {
117 let f: Box_<F> = Box_::new(f);
118 connect_raw(
119 self.as_ptr() as *mut _,
120 b"attach\0".as_ptr() as *const _,
121 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
122 attach_trampoline::<Self, F> as *const (),
123 )),
124 Box_::into_raw(f),
125 )
126 }
127 }
128
129 #[doc(alias = "bring-to-front")]
130 fn connect_bring_to_front<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
131 unsafe extern "C" fn bring_to_front_trampoline<
132 P: IsA<WebInspector>,
133 F: Fn(&P) -> bool + 'static,
134 >(
135 this: *mut ffi::WebKitWebInspector,
136 f: glib::ffi::gpointer,
137 ) -> glib::ffi::gboolean {
138 let f: &F = &*(f as *const F);
139 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
140 }
141 unsafe {
142 let f: Box_<F> = Box_::new(f);
143 connect_raw(
144 self.as_ptr() as *mut _,
145 b"bring-to-front\0".as_ptr() as *const _,
146 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
147 bring_to_front_trampoline::<Self, F> as *const (),
148 )),
149 Box_::into_raw(f),
150 )
151 }
152 }
153
154 #[doc(alias = "closed")]
155 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
156 unsafe extern "C" fn closed_trampoline<P: IsA<WebInspector>, F: Fn(&P) + 'static>(
157 this: *mut ffi::WebKitWebInspector,
158 f: glib::ffi::gpointer,
159 ) {
160 let f: &F = &*(f as *const F);
161 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref())
162 }
163 unsafe {
164 let f: Box_<F> = Box_::new(f);
165 connect_raw(
166 self.as_ptr() as *mut _,
167 b"closed\0".as_ptr() as *const _,
168 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
169 closed_trampoline::<Self, F> as *const (),
170 )),
171 Box_::into_raw(f),
172 )
173 }
174 }
175
176 #[doc(alias = "detach")]
177 fn connect_detach<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
178 unsafe extern "C" fn detach_trampoline<P: IsA<WebInspector>, F: Fn(&P) -> bool + 'static>(
179 this: *mut ffi::WebKitWebInspector,
180 f: glib::ffi::gpointer,
181 ) -> glib::ffi::gboolean {
182 let f: &F = &*(f as *const F);
183 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
184 }
185 unsafe {
186 let f: Box_<F> = Box_::new(f);
187 connect_raw(
188 self.as_ptr() as *mut _,
189 b"detach\0".as_ptr() as *const _,
190 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
191 detach_trampoline::<Self, F> as *const (),
192 )),
193 Box_::into_raw(f),
194 )
195 }
196 }
197
198 #[doc(alias = "open-window")]
199 fn connect_open_window<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
200 unsafe extern "C" fn open_window_trampoline<
201 P: IsA<WebInspector>,
202 F: Fn(&P) -> bool + 'static,
203 >(
204 this: *mut ffi::WebKitWebInspector,
205 f: glib::ffi::gpointer,
206 ) -> glib::ffi::gboolean {
207 let f: &F = &*(f as *const F);
208 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
209 }
210 unsafe {
211 let f: Box_<F> = Box_::new(f);
212 connect_raw(
213 self.as_ptr() as *mut _,
214 b"open-window\0".as_ptr() as *const _,
215 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
216 open_window_trampoline::<Self, F> as *const (),
217 )),
218 Box_::into_raw(f),
219 )
220 }
221 }
222
223 #[doc(alias = "attached-height")]
224 fn connect_attached_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
225 unsafe extern "C" fn notify_attached_height_trampoline<
226 P: IsA<WebInspector>,
227 F: Fn(&P) + 'static,
228 >(
229 this: *mut ffi::WebKitWebInspector,
230 _param_spec: glib::ffi::gpointer,
231 f: glib::ffi::gpointer,
232 ) {
233 let f: &F = &*(f as *const F);
234 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref())
235 }
236 unsafe {
237 let f: Box_<F> = Box_::new(f);
238 connect_raw(
239 self.as_ptr() as *mut _,
240 b"notify::attached-height\0".as_ptr() as *const _,
241 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
242 notify_attached_height_trampoline::<Self, F> as *const (),
243 )),
244 Box_::into_raw(f),
245 )
246 }
247 }
248
249 #[cfg(feature = "v2_8")]
250 #[cfg_attr(docsrs, doc(cfg(feature = "v2_8")))]
251 #[doc(alias = "can-attach")]
252 fn connect_can_attach_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
253 unsafe extern "C" fn notify_can_attach_trampoline<P: IsA<WebInspector>, F: Fn(&P) + 'static>(
254 this: *mut ffi::WebKitWebInspector,
255 _param_spec: glib::ffi::gpointer,
256 f: glib::ffi::gpointer,
257 ) {
258 let f: &F = &*(f as *const F);
259 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref())
260 }
261 unsafe {
262 let f: Box_<F> = Box_::new(f);
263 connect_raw(
264 self.as_ptr() as *mut _,
265 b"notify::can-attach\0".as_ptr() as *const _,
266 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
267 notify_can_attach_trampoline::<Self, F> as *const (),
268 )),
269 Box_::into_raw(f),
270 )
271 }
272 }
273
274 #[doc(alias = "inspected-uri")]
275 fn connect_inspected_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
276 unsafe extern "C" fn notify_inspected_uri_trampoline<
277 P: IsA<WebInspector>,
278 F: Fn(&P) + 'static,
279 >(
280 this: *mut ffi::WebKitWebInspector,
281 _param_spec: glib::ffi::gpointer,
282 f: glib::ffi::gpointer,
283 ) {
284 let f: &F = &*(f as *const F);
285 f(WebInspector::from_glib_borrow(this).unsafe_cast_ref())
286 }
287 unsafe {
288 let f: Box_<F> = Box_::new(f);
289 connect_raw(
290 self.as_ptr() as *mut _,
291 b"notify::inspected-uri\0".as_ptr() as *const _,
292 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
293 notify_inspected_uri_trampoline::<Self, F> as *const (),
294 )),
295 Box_::into_raw(f),
296 )
297 }
298 }
299}
300
301impl<O: IsA<WebInspector>> WebInspectorExt for O {}