[dconf-editor] Rework KeyEditorChildFlags constructor.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Rework KeyEditorChildFlags constructor.
- Date: Thu, 1 Feb 2018 01:20:42 +0000 (UTC)
commit e1afe557deb93901c32c9874ffdea78599d7b020
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Feb 1 02:05:15 2018 +0100
Rework KeyEditorChildFlags constructor.
editor/dconf-view.vala | 26 ++++++++++++--------------
editor/registry-info.vala | 11 ++++++++++-
2 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index 76d623f..36ada7a 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -91,12 +91,15 @@ private class KeyEditorChildEnum : MenuButton, KeyEditorChild
private class KeyEditorChildFlags : Grid, KeyEditorChild
{
+ private string [] all_flags;
+ private ContextPopover popover = new ContextPopover ();
+
private Variant variant;
private Label label = new Label ("");
- public KeyEditorChildFlags (GSettingsKey key, Variant initial_value, ModificationsHandler
modifications_handler)
- requires (key.type_string == "<flags>")
+ public KeyEditorChildFlags (Variant initial_value, string [] _all_flags, string [] active_flags)
{
+ all_flags = _all_flags;
this.visible = true;
this.hexpand = true;
this.orientation = Orientation.HORIZONTAL;
@@ -114,18 +117,7 @@ private class KeyEditorChildFlags : Grid, KeyEditorChild
label.hexpand = true;
this.add (label);
- ContextPopover popover = new ContextPopover ();
-
- string [] all_flags = key.range_content.get_strv ();
- popover.create_flags_list (key.settings.get_strv (key.name), all_flags);
- GSettingsKey ref_key = key;
- ulong delayed_modifications_changed_handler = modifications_handler.delayed_changes_changed.connect
(() => {
- string [] active_flags = modifications_handler.get_key_custom_value (ref_key).get_strv ();
- foreach (string flag in all_flags)
- popover.update_flag_status (flag, flag in active_flags);
- });
- popover.destroy.connect (() => modifications_handler.disconnect
(delayed_modifications_changed_handler));
-
+ popover.create_flags_list (active_flags, all_flags);
popover.set_relative_to (button);
popover.value_changed.connect ((gvariant) => {
if (gvariant == null) // TODO better (2/3)
@@ -137,6 +129,12 @@ private class KeyEditorChildFlags : Grid, KeyEditorChild
button.set_popover ((Popover) popover);
}
+ public void update_flags (string [] active_flags)
+ {
+ foreach (string flag in all_flags)
+ popover.update_flag_status (flag, flag in active_flags);
+ }
+
public Variant get_variant ()
{
return variant;
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 0cd1c04..44ff6bf 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -276,7 +276,16 @@ class RegistryInfo : Grid, BrowsableView
}
case "<flags>":
- return (KeyEditorChild) new KeyEditorChildFlags ((GSettingsKey) key, initial_value,
modifications_handler);
+ string [] all_flags = ((GSettingsKey) key).range_content.get_strv ();
+ string [] active_flags = ((GSettingsKey) key).settings.get_strv (key.name);
+ KeyEditorChildFlags key_editor_child_flags = new KeyEditorChildFlags (initial_value,
all_flags, active_flags);
+
+ ulong delayed_modifications_changed_handler =
modifications_handler.delayed_changes_changed.connect (() => {
+ active_flags = modifications_handler.get_key_custom_value (key).get_strv ();
+ key_editor_child_flags.update_flags (active_flags);
+ });
+ key_editor_child_flags.destroy.connect (() => modifications_handler.disconnect
(delayed_modifications_changed_handler));
+ return (KeyEditorChild) key_editor_child_flags;
case "b":
return (KeyEditorChild) new KeyEditorChildBool (initial_value.get_boolean ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]