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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::CssSectionType;
use glib::translate::*;

glib::wrapper! {
    /// Defines a part of a CSS document. Because sections are nested into
    /// one another, you can use [`parent()`][Self::parent()] to get the
    /// containing region.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct CssSection(Shared<ffi::GtkCssSection>);

    match fn {
        ref => |ptr| ffi::gtk_css_section_ref(ptr),
        unref => |ptr| ffi::gtk_css_section_unref(ptr),
        type_ => || ffi::gtk_css_section_get_type(),
    }
}

impl CssSection {
    /// Returns the line in the CSS document where this section end.
    /// The line number is 0-indexed, so the first line of the document
    /// will return 0.
    /// This value may change in future invocations of this function if
    /// `self` is not yet parsed completely. This will for example
    /// happen in the GtkCssProvider::parsing-error signal.
    /// The end position and line may be identical to the start
    /// position and line for sections which failed to parse anything
    /// successfully.
    ///
    /// # Returns
    ///
    /// the line number
    #[doc(alias = "gtk_css_section_get_end_line")]
    #[doc(alias = "get_end_line")]
    pub fn end_line(&self) -> u32 {
        unsafe { ffi::gtk_css_section_get_end_line(self.to_glib_none().0) }
    }

    /// Returns the offset in bytes from the start of the current line
    /// returned via [`end_line()`][Self::end_line()].
    /// This value may change in future invocations of this function if
    /// `self` is not yet parsed completely. This will for example
    /// happen in the GtkCssProvider::parsing-error signal.
    /// The end position and line may be identical to the start
    /// position and line for sections which failed to parse anything
    /// successfully.
    ///
    /// # Returns
    ///
    /// the offset in bytes from the start of the line.
    #[doc(alias = "gtk_css_section_get_end_position")]
    #[doc(alias = "get_end_position")]
    pub fn end_position(&self) -> u32 {
        unsafe { ffi::gtk_css_section_get_end_position(self.to_glib_none().0) }
    }

    /// Gets the file that `self` was parsed from. If no such file exists,
    /// for example because the CSS was loaded via
    /// [`CssProviderExt::load_from_data()`][crate::prelude::CssProviderExt::load_from_data()], then [`None`] is returned.
    ///
    /// # Returns
    ///
    /// the [`gio::File`][crate::gio::File] that `self` was parsed from
    ///  or [`None`] if `self` was parsed from other data
    #[doc(alias = "gtk_css_section_get_file")]
    #[doc(alias = "get_file")]
    pub fn file(&self) -> Option<gio::File> {
        unsafe { from_glib_none(ffi::gtk_css_section_get_file(self.to_glib_none().0)) }
    }

    /// Gets the parent section for the given `self`. The parent section is
    /// the section that contains this `self`. A special case are sections of
    /// type [`CssSectionType::Document`][crate::CssSectionType::Document]. Their parent will either be [`None`]
    /// if they are the original CSS document that was loaded by
    /// [`CssProviderExt::load_from_file()`][crate::prelude::CssProviderExt::load_from_file()] or a section of type
    /// [`CssSectionType::Import`][crate::CssSectionType::Import] if it was loaded with an import rule from
    /// a different file.
    ///
    /// # Returns
    ///
    /// the parent section or [`None`] if none
    #[doc(alias = "gtk_css_section_get_parent")]
    #[doc(alias = "get_parent")]
    #[must_use]
    pub fn parent(&self) -> Option<CssSection> {
        unsafe { from_glib_none(ffi::gtk_css_section_get_parent(self.to_glib_none().0)) }
    }

    /// Gets the type of information that `self` describes.
    ///
    /// # Returns
    ///
    /// the type of `self`
    #[doc(alias = "gtk_css_section_get_section_type")]
    #[doc(alias = "get_section_type")]
    pub fn section_type(&self) -> CssSectionType {
        unsafe { from_glib(ffi::gtk_css_section_get_section_type(self.to_glib_none().0)) }
    }

    /// Returns the line in the CSS document where this section starts.
    /// The line number is 0-indexed, so the first line of the document
    /// will return 0.
    ///
    /// # Returns
    ///
    /// the line number
    #[doc(alias = "gtk_css_section_get_start_line")]
    #[doc(alias = "get_start_line")]
    pub fn start_line(&self) -> u32 {
        unsafe { ffi::gtk_css_section_get_start_line(self.to_glib_none().0) }
    }

    /// Returns the offset in bytes from the start of the current line
    /// returned via [`start_line()`][Self::start_line()].
    ///
    /// # Returns
    ///
    /// the offset in bytes from the start of the line.
    #[doc(alias = "gtk_css_section_get_start_position")]
    #[doc(alias = "get_start_position")]
    pub fn start_position(&self) -> u32 {
        unsafe { ffi::gtk_css_section_get_start_position(self.to_glib_none().0) }
    }
}