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