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

use crate::{ffi, PageLayout, SizingMode};
use glib::{
    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,
            ))
        }
    }

    #[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,
            ))
        }
    }

    #[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: &impl IsA<papers_document::Document>) {
        unsafe {
            ffi::pps_document_model_set_document(
                self.to_glib_none().0,
                document.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());
        }
    }

    #[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: libc::c_int,
            p0: libc::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 _,
                b"page-changed\0".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 = "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 _,
                b"notify::continuous\0".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 _,
                b"notify::document\0".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 _,
                b"notify::dual-odd-left\0".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 _,
                b"notify::inverted-colors\0".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 _,
                b"notify::max-scale\0".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 _,
                b"notify::min-scale\0".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 _,
                b"notify::page\0".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 _,
                b"notify::page-layout\0".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 _,
                b"notify::rotation\0".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 _,
                b"notify::rtl\0".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 _,
                b"notify::scale\0".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 _,
                b"notify::sizing-mode\0".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()
    }
}
