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

use glib::object::Cast;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    #[doc(alias = "HdyTabPage")]
    pub struct TabPage(Object<ffi::HdyTabPage, ffi::HdyTabPageClass>);

    match fn {
        type_ => || ffi::hdy_tab_page_get_type(),
    }
}

impl TabPage {
    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`TabPage`] objects.
    ///
    /// This method returns an instance of [`TabPageBuilder`] which can be used to create [`TabPage`] objects.
    pub fn builder() -> TabPageBuilder {
        TabPageBuilder::default()
    }

    #[doc(alias = "hdy_tab_page_get_child")]
    #[doc(alias = "get_child")]
    pub fn child(&self) -> Option<gtk::Widget> {
        unsafe { from_glib_none(ffi::hdy_tab_page_get_child(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_icon")]
    #[doc(alias = "get_icon")]
    pub fn icon(&self) -> Option<gio::Icon> {
        unsafe { from_glib_none(ffi::hdy_tab_page_get_icon(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_indicator_activatable")]
    #[doc(alias = "get_indicator_activatable")]
    pub fn is_indicator_activatable(&self) -> bool {
        unsafe {
            from_glib(ffi::hdy_tab_page_get_indicator_activatable(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "hdy_tab_page_get_indicator_icon")]
    #[doc(alias = "get_indicator_icon")]
    pub fn indicator_icon(&self) -> Option<gio::Icon> {
        unsafe { from_glib_none(ffi::hdy_tab_page_get_indicator_icon(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_loading")]
    #[doc(alias = "get_loading")]
    pub fn is_loading(&self) -> bool {
        unsafe { from_glib(ffi::hdy_tab_page_get_loading(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_needs_attention")]
    #[doc(alias = "get_needs_attention")]
    pub fn needs_attention(&self) -> bool {
        unsafe { from_glib(ffi::hdy_tab_page_get_needs_attention(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_parent")]
    #[doc(alias = "get_parent")]
    pub fn parent(&self) -> Option<TabPage> {
        unsafe { from_glib_none(ffi::hdy_tab_page_get_parent(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_pinned")]
    #[doc(alias = "get_pinned")]
    pub fn is_pinned(&self) -> bool {
        unsafe { from_glib(ffi::hdy_tab_page_get_pinned(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_selected")]
    #[doc(alias = "get_selected")]
    pub fn is_selected(&self) -> bool {
        unsafe { from_glib(ffi::hdy_tab_page_get_selected(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_title")]
    #[doc(alias = "get_title")]
    pub fn title(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::hdy_tab_page_get_title(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_get_tooltip")]
    #[doc(alias = "get_tooltip")]
    pub fn tooltip(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::hdy_tab_page_get_tooltip(self.to_glib_none().0)) }
    }

    #[doc(alias = "hdy_tab_page_set_icon")]
    pub fn set_icon<P: IsA<gio::Icon>>(&self, icon: Option<&P>) {
        unsafe {
            ffi::hdy_tab_page_set_icon(
                self.to_glib_none().0,
                icon.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_tab_page_set_indicator_activatable")]
    pub fn set_indicator_activatable(&self, activatable: bool) {
        unsafe {
            ffi::hdy_tab_page_set_indicator_activatable(
                self.to_glib_none().0,
                activatable.into_glib(),
            );
        }
    }

    #[doc(alias = "hdy_tab_page_set_indicator_icon")]
    pub fn set_indicator_icon<P: IsA<gio::Icon>>(&self, indicator_icon: Option<&P>) {
        unsafe {
            ffi::hdy_tab_page_set_indicator_icon(
                self.to_glib_none().0,
                indicator_icon.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_tab_page_set_loading")]
    pub fn set_loading(&self, loading: bool) {
        unsafe {
            ffi::hdy_tab_page_set_loading(self.to_glib_none().0, loading.into_glib());
        }
    }

    #[doc(alias = "hdy_tab_page_set_needs_attention")]
    pub fn set_needs_attention(&self, needs_attention: bool) {
        unsafe {
            ffi::hdy_tab_page_set_needs_attention(
                self.to_glib_none().0,
                needs_attention.into_glib(),
            );
        }
    }

    #[doc(alias = "hdy_tab_page_set_title")]
    pub fn set_title(&self, title: Option<&str>) {
        unsafe {
            ffi::hdy_tab_page_set_title(self.to_glib_none().0, title.to_glib_none().0);
        }
    }

    #[doc(alias = "hdy_tab_page_set_tooltip")]
    pub fn set_tooltip(&self, tooltip: Option<&str>) {
        unsafe {
            ffi::hdy_tab_page_set_tooltip(self.to_glib_none().0, tooltip.to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "icon")]
    pub fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_icon_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::icon\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_icon_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "indicator-activatable")]
    pub fn connect_indicator_activatable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_indicator_activatable_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::indicator-activatable\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_indicator_activatable_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "indicator-icon")]
    pub fn connect_indicator_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_indicator_icon_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::indicator-icon\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_indicator_icon_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "loading")]
    pub fn connect_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_loading_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::loading\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_loading_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "needs-attention")]
    pub fn connect_needs_attention_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_needs_attention_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::needs-attention\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_needs_attention_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "pinned")]
    pub fn connect_pinned_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_pinned_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::pinned\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_pinned_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "selected")]
    pub fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_selected_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::selected\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_selected_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "title")]
    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_title_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::title\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_title_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    #[doc(alias = "tooltip")]
    pub fn connect_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_tooltip_trampoline<F: Fn(&TabPage) + 'static>(
            this: *mut ffi::HdyTabPage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::tooltip\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_tooltip_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`TabPage`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
pub struct TabPageBuilder {
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    child: Option<gtk::Widget>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    icon: Option<gio::Icon>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    indicator_activatable: Option<bool>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    indicator_icon: Option<gio::Icon>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    loading: Option<bool>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    needs_attention: Option<bool>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    parent: Option<TabPage>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    title: Option<String>,
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    tooltip: Option<String>,
}

impl TabPageBuilder {
    // rustdoc-stripper-ignore-next
    /// Create a new [`TabPageBuilder`].
    pub fn new() -> Self {
        Self::default()
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`TabPage`].
    pub fn build(self) -> TabPage {
        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref child) = self.child {
            properties.push(("child", child));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref icon) = self.icon {
            properties.push(("icon", icon));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref indicator_activatable) = self.indicator_activatable {
            properties.push(("indicator-activatable", indicator_activatable));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref indicator_icon) = self.indicator_icon {
            properties.push(("indicator-icon", indicator_icon));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref loading) = self.loading {
            properties.push(("loading", loading));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref needs_attention) = self.needs_attention {
            properties.push(("needs-attention", needs_attention));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref parent) = self.parent {
            properties.push(("parent", parent));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref title) = self.title {
            properties.push(("title", title));
        }
        #[cfg(any(feature = "v1_2", feature = "dox"))]
        if let Some(ref tooltip) = self.tooltip {
            properties.push(("tooltip", tooltip));
        }
        glib::Object::new::<TabPage>(&properties).expect("Failed to create an instance of TabPage")
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn child<P: IsA<gtk::Widget>>(mut self, child: &P) -> Self {
        self.child = Some(child.clone().upcast());
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn icon<P: IsA<gio::Icon>>(mut self, icon: &P) -> Self {
        self.icon = Some(icon.clone().upcast());
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn indicator_activatable(mut self, indicator_activatable: bool) -> Self {
        self.indicator_activatable = Some(indicator_activatable);
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn indicator_icon<P: IsA<gio::Icon>>(mut self, indicator_icon: &P) -> Self {
        self.indicator_icon = Some(indicator_icon.clone().upcast());
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn loading(mut self, loading: bool) -> Self {
        self.loading = Some(loading);
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn needs_attention(mut self, needs_attention: bool) -> Self {
        self.needs_attention = Some(needs_attention);
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn parent(mut self, parent: &TabPage) -> Self {
        self.parent = Some(parent.clone());
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn title(mut self, title: &str) -> Self {
        self.title = Some(title.to_string());
        self
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_2")))]
    pub fn tooltip(mut self, tooltip: &str) -> Self {
        self.tooltip = Some(tooltip.to_string());
        self
    }
}

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