gio/auto/settings_schema_key.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 crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 /// #GSettingsSchemaKey is an opaque data structure and can only be accessed
10 /// using the following functions.
11 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
12 pub struct SettingsSchemaKey(Shared<ffi::GSettingsSchemaKey>);
13
14 match fn {
15 ref => |ptr| ffi::g_settings_schema_key_ref(ptr),
16 unref => |ptr| ffi::g_settings_schema_key_unref(ptr),
17 type_ => || ffi::g_settings_schema_key_get_type(),
18 }
19}
20
21impl SettingsSchemaKey {
22 /// Gets the default value for @self.
23 ///
24 /// Note that this is the default value according to the schema. System
25 /// administrator defaults and lockdown are not visible via this API.
26 ///
27 /// # Returns
28 ///
29 /// the default value for the key
30 #[doc(alias = "g_settings_schema_key_get_default_value")]
31 #[doc(alias = "get_default_value")]
32 pub fn default_value(&self) -> glib::Variant {
33 unsafe {
34 from_glib_full(ffi::g_settings_schema_key_get_default_value(
35 self.to_glib_none().0,
36 ))
37 }
38 }
39
40 /// Gets the description for @self.
41 ///
42 /// If no description has been provided in the schema for @self, returns
43 /// [`None`].
44 ///
45 /// The description can be one sentence to several paragraphs in length.
46 /// Paragraphs are delimited with a double newline. Descriptions can be
47 /// translated and the value returned from this function is is the
48 /// current locale.
49 ///
50 /// This function is slow. The summary and description information for
51 /// the schemas is not stored in the compiled schema database so this
52 /// function has to parse all of the source XML files in the schema
53 /// directory.
54 ///
55 /// # Returns
56 ///
57 /// the description for @self, or [`None`]
58 #[doc(alias = "g_settings_schema_key_get_description")]
59 #[doc(alias = "get_description")]
60 pub fn description(&self) -> Option<glib::GString> {
61 unsafe {
62 from_glib_none(ffi::g_settings_schema_key_get_description(
63 self.to_glib_none().0,
64 ))
65 }
66 }
67
68 /// Gets the name of @self.
69 ///
70 /// # Returns
71 ///
72 /// the name of @self.
73 #[doc(alias = "g_settings_schema_key_get_name")]
74 #[doc(alias = "get_name")]
75 pub fn name(&self) -> glib::GString {
76 unsafe { from_glib_none(ffi::g_settings_schema_key_get_name(self.to_glib_none().0)) }
77 }
78
79 /// Queries the range of a key.
80 ///
81 /// This function will return a #GVariant that fully describes the range
82 /// of values that are valid for @self.
83 ///
84 /// The type of #GVariant returned is `(sv)`. The string describes
85 /// the type of range restriction in effect. The type and meaning of
86 /// the value contained in the variant depends on the string.
87 ///
88 /// If the string is `'type'` then the variant contains an empty array.
89 /// The element type of that empty array is the expected type of value
90 /// and all values of that type are valid.
91 ///
92 /// If the string is `'enum'` then the variant contains an array
93 /// enumerating the possible values. Each item in the array is
94 /// a possible valid value and no other values are valid.
95 ///
96 /// If the string is `'flags'` then the variant contains an array. Each
97 /// item in the array is a value that may appear zero or one times in an
98 /// array to be used as the value for this key. For example, if the
99 /// variant contained the array `['x', 'y']` then the valid values for
100 /// the key would be `[]`, `['x']`, `['y']`, `['x', 'y']` and
101 /// `['y', 'x']`.
102 ///
103 /// Finally, if the string is `'range'` then the variant contains a pair
104 /// of like-typed values -- the minimum and maximum permissible values
105 /// for this key.
106 ///
107 /// This information should not be used by normal programs. It is
108 /// considered to be a hint for introspection purposes. Normal programs
109 /// should already know what is permitted by their own schema. The
110 /// format may change in any way in the future -- but particularly, new
111 /// forms may be added to the possibilities described above.
112 ///
113 /// You should free the returned value with g_variant_unref() when it is
114 /// no longer needed.
115 ///
116 /// # Returns
117 ///
118 /// a #GVariant describing the range
119 #[doc(alias = "g_settings_schema_key_get_range")]
120 #[doc(alias = "get_range")]
121 pub fn range(&self) -> glib::Variant {
122 unsafe { from_glib_full(ffi::g_settings_schema_key_get_range(self.to_glib_none().0)) }
123 }
124
125 /// Gets the summary for @self.
126 ///
127 /// If no summary has been provided in the schema for @self, returns
128 /// [`None`].
129 ///
130 /// The summary is a short description of the purpose of the key; usually
131 /// one short sentence. Summaries can be translated and the value
132 /// returned from this function is is the current locale.
133 ///
134 /// This function is slow. The summary and description information for
135 /// the schemas is not stored in the compiled schema database so this
136 /// function has to parse all of the source XML files in the schema
137 /// directory.
138 ///
139 /// # Returns
140 ///
141 /// the summary for @self, or [`None`]
142 #[doc(alias = "g_settings_schema_key_get_summary")]
143 #[doc(alias = "get_summary")]
144 pub fn summary(&self) -> Option<glib::GString> {
145 unsafe {
146 from_glib_none(ffi::g_settings_schema_key_get_summary(
147 self.to_glib_none().0,
148 ))
149 }
150 }
151
152 /// Gets the #GVariantType of @self.
153 ///
154 /// # Returns
155 ///
156 /// the type of @self
157 #[doc(alias = "g_settings_schema_key_get_value_type")]
158 #[doc(alias = "get_value_type")]
159 pub fn value_type(&self) -> glib::VariantType {
160 unsafe {
161 from_glib_none(ffi::g_settings_schema_key_get_value_type(
162 self.to_glib_none().0,
163 ))
164 }
165 }
166
167 /// Checks if the given @value is within the
168 /// permitted range for @self.
169 ///
170 /// It is a programmer error if @value is not of the correct type — you
171 /// must check for this first.
172 /// ## `value`
173 /// the value to check
174 ///
175 /// # Returns
176 ///
177 /// [`true`] if @value is valid for @self
178 #[doc(alias = "g_settings_schema_key_range_check")]
179 pub fn range_check(&self, value: &glib::Variant) -> bool {
180 unsafe {
181 from_glib(ffi::g_settings_schema_key_range_check(
182 self.to_glib_none().0,
183 value.to_glib_none().0,
184 ))
185 }
186 }
187}
188
189impl std::fmt::Display for SettingsSchemaKey {
190 #[inline]
191 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
192 f.write_str(&self.name())
193 }
194}