// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::WebViewBase;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    pub struct WebInspector(Object<ffi::WebKitWebInspector, ffi::WebKitWebInspectorClass>);

    match fn {
        get_type => || ffi::webkit_web_inspector_get_type(),
    }
}

pub const NONE_WEB_INSPECTOR: Option<&WebInspector> = None;

pub trait WebInspectorExt: 'static {
    #[doc(alias = "webkit_web_inspector_attach")]
    fn attach(&self);

    #[doc(alias = "webkit_web_inspector_close")]
    fn close(&self);

    #[doc(alias = "webkit_web_inspector_detach")]
    fn detach(&self);

    #[doc(alias = "webkit_web_inspector_get_attached_height")]
    fn get_attached_height(&self) -> u32;

    #[cfg(any(feature = "v2_8", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_8")))]
    #[doc(alias = "webkit_web_inspector_get_can_attach")]
    fn get_can_attach(&self) -> bool;

    #[doc(alias = "webkit_web_inspector_get_inspected_uri")]
    fn get_inspected_uri(&self) -> Option<glib::GString>;

    #[doc(alias = "webkit_web_inspector_get_web_view")]
    fn get_web_view(&self) -> Option<WebViewBase>;

    #[doc(alias = "webkit_web_inspector_is_attached")]
    fn is_attached(&self) -> bool;

    #[doc(alias = "webkit_web_inspector_show")]
    fn show(&self);

    fn connect_attach<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_bring_to_front<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_detach<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_open_window<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_attached_height_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    #[cfg(any(feature = "v2_8", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_8")))]
    fn connect_property_can_attach_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_inspected_uri_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;
}

impl<O: IsA<WebInspector>> WebInspectorExt for O {
    fn attach(&self) {
        unsafe {
            ffi::webkit_web_inspector_attach(self.as_ref().to_glib_none().0);
        }
    }

    fn close(&self) {
        unsafe {
            ffi::webkit_web_inspector_close(self.as_ref().to_glib_none().0);
        }
    }

    fn detach(&self) {
        unsafe {
            ffi::webkit_web_inspector_detach(self.as_ref().to_glib_none().0);
        }
    }

    fn get_attached_height(&self) -> u32 {
        unsafe { ffi::webkit_web_inspector_get_attached_height(self.as_ref().to_glib_none().0) }
    }

    #[cfg(any(feature = "v2_8", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_8")))]
    fn get_can_attach(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_inspector_get_can_attach(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_inspected_uri(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_web_inspector_get_inspected_uri(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_web_view(&self) -> Option<WebViewBase> {
        unsafe {
            from_glib_none(ffi::webkit_web_inspector_get_web_view(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_attached(&self) -> bool {
        unsafe {
            from_glib(ffi::webkit_web_inspector_is_attached(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn show(&self) {
        unsafe {
            ffi::webkit_web_inspector_show(self.as_ref().to_glib_none().0);
        }
    }

    fn connect_attach<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn attach_trampoline<P, F: Fn(&P) -> bool + 'static>(
            this: *mut ffi::WebKitWebInspector,
            f: glib::ffi::gpointer,
        ) -> glib::ffi::gboolean
        where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref()).to_glib()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"attach\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    attach_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_bring_to_front<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn bring_to_front_trampoline<P, F: Fn(&P) -> bool + 'static>(
            this: *mut ffi::WebKitWebInspector,
            f: glib::ffi::gpointer,
        ) -> glib::ffi::gboolean
        where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref()).to_glib()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"bring-to-front\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    bring_to_front_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn closed_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ffi::WebKitWebInspector,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"closed\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    closed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_detach<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn detach_trampoline<P, F: Fn(&P) -> bool + 'static>(
            this: *mut ffi::WebKitWebInspector,
            f: glib::ffi::gpointer,
        ) -> glib::ffi::gboolean
        where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref()).to_glib()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"detach\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    detach_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_open_window<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn open_window_trampoline<P, F: Fn(&P) -> bool + 'static>(
            this: *mut ffi::WebKitWebInspector,
            f: glib::ffi::gpointer,
        ) -> glib::ffi::gboolean
        where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref()).to_glib()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"open-window\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    open_window_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_attached_height_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_attached_height_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ffi::WebKitWebInspector,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::attached-height\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_attached_height_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v2_8", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_8")))]
    fn connect_property_can_attach_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_can_attach_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ffi::WebKitWebInspector,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::can-attach\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_can_attach_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_inspected_uri_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_inspected_uri_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ffi::WebKitWebInspector,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<WebInspector>,
        {
            let f: &F = &*(f as *const F);
            f(&WebInspector::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::inspected-uri\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_inspected_uri_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for WebInspector {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("WebInspector")
    }
}
