[dconf-editor] Improve path restoration at startup.



commit 59d8c0ad71341d93a014d82a439588ae1a933a3c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Sep 14 11:09:42 2018 +0200

    Improve path restoration at startup.

 editor/ca.desrt.dconf-editor.gschema.xml |  5 +++++
 editor/dconf-window.vala                 | 19 +++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index 89dc573..b9cbf2b 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -118,6 +118,11 @@
       <summary>A flag to restore the last view</summary>
       <description>If “true”, Dconf Editor tries at launch to navigate to the path described in the 
“saved-view” key.</description>
     </key>
+    <key name="saved-pathbar-path" type="s">
+      <default>'/'</default>
+      <summary>A path to restore the pathbar state</summary>
+      <description>If the “restore-view” key is set to “true”, and if the path requested at startup is a 
parent path of this one, Dconf Editor tries to restore the pathbar state at this path.</description>
+    </key>
     <key name="saved-view" type="s">
       <default>'/'</default>
       <summary>A path to restore the last view</summary>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index ee0c5ac..88eb423 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -117,6 +117,16 @@ private class DConfWindow : ApplicationWindow
         settings.bind ("mouse-forward-button", this, "mouse-forward-button", 
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
 
         /* init current_path */
+        bool restore_view = settings.get_boolean ("restore-view");
+        if (restore_view)
+        {
+            string saved_path = settings.get_string ("saved-pathbar-path");
+            string fallback_path = model.get_fallback_path (saved_path);
+            /* path_widget.set_path (ModelUtils.is_folder_path (saved_path) ? ViewType.FOLDER : 
ViewType.OBJECT, saved_path);
+            path_widget.update_ghosts (fallback_path);  // TODO allow a complete state restoration 
(including search and this) */
+            path_widget.set_path (ModelUtils.is_folder_path (fallback_path) ? ViewType.FOLDER : 
ViewType.OBJECT, fallback_path);
+        }
+
         SchemasUtility schemas_utility = new SchemasUtility ();
         bool strict = false;
         string? first_path = path;
@@ -125,7 +135,7 @@ private class DConfWindow : ApplicationWindow
             if (key_name != null)
                 assert_not_reached ();
 
-            if (first_path == null && settings.get_boolean ("restore-view"))
+            if (first_path == null && restore_view)
                 first_path = settings.get_string ("saved-view");
         }
         else if (schemas_utility.is_relocatable_schema ((!) schema))
@@ -133,7 +143,7 @@ private class DConfWindow : ApplicationWindow
             if (first_path == null)
             {
                 warning (_("Schema is relocatable, a path is needed."));
-                if (settings.get_boolean ("restore-view"))
+                if (restore_view)
                     first_path = settings.get_string ("saved-view");
             }
             else
@@ -159,7 +169,7 @@ private class DConfWindow : ApplicationWindow
             else if (first_path != null && first_path != schema_path)
             {
                 warning (_("Schema is not installed on given path."));
-                if (settings.get_boolean ("restore-view"))
+                if (restore_view)
                     first_path = settings.get_string ("saved-view");
             }
             else if (key_name == null)
@@ -174,7 +184,7 @@ private class DConfWindow : ApplicationWindow
         {
             if ((!) schema != "")
                 warning (_("Unknown schema “%s”.").printf ((!) schema));
-            if (settings.get_boolean ("restore-view"))
+            if (restore_view)
                 first_path = settings.get_string ("saved-view");
         }
 
@@ -410,6 +420,7 @@ private class DConfWindow : ApplicationWindow
 
         settings.delay ();
         settings.set_string ("saved-view", saved_view);
+        settings.set_string ("saved-pathbar-path", path_widget.complete_path);
         if (window_width <= 630)    settings.set_int ("window-width", 630);
         else                        settings.set_int ("window-width", window_width);
         if (window_height <= 420)   settings.set_int ("window-height", 420);


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