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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
// 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 glib::translate::*;
glib::wrapper! {
/// #GSettingsSchemaKey is an opaque data structure and can only be accessed
/// using the following functions.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SettingsSchemaKey(Shared<ffi::GSettingsSchemaKey>);
match fn {
ref => |ptr| ffi::g_settings_schema_key_ref(ptr),
unref => |ptr| ffi::g_settings_schema_key_unref(ptr),
type_ => || ffi::g_settings_schema_key_get_type(),
}
}
impl SettingsSchemaKey {
/// Gets the default value for @self.
///
/// Note that this is the default value according to the schema. System
/// administrator defaults and lockdown are not visible via this API.
///
/// # Returns
///
/// the default value for the key
#[doc(alias = "g_settings_schema_key_get_default_value")]
#[doc(alias = "get_default_value")]
pub fn default_value(&self) -> glib::Variant {
unsafe {
from_glib_full(ffi::g_settings_schema_key_get_default_value(
self.to_glib_none().0,
))
}
}
/// Gets the description for @self.
///
/// If no description has been provided in the schema for @self, returns
/// [`None`].
///
/// The description can be one sentence to several paragraphs in length.
/// Paragraphs are delimited with a double newline. Descriptions can be
/// translated and the value returned from this function is is the
/// current locale.
///
/// This function is slow. The summary and description information for
/// the schemas is not stored in the compiled schema database so this
/// function has to parse all of the source XML files in the schema
/// directory.
///
/// # Returns
///
/// the description for @self, or [`None`]
#[doc(alias = "g_settings_schema_key_get_description")]
#[doc(alias = "get_description")]
pub fn description(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::g_settings_schema_key_get_description(
self.to_glib_none().0,
))
}
}
/// Gets the name of @self.
///
/// # Returns
///
/// the name of @self.
#[doc(alias = "g_settings_schema_key_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::g_settings_schema_key_get_name(self.to_glib_none().0)) }
}
/// Queries the range of a key.
///
/// This function will return a #GVariant that fully describes the range
/// of values that are valid for @self.
///
/// The type of #GVariant returned is `(sv)`. The string describes
/// the type of range restriction in effect. The type and meaning of
/// the value contained in the variant depends on the string.
///
/// If the string is `'type'` then the variant contains an empty array.
/// The element type of that empty array is the expected type of value
/// and all values of that type are valid.
///
/// If the string is `'enum'` then the variant contains an array
/// enumerating the possible values. Each item in the array is
/// a possible valid value and no other values are valid.
///
/// If the string is `'flags'` then the variant contains an array. Each
/// item in the array is a value that may appear zero or one times in an
/// array to be used as the value for this key. For example, if the
/// variant contained the array `['x', 'y']` then the valid values for
/// the key would be `[]`, `['x']`, `['y']`, `['x', 'y']` and
/// `['y', 'x']`.
///
/// Finally, if the string is `'range'` then the variant contains a pair
/// of like-typed values -- the minimum and maximum permissible values
/// for this key.
///
/// This information should not be used by normal programs. It is
/// considered to be a hint for introspection purposes. Normal programs
/// should already know what is permitted by their own schema. The
/// format may change in any way in the future -- but particularly, new
/// forms may be added to the possibilities described above.
///
/// You should free the returned value with g_variant_unref() when it is
/// no longer needed.
///
/// # Returns
///
/// a #GVariant describing the range
#[doc(alias = "g_settings_schema_key_get_range")]
#[doc(alias = "get_range")]
pub fn range(&self) -> glib::Variant {
unsafe { from_glib_full(ffi::g_settings_schema_key_get_range(self.to_glib_none().0)) }
}
/// Gets the summary for @self.
///
/// If no summary has been provided in the schema for @self, returns
/// [`None`].
///
/// The summary is a short description of the purpose of the key; usually
/// one short sentence. Summaries can be translated and the value
/// returned from this function is is the current locale.
///
/// This function is slow. The summary and description information for
/// the schemas is not stored in the compiled schema database so this
/// function has to parse all of the source XML files in the schema
/// directory.
///
/// # Returns
///
/// the summary for @self, or [`None`]
#[doc(alias = "g_settings_schema_key_get_summary")]
#[doc(alias = "get_summary")]
pub fn summary(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::g_settings_schema_key_get_summary(
self.to_glib_none().0,
))
}
}
/// Gets the #GVariantType of @self.
///
/// # Returns
///
/// the type of @self
#[doc(alias = "g_settings_schema_key_get_value_type")]
#[doc(alias = "get_value_type")]
pub fn value_type(&self) -> glib::VariantType {
unsafe {
from_glib_none(ffi::g_settings_schema_key_get_value_type(
self.to_glib_none().0,
))
}
}
/// Checks if the given @value is within the
/// permitted range for @self.
///
/// It is a programmer error if @value is not of the correct type — you
/// must check for this first.
/// ## `value`
/// the value to check
///
/// # Returns
///
/// [`true`] if @value is valid for @self
#[doc(alias = "g_settings_schema_key_range_check")]
pub fn range_check(&self, value: &glib::Variant) -> bool {
unsafe {
from_glib(ffi::g_settings_schema_key_range_check(
self.to_glib_none().0,
value.to_glib_none().0,
))
}
}
}
impl std::fmt::Display for SettingsSchemaKey {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&self.name())
}
}