[dconf-editor] Handle the empty tuple.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Handle the empty tuple.
- Date: Mon, 19 Mar 2018 11:21:18 +0000 (UTC)
commit 51d4211257ffa91814671fc14b401ebe0dc55ac8
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Mar 19 12:21:03 2018 +0100
Handle the empty tuple.
editor/ca.desrt.dconf-editor.gschema.xml | 5 +++++
editor/key-list-box-row.vala | 8 ++++++--
editor/registry-info.ui | 10 ++++++++++
editor/registry-info.vala | 10 +++++++---
editor/setting-object.vala | 2 ++
5 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index e2d3484..ec464e3 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -344,6 +344,11 @@
<summary>A 1-choice integer value</summary>
<description>A range could limit an integer key to only allow one value, but that’s probably an error.
Dconf Editor warns you in that case.</description>
</key>
+ <key name="weird-triv" type="()">
+ <default>()</default>
+ <summary>The empty tuple, type and value “()”</summary>
+ <description>There’s an empty tuple type (called sometimes “triv”) that is a tuple with no content,
and can only take “()” as value.</description>
+ </key>
</schema>
<schema id="ca.desrt.dconf-editor.Demo.Empty" path="/ca/desrt/dconf-editor/Demo/Empty/">
</schema>
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 3e023e6..de86d4c 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -408,7 +408,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
bool planned_change = modifications_handler.key_has_planned_change (key.full_name);
Variant? planned_value = modifications_handler.get_key_planned_value (key.full_name);
- if (key.type_string == "b" || key.type_string == "mb")
+ if (key.type_string == "b" || key.type_string == "mb" || key.type_string == "()")
{
popover.new_section ();
bool delayed_apply_menu = modifications_handler.get_current_delay_mode ();
@@ -553,7 +553,8 @@ private class KeyListBoxRowEditable : KeyListBoxRow
(key.type_string == "n" || key.type_string == "i" || key.type_string == "h" ||
key.type_string == "x")
&& (key.range_type == "range")
&& (Key.get_variant_as_int64 (key.range_content.get_child_value (1)) -
Key.get_variant_as_int64 (key.range_content.get_child_value (0)) < 13)
- ))
+ )
+ || key.type_string == "()")
{
popover.new_section ();
GLib.Action action;
@@ -809,6 +810,9 @@ private class ContextPopover : Popover
number++)
current_section.append (number.to_string (), @"$group_dot_action(@mm$type_string
$number)");
break;
+ case "()":
+ current_section.append ("()", @"$group_dot_action(@mm() ())");
+ break;
}
((GLib.ActionGroup) current_group).action_state_changed [ACTION_NAME].connect ((unknown_string,
tmp_variant) => {
diff --git a/editor/registry-info.ui b/editor/registry-info.ui
index 52d8a28..b338e16 100644
--- a/editor/registry-info.ui
+++ b/editor/registry-info.ui
@@ -159,6 +159,16 @@
<property name="label" translatable="yes">This integer key can only take one value.
That’s probably an error of the application that installed this schema. If possible, please open a bug about
it.</property>
</object>
</child>
+ <child>
+ <object class="GtkLabel" id="one_choice_tuple_warning">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0.5</property>
+ <property name="max-width-chars">40</property>
+ <property name="wrap">True</property>
+ <property name="label" translatable="yes">This key has a special “empty tuple” type.
That’s probably an error of the application that installed this schema. If possible, please open a bug about
it.</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 943aaf2..6d2833b 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -26,6 +26,7 @@ class RegistryInfo : Grid, BrowsableView
[GtkChild] private Revealer one_choice_warning_revealer;
[GtkChild] private Label one_choice_enum_warning;
[GtkChild] private Label one_choice_integer_warning;
+ [GtkChild] private Label one_choice_tuple_warning;
[GtkChild] private ListBox properties_list_box;
[GtkChild] private Button erase_button;
@@ -166,9 +167,9 @@ class RegistryInfo : Grid, BrowsableView
bool is_key_editor_child_single = key_editor_child is KeyEditorChildSingle;
if (is_key_editor_child_single)
{
- bool is_enum = tmp_string == "<enum>";
- one_choice_integer_warning.visible = !is_enum;
- one_choice_enum_warning.visible = is_enum;
+ one_choice_enum_warning.visible = tmp_string == "<enum>";
+ one_choice_tuple_warning.visible = tmp_string == "()";
+ one_choice_integer_warning.visible = (tmp_string != "<enum>") && (tmp_string != "()");
}
one_choice_warning_revealer.set_reveal_child (is_key_editor_child_single);
@@ -334,6 +335,9 @@ class RegistryInfo : Grid, BrowsableView
range_content_or_null = ((GSettingsKey) key).range_content;
return (KeyEditorChild) new KeyEditorChildNullableBool (initial_value, delay_mode,
has_planned_change, range_content_or_null);
+ case "()":
+ return (KeyEditorChild) new KeyEditorChildSingle (new Variant ("()", "()"), "()");
+
default:
if ("a" in key.type_string)
return (KeyEditorChild) new KeyEditorChildArray (key.type_string, initial_value);
diff --git a/editor/setting-object.vala b/editor/setting-object.vala
index ecda72d..40e97ed 100644
--- a/editor/setting-object.vala
+++ b/editor/setting-object.vala
@@ -92,6 +92,8 @@ public abstract class Key : SettingObject
return _("Integer");
case "v":
return _("Variant");
+ case "()":
+ return _("Empty tuple");
default:
return type;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]