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 * 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 * Returns: 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, true); 209 } 210 211 alias doref = ref_; 212 /** 213 * Increase the reference count of @source, returning a new reference. 214 * 215 * Returns: a new reference to @source 216 * 217 * Since: 2.32 218 */ 219 public SettingsSchemaSource ref_() 220 { 221 auto p = g_settings_schema_source_ref(gSettingsSchemaSource); 222 223 if(p is null) 224 { 225 return null; 226 } 227 228 return ObjectG.getDObject!(SettingsSchemaSource)(cast(GSettingsSchemaSource*) p, true); 229 } 230 231 /** 232 * Decrease the reference count of @source, possibly freeing it. 233 * 234 * Since: 2.32 235 */ 236 public void unref() 237 { 238 g_settings_schema_source_unref(gSettingsSchemaSource); 239 } 240 241 /** 242 * Gets the default system schema source. 243 * 244 * This function is not required for normal uses of #GSettings but it 245 * may be useful to authors of plugin management systems or to those who 246 * want to introspect the content of schemas. 247 * 248 * If no schemas are installed, %NULL will be returned. 249 * 250 * The returned source may actually consist of multiple schema sources 251 * from different directories, depending on which directories were given 252 * in `XDG_DATA_DIRS` and `GSETTINGS_SCHEMA_DIR`. For this reason, all 253 * lookups performed against the default source should probably be done 254 * recursively. 255 * 256 * Returns: the default schema source 257 * 258 * Since: 2.32 259 */ 260 public static SettingsSchemaSource getDefault() 261 { 262 auto p = g_settings_schema_source_get_default(); 263 264 if(p is null) 265 { 266 return null; 267 } 268 269 return ObjectG.getDObject!(SettingsSchemaSource)(cast(GSettingsSchemaSource*) p); 270 } 271 }