[dconf-editor] Try to restore selection when entering delay mode.



commit 32aeb0095ffb77a7a62154c56646f2087bbd6556
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Feb 9 02:18:31 2018 +0100

    Try to restore selection when entering delay mode.

 editor/dconf-window.vala  |    4 ++--
 editor/registry-view.vala |    4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 247f4cf..b7ae3b8 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -773,8 +773,8 @@ class DConfWindow : ApplicationWindow
                         return true;
                     }
                     browser_view.discard_row_popover ();
-                    string? selected_row = browser_view.get_selected_row_name ();
-                    if (selected_row != null && ((!) selected_row).has_suffix ("/"))
+                    string selected_row = browser_view.get_selected_row_name ();
+                    if (selected_row.has_suffix ("/"))
                         reset_path ((!) selected_row, true);
                     else
                         browser_view.set_selected_to_default ();
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 832e752..a44b197 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -206,6 +206,7 @@ class RegistryView : RegistryList
         requires (key_model != null)
     {
         uint position = 0;
+        uint fallback = 0;
         while (position < ((!) key_model).get_n_items ())
         {
             SettingObject object = (SettingObject) ((!) key_model).get_object (position);
@@ -215,10 +216,11 @@ class RegistryView : RegistryList
                  || context == ".dconf" && object is DConfKey // theorical?
                  || object is GSettingsKey && ((GSettingsKey) object).schema_id == context)
                     return (int) position;
+                fallback = position;
             }
             position++;
         }
-        return 0; // selected row may have been removed
+        return (int) fallback; // selected row may have been removed or context could be ""
     }
 
     /*\


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