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

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

glib::wrapper! {
    #[doc(alias = "PpsSidebarPage")]
    pub struct SidebarPage(Object<ffi::PpsSidebarPage, ffi::PpsSidebarPageClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;

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

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

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::SidebarPage>> Sealed for T {}
}

pub trait SidebarPageExt: IsA<SidebarPage> + sealed::Sealed + 'static {
    #[doc(alias = "pps_sidebar_page_get_document_model")]
    #[doc(alias = "get_document_model")]
    fn document_model(&self) -> Option<papers_view::DocumentModel> {
        unsafe {
            from_glib_none(ffi::pps_sidebar_page_get_document_model(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_sidebar_page_navigate_to_view")]
    fn navigate_to_view(&self) {
        unsafe {
            ffi::pps_sidebar_page_navigate_to_view(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "pps_sidebar_page_support_document")]
    fn support_document(&self, document: &impl IsA<papers_document::Document>) -> bool {
        unsafe {
            from_glib(ffi::pps_sidebar_page_support_document(
                self.as_ref().to_glib_none().0,
                document.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "navigated-to-view")]
    fn connect_navigated_to_view<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn navigated_to_view_trampoline<
            P: IsA<SidebarPage>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::PpsSidebarPage,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(SidebarPage::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"navigated-to-view\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    navigated_to_view_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<SidebarPage>> SidebarPageExt for O {}
