webkit2gtk_webextension/auto/
uri_request.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files.git)
3// DO NOT EDIT
4
5use glib::object::Cast;
6use glib::object::IsA;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10use std::boxed::Box as Box_;
11use std::fmt;
12use std::mem::transmute;
13
14glib::wrapper! {
15    #[doc(alias = "WebKitURIRequest")]
16    pub struct URIRequest(Object<ffi::WebKitURIRequest, ffi::WebKitURIRequestClass>);
17
18    match fn {
19        type_ => || ffi::webkit_uri_request_get_type(),
20    }
21}
22
23impl URIRequest {
24        pub const NONE: Option<&'static URIRequest> = None;
25    
26
27    #[doc(alias = "webkit_uri_request_new")]
28    pub fn new(uri: &str) -> URIRequest {
29        assert_initialized_main_thread!();
30        unsafe {
31            from_glib_full(ffi::webkit_uri_request_new(uri.to_glib_none().0))
32        }
33    }
34}
35
36pub trait URIRequestExt: 'static {
37    //#[doc(alias = "webkit_uri_request_get_http_headers")]
38    //#[doc(alias = "get_http_headers")]
39    //fn http_headers(&self) -> /*Ignored*/Option<soup::MessageHeaders>;
40
41    #[cfg(any(feature = "v2_12", feature = "dox"))]
42    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_12")))]
43    #[doc(alias = "webkit_uri_request_get_http_method")]
44    #[doc(alias = "get_http_method")]
45    fn http_method(&self) -> Option<glib::GString>;
46
47    #[doc(alias = "webkit_uri_request_get_uri")]
48    #[doc(alias = "get_uri")]
49    fn uri(&self) -> Option<glib::GString>;
50
51    #[doc(alias = "webkit_uri_request_set_uri")]
52    fn set_uri(&self, uri: &str);
53
54    #[doc(alias = "uri")]
55    fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
56}
57
58impl<O: IsA<URIRequest>> URIRequestExt for O {
59    //fn http_headers(&self) -> /*Ignored*/Option<soup::MessageHeaders> {
60    //    unsafe { TODO: call ffi:webkit_uri_request_get_http_headers() }
61    //}
62
63    #[cfg(any(feature = "v2_12", feature = "dox"))]
64    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_12")))]
65    fn http_method(&self) -> Option<glib::GString> {
66        unsafe {
67            from_glib_none(ffi::webkit_uri_request_get_http_method(self.as_ref().to_glib_none().0))
68        }
69    }
70
71    fn uri(&self) -> Option<glib::GString> {
72        unsafe {
73            from_glib_none(ffi::webkit_uri_request_get_uri(self.as_ref().to_glib_none().0))
74        }
75    }
76
77    fn set_uri(&self, uri: &str) {
78        unsafe {
79            ffi::webkit_uri_request_set_uri(self.as_ref().to_glib_none().0, uri.to_glib_none().0);
80        }
81    }
82
83    fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
84        unsafe extern "C" fn notify_uri_trampoline<P: IsA<URIRequest>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitURIRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
85            let f: &F = &*(f as *const F);
86            f(URIRequest::from_glib_borrow(this).unsafe_cast_ref())
87        }
88        unsafe {
89            let f: Box_<F> = Box_::new(f);
90            connect_raw(self.as_ptr() as *mut _, b"notify::uri\0".as_ptr() as *const _,
91                Some(transmute::<_, unsafe extern "C" fn()>(notify_uri_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
92        }
93    }
94}
95
96impl fmt::Display for URIRequest {
97    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
98        f.write_str("URIRequest")
99    }
100}