1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// A range of pages to print.
    ///
    /// See also [`PrintSettings::set_page_ranges()`][crate::PrintSettings::set_page_ranges()].
    #[doc(alias = "GtkPageRange")]
    pub struct PageRange(BoxedInline<ffi::GtkPageRange>);
}

impl PageRange {
    pub fn new(start: i32, end: i32) -> Self {
        skip_assert_initialized!();
        unsafe { Self::unsafe_from(ffi::GtkPageRange { start, end }) }
    }

    pub fn start(&self) -> i32 {
        self.inner.start
    }

    pub fn end(&self) -> i32 {
        self.inner.end
    }
}

impl fmt::Debug for PageRange {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("PageRange")
            .field("start", &self.start())
            .field("end", &self.end())
            .finish()
    }
}