SettingsSchemaSource#
Added in version 2.32.
- class SettingsSchemaSource(*args, **kwargs)#
This is an opaque structure type. You may not access it directly.
Constructors#
- class SettingsSchemaSource
- classmethod new_from_directory(directory: str, parent: SettingsSchemaSource | None, trusted: bool) SettingsSchemaSource#
Attempts to create a new schema source corresponding to the contents of the given directory.
This function is not required for normal uses of
Settingsbut it may be useful to authors of plugin management systems.The directory should contain a file called
gschemas.compiledas produced by the [glib-compile-schemas][glib-compile-schemas] tool.If
trustedisTruethengschemas.compiledis trusted not to be corrupted. This assumption has a performance advantage, but can result in crashes or inconsistent behaviour in the case of a corrupted file. Generally, you should settrustedtoTruefor files installed by the system and toFalsefor files in the home directory.In either case, an empty file or some types of corruption in the file will result in %G_FILE_ERROR_INVAL being returned.
If
parentis non-Nonethen there are two effects.First, if
lookup()is called with therecursiveflag set toTrueand the schema can not be found in the source, the lookup will recurse to the parent.Second, any references to other schemas specified within this source (ie:
childorextends) references may be resolved from theparent.For this second reason, except in very unusual situations, the
parentshould probably be given as the default schema source, as returned byget_default().Added in version 2.32.
- Parameters:
directory – the filename of a directory
parent – a
SettingsSchemaSource, orNonetrusted –
True, if the directory is trusted
Methods#
- class SettingsSchemaSource
- classmethod get_default() SettingsSchemaSource | None#
Gets the default system schema source.
This function is not required for normal uses of
Settingsbut it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas.If no schemas are installed,
Nonewill be returned.The returned source may actually consist of multiple schema sources from different directories, depending on which directories were given in
XDG_DATA_DIRSandGSETTINGS_SCHEMA_DIR. For this reason, all lookups performed against the default source should probably be done recursively.Added in version 2.32.
- list_schemas(recursive: bool) tuple[list[str], list[str]]#
Lists the schemas in a given source.
If
recursiveisTruethen include parent sources. IfFalsethen only include the schemas from one source (ie: one directory). You probably wantTrue.Non-relocatable schemas are those for which you can call
new(). Relocatable schemas are those for which you must usenew_with_path().Do not call this function from normal programs. This is designed for use by database editors, commandline tools, etc.
Added in version 2.40.
- Parameters:
recursive – if we should recurse
- lookup(schema_id: str, recursive: bool) SettingsSchema | None#
Looks up a schema with the identifier
schema_idinsource.This function is not required for normal uses of
Settingsbut it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas.If the schema isn’t found directly in
sourceandrecursiveisTruethen the parent sources will also be checked.If the schema isn’t found,
Noneis returned.Added in version 2.32.
- Parameters:
schema_id – a schema ID
recursive –
Trueif the lookup should be recursive