Skip to main content

gio/auto/
settings_schema.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::{SettingsSchemaKey, ffi};
6use glib::translate::*;
7
8glib::wrapper! {
9    ///
10    /// }
11    /// ```text
12    ///
13    /// It's also possible that the plugin system expects the schema source
14    /// files (ie: `.gschema.xml` files) instead of a `gschemas.compiled` file.
15    /// In that case, the plugin loading system must compile the schemas for
16    /// itself before attempting to create the settings source.
17    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
18    pub struct SettingsSchema(Shared<ffi::GSettingsSchema>);
19
20    match fn {
21        ref => |ptr| ffi::g_settings_schema_ref(ptr),
22        unref => |ptr| ffi::g_settings_schema_unref(ptr),
23        type_ => || ffi::g_settings_schema_get_type(),
24    }
25}
26
27impl SettingsSchema {
28    /// Get the ID of @self.
29    ///
30    /// # Returns
31    ///
32    /// the ID
33    #[doc(alias = "g_settings_schema_get_id")]
34    #[doc(alias = "get_id")]
35    pub fn id(&self) -> glib::GString {
36        unsafe { from_glib_none(ffi::g_settings_schema_get_id(self.to_glib_none().0)) }
37    }
38
39    /// Gets the key named @name from @self.
40    ///
41    /// It is a programmer error to request a key that does not exist.  See
42    /// g_settings_schema_list_keys().
43    /// ## `name`
44    /// the name of a key
45    ///
46    /// # Returns
47    ///
48    /// the #GSettingsSchemaKey for @name
49    #[doc(alias = "g_settings_schema_get_key")]
50    #[doc(alias = "get_key")]
51    pub fn key(&self, name: &str) -> SettingsSchemaKey {
52        unsafe {
53            from_glib_full(ffi::g_settings_schema_get_key(
54                self.to_glib_none().0,
55                name.to_glib_none().0,
56            ))
57        }
58    }
59
60    /// Gets the path associated with @self, or [`None`].
61    ///
62    /// Schemas may be single-instance or relocatable.  Single-instance
63    /// schemas correspond to exactly one set of keys in the backend
64    /// database: those located at the path returned by this function.
65    ///
66    /// Relocatable schemas can be referenced by other schemas and can
67    /// therefore describe multiple sets of keys at different locations.  For
68    /// relocatable schemas, this function will return [`None`].
69    ///
70    /// # Returns
71    ///
72    /// the path of the schema, or [`None`]
73    #[doc(alias = "g_settings_schema_get_path")]
74    #[doc(alias = "get_path")]
75    pub fn path(&self) -> Option<glib::GString> {
76        unsafe { from_glib_none(ffi::g_settings_schema_get_path(self.to_glib_none().0)) }
77    }
78
79    /// Checks if @self has a key named @name.
80    /// ## `name`
81    /// the name of a key
82    ///
83    /// # Returns
84    ///
85    /// [`true`] if such a key exists
86    #[doc(alias = "g_settings_schema_has_key")]
87    pub fn has_key(&self, name: &str) -> bool {
88        unsafe {
89            from_glib(ffi::g_settings_schema_has_key(
90                self.to_glib_none().0,
91                name.to_glib_none().0,
92            ))
93        }
94    }
95
96    /// Gets the list of children in @self.
97    ///
98    /// You should free the return value with g_strfreev() when you are done
99    /// with it.
100    ///
101    /// # Returns
102    ///
103    /// a list of
104    ///    the children on @settings, in no defined order
105    #[doc(alias = "g_settings_schema_list_children")]
106    pub fn list_children(&self) -> Vec<glib::GString> {
107        unsafe {
108            FromGlibPtrContainer::from_glib_full(ffi::g_settings_schema_list_children(
109                self.to_glib_none().0,
110            ))
111        }
112    }
113
114    /// Introspects the list of keys on @self.
115    ///
116    /// You should probably not be calling this function from "normal" code
117    /// (since you should already know what keys are in your schema).  This
118    /// function is intended for introspection reasons.
119    ///
120    /// # Returns
121    ///
122    /// a list
123    ///   of the keys on @self, in no defined order
124    #[doc(alias = "g_settings_schema_list_keys")]
125    pub fn list_keys(&self) -> Vec<glib::GString> {
126        unsafe {
127            FromGlibPtrContainer::from_glib_full(ffi::g_settings_schema_list_keys(
128                self.to_glib_none().0,
129            ))
130        }
131    }
132}