[dconf-editor] Save current_type.



commit 2aa44c57e18b49309182a27100bbfe6eac94a8b3
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Feb 16 11:54:08 2018 +0100

    Save current_type.

 editor/browser-view.vala |   15 +++++----------
 editor/dconf-window.vala |    8 +++++---
 2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index e8b0e94..6f9b55f 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -203,37 +203,32 @@ class BrowserView : Grid
             info_bar.show_warning ("soft-reload-folder");
     }
 
-    private void show_hard_reload_warning ()
-    {
-        info_bar.show_warning (current_view == ViewType.FOLDER ? "hard-reload-folder" : 
"hard-reload-object");
-    }
-
     public void reload_search (string current_path, string [] bookmarks)
     {
         hide_reload_warning ();
         current_child.reload_search (current_path, bookmarks, sorting_options);
     }
 
-    public bool check_reload (string path, bool show_infobar)
+    public bool check_reload (ViewType type, string path, bool show_infobar)
     {
         SettingsModel model = modifications_handler.model;
 
-        if (current_view == ViewType.FOLDER)
+        if (type == ViewType.FOLDER)
         {
             GLib.ListStore? fresh_key_model = model.get_children (path);
             if (fresh_key_model != null && !current_child.check_reload_folder ((!) fresh_key_model))
                 return false;
         }
-        else if (current_view == ViewType.OBJECT)
+        else if (type == ViewType.OBJECT)
         {
             Variant? properties = model.get_key_properties (path, last_context);
             if (properties != null && !current_child.check_reload_object ((!) properties))
                 return false;
         }
 
-        if (show_infobar && current_view != ViewType.SEARCH)
+        if (show_infobar && type != ViewType.SEARCH)
         {
-            show_hard_reload_warning ();
+            info_bar.show_warning (type == ViewType.FOLDER ? "hard-reload-folder" : "hard-reload-object");
             return false;
         }
         return true;
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 3799ab4..736c4b5 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -35,6 +35,7 @@ public enum ViewType {
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/dconf-editor.ui")]
 class DConfWindow : ApplicationWindow
 {
+    private ViewType current_type = ViewType.FOLDER;
     private string current_path = "/";
 
     private SettingsModel model = new SettingsModel ();
@@ -203,7 +204,7 @@ class DConfWindow : ApplicationWindow
         model.finalize_model ();
 
         model.paths_changed.connect ((_model, modified_path_specs, internal_changes) => {
-                if (browser_view.check_reload (current_path, !internal_changes))    // handle infobars in 
needed
+                if (browser_view.check_reload (current_type, current_path, !internal_changes))    // handle 
infobars in needed
                 {
                     if (internal_changes)
                         reload_view ();
@@ -601,6 +602,7 @@ class DConfWindow : ApplicationWindow
     private void update_current_path (ViewType type, string path)
         requires (type != ViewType.SEARCH)
     {
+        current_type = type;
         current_path = path;
         browser_view.set_path (type, path);
         bookmarks_button.set_path (type, path);
@@ -614,7 +616,7 @@ class DConfWindow : ApplicationWindow
 
         GLib.Menu menu = new GLib.Menu ();
 
-        if (SettingsModel.is_key_path (current_path))   // mainly here for ensuring menu is never empty
+        if (current_type == ViewType.OBJECT)   // mainly here for ensuring menu is never empty
         {
             Variant variant = new Variant.string (model.get_key_copy_text (current_path, 
browser_view.last_context));
             menu.append (_("Copy descriptor"), "app.copy(" + variant.print (false) + ")");
@@ -741,7 +743,7 @@ class DConfWindow : ApplicationWindow
                     browser_view.discard_row_popover (); // TODO avoid duplicate get_selected_row () call
 
                     string? selected_row_text = browser_view.get_copy_text ();
-                    if (selected_row_text == null && SettingsModel.is_key_path (current_path))
+                    if (selected_row_text == null && current_type == ViewType.OBJECT)
                         selected_row_text = model.get_key_copy_text (current_path, 
browser_view.last_context);
                     ConfigurationEditor application = (ConfigurationEditor) get_application ();
                     application.copy (selected_row_text == null ? current_path : (!) selected_row_text);


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