1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.SettingsSchemaKey;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.Str;
30 private import glib.Variant;
31 private import glib.VariantType;
32 private import glib.c.functions;
33 private import gobject.ObjectG;
34 private import gtkd.Loader;
35 
36 
37 /**
38  * #GSettingsSchemaKey is an opaque data structure and can only be accessed
39  * using the following functions.
40  */
41 public class SettingsSchemaKey
42 {
43 	/** the main Gtk struct */
44 	protected GSettingsSchemaKey* gSettingsSchemaKey;
45 	protected bool ownedRef;
46 
47 	/** Get the main Gtk struct */
48 	public GSettingsSchemaKey* getSettingsSchemaKeyStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gSettingsSchemaKey;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gSettingsSchemaKey;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GSettingsSchemaKey* gSettingsSchemaKey, bool ownedRef = false)
65 	{
66 		this.gSettingsSchemaKey = gSettingsSchemaKey;
67 		this.ownedRef = ownedRef;
68 	}
69 
70 	~this ()
71 	{
72 		if ( Linker.isLoaded(LIBRARY_GIO) && ownedRef )
73 			g_settings_schema_key_unref(gSettingsSchemaKey);
74 	}
75 
76 
77 	/** */
78 	public static GType getType()
79 	{
80 		return g_settings_schema_key_get_type();
81 	}
82 
83 	/**
84 	 * Gets the default value for @key.
85 	 *
86 	 * Note that this is the default value according to the schema.  System
87 	 * administrator defaults and lockdown are not visible via this API.
88 	 *
89 	 * Returns: the default value for the key
90 	 *
91 	 * Since: 2.40
92 	 */
93 	public Variant getDefaultValue()
94 	{
95 		auto __p = g_settings_schema_key_get_default_value(gSettingsSchemaKey);
96 
97 		if(__p is null)
98 		{
99 			return null;
100 		}
101 
102 		return new Variant(cast(GVariant*) __p, true);
103 	}
104 
105 	/**
106 	 * Gets the description for @key.
107 	 *
108 	 * If no description has been provided in the schema for @key, returns
109 	 * %NULL.
110 	 *
111 	 * The description can be one sentence to several paragraphs in length.
112 	 * Paragraphs are delimited with a double newline.  Descriptions can be
113 	 * translated and the value returned from this function is is the
114 	 * current locale.
115 	 *
116 	 * This function is slow.  The summary and description information for
117 	 * the schemas is not stored in the compiled schema database so this
118 	 * function has to parse all of the source XML files in the schema
119 	 * directory.
120 	 *
121 	 * Returns: the description for @key, or %NULL
122 	 *
123 	 * Since: 2.34
124 	 */
125 	public string getDescription()
126 	{
127 		return Str.toString(g_settings_schema_key_get_description(gSettingsSchemaKey));
128 	}
129 
130 	/**
131 	 * Gets the name of @key.
132 	 *
133 	 * Returns: the name of @key.
134 	 *
135 	 * Since: 2.44
136 	 */
137 	public string getName()
138 	{
139 		return Str.toString(g_settings_schema_key_get_name(gSettingsSchemaKey));
140 	}
141 
142 	/**
143 	 * Queries the range of a key.
144 	 *
145 	 * This function will return a #GVariant that fully describes the range
146 	 * of values that are valid for @key.
147 	 *
148 	 * The type of #GVariant returned is `(sv)`. The string describes
149 	 * the type of range restriction in effect. The type and meaning of
150 	 * the value contained in the variant depends on the string.
151 	 *
152 	 * If the string is `'type'` then the variant contains an empty array.
153 	 * The element type of that empty array is the expected type of value
154 	 * and all values of that type are valid.
155 	 *
156 	 * If the string is `'enum'` then the variant contains an array
157 	 * enumerating the possible values. Each item in the array is
158 	 * a possible valid value and no other values are valid.
159 	 *
160 	 * If the string is `'flags'` then the variant contains an array. Each
161 	 * item in the array is a value that may appear zero or one times in an
162 	 * array to be used as the value for this key. For example, if the
163 	 * variant contained the array `['x', 'y']` then the valid values for
164 	 * the key would be `[]`, `['x']`, `['y']`, `['x', 'y']` and
165 	 * `['y', 'x']`.
166 	 *
167 	 * Finally, if the string is `'range'` then the variant contains a pair
168 	 * of like-typed values -- the minimum and maximum permissible values
169 	 * for this key.
170 	 *
171 	 * This information should not be used by normal programs.  It is
172 	 * considered to be a hint for introspection purposes.  Normal programs
173 	 * should already know what is permitted by their own schema.  The
174 	 * format may change in any way in the future -- but particularly, new
175 	 * forms may be added to the possibilities described above.
176 	 *
177 	 * You should free the returned value with g_variant_unref() when it is
178 	 * no longer needed.
179 	 *
180 	 * Returns: a #GVariant describing the range
181 	 *
182 	 * Since: 2.40
183 	 */
184 	public Variant getRange()
185 	{
186 		auto __p = g_settings_schema_key_get_range(gSettingsSchemaKey);
187 
188 		if(__p is null)
189 		{
190 			return null;
191 		}
192 
193 		return new Variant(cast(GVariant*) __p, true);
194 	}
195 
196 	/**
197 	 * Gets the summary for @key.
198 	 *
199 	 * If no summary has been provided in the schema for @key, returns
200 	 * %NULL.
201 	 *
202 	 * The summary is a short description of the purpose of the key; usually
203 	 * one short sentence.  Summaries can be translated and the value
204 	 * returned from this function is is the current locale.
205 	 *
206 	 * This function is slow.  The summary and description information for
207 	 * the schemas is not stored in the compiled schema database so this
208 	 * function has to parse all of the source XML files in the schema
209 	 * directory.
210 	 *
211 	 * Returns: the summary for @key, or %NULL
212 	 *
213 	 * Since: 2.34
214 	 */
215 	public string getSummary()
216 	{
217 		return Str.toString(g_settings_schema_key_get_summary(gSettingsSchemaKey));
218 	}
219 
220 	/**
221 	 * Gets the #GVariantType of @key.
222 	 *
223 	 * Returns: the type of @key
224 	 *
225 	 * Since: 2.40
226 	 */
227 	public VariantType getValueType()
228 	{
229 		auto __p = g_settings_schema_key_get_value_type(gSettingsSchemaKey);
230 
231 		if(__p is null)
232 		{
233 			return null;
234 		}
235 
236 		return new VariantType(cast(GVariantType*) __p);
237 	}
238 
239 	/**
240 	 * Checks if the given @value is of the correct type and within the
241 	 * permitted range for @key.
242 	 *
243 	 * It is a programmer error if @value is not of the correct type -- you
244 	 * must check for this first.
245 	 *
246 	 * Params:
247 	 *     value = the value to check
248 	 *
249 	 * Returns: %TRUE if @value is valid for @key
250 	 *
251 	 * Since: 2.40
252 	 */
253 	public bool rangeCheck(Variant value)
254 	{
255 		return g_settings_schema_key_range_check(gSettingsSchemaKey, (value is null) ? null : value.getVariantStruct()) != 0;
256 	}
257 
258 	alias doref = ref_;
259 	/**
260 	 * Increase the reference count of @key, returning a new reference.
261 	 *
262 	 * Returns: a new reference to @key
263 	 *
264 	 * Since: 2.40
265 	 */
266 	public SettingsSchemaKey ref_()
267 	{
268 		auto __p = g_settings_schema_key_ref(gSettingsSchemaKey);
269 
270 		if(__p is null)
271 		{
272 			return null;
273 		}
274 
275 		return ObjectG.getDObject!(SettingsSchemaKey)(cast(GSettingsSchemaKey*) __p, true);
276 	}
277 
278 	/**
279 	 * Decrease the reference count of @key, possibly freeing it.
280 	 *
281 	 * Since: 2.40
282 	 */
283 	public void unref()
284 	{
285 		g_settings_schema_key_unref(gSettingsSchemaKey);
286 	}
287 }