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

use crate::{ffi, Link};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "PpsOutlines")]
    pub struct Outlines(Object<ffi::PpsOutlines, ffi::PpsOutlinesClass>);

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

impl Outlines {
    pub const NONE: Option<&'static Outlines> = None;

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

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

pub trait OutlinesExt: IsA<Outlines> + 'static {
    #[doc(alias = "pps_outlines_get_children")]
    #[doc(alias = "get_children")]
    fn children(&self) -> Option<gio::ListModel> {
        unsafe {
            from_glib_none(ffi::pps_outlines_get_children(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_outlines_get_expand")]
    #[doc(alias = "get_expand")]
    #[doc(alias = "expand")]
    fn expands(&self) -> bool {
        unsafe { from_glib(ffi::pps_outlines_get_expand(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "pps_outlines_get_link")]
    #[doc(alias = "get_link")]
    fn link(&self) -> Option<Link> {
        unsafe { from_glib_none(ffi::pps_outlines_get_link(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "pps_outlines_set_children")]
    #[doc(alias = "children")]
    fn set_children(&self, children: impl IsA<gio::ListModel>) {
        unsafe {
            ffi::pps_outlines_set_children(
                self.as_ref().to_glib_none().0,
                children.upcast().into_glib_ptr(),
            );
        }
    }

    #[doc(alias = "pps_outlines_set_expand")]
    #[doc(alias = "expand")]
    fn set_expand(&self, expand: bool) {
        unsafe {
            ffi::pps_outlines_set_expand(self.as_ref().to_glib_none().0, expand.into_glib());
        }
    }

    #[doc(alias = "pps_outlines_set_label")]
    #[doc(alias = "label")]
    fn set_label(&self, label: &str) {
        unsafe {
            ffi::pps_outlines_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
        }
    }

    #[doc(alias = "pps_outlines_set_link")]
    #[doc(alias = "link")]
    fn set_link(&self, link: &Link) {
        unsafe {
            ffi::pps_outlines_set_link(self.as_ref().to_glib_none().0, link.to_glib_none().0);
        }
    }

    #[doc(alias = "pps_outlines_set_markup")]
    #[doc(alias = "markup")]
    fn set_markup(&self, markup: &str) {
        unsafe {
            ffi::pps_outlines_set_markup(self.as_ref().to_glib_none().0, markup.to_glib_none().0);
        }
    }

    fn label(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "label")
    }

    fn markup(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "markup")
    }

    #[doc(alias = "children")]
    fn connect_children_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_children_trampoline<P: IsA<Outlines>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsOutlines,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Outlines::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::children".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_children_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "expand")]
    fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_expand_trampoline<P: IsA<Outlines>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsOutlines,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Outlines::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::expand".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_expand_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "label")]
    fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_label_trampoline<P: IsA<Outlines>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsOutlines,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Outlines::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::label".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_label_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "link")]
    fn connect_link_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_link_trampoline<P: IsA<Outlines>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsOutlines,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Outlines::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::link".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_link_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "markup")]
    fn connect_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_markup_trampoline<P: IsA<Outlines>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsOutlines,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Outlines::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::markup".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_markup_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Outlines>> OutlinesExt for O {}
