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! {
    /// 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) -> PageRange {
        skip_assert_initialized!();
        unsafe { PageRange::unsafe_from(ffi::GtkPageRange { start, end }) }
    }

    #[doc(alias = "get_start")]
    pub fn start(&self) -> i32 {
        self.inner.start
    }

    #[doc(alias = "get_end")]
    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()
    }
}