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