--- a/editor/dconf-model.vala 2012-03-07 05:49:37.000000000 +0100 +++ b/editor/dconf-model.vala 2012-10-05 11:11:05.996836928 +0200 @@ -611,7 +611,7 @@ } /* Add keys for the values in the schemas */ - foreach (var schema in schemas.schemas) + foreach (var schema in schemas.schemas.get_values()) root.load_schema(schema, schema.path[1:schema.path.length]); } --- a/editor/dconf-schema.vala 2012-03-07 05:49:37.000000000 +0100 +++ b/editor/dconf-schema.vala 2012-10-05 11:14:41.804831349 +0200 @@ -345,7 +345,7 @@ public class SchemaList { - public GLib.List schemas = new GLib.List(); + public GLib.HashTable schemas = new GLib.HashTable(str_hash, str_equal); public GLib.HashTable keys = new GLib.HashTable(str_hash, str_equal); public GLib.HashTable enums = new GLib.HashTable(str_hash, str_equal); public GLib.HashTable flags = new GLib.HashTable(str_hash, str_equal); @@ -385,7 +385,7 @@ string full_name = schema.path + key.name; keys.insert(full_name, key); } - schemas.append(schema); + schemas.insert(schema.id, schema); } else if (node->name == "enum") { @@ -404,19 +404,78 @@ delete doc; } + public void parse_override(string path) + { + var keyfile = new KeyFile(); + try + { + keyfile.load_from_file(path, KeyFileFlags.NONE); + } + catch (Error e) + { + warning("Failed to load override file %s: %s", path, e.message); + return; + } + + foreach (var group in keyfile.get_groups()) + { + var schema = schemas.lookup(group); + if (schema == null) + continue; + + string[] keys; + try { keys = keyfile.get_keys(group); } catch (Error e) { continue; } + + foreach (var key_name in keys) + { + string value; + try { value = keyfile.get_value(group, key_name); } catch (Error e) { continue; } + + var key = schema.keys.lookup (key_name); + if (key == null) + continue; + + Variant default_value; + try + { + default_value = Variant.parse(new VariantType(key.type), value); + } + catch (VariantParseError e) + { + // ... + continue; + } + + key.default_value = default_value; + } + } + } + public void load_directory(string dir) throws Error { - File directory = File.new_for_path(dir); + var directory = File.new_for_path(dir); + var i = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0, null); - FileInfo info; - while ((info = i.next_file (null)) != null) { - string name = info.get_name(); + while (true) + { + var info = i.next_file (null); + if (info == null) + break; + var name = info.get_name(); + if (name.has_suffix(".gschema.xml") || name.has_suffix(".enums.xml")) + parse_file(Path.build_filename(dir, name, null)); + } - if (!name.has_suffix(".gschema.xml") && !name.has_suffix(".enums.xml")) - continue; + i = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0, null); + while (true) + { + var info = i.next_file (null); + if (info == null) + break; + var name = info.get_name(); - string path = Path.build_filename(dir, name, null); - parse_file(path); + if (name.has_suffix(".override")) + parse_override(Path.build_filename(dir, name, null)); } } }