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