Skip to main content

sourceview5/auto/
style.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    #[doc(alias = "GtkSourceStyle")]
11    pub struct Style(Object<ffi::GtkSourceStyle, ffi::GtkSourceStyleClass>);
12
13    match fn {
14        type_ => || ffi::gtk_source_style_get_type(),
15    }
16}
17
18impl Style {
19    // rustdoc-stripper-ignore-next
20    /// Creates a new builder-pattern struct instance to construct [`Style`] objects.
21    ///
22    /// This method returns an instance of [`StyleBuilder`](crate::builders::StyleBuilder) which can be used to create [`Style`] objects.
23    pub fn builder() -> StyleBuilder {
24        StyleBuilder::new()
25    }
26
27    #[doc(alias = "gtk_source_style_apply")]
28    pub fn apply(&self, tag: &impl IsA<gtk::TextTag>) {
29        unsafe {
30            ffi::gtk_source_style_apply(self.to_glib_none().0, tag.as_ref().to_glib_none().0);
31        }
32    }
33
34    #[doc(alias = "gtk_source_style_copy")]
35    #[must_use]
36    pub fn copy(&self) -> Style {
37        unsafe { from_glib_full(ffi::gtk_source_style_copy(self.to_glib_none().0)) }
38    }
39
40    pub fn background(&self) -> Option<glib::GString> {
41        ObjectExt::property(self, "background")
42    }
43
44    #[doc(alias = "background-set")]
45    pub fn is_background_set(&self) -> bool {
46        ObjectExt::property(self, "background-set")
47    }
48
49    pub fn is_bold(&self) -> bool {
50        ObjectExt::property(self, "bold")
51    }
52
53    #[doc(alias = "bold-set")]
54    pub fn is_bold_set(&self) -> bool {
55        ObjectExt::property(self, "bold-set")
56    }
57
58    pub fn foreground(&self) -> Option<glib::GString> {
59        ObjectExt::property(self, "foreground")
60    }
61
62    #[doc(alias = "foreground-set")]
63    pub fn is_foreground_set(&self) -> bool {
64        ObjectExt::property(self, "foreground-set")
65    }
66
67    pub fn is_italic(&self) -> bool {
68        ObjectExt::property(self, "italic")
69    }
70
71    #[doc(alias = "italic-set")]
72    pub fn is_italic_set(&self) -> bool {
73        ObjectExt::property(self, "italic-set")
74    }
75
76    #[doc(alias = "line-background")]
77    pub fn line_background(&self) -> Option<glib::GString> {
78        ObjectExt::property(self, "line-background")
79    }
80
81    #[doc(alias = "line-background-set")]
82    pub fn is_line_background_set(&self) -> bool {
83        ObjectExt::property(self, "line-background-set")
84    }
85
86    #[doc(alias = "pango-underline")]
87    pub fn pango_underline(&self) -> pango::Underline {
88        ObjectExt::property(self, "pango-underline")
89    }
90
91    pub fn scale(&self) -> Option<glib::GString> {
92        ObjectExt::property(self, "scale")
93    }
94
95    #[doc(alias = "scale-set")]
96    pub fn is_scale_set(&self) -> bool {
97        ObjectExt::property(self, "scale-set")
98    }
99
100    pub fn is_strikethrough(&self) -> bool {
101        ObjectExt::property(self, "strikethrough")
102    }
103
104    #[doc(alias = "strikethrough-set")]
105    pub fn is_strikethrough_set(&self) -> bool {
106        ObjectExt::property(self, "strikethrough-set")
107    }
108
109    #[doc(alias = "underline-color")]
110    pub fn underline_color(&self) -> Option<glib::GString> {
111        ObjectExt::property(self, "underline-color")
112    }
113
114    #[doc(alias = "underline-color-set")]
115    pub fn is_underline_color_set(&self) -> bool {
116        ObjectExt::property(self, "underline-color-set")
117    }
118
119    #[doc(alias = "underline-set")]
120    pub fn is_underline_set(&self) -> bool {
121        ObjectExt::property(self, "underline-set")
122    }
123
124    pub fn weight(&self) -> pango::Weight {
125        ObjectExt::property(self, "weight")
126    }
127
128    #[doc(alias = "weight-set")]
129    pub fn is_weight_set(&self) -> bool {
130        ObjectExt::property(self, "weight-set")
131    }
132}
133
134// rustdoc-stripper-ignore-next
135/// A [builder-pattern] type to construct [`Style`] objects.
136///
137/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
138#[must_use = "The builder must be built to be used"]
139pub struct StyleBuilder {
140    builder: glib::object::ObjectBuilder<'static, Style>,
141}
142
143impl StyleBuilder {
144    fn new() -> Self {
145        Self {
146            builder: glib::object::Object::builder(),
147        }
148    }
149
150    pub fn background(self, background: impl Into<glib::GString>) -> Self {
151        Self {
152            builder: self.builder.property("background", background.into()),
153        }
154    }
155
156    pub fn background_set(self, background_set: bool) -> Self {
157        Self {
158            builder: self.builder.property("background-set", background_set),
159        }
160    }
161
162    pub fn bold(self, bold: bool) -> Self {
163        Self {
164            builder: self.builder.property("bold", bold),
165        }
166    }
167
168    pub fn bold_set(self, bold_set: bool) -> Self {
169        Self {
170            builder: self.builder.property("bold-set", bold_set),
171        }
172    }
173
174    pub fn foreground(self, foreground: impl Into<glib::GString>) -> Self {
175        Self {
176            builder: self.builder.property("foreground", foreground.into()),
177        }
178    }
179
180    pub fn foreground_set(self, foreground_set: bool) -> Self {
181        Self {
182            builder: self.builder.property("foreground-set", foreground_set),
183        }
184    }
185
186    pub fn italic(self, italic: bool) -> Self {
187        Self {
188            builder: self.builder.property("italic", italic),
189        }
190    }
191
192    pub fn italic_set(self, italic_set: bool) -> Self {
193        Self {
194            builder: self.builder.property("italic-set", italic_set),
195        }
196    }
197
198    pub fn line_background(self, line_background: impl Into<glib::GString>) -> Self {
199        Self {
200            builder: self
201                .builder
202                .property("line-background", line_background.into()),
203        }
204    }
205
206    pub fn line_background_set(self, line_background_set: bool) -> Self {
207        Self {
208            builder: self
209                .builder
210                .property("line-background-set", line_background_set),
211        }
212    }
213
214    pub fn pango_underline(self, pango_underline: pango::Underline) -> Self {
215        Self {
216            builder: self.builder.property("pango-underline", pango_underline),
217        }
218    }
219
220    pub fn scale(self, scale: impl Into<glib::GString>) -> Self {
221        Self {
222            builder: self.builder.property("scale", scale.into()),
223        }
224    }
225
226    pub fn scale_set(self, scale_set: bool) -> Self {
227        Self {
228            builder: self.builder.property("scale-set", scale_set),
229        }
230    }
231
232    pub fn strikethrough(self, strikethrough: bool) -> Self {
233        Self {
234            builder: self.builder.property("strikethrough", strikethrough),
235        }
236    }
237
238    pub fn strikethrough_set(self, strikethrough_set: bool) -> Self {
239        Self {
240            builder: self
241                .builder
242                .property("strikethrough-set", strikethrough_set),
243        }
244    }
245
246    pub fn underline_color(self, underline_color: impl Into<glib::GString>) -> Self {
247        Self {
248            builder: self
249                .builder
250                .property("underline-color", underline_color.into()),
251        }
252    }
253
254    pub fn underline_color_set(self, underline_color_set: bool) -> Self {
255        Self {
256            builder: self
257                .builder
258                .property("underline-color-set", underline_color_set),
259        }
260    }
261
262    pub fn underline_set(self, underline_set: bool) -> Self {
263        Self {
264            builder: self.builder.property("underline-set", underline_set),
265        }
266    }
267
268    pub fn weight(self, weight: pango::Weight) -> Self {
269        Self {
270            builder: self.builder.property("weight", weight),
271        }
272    }
273
274    pub fn weight_set(self, weight_set: bool) -> Self {
275        Self {
276            builder: self.builder.property("weight-set", weight_set),
277        }
278    }
279
280    // rustdoc-stripper-ignore-next
281    /// Build the [`Style`].
282    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
283    pub fn build(self) -> Style {
284        assert_initialized_main_thread!();
285        self.builder.build()
286    }
287}