source: appstream-generator/build/girepo/gio/SettingsSchemaSource.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 7.4 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.SettingsSchemaSource;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.SettingsSchema;
26private import glib.ConstructionException;
27private import glib.ErrorG;
28private import glib.GException;
29private import glib.Str;
30private import gobject.ObjectG;
31
32
33/**
34 * This is an opaque structure type.  You may not access it directly.
35 *
36 * Since: 2.32
37 */
38public class SettingsSchemaSource
39{
40        /** the main Gtk struct */
41        protected GSettingsSchemaSource* gSettingsSchemaSource;
42        protected bool ownedRef;
43
44        /** Get the main Gtk struct */
45        public GSettingsSchemaSource* getSettingsSchemaSourceStruct()
46        {
47                return gSettingsSchemaSource;
48        }
49
50        /** the main Gtk struct as a void* */
51        protected void* getStruct()
52        {
53                return cast(void*)gSettingsSchemaSource;
54        }
55
56        /**
57         * Sets our main struct and passes it to the parent class.
58         */
59        public this (GSettingsSchemaSource* gSettingsSchemaSource, bool ownedRef = false)
60        {
61                this.gSettingsSchemaSource = gSettingsSchemaSource;
62                this.ownedRef = ownedRef;
63        }
64
65
66        /** */
67        public static GType getType()
68        {
69                return g_settings_schema_source_get_type();
70        }
71
72        /**
73         * Attempts to create a new schema source corresponding to the contents
74         * of the given directory.
75         *
76         * This function is not required for normal uses of #GSettings but it
77         * may be useful to authors of plugin management systems.
78         *
79         * The directory should contain a file called `gschemas.compiled` as
80         * produced by the [glib-compile-schemas][glib-compile-schemas] tool.
81         *
82         * If @trusted is %TRUE then `gschemas.compiled` is trusted not to be
83         * corrupted. This assumption has a performance advantage, but can result
84         * in crashes or inconsistent behaviour in the case of a corrupted file.
85         * Generally, you should set @trusted to %TRUE for files installed by the
86         * system and to %FALSE for files in the home directory.
87         *
88         * If @parent is non-%NULL then there are two effects.
89         *
90         * First, if g_settings_schema_source_lookup() is called with the
91         * @recursive flag set to %TRUE and the schema can not be found in the
92         * source, the lookup will recurse to the parent.
93         *
94         * Second, any references to other schemas specified within this
95         * source (ie: `child` or `extends`) references may be resolved
96         * from the @parent.
97         *
98         * For this second reason, except in very unusual situations, the
99         * @parent should probably be given as the default schema source, as
100         * returned by g_settings_schema_source_get_default().
101         *
102         * Params:
103         *     directory = the filename of a directory
104         *     parent = a #GSettingsSchemaSource, or %NULL
105         *     trusted = %TRUE, if the directory is trusted
106         *
107         * Since: 2.32
108         *
109         * Throws: GException on failure.
110         * Throws: ConstructionException GTK+ fails to create the object.
111         */
112        public this(string directory, SettingsSchemaSource parent, bool trusted)
113        {
114                GError* err = null;
115               
116                auto p = g_settings_schema_source_new_from_directory(Str.toStringz(directory), (parent is null) ? null : parent.getSettingsSchemaSourceStruct(), trusted, &err);
117               
118                if (err !is null)
119                {
120                        throw new GException( new ErrorG(err) );
121                }
122               
123                if(p is null)
124                {
125                        throw new ConstructionException("null returned by new_from_directory");
126                }
127               
128                this(cast(GSettingsSchemaSource*) p);
129        }
130
131        /**
132         * Lists the schemas in a given source.
133         *
134         * If @recursive is %TRUE then include parent sources.  If %FALSE then
135         * only include the schemas from one source (ie: one directory).  You
136         * probably want %TRUE.
137         *
138         * Non-relocatable schemas are those for which you can call
139         * g_settings_new().  Relocatable schemas are those for which you must
140         * use g_settings_new_with_path().
141         *
142         * Do not call this function from normal programs.  This is designed for
143         * use by database editors, commandline tools, etc.
144         *
145         * Params:
146         *     recursive = if we should recurse
147         *     nonRelocatable = the
148         *         list of non-relocatable schemas
149         *     relocatable = the list
150         *         of relocatable schemas
151         *
152         * Since: 2.40
153         */
154        public void listSchemas(bool recursive, out string[] nonRelocatable, out string[] relocatable)
155        {
156                char** outnonRelocatable = null;
157                char** outrelocatable = null;
158               
159                g_settings_schema_source_list_schemas(gSettingsSchemaSource, recursive, &outnonRelocatable, &outrelocatable);
160               
161                nonRelocatable = Str.toStringArray(outnonRelocatable);
162                relocatable = Str.toStringArray(outrelocatable);
163        }
164
165        /**
166         * Looks up a schema with the identifier @schema_id in @source.
167         *
168         * This function is not required for normal uses of #GSettings but it
169         * may be useful to authors of plugin management systems or to those who
170         * want to introspect the content of schemas.
171         *
172         * If the schema isn't found directly in @source and @recursive is %TRUE
173         * then the parent sources will also be checked.
174         *
175         * If the schema isn't found, %NULL is returned.
176         *
177         * Params:
178         *     schemaId = a schema ID
179         *     recursive = %TRUE if the lookup should be recursive
180         *
181         * Returns: a new #GSettingsSchema
182         *
183         * Since: 2.32
184         */
185        public SettingsSchema lookup(string schemaId, bool recursive)
186        {
187                auto p = g_settings_schema_source_lookup(gSettingsSchemaSource, Str.toStringz(schemaId), recursive);
188               
189                if(p is null)
190                {
191                        return null;
192                }
193               
194                return ObjectG.getDObject!(SettingsSchema)(cast(GSettingsSchema*) p, true);
195        }
196
197        /**
198         * Increase the reference count of @source, returning a new reference.
199         *
200         * Returns: a new reference to @source
201         *
202         * Since: 2.32
203         */
204        public SettingsSchemaSource doref()
205        {
206                auto p = g_settings_schema_source_ref(gSettingsSchemaSource);
207               
208                if(p is null)
209                {
210                        return null;
211                }
212               
213                return ObjectG.getDObject!(SettingsSchemaSource)(cast(GSettingsSchemaSource*) p, true);
214        }
215
216        /**
217         * Decrease the reference count of @source, possibly freeing it.
218         *
219         * Since: 2.32
220         */
221        public void unref()
222        {
223                g_settings_schema_source_unref(gSettingsSchemaSource);
224        }
225
226        /**
227         * Gets the default system schema source.
228         *
229         * This function is not required for normal uses of #GSettings but it
230         * may be useful to authors of plugin management systems or to those who
231         * want to introspect the content of schemas.
232         *
233         * If no schemas are installed, %NULL will be returned.
234         *
235         * The returned source may actually consist of multiple schema sources
236         * from different directories, depending on which directories were given
237         * in `XDG_DATA_DIRS` and `GSETTINGS_SCHEMA_DIR`. For this reason, all
238         * lookups performed against the default source should probably be done
239         * recursively.
240         *
241         * Returns: the default schema source
242         *
243         * Since: 2.32
244         */
245        public static SettingsSchemaSource getDefault()
246        {
247                auto p = g_settings_schema_source_get_default();
248               
249                if(p is null)
250                {
251                        return null;
252                }
253               
254                return ObjectG.getDObject!(SettingsSchemaSource)(cast(GSettingsSchemaSource*) p);
255        }
256}
Note: See TracBrowser for help on using the repository browser.