[dconf-editor] More work in Key constructor, less after.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] More work in Key constructor, less after.
- Date: Wed, 30 Sep 2015 20:27:10 +0000 (UTC)
commit 3fef20d57b63b498f5de57135906ddf1af6eeddd
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Sep 30 21:53:58 2015 +0200
More work in Key constructor, less after.
editor/dconf-model.vala | 39 ++++++++++++++++-----------------------
1 files changed, 16 insertions(+), 23 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index e5a5a8f..a34249b 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -32,27 +32,8 @@ public class Key : GLib.Object
public SchemaKey? schema;
- public bool has_schema
- {
- get { return schema != null; }
- }
-
- public string type_string
- {
- private set {}
- public get
- {
- if (value != null)
- {
- if (value.is_of_type(VariantType.STRING) && has_schema && schema.enum_name != null)
- return "<enum>";
- else
- return value.get_type_string();
- }
- else
- return schema.type;
- }
- }
+ public bool has_schema { get; private set; }
+ public string type_string { get; private set; default = "*"; }
private Variant? _value = null;
public Variant value
@@ -60,7 +41,7 @@ public class Key : GLib.Object
get
{
update_value();
- return _value ?? schema.default_value;
+ return _value ?? schema.default_value; // TODO cannot that error?
}
set
{
@@ -89,7 +70,7 @@ public class Key : GLib.Object
value_changed ();
}
- public Key(SettingsModel model, Directory parent, string name, string full_name)
+ public Key (SettingsModel model, Directory parent, string name, string full_name)
{
this.model = model;
this.parent = parent;
@@ -97,6 +78,18 @@ public class Key : GLib.Object
this.full_name = full_name;
this.schema = model.schemas.keys.lookup(full_name);
+ has_schema = schema != null;
+
+ if (has_schema)
+ {
+ if (schema.type == "s" && schema.enum_name != null)
+ type_string = "<enum>";
+ else
+ type_string = schema.type;
+ }
+ else if (value != null)
+ type_string = value.get_type_string ();
+
model.item_changed.connect (item_changed);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]