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