[dconf-editor] Specify current value in RegistryInfo.



commit d6e46eb21bccdc006b2c7eebf56c213c1c18d7f1
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jul 18 16:30:53 2016 +0200

    Specify current value in RegistryInfo.

 editor/registry-info.vala |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index a60d2be..dcb9211 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -60,6 +60,17 @@ class RegistryInfo : Grid
 
         if (!dict.lookup ("type-code",    "s", out tmp_string)) assert_not_reached ();
 
+        Label label = new Label (get_current_value_text (has_schema && ((GSettingsKey) key).is_default, 
key));
+        key.value_changed.connect (() => { label.set_text (get_current_value_text (has_schema && 
((GSettingsKey) key).is_default, key)); });
+        label.halign = Align.START;
+        label.xalign = 0;
+        label.yalign = 0;
+        label.hexpand = true;
+        label.show ();
+        add_row_from_widget (_("Current value"), label, null);
+
+        add_separator ();
+
         bool disable_revealer_for_value = false;
         KeyEditorChild key_editor_child = create_child (key);
         if (has_schema)
@@ -163,6 +174,14 @@ class RegistryInfo : Grid
         }
     }
 
+    private static string get_current_value_text (bool is_default, Key key)
+    {
+        if (is_default)
+            return _("Default value");
+        else
+            return Key.cool_text_value_from_variant (key.value, key.type_string);
+    }
+
     /*\
     * * Rows creation
     \*/
@@ -177,6 +196,17 @@ class RegistryInfo : Grid
         properties_list_box.add (new PropertyRow.from_widgets (property_name, widget, type != null ? 
add_warning ((!) type) : null));
     }
 
+    private void add_separator ()
+    {
+        Separator separator = new Separator (Orientation.HORIZONTAL);
+        separator.halign = Align.CENTER;
+        separator.width_request = 620;
+        separator.margin_bottom = 5;
+        separator.margin_top = 5;
+        separator.show ();
+        properties_list_box.add (separator);
+    }
+
     private static Widget? add_warning (string type)
     {
         if (type != "<flags>" && ((type != "s" && "s" in type) || (type != "g" && "g" in type)) || (type != 
"o" && "o" in type))
@@ -195,10 +225,8 @@ class RegistryInfo : Grid
     private static Widget warning_label (string text)
     {
         Label label = new Label (text);
-        label.visible = true;
         label.max_width_chars = 59;
         label.wrap = true;
-        label.halign = Align.START;
         StyleContext context = label.get_style_context ();
         context.add_class ("italic-label");
         context.add_class ("greyed-label");
@@ -237,10 +265,11 @@ private class PropertyRow : ListBoxRow
 
         if (warning != null)
         {
+            ((!) warning).hexpand = true;
+            ((!) warning).halign = Align.CENTER;
+            ((!) warning).show ();
             grid.row_spacing = 4;
             grid.attach ((!) warning, 0, 1, 2, 1);
-            warning.hexpand = true;
-            warning.halign = Align.CENTER;
         }
     }
 }


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