gtk4/
css_location.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::fmt;
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    #[doc(alias = "GtkCssLocation")]
10    pub struct CssLocation(BoxedInline<ffi::GtkCssLocation>);
11}
12
13impl CssLocation {
14    #[inline]
15    pub fn new(
16        bytes: usize,
17        chars: usize,
18        lines: usize,
19        line_bytes: usize,
20        line_chars: usize,
21    ) -> Self {
22        assert_initialized_main_thread!();
23        unsafe {
24            Self::unsafe_from(ffi::GtkCssLocation {
25                bytes,
26                chars,
27                lines,
28                line_bytes,
29                line_chars,
30            })
31        }
32    }
33
34    #[inline]
35    pub fn bytes(&self) -> usize {
36        self.inner.bytes
37    }
38
39    #[inline]
40    pub fn chars(&self) -> usize {
41        self.inner.chars
42    }
43
44    #[inline]
45    pub fn lines(&self) -> usize {
46        self.inner.lines
47    }
48
49    #[inline]
50    pub fn line_bytes(&self) -> usize {
51        self.inner.line_bytes
52    }
53
54    #[inline]
55    pub fn line_chars(&self) -> usize {
56        self.inner.line_chars
57    }
58}
59
60impl fmt::Debug for CssLocation {
61    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
62        f.debug_struct("CssLocation")
63            .field("bytes", &self.bytes())
64            .field("chars", &self.chars())
65            .field("lines", &self.lines())
66            .field("line_bytes", &self.line_bytes())
67            .field("line_chars", &self.line_chars())
68            .finish()
69    }
70}