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 glib.Str;
28 private import glib.Variant;
29 private import glib.VariantType;
30 private import gobject.ObjectG;
31 private import gtkc.gio;
32 public  import gtkc.giotypes;
33 
34 
35 /**
36  * #GSettingsSchemaKey is an opaque data structure and can only be accessed
37  * using the following functions.
38  */
39 public class SettingsSchemaKey
40 {
41 	/** the main Gtk struct */
42 	protected GSettingsSchemaKey* gSettingsSchemaKey;
43 
44 	/** Get the main Gtk struct */
45 	public GSettingsSchemaKey* getSettingsSchemaKeyStruct()
46 	{
47 		return gSettingsSchemaKey;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected void* getStruct()
52 	{
53 		return cast(void*)gSettingsSchemaKey;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (GSettingsSchemaKey* gSettingsSchemaKey)
60 	{
61 		this.gSettingsSchemaKey = gSettingsSchemaKey;
62 	}
63 
64 
65 	/** */
66 	public static GType getType()
67 	{
68 		return g_settings_schema_key_get_type();
69 	}
70 
71 	/**
72 	 * Gets the default value for @key.
73 	 *
74 	 * Note that this is the default value according to the schema.  System
75 	 * administrator defaults and lockdown are not visible via this API.
76 	 *
77 	 * Return: the default value for the key
78 	 *
79 	 * Since: 2.40
80 	 */
81 	public Variant getDefaultValue()
82 	{
83 		auto p = g_settings_schema_key_get_default_value(gSettingsSchemaKey);
84 		
85 		if(p is null)
86 		{
87 			return null;
88 		}
89 		
90 		return new Variant(cast(GVariant*) p);
91 	}
92 
93 	/**
94 	 * Gets the description for @key.
95 	 *
96 	 * If no description has been provided in the schema for @key, returns
97 	 * %NULL.
98 	 *
99 	 * The description can be one sentence to several paragraphs in length.
100 	 * Paragraphs are delimited with a double newline.  Descriptions can be
101 	 * translated and the value returned from this function is is the
102 	 * current locale.
103 	 *
104 	 * This function is slow.  The summary and description information for
105 	 * the schemas is not stored in the compiled schema database so this
106 	 * function has to parse all of the source XML files in the schema
107 	 * directory.
108 	 *
109 	 * Return: the description for @key, or %NULL
110 	 *
111 	 * Since: 2.34
112 	 */
113 	public string getDescription()
114 	{
115 		return Str.toString(g_settings_schema_key_get_description(gSettingsSchemaKey));
116 	}
117 
118 	/**
119 	 * Gets the name of @key.
120 	 *
121 	 * Return: the name of @key.
122 	 *
123 	 * Since: 2.44
124 	 */
125 	public string getName()
126 	{
127 		return Str.toString(g_settings_schema_key_get_name(gSettingsSchemaKey));
128 	}
129 
130 	/**
131 	 * Queries the range of a key.
132 	 *
133 	 * This function will return a #GVariant that fully describes the range
134 	 * of values that are valid for @key.
135 	 *
136 	 * The type of #GVariant returned is `(sv)`. The string describes
137 	 * the type of range restriction in effect. The type and meaning of
138 	 * the value contained in the variant depends on the string.
139 	 *
140 	 * If the string is `'type'` then the variant contains an empty array.
141 	 * The element type of that empty array is the expected type of value
142 	 * and all values of that type are valid.
143 	 *
144 	 * If the string is `'enum'` then the variant contains an array
145 	 * enumerating the possible values. Each item in the array is
146 	 * a possible valid value and no other values are valid.
147 	 *
148 	 * If the string is `'flags'` then the variant contains an array. Each
149 	 * item in the array is a value that may appear zero or one times in an
150 	 * array to be used as the value for this key. For example, if the
151 	 * variant contained the array `['x', 'y']` then the valid values for
152 	 * the key would be `[]`, `['x']`, `['y']`, `['x', 'y']` and
153 	 * `['y', 'x']`.
154 	 *
155 	 * Finally, if the string is `'range'` then the variant contains a pair
156 	 * of like-typed values -- the minimum and maximum permissible values
157 	 * for this key.
158 	 *
159 	 * This information should not be used by normal programs.  It is
160 	 * considered to be a hint for introspection purposes.  Normal programs
161 	 * should already know what is permitted by their own schema.  The
162 	 * format may change in any way in the future -- but particularly, new
163 	 * forms may be added to the possibilities described above.
164 	 *
165 	 * You should free the returned value with g_variant_unref() when it is
166 	 * no longer needed.
167 	 *
168 	 * Return: a #GVariant describing the range
169 	 *
170 	 * Since: 2.40
171 	 */
172 	public Variant getRange()
173 	{
174 		auto p = g_settings_schema_key_get_range(gSettingsSchemaKey);
175 		
176 		if(p is null)
177 		{
178 			return null;
179 		}
180 		
181 		return new Variant(cast(GVariant*) p);
182 	}
183 
184 	/**
185 	 * Gets the summary for @key.
186 	 *
187 	 * If no summary has been provided in the schema for @key, returns
188 	 * %NULL.
189 	 *
190 	 * The summary is a short description of the purpose of the key; usually
191 	 * one short sentence.  Summaries can be translated and the value
192 	 * returned from this function is is the current locale.
193 	 *
194 	 * This function is slow.  The summary and description information for
195 	 * the schemas is not stored in the compiled schema database so this
196 	 * function has to parse all of the source XML files in the schema
197 	 * directory.
198 	 *
199 	 * Return: the summary for @key, or %NULL
200 	 *
201 	 * Since: 2.34
202 	 */
203 	public string getSummary()
204 	{
205 		return Str.toString(g_settings_schema_key_get_summary(gSettingsSchemaKey));
206 	}
207 
208 	/**
209 	 * Gets the #GVariantType of @key.
210 	 *
211 	 * Return: the type of @key
212 	 *
213 	 * Since: 2.40
214 	 */
215 	public VariantType getValueType()
216 	{
217 		auto p = g_settings_schema_key_get_value_type(gSettingsSchemaKey);
218 		
219 		if(p is null)
220 		{
221 			return null;
222 		}
223 		
224 		return new VariantType(cast(GVariantType*) p);
225 	}
226 
227 	/**
228 	 * Checks if the given @value is of the correct type and within the
229 	 * permitted range for @key.
230 	 *
231 	 * It is a programmer error if @value is not of the correct type -- you
232 	 * must check for this first.
233 	 *
234 	 * Params:
235 	 *     value = the value to check
236 	 *
237 	 * Return: %TRUE if @value is valid for @key
238 	 *
239 	 * Since: 2.40
240 	 */
241 	public bool rangeCheck(Variant value)
242 	{
243 		return g_settings_schema_key_range_check(gSettingsSchemaKey, (value is null) ? null : value.getVariantStruct()) != 0;
244 	}
245 
246 	/**
247 	 * Increase the reference count of @key, returning a new reference.
248 	 *
249 	 * Return: a new reference to @key
250 	 *
251 	 * Since: 2.40
252 	 */
253 	public SettingsSchemaKey doref()
254 	{
255 		auto p = g_settings_schema_key_ref(gSettingsSchemaKey);
256 		
257 		if(p is null)
258 		{
259 			return null;
260 		}
261 		
262 		return ObjectG.getDObject!(SettingsSchemaKey)(cast(GSettingsSchemaKey*) p);
263 	}
264 
265 	/**
266 	 * Decrease the reference count of @key, possibly freeing it.
267 	 *
268 	 * Since: 2.40
269 	 */
270 	public void unref()
271 	{
272 		g_settings_schema_key_unref(gSettingsSchemaKey);
273 	}
274 }