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

use crate::{Document, ffi};
use glib::translate::*;

glib::wrapper! {
    #[doc(alias = "PopplerPSFile")]
    pub struct PSFile(Object<ffi::PopplerPSFile>);

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

impl PSFile {
    #[doc(alias = "poppler_ps_file_new")]
    pub fn new(document: &Document, filename: &str, first_page: i32, n_pages: i32) -> PSFile {
        unsafe {
            from_glib_full(ffi::poppler_ps_file_new(
                document.to_glib_none().0,
                filename.to_glib_none().0,
                first_page,
                n_pages,
            ))
        }
    }

    #[cfg(target_os = "linux")]
    #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
    #[cfg(feature = "v21_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v21_12")))]
    #[doc(alias = "poppler_ps_file_new_fd")]
    pub fn new_fd(document: &Document, fd: i32, first_page: i32, n_pages: i32) -> PSFile {
        unsafe {
            from_glib_full(ffi::poppler_ps_file_new_fd(
                document.to_glib_none().0,
                fd,
                first_page,
                n_pages,
            ))
        }
    }

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

    #[doc(alias = "poppler_ps_file_set_paper_size")]
    pub fn set_paper_size(&self, width: f64, height: f64) {
        unsafe {
            ffi::poppler_ps_file_set_paper_size(self.to_glib_none().0, width, height);
        }
    }
}
