// 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 crate::{HeaderBar, HeaderGroupChild};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};

glib::wrapper! {
    #[doc(alias = "HdyHeaderGroup")]
    pub struct HeaderGroup(Object<ffi::HdyHeaderGroup, ffi::HdyHeaderGroupClass>) @implements gtk::Buildable;

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

impl HeaderGroup {
    #[doc(alias = "hdy_header_group_new")]
    pub fn new() -> HeaderGroup {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::hdy_header_group_new()) }
    }

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

    #[doc(alias = "hdy_header_group_add_gtk_header_bar")]
    pub fn add_gtk_header_bar(&self, header_bar: &impl IsA<gtk::HeaderBar>) {
        unsafe {
            ffi::hdy_header_group_add_gtk_header_bar(
                self.to_glib_none().0,
                header_bar.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_header_group_add_header_bar")]
    pub fn add_header_bar(&self, header_bar: &impl IsA<HeaderBar>) {
        unsafe {
            ffi::hdy_header_group_add_header_bar(
                self.to_glib_none().0,
                header_bar.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_header_group_add_header_group")]
    pub fn add_header_group(&self, header_group: &HeaderGroup) {
        unsafe {
            ffi::hdy_header_group_add_header_group(
                self.to_glib_none().0,
                header_group.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_header_group_get_children")]
    #[doc(alias = "get_children")]
    pub fn children(&self) -> Vec<HeaderGroupChild> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::hdy_header_group_get_children(
                self.to_glib_none().0,
            ))
        }
    }

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

    #[doc(alias = "hdy_header_group_remove_child")]
    pub fn remove_child(&self, child: &HeaderGroupChild) {
        unsafe {
            ffi::hdy_header_group_remove_child(self.to_glib_none().0, child.to_glib_none().0);
        }
    }

    #[doc(alias = "hdy_header_group_remove_gtk_header_bar")]
    pub fn remove_gtk_header_bar(&self, header_bar: &impl IsA<gtk::HeaderBar>) {
        unsafe {
            ffi::hdy_header_group_remove_gtk_header_bar(
                self.to_glib_none().0,
                header_bar.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_header_group_remove_header_bar")]
    pub fn remove_header_bar(&self, header_bar: &impl IsA<HeaderBar>) {
        unsafe {
            ffi::hdy_header_group_remove_header_bar(
                self.to_glib_none().0,
                header_bar.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "hdy_header_group_remove_header_group")]
    pub fn remove_header_group(&self, header_group: &HeaderGroup) {
        unsafe {
            ffi::hdy_header_group_remove_header_group(
                self.to_glib_none().0,
                header_group.to_glib_none().0,
            );
        }
    }

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

    #[doc(alias = "update-decoration-layouts")]
    pub fn connect_update_decoration_layouts<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn update_decoration_layouts_trampoline<F: Fn(&HeaderGroup) + 'static>(
            this: *mut ffi::HdyHeaderGroup,
            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"update-decoration-layouts\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    update_decoration_layouts_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "decorate-all")]
    pub fn connect_decorate_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_decorate_all_trampoline<F: Fn(&HeaderGroup) + 'static>(
            this: *mut ffi::HdyHeaderGroup,
            _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::decorate-all\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_decorate_all_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl Default for HeaderGroup {
    fn default() -> Self {
        Self::new()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`HeaderGroup`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct HeaderGroupBuilder {
    builder: glib::object::ObjectBuilder<'static, HeaderGroup>,
}

impl HeaderGroupBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    pub fn decorate_all(self, decorate_all: bool) -> Self {
        Self {
            builder: self.builder.property("decorate-all", decorate_all),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`HeaderGroup`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> HeaderGroup {
        self.builder.build()
    }
}

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