libappstream/auto/
context.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.git)
4// DO NOT EDIT
5
6use crate::{ffi, FormatStyle, FormatVersion, ValueFlags};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    #[doc(alias = "AsContext")]
11    pub struct Context(Object<ffi::AsContext, ffi::AsContextClass>);
12
13    match fn {
14        type_ => || ffi::as_context_get_type(),
15    }
16}
17
18impl Context {
19    pub const NONE: Option<&'static Context> = None;
20
21    #[doc(alias = "as_context_new")]
22    pub fn new() -> Context {
23        assert_initialized_main_thread!();
24        unsafe { from_glib_full(ffi::as_context_new()) }
25    }
26}
27
28impl Default for Context {
29    fn default() -> Self {
30        Self::new()
31    }
32}
33
34pub trait ContextExt: IsA<Context> + 'static {
35    #[doc(alias = "as_context_get_filename")]
36    #[doc(alias = "get_filename")]
37    fn filename(&self) -> Option<glib::GString> {
38        unsafe { from_glib_none(ffi::as_context_get_filename(self.as_ref().to_glib_none().0)) }
39    }
40
41    #[doc(alias = "as_context_get_format_version")]
42    #[doc(alias = "get_format_version")]
43    fn format_version(&self) -> FormatVersion {
44        unsafe {
45            from_glib(ffi::as_context_get_format_version(
46                self.as_ref().to_glib_none().0,
47            ))
48        }
49    }
50
51    #[doc(alias = "as_context_get_locale")]
52    #[doc(alias = "get_locale")]
53    fn locale(&self) -> Option<glib::GString> {
54        unsafe { from_glib_none(ffi::as_context_get_locale(self.as_ref().to_glib_none().0)) }
55    }
56
57    #[doc(alias = "as_context_get_locale_use_all")]
58    #[doc(alias = "get_locale_use_all")]
59    fn is_locale_use_all(&self) -> bool {
60        unsafe {
61            from_glib(ffi::as_context_get_locale_use_all(
62                self.as_ref().to_glib_none().0,
63            ))
64        }
65    }
66
67    #[doc(alias = "as_context_get_media_baseurl")]
68    #[doc(alias = "get_media_baseurl")]
69    fn media_baseurl(&self) -> Option<glib::GString> {
70        unsafe {
71            from_glib_none(ffi::as_context_get_media_baseurl(
72                self.as_ref().to_glib_none().0,
73            ))
74        }
75    }
76
77    #[doc(alias = "as_context_get_origin")]
78    #[doc(alias = "get_origin")]
79    fn origin(&self) -> Option<glib::GString> {
80        unsafe { from_glib_none(ffi::as_context_get_origin(self.as_ref().to_glib_none().0)) }
81    }
82
83    #[doc(alias = "as_context_get_priority")]
84    #[doc(alias = "get_priority")]
85    fn priority(&self) -> i32 {
86        unsafe { ffi::as_context_get_priority(self.as_ref().to_glib_none().0) }
87    }
88
89    #[doc(alias = "as_context_get_style")]
90    #[doc(alias = "get_style")]
91    fn style(&self) -> FormatStyle {
92        unsafe { from_glib(ffi::as_context_get_style(self.as_ref().to_glib_none().0)) }
93    }
94
95    #[doc(alias = "as_context_get_value_flags")]
96    #[doc(alias = "get_value_flags")]
97    fn value_flags(&self) -> ValueFlags {
98        unsafe {
99            from_glib(ffi::as_context_get_value_flags(
100                self.as_ref().to_glib_none().0,
101            ))
102        }
103    }
104
105    #[doc(alias = "as_context_has_media_baseurl")]
106    fn has_media_baseurl(&self) -> bool {
107        unsafe {
108            from_glib(ffi::as_context_has_media_baseurl(
109                self.as_ref().to_glib_none().0,
110            ))
111        }
112    }
113
114    #[doc(alias = "as_context_set_filename")]
115    fn set_filename(&self, fname: &str) {
116        unsafe {
117            ffi::as_context_set_filename(self.as_ref().to_glib_none().0, fname.to_glib_none().0);
118        }
119    }
120
121    #[doc(alias = "as_context_set_format_version")]
122    fn set_format_version(&self, ver: FormatVersion) {
123        unsafe {
124            ffi::as_context_set_format_version(self.as_ref().to_glib_none().0, ver.into_glib());
125        }
126    }
127
128    #[doc(alias = "as_context_set_locale")]
129    fn set_locale(&self, locale: Option<&str>) {
130        unsafe {
131            ffi::as_context_set_locale(self.as_ref().to_glib_none().0, locale.to_glib_none().0);
132        }
133    }
134
135    #[doc(alias = "as_context_set_media_baseurl")]
136    fn set_media_baseurl(&self, value: &str) {
137        unsafe {
138            ffi::as_context_set_media_baseurl(
139                self.as_ref().to_glib_none().0,
140                value.to_glib_none().0,
141            );
142        }
143    }
144
145    #[doc(alias = "as_context_set_origin")]
146    fn set_origin(&self, value: &str) {
147        unsafe {
148            ffi::as_context_set_origin(self.as_ref().to_glib_none().0, value.to_glib_none().0);
149        }
150    }
151
152    #[doc(alias = "as_context_set_priority")]
153    fn set_priority(&self, priority: i32) {
154        unsafe {
155            ffi::as_context_set_priority(self.as_ref().to_glib_none().0, priority);
156        }
157    }
158
159    #[doc(alias = "as_context_set_style")]
160    fn set_style(&self, style: FormatStyle) {
161        unsafe {
162            ffi::as_context_set_style(self.as_ref().to_glib_none().0, style.into_glib());
163        }
164    }
165
166    #[doc(alias = "as_context_set_value_flags")]
167    fn set_value_flags(&self, flags: ValueFlags) {
168        unsafe {
169            ffi::as_context_set_value_flags(self.as_ref().to_glib_none().0, flags.into_glib());
170        }
171    }
172}
173
174impl<O: IsA<Context>> ContextExt for O {}