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