[dconf-editor] Add a panned_value variable in Key.



commit c9f46ceb0a39378de81e4a20a3840943bfcc2eff
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jun 10 03:12:38 2016 +0200

    Add a panned_value variable in Key.

 editor/dconf-model.vala            |    6 ++----
 editor/modifications-revealer.vala |   22 +++++++++-------------
 2 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 0883e4a..fe11d56 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -179,6 +179,7 @@ public abstract class Key : SettingObject
     public string type_string { get; protected set; default = "*"; }
     public Variant properties { owned get; protected set; }
 
+    public Variant? planned_value { get; set; default = null; }
     public abstract Variant value { owned get; set; }
 
     public signal void value_changed ();
@@ -329,17 +330,14 @@ public class DConfKey : Key
 
     public bool is_ghost { get; set; default = false; }
 
-    private Variant _value;
     public override Variant value
     {
         owned get
         {
-            _value = (!) client.read (full_name);
-            return _value;
+            return (!) client.read (full_name);
         }
         set
         {
-            _value = value;
             try
             {
                 client.write_sync (full_name, value);
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 3c34d10..084ffc9 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -26,7 +26,6 @@ class ModificationsRevealer : Revealer
     private GenericSet<string> gsettings_keys_awaiting_hashtable = new GenericSet<string> (str_hash, 
str_equal);
 
     private DConf.Client dconf_client = new DConf.Client ();
-    private HashTable<string, Variant?> dconf_values_hashtable = new HashTable<string, Variant?> (str_hash, 
str_equal);
     private HashTable<string, DConfKey> dconf_keys_awaiting_hashtable = new HashTable<string, DConfKey> 
(str_hash, str_equal);
 
     /*\
@@ -35,9 +34,8 @@ class ModificationsRevealer : Revealer
 
     public void add_delayed_dconf_settings (DConfKey key, Variant? new_value)
     {
-        string full_name = key.full_name;
-        dconf_values_hashtable.insert (full_name, new_value);
-        dconf_keys_awaiting_hashtable.insert (full_name, key);
+        key.planned_value = new_value;
+        dconf_keys_awaiting_hashtable.insert (key.full_name, key);
 
         update ();
     }
@@ -79,19 +77,14 @@ class ModificationsRevealer : Revealer
 
         /* DConf stuff */
 
+        DConf.Changeset dconf_changeset = new DConf.Changeset ();
         dconf_keys_awaiting_hashtable.foreach_remove ((full_name, key) => {
-                Variant? new_value = dconf_values_hashtable.lookup (full_name);
-                if (new_value == null)
+                dconf_changeset.set (full_name, key.planned_value);
+                if (key.planned_value == null)
                     key.is_ghost = true;
                 return true;
             });
 
-        DConf.Changeset dconf_changeset = new DConf.Changeset ();
-        dconf_values_hashtable.foreach_remove ((full_name, new_value) => {
-                dconf_changeset.set (full_name, new_value);
-                return true;
-            });
-
         try {
             dconf_client.change_sync (dconf_changeset);
         } catch (Error error) {
@@ -104,10 +97,13 @@ class ModificationsRevealer : Revealer
     {
         set_reveal_child (false);
 
+        /* GSettings stuff */
+
         delayed_settings_hashtable.foreach_remove ((schema_id, schema_settings) => { schema_settings.revert 
(); return true; });
         gsettings_keys_awaiting_hashtable.remove_all ();
 
-        dconf_values_hashtable.remove_all ();
+        /* DConf stuff */
+
         dconf_keys_awaiting_hashtable.remove_all ();
     }
 


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