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

use crate::{ffi, AnnotationEditingState, PageLayout, SizingMode};
use glib::{
    object::ObjectType as _,
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "PpsDocumentModel")]
    pub struct DocumentModel(Object<ffi::PpsDocumentModel, ffi::PpsDocumentModelClass>);

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

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

    #[doc(alias = "pps_document_model_new_with_document")]
    #[doc(alias = "new_with_document")]
    pub fn with_document(document: &impl IsA<papers_document::Document>) -> DocumentModel {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::pps_document_model_new_with_document(
                document.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_document_model_get_annotation_editing_state")]
    #[doc(alias = "get_annotation_editing_state")]
    #[doc(alias = "annotation-editing-state")]
    pub fn annotation_editing_state(&self) -> AnnotationEditingState {
        unsafe {
            from_glib(ffi::pps_document_model_get_annotation_editing_state(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_document_model_get_continuous")]
    #[doc(alias = "get_continuous")]
    #[doc(alias = "continuous")]
    pub fn is_continuous(&self) -> bool {
        unsafe {
            from_glib(ffi::pps_document_model_get_continuous(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_document_model_get_document")]
    #[doc(alias = "get_document")]
    pub fn document(&self) -> Option<papers_document::Document> {
        unsafe { from_glib_none(ffi::pps_document_model_get_document(self.to_glib_none().0)) }
    }

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

    #[doc(alias = "pps_document_model_get_inverted_colors")]
    #[doc(alias = "get_inverted_colors")]
    #[doc(alias = "inverted-colors")]
    pub fn is_inverted_colors(&self) -> bool {
        unsafe {
            from_glib(ffi::pps_document_model_get_inverted_colors(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_document_model_get_max_scale")]
    #[doc(alias = "get_max_scale")]
    #[doc(alias = "max-scale")]
    pub fn max_scale(&self) -> f64 {
        unsafe { ffi::pps_document_model_get_max_scale(self.to_glib_none().0) }
    }

    #[doc(alias = "pps_document_model_get_min_scale")]
    #[doc(alias = "get_min_scale")]
    #[doc(alias = "min-scale")]
    pub fn min_scale(&self) -> f64 {
        unsafe { ffi::pps_document_model_get_min_scale(self.to_glib_none().0) }
    }

    #[doc(alias = "pps_document_model_get_page")]
    #[doc(alias = "get_page")]
    pub fn page(&self) -> i32 {
        unsafe { ffi::pps_document_model_get_page(self.to_glib_none().0) }
    }

    #[doc(alias = "pps_document_model_get_page_layout")]
    #[doc(alias = "get_page_layout")]
    #[doc(alias = "page-layout")]
    pub fn page_layout(&self) -> PageLayout {
        unsafe {
            from_glib(ffi::pps_document_model_get_page_layout(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_document_model_get_rotation")]
    #[doc(alias = "get_rotation")]
    pub fn rotation(&self) -> i32 {
        unsafe { ffi::pps_document_model_get_rotation(self.to_glib_none().0) }
    }

    #[doc(alias = "pps_document_model_get_rtl")]
    #[doc(alias = "get_rtl")]
    #[doc(alias = "rtl")]
    pub fn is_rtl(&self) -> bool {
        unsafe { from_glib(ffi::pps_document_model_get_rtl(self.to_glib_none().0)) }
    }

    #[doc(alias = "pps_document_model_get_scale")]
    #[doc(alias = "get_scale")]
    pub fn scale(&self) -> f64 {
        unsafe { ffi::pps_document_model_get_scale(self.to_glib_none().0) }
    }

    #[doc(alias = "pps_document_model_get_sizing_mode")]
    #[doc(alias = "get_sizing_mode")]
    #[doc(alias = "sizing-mode")]
    pub fn sizing_mode(&self) -> SizingMode {
        unsafe {
            from_glib(ffi::pps_document_model_get_sizing_mode(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_document_model_set_annotation_editing_state")]
    #[doc(alias = "annotation-editing-state")]
    pub fn set_annotation_editing_state(&self, state: AnnotationEditingState) {
        unsafe {
            ffi::pps_document_model_set_annotation_editing_state(
                self.to_glib_none().0,
                state.into_glib(),
            );
        }
    }

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

    #[doc(alias = "pps_document_model_set_document")]
    #[doc(alias = "document")]
    pub fn set_document(&self, document: Option<&impl IsA<papers_document::Document>>) {
        unsafe {
            ffi::pps_document_model_set_document(
                self.to_glib_none().0,
                document.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

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

    #[doc(alias = "pps_document_model_set_inverted_colors")]
    #[doc(alias = "inverted-colors")]
    pub fn set_inverted_colors(&self, inverted_colors: bool) {
        unsafe {
            ffi::pps_document_model_set_inverted_colors(
                self.to_glib_none().0,
                inverted_colors.into_glib(),
            );
        }
    }

    #[doc(alias = "pps_document_model_set_max_scale")]
    #[doc(alias = "max-scale")]
    pub fn set_max_scale(&self, max_scale: f64) {
        unsafe {
            ffi::pps_document_model_set_max_scale(self.to_glib_none().0, max_scale);
        }
    }

    #[doc(alias = "pps_document_model_set_min_scale")]
    #[doc(alias = "min-scale")]
    pub fn set_min_scale(&self, min_scale: f64) {
        unsafe {
            ffi::pps_document_model_set_min_scale(self.to_glib_none().0, min_scale);
        }
    }

    #[doc(alias = "pps_document_model_set_page")]
    #[doc(alias = "page")]
    pub fn set_page(&self, page: i32) {
        unsafe {
            ffi::pps_document_model_set_page(self.to_glib_none().0, page);
        }
    }

    #[doc(alias = "pps_document_model_set_page_by_label")]
    pub fn set_page_by_label(&self, page_label: &str) {
        unsafe {
            ffi::pps_document_model_set_page_by_label(
                self.to_glib_none().0,
                page_label.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "pps_document_model_set_page_layout")]
    #[doc(alias = "page-layout")]
    pub fn set_page_layout(&self, layout: PageLayout) {
        unsafe {
            ffi::pps_document_model_set_page_layout(self.to_glib_none().0, layout.into_glib());
        }
    }

    #[doc(alias = "pps_document_model_set_rotation")]
    #[doc(alias = "rotation")]
    pub fn set_rotation(&self, rotation: i32) {
        unsafe {
            ffi::pps_document_model_set_rotation(self.to_glib_none().0, rotation);
        }
    }

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

    #[doc(alias = "pps_document_model_set_scale")]
    #[doc(alias = "scale")]
    pub fn set_scale(&self, scale: f64) {
        unsafe {
            ffi::pps_document_model_set_scale(self.to_glib_none().0, scale);
        }
    }

    #[doc(alias = "pps_document_model_set_sizing_mode")]
    #[doc(alias = "sizing-mode")]
    pub fn set_sizing_mode(&self, mode: SizingMode) {
        unsafe {
            ffi::pps_document_model_set_sizing_mode(self.to_glib_none().0, mode.into_glib());
        }
    }

    #[cfg(not(feature = "v48"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v48"))))]
    #[doc(alias = "annotation-editing-state")]
    pub fn annotation_editing_state(&self) -> AnnotationEditingState {
        ObjectExt::property(self, "annotation-editing-state")
    }

    #[cfg(not(feature = "v48"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v48"))))]
    #[doc(alias = "annotation-editing-state")]
    pub fn set_annotation_editing_state(&self, annotation_editing_state: AnnotationEditingState) {
        ObjectExt::set_property(self, "annotation-editing-state", annotation_editing_state)
    }

    #[doc(alias = "dual-odd-left")]
    pub fn is_dual_odd_left(&self) -> bool {
        ObjectExt::property(self, "dual-odd-left")
    }

    #[doc(alias = "dual-odd-left")]
    pub fn set_dual_odd_left(&self, dual_odd_left: bool) {
        ObjectExt::set_property(self, "dual-odd-left", dual_odd_left)
    }

    #[doc(alias = "page-changed")]
    pub fn connect_page_changed<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn page_changed_trampoline<F: Fn(&DocumentModel, i32, i32) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            object: std::ffi::c_int,
            p0: std::ffi::c_int,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), object, p0)
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"page-changed".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    page_changed_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "annotation-editing-state")]
    pub fn connect_annotation_editing_state_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_annotation_editing_state_trampoline<
            F: Fn(&DocumentModel) + 'static,
        >(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::annotation-editing-state".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_annotation_editing_state_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "continuous")]
    pub fn connect_continuous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_continuous_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::continuous".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_continuous_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "document")]
    pub fn connect_document_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_document_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::document".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_document_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "dual-odd-left")]
    pub fn connect_dual_odd_left_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_dual_odd_left_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::dual-odd-left".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_dual_odd_left_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "inverted-colors")]
    pub fn connect_inverted_colors_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_inverted_colors_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::inverted-colors".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_inverted_colors_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "max-scale")]
    pub fn connect_max_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_scale_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::max-scale".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_max_scale_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "min-scale")]
    pub fn connect_min_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_min_scale_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::min-scale".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_min_scale_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "page")]
    pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_page_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::page".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_page_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "page-layout")]
    pub fn connect_page_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_page_layout_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::page-layout".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_page_layout_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "rotation")]
    pub fn connect_rotation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_rotation_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::rotation".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_rotation_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "rtl")]
    pub fn connect_rtl_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_rtl_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::rtl".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_rtl_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "scale")]
    pub fn connect_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_scale_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::scale".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_scale_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "sizing-mode")]
    pub fn connect_sizing_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_sizing_mode_trampoline<F: Fn(&DocumentModel) + 'static>(
            this: *mut ffi::PpsDocumentModel,
            _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 _,
                c"notify::sizing-mode".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_sizing_mode_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

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