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