sourceview/auto/
style.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use glib::object::Cast;
6use glib::object::ObjectType as ObjectType_;
7use glib::translate::*;
8use glib::GString;
9use glib::StaticType;
10use glib::ToValue;
11use glib::Value;
12use gobject_sys;
13use gtk_source_sys;
14use pango;
15use std::fmt;
16
17glib_wrapper! {
18    pub struct Style(Object<gtk_source_sys::GtkSourceStyle, gtk_source_sys::GtkSourceStyleClass, StyleClass>);
19
20    match fn {
21        get_type => || gtk_source_sys::gtk_source_style_get_type(),
22    }
23}
24
25impl Style {
26    pub fn get_property_background(&self) -> Option<GString> {
27        unsafe {
28            let mut value = Value::from_type(<GString as StaticType>::static_type());
29            gobject_sys::g_object_get_property(
30                self.as_ptr() as *mut gobject_sys::GObject,
31                b"background\0".as_ptr() as *const _,
32                value.to_glib_none_mut().0,
33            );
34            value
35                .get()
36                .expect("Return Value for property `background` getter")
37        }
38    }
39
40    pub fn get_property_background_set(&self) -> bool {
41        unsafe {
42            let mut value = Value::from_type(<bool as StaticType>::static_type());
43            gobject_sys::g_object_get_property(
44                self.as_ptr() as *mut gobject_sys::GObject,
45                b"background-set\0".as_ptr() as *const _,
46                value.to_glib_none_mut().0,
47            );
48            value
49                .get()
50                .expect("Return Value for property `background-set` getter")
51                .unwrap()
52        }
53    }
54
55    pub fn get_property_bold(&self) -> bool {
56        unsafe {
57            let mut value = Value::from_type(<bool as StaticType>::static_type());
58            gobject_sys::g_object_get_property(
59                self.as_ptr() as *mut gobject_sys::GObject,
60                b"bold\0".as_ptr() as *const _,
61                value.to_glib_none_mut().0,
62            );
63            value
64                .get()
65                .expect("Return Value for property `bold` getter")
66                .unwrap()
67        }
68    }
69
70    pub fn get_property_bold_set(&self) -> bool {
71        unsafe {
72            let mut value = Value::from_type(<bool as StaticType>::static_type());
73            gobject_sys::g_object_get_property(
74                self.as_ptr() as *mut gobject_sys::GObject,
75                b"bold-set\0".as_ptr() as *const _,
76                value.to_glib_none_mut().0,
77            );
78            value
79                .get()
80                .expect("Return Value for property `bold-set` getter")
81                .unwrap()
82        }
83    }
84
85    pub fn get_property_foreground(&self) -> Option<GString> {
86        unsafe {
87            let mut value = Value::from_type(<GString as StaticType>::static_type());
88            gobject_sys::g_object_get_property(
89                self.as_ptr() as *mut gobject_sys::GObject,
90                b"foreground\0".as_ptr() as *const _,
91                value.to_glib_none_mut().0,
92            );
93            value
94                .get()
95                .expect("Return Value for property `foreground` getter")
96        }
97    }
98
99    pub fn get_property_foreground_set(&self) -> bool {
100        unsafe {
101            let mut value = Value::from_type(<bool as StaticType>::static_type());
102            gobject_sys::g_object_get_property(
103                self.as_ptr() as *mut gobject_sys::GObject,
104                b"foreground-set\0".as_ptr() as *const _,
105                value.to_glib_none_mut().0,
106            );
107            value
108                .get()
109                .expect("Return Value for property `foreground-set` getter")
110                .unwrap()
111        }
112    }
113
114    pub fn get_property_italic(&self) -> bool {
115        unsafe {
116            let mut value = Value::from_type(<bool as StaticType>::static_type());
117            gobject_sys::g_object_get_property(
118                self.as_ptr() as *mut gobject_sys::GObject,
119                b"italic\0".as_ptr() as *const _,
120                value.to_glib_none_mut().0,
121            );
122            value
123                .get()
124                .expect("Return Value for property `italic` getter")
125                .unwrap()
126        }
127    }
128
129    pub fn get_property_italic_set(&self) -> bool {
130        unsafe {
131            let mut value = Value::from_type(<bool as StaticType>::static_type());
132            gobject_sys::g_object_get_property(
133                self.as_ptr() as *mut gobject_sys::GObject,
134                b"italic-set\0".as_ptr() as *const _,
135                value.to_glib_none_mut().0,
136            );
137            value
138                .get()
139                .expect("Return Value for property `italic-set` getter")
140                .unwrap()
141        }
142    }
143
144    pub fn get_property_line_background(&self) -> Option<GString> {
145        unsafe {
146            let mut value = Value::from_type(<GString as StaticType>::static_type());
147            gobject_sys::g_object_get_property(
148                self.as_ptr() as *mut gobject_sys::GObject,
149                b"line-background\0".as_ptr() as *const _,
150                value.to_glib_none_mut().0,
151            );
152            value
153                .get()
154                .expect("Return Value for property `line-background` getter")
155        }
156    }
157
158    pub fn get_property_line_background_set(&self) -> bool {
159        unsafe {
160            let mut value = Value::from_type(<bool as StaticType>::static_type());
161            gobject_sys::g_object_get_property(
162                self.as_ptr() as *mut gobject_sys::GObject,
163                b"line-background-set\0".as_ptr() as *const _,
164                value.to_glib_none_mut().0,
165            );
166            value
167                .get()
168                .expect("Return Value for property `line-background-set` getter")
169                .unwrap()
170        }
171    }
172
173    pub fn get_property_pango_underline(&self) -> pango::Underline {
174        unsafe {
175            let mut value = Value::from_type(<pango::Underline as StaticType>::static_type());
176            gobject_sys::g_object_get_property(
177                self.as_ptr() as *mut gobject_sys::GObject,
178                b"pango-underline\0".as_ptr() as *const _,
179                value.to_glib_none_mut().0,
180            );
181            value
182                .get()
183                .expect("Return Value for property `pango-underline` getter")
184                .unwrap()
185        }
186    }
187
188    pub fn get_property_scale(&self) -> Option<GString> {
189        unsafe {
190            let mut value = Value::from_type(<GString as StaticType>::static_type());
191            gobject_sys::g_object_get_property(
192                self.as_ptr() as *mut gobject_sys::GObject,
193                b"scale\0".as_ptr() as *const _,
194                value.to_glib_none_mut().0,
195            );
196            value
197                .get()
198                .expect("Return Value for property `scale` getter")
199        }
200    }
201
202    pub fn get_property_scale_set(&self) -> bool {
203        unsafe {
204            let mut value = Value::from_type(<bool as StaticType>::static_type());
205            gobject_sys::g_object_get_property(
206                self.as_ptr() as *mut gobject_sys::GObject,
207                b"scale-set\0".as_ptr() as *const _,
208                value.to_glib_none_mut().0,
209            );
210            value
211                .get()
212                .expect("Return Value for property `scale-set` getter")
213                .unwrap()
214        }
215    }
216
217    pub fn get_property_strikethrough(&self) -> bool {
218        unsafe {
219            let mut value = Value::from_type(<bool as StaticType>::static_type());
220            gobject_sys::g_object_get_property(
221                self.as_ptr() as *mut gobject_sys::GObject,
222                b"strikethrough\0".as_ptr() as *const _,
223                value.to_glib_none_mut().0,
224            );
225            value
226                .get()
227                .expect("Return Value for property `strikethrough` getter")
228                .unwrap()
229        }
230    }
231
232    pub fn get_property_strikethrough_set(&self) -> bool {
233        unsafe {
234            let mut value = Value::from_type(<bool as StaticType>::static_type());
235            gobject_sys::g_object_get_property(
236                self.as_ptr() as *mut gobject_sys::GObject,
237                b"strikethrough-set\0".as_ptr() as *const _,
238                value.to_glib_none_mut().0,
239            );
240            value
241                .get()
242                .expect("Return Value for property `strikethrough-set` getter")
243                .unwrap()
244        }
245    }
246
247    #[cfg_attr(feature = "v3_18", deprecated)]
248    pub fn get_property_underline(&self) -> bool {
249        unsafe {
250            let mut value = Value::from_type(<bool as StaticType>::static_type());
251            gobject_sys::g_object_get_property(
252                self.as_ptr() as *mut gobject_sys::GObject,
253                b"underline\0".as_ptr() as *const _,
254                value.to_glib_none_mut().0,
255            );
256            value
257                .get()
258                .expect("Return Value for property `underline` getter")
259                .unwrap()
260        }
261    }
262
263    pub fn get_property_underline_color(&self) -> Option<GString> {
264        unsafe {
265            let mut value = Value::from_type(<GString as StaticType>::static_type());
266            gobject_sys::g_object_get_property(
267                self.as_ptr() as *mut gobject_sys::GObject,
268                b"underline-color\0".as_ptr() as *const _,
269                value.to_glib_none_mut().0,
270            );
271            value
272                .get()
273                .expect("Return Value for property `underline-color` getter")
274        }
275    }
276
277    pub fn get_property_underline_color_set(&self) -> bool {
278        unsafe {
279            let mut value = Value::from_type(<bool as StaticType>::static_type());
280            gobject_sys::g_object_get_property(
281                self.as_ptr() as *mut gobject_sys::GObject,
282                b"underline-color-set\0".as_ptr() as *const _,
283                value.to_glib_none_mut().0,
284            );
285            value
286                .get()
287                .expect("Return Value for property `underline-color-set` getter")
288                .unwrap()
289        }
290    }
291
292    pub fn get_property_underline_set(&self) -> bool {
293        unsafe {
294            let mut value = Value::from_type(<bool as StaticType>::static_type());
295            gobject_sys::g_object_get_property(
296                self.as_ptr() as *mut gobject_sys::GObject,
297                b"underline-set\0".as_ptr() as *const _,
298                value.to_glib_none_mut().0,
299            );
300            value
301                .get()
302                .expect("Return Value for property `underline-set` getter")
303                .unwrap()
304        }
305    }
306}
307
308#[derive(Clone, Default)]
309pub struct StyleBuilder {
310    background: Option<String>,
311    background_set: Option<bool>,
312    bold: Option<bool>,
313    bold_set: Option<bool>,
314    foreground: Option<String>,
315    foreground_set: Option<bool>,
316    italic: Option<bool>,
317    italic_set: Option<bool>,
318    line_background: Option<String>,
319    line_background_set: Option<bool>,
320    pango_underline: Option<pango::Underline>,
321    scale: Option<String>,
322    scale_set: Option<bool>,
323    strikethrough: Option<bool>,
324    strikethrough_set: Option<bool>,
325    underline: Option<bool>,
326    underline_color: Option<String>,
327    underline_color_set: Option<bool>,
328    underline_set: Option<bool>,
329}
330
331impl StyleBuilder {
332    pub fn new() -> Self {
333        Self::default()
334    }
335
336    pub fn build(self) -> Style {
337        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
338        if let Some(ref background) = self.background {
339            properties.push(("background", background));
340        }
341        if let Some(ref background_set) = self.background_set {
342            properties.push(("background-set", background_set));
343        }
344        if let Some(ref bold) = self.bold {
345            properties.push(("bold", bold));
346        }
347        if let Some(ref bold_set) = self.bold_set {
348            properties.push(("bold-set", bold_set));
349        }
350        if let Some(ref foreground) = self.foreground {
351            properties.push(("foreground", foreground));
352        }
353        if let Some(ref foreground_set) = self.foreground_set {
354            properties.push(("foreground-set", foreground_set));
355        }
356        if let Some(ref italic) = self.italic {
357            properties.push(("italic", italic));
358        }
359        if let Some(ref italic_set) = self.italic_set {
360            properties.push(("italic-set", italic_set));
361        }
362        if let Some(ref line_background) = self.line_background {
363            properties.push(("line-background", line_background));
364        }
365        if let Some(ref line_background_set) = self.line_background_set {
366            properties.push(("line-background-set", line_background_set));
367        }
368        if let Some(ref pango_underline) = self.pango_underline {
369            properties.push(("pango-underline", pango_underline));
370        }
371        if let Some(ref scale) = self.scale {
372            properties.push(("scale", scale));
373        }
374        if let Some(ref scale_set) = self.scale_set {
375            properties.push(("scale-set", scale_set));
376        }
377        if let Some(ref strikethrough) = self.strikethrough {
378            properties.push(("strikethrough", strikethrough));
379        }
380        if let Some(ref strikethrough_set) = self.strikethrough_set {
381            properties.push(("strikethrough-set", strikethrough_set));
382        }
383        if let Some(ref underline) = self.underline {
384            properties.push(("underline", underline));
385        }
386        if let Some(ref underline_color) = self.underline_color {
387            properties.push(("underline-color", underline_color));
388        }
389        if let Some(ref underline_color_set) = self.underline_color_set {
390            properties.push(("underline-color-set", underline_color_set));
391        }
392        if let Some(ref underline_set) = self.underline_set {
393            properties.push(("underline-set", underline_set));
394        }
395        glib::Object::new(Style::static_type(), &properties)
396            .expect("object new")
397            .downcast()
398            .expect("downcast")
399    }
400
401    pub fn background(mut self, background: &str) -> Self {
402        self.background = Some(background.to_string());
403        self
404    }
405
406    pub fn background_set(mut self, background_set: bool) -> Self {
407        self.background_set = Some(background_set);
408        self
409    }
410
411    pub fn bold(mut self, bold: bool) -> Self {
412        self.bold = Some(bold);
413        self
414    }
415
416    pub fn bold_set(mut self, bold_set: bool) -> Self {
417        self.bold_set = Some(bold_set);
418        self
419    }
420
421    pub fn foreground(mut self, foreground: &str) -> Self {
422        self.foreground = Some(foreground.to_string());
423        self
424    }
425
426    pub fn foreground_set(mut self, foreground_set: bool) -> Self {
427        self.foreground_set = Some(foreground_set);
428        self
429    }
430
431    pub fn italic(mut self, italic: bool) -> Self {
432        self.italic = Some(italic);
433        self
434    }
435
436    pub fn italic_set(mut self, italic_set: bool) -> Self {
437        self.italic_set = Some(italic_set);
438        self
439    }
440
441    pub fn line_background(mut self, line_background: &str) -> Self {
442        self.line_background = Some(line_background.to_string());
443        self
444    }
445
446    pub fn line_background_set(mut self, line_background_set: bool) -> Self {
447        self.line_background_set = Some(line_background_set);
448        self
449    }
450
451    pub fn pango_underline(mut self, pango_underline: pango::Underline) -> Self {
452        self.pango_underline = Some(pango_underline);
453        self
454    }
455
456    pub fn scale(mut self, scale: &str) -> Self {
457        self.scale = Some(scale.to_string());
458        self
459    }
460
461    pub fn scale_set(mut self, scale_set: bool) -> Self {
462        self.scale_set = Some(scale_set);
463        self
464    }
465
466    pub fn strikethrough(mut self, strikethrough: bool) -> Self {
467        self.strikethrough = Some(strikethrough);
468        self
469    }
470
471    pub fn strikethrough_set(mut self, strikethrough_set: bool) -> Self {
472        self.strikethrough_set = Some(strikethrough_set);
473        self
474    }
475
476    pub fn underline(mut self, underline: bool) -> Self {
477        self.underline = Some(underline);
478        self
479    }
480
481    pub fn underline_color(mut self, underline_color: &str) -> Self {
482        self.underline_color = Some(underline_color.to_string());
483        self
484    }
485
486    pub fn underline_color_set(mut self, underline_color_set: bool) -> Self {
487        self.underline_color_set = Some(underline_color_set);
488        self
489    }
490
491    pub fn underline_set(mut self, underline_set: bool) -> Self {
492        self.underline_set = Some(underline_set);
493        self
494    }
495}
496
497impl fmt::Display for Style {
498    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
499        write!(f, "Style")
500    }
501}