[dconf-editor] Rework KeyEditorChildEnum constructor.



commit 43a503ea92e2c7599d0fd8c3f49a99eb251b32d7
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Feb 1 00:48:59 2018 +0100

    Rework KeyEditorChildEnum constructor.

 editor/dconf-view.vala    |   10 ++--------
 editor/registry-info.vala |   11 ++++++++---
 2 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index f8239ce..da67c1f 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -51,8 +51,7 @@ private class KeyEditorChildEnum : MenuButton, KeyEditorChild
     private Variant variant;
     private GLib.Action action;
 
-    public KeyEditorChildEnum (Key key, Variant initial_value, ModificationsHandler modifications_handler)
-        requires (key.type_string == "<enum>")
+    public KeyEditorChildEnum (Variant initial_value, bool delay_mode, bool has_planned_change, Variant 
range_content)
     {
         this.visible = true;
         this.hexpand = true;
@@ -61,12 +60,7 @@ private class KeyEditorChildEnum : MenuButton, KeyEditorChild
         this.width_request = 100;
 
         ContextPopover popover = new ContextPopover ();
-        action = popover.create_buttons_list (false,
-                                              modifications_handler.get_current_delay_mode (),
-                                              modifications_handler.key_has_planned_change (key.full_name),
-                                              "<enum>",
-                                              modifications_handler.get_key_custom_value (key),
-                                              ((GSettingsKey) key).range_content);
+        action = popover.create_buttons_list (false, delay_mode, has_planned_change, "<enum>", 
initial_value, range_content);
         popover.set_relative_to (this);
 
         popover.value_changed.connect ((gvariant) => {
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 6f9a4fc..e033936 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -265,9 +265,14 @@ class RegistryInfo : Grid, BrowsableView
             case "<enum>":
                 switch (((GSettingsKey) key).range_content.n_children ())
                 {
-                    case 0:  assert_not_reached ();
-                    case 1:  return (KeyEditorChild) new KeyEditorChildSingle (model.get_key_value (key), 
model.get_key_value (key).get_string ());
-                    default: return (KeyEditorChild) new KeyEditorChildEnum (key, initial_value, 
modifications_handler);
+                    case 0: assert_not_reached ();
+                    case 1:
+                        return (KeyEditorChild) new KeyEditorChildSingle (model.get_key_value (key), 
model.get_key_value (key).get_string ());
+                    default:
+                        bool delay_mode = modifications_handler.get_current_delay_mode ();
+                        bool has_planned_change = modifications_handler.key_has_planned_change 
(key.full_name);
+                        Variant range_content = ((GSettingsKey) key).range_content;
+                        return (KeyEditorChild) new KeyEditorChildEnum (initial_value, delay_mode, 
has_planned_change, range_content);
                 }
             case "<flags>":
                 return (KeyEditorChild) new KeyEditorChildFlags ((GSettingsKey) key, initial_value, 
modifications_handler);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]