[dconf-editor] Add variant and vardict examples.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Add variant and vardict examples.
- Date: Mon, 19 Mar 2018 10:32:58 +0000 (UTC)
commit 99700af66ba806100b6abd1467ca6cae9ea46b7c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Mar 19 11:31:26 2018 +0100
Add variant and vardict examples.
editor/ca.desrt.dconf-editor.gschema.xml | 10 ++++++++++
editor/registry-info.vala | 7 ++++++-
editor/setting-object.vala | 2 ++
3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index d3f02c5..e2d3484 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -323,6 +323,16 @@
<summary>A nullable string, type ‘ms’</summary>
<description>GSettings allows nullable types, that are similar to other types but could take a
“nothing” value. A nullable string can take any string as value, including the empty string “''”, or can be
NULL (nothing).</description>
</key>
+ <key name="variant" type="v">
+ <default><@mmb just nothing></default>
+ <summary>A variant, type ‘v’</summary>
+ <description>Variants could be stored inside variants, and consequently as a GSettings type. Their
representation use the XML brackets (‘<’ and ‘>’ characters, in a gschema file “&#60;” and
“&#62;” respectively), with a parsable representation of their content inside. If unclear, the type can
be given in the value with a prefix annotation like “@x” (where “x” is the type string) or “int64”. See
https://developer.gnome.org/glib/stable/gvariant-text.html for complete documentation.</description>
+ </key>
+ <key name="variant-dictionary" type="a{sv}">
+ <default>{'title': <'Example'>, 'character': <uint32 56>, 'bold':
<true>}</default>
+ <summary>A “vardict”, type ‘a{sv}’</summary>
+ <description>A dictionary maps values of a basic type to another value (of any type). One simple use
case is to map strings to variants.</description>
+ </key>
<key name="weird-enum" enum="ca.desrt.dconf-editor.DemoWeirdEnum">
<default>'only-choice'</default>
<summary>A 1-choice enumeration</summary>
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index bda9078..943aaf2 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -407,6 +407,10 @@ class RegistryInfo : Grid, BrowsableView
if (type == "d") // TODO if type contains "d"; on Intl.get_language_names ()[0] != "C"?
return warning_label (_("Use a dot as decimal mark and no thousands separator. You can use the
X.Ye+Z notation."));
+ if ("v" in type)
+ return warning_label (_("Variants content should be surrounded by XML brackets (‘<’ and ‘>’).
See https://developer.gnome.org/glib/stable/gvariant-text.html for complete documentation."));
+
+ /* the "<flags>" special type is not concerned but has an 's' and a 'g' in it; "s", "g" and "o"
types have a specific UI */
if (type != "<flags>" && ((type != "s" && "s" in type) || (type != "g" && "g" in type)) || (type !=
"o" && "o" in type))
{
if ("m" in type)
@@ -415,7 +419,8 @@ class RegistryInfo : Grid, BrowsableView
else
return warning_label (_("Strings, signatures and object paths should be surrounded by
quotation marks."));
}
- else if (type != "m" && type != "mb" && type != "<enum>" && "m" in type)
+ /* the "mb" type has a specific UI; the "<enum>" special type is not concerned but has an 'm' in it
*/
+ else if (type != "mb" && type != "<enum>" && "m" in type)
/* Translators: neither the "nothing" keyword nor the "m" type should be translated; a "maybe
type" is a type of variant that is nullable. */
return warning_label (_("Use the keyword “nothing” to set a maybe type (beginning with “m”) to
its empty value."));
return null;
diff --git a/editor/setting-object.vala b/editor/setting-object.vala
index 12fd682..ecda72d 100644
--- a/editor/setting-object.vala
+++ b/editor/setting-object.vala
@@ -90,6 +90,8 @@ public abstract class Key : SettingObject
case "x":
case "t":
return _("Integer");
+ case "v":
+ return _("Variant");
default:
return type;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]