[dconf-editor] Add config entry in Pathbar menu.



commit 38e04dea28fc81d16b61e7bf6e15ea532fecd9bc
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jan 4 17:58:47 2019 +0100

    Add config entry in Pathbar menu.
    
    The "Show folder informations" functionality does not look right
    as a browsable entry of the keys list. So, let's place it in the
    pathbar menu, where it looks good, and disable it for now, as it
    is not done, and probably will not be for the next release 3.32.

 editor/adaptative-pathbar.vala | 26 ++++++++++++++++++++++++--
 editor/browser-window.vala     |  8 ++++++++
 editor/dconf-window.vala       |  6 +++++-
 editor/large-pathbar.vala      | 13 +++++++------
 editor/short-pathbar.vala      |  7 +------
 5 files changed, 45 insertions(+), 15 deletions(-)
---
diff --git a/editor/adaptative-pathbar.vala b/editor/adaptative-pathbar.vala
index 77e9e6e..bc24b6d 100644
--- a/editor/adaptative-pathbar.vala
+++ b/editor/adaptative-pathbar.vala
@@ -209,11 +209,33 @@ private interface Pathbar
         return index_of_last_slash == -1 ? complete_path : complete_path.slice (0, index_of_last_slash + 1);
     }
 
-    /* called from inside the pathbar, by ShortPathbar and LargePathbarItem (so cannot make "protected") */
-    internal static void add_copy_path_entry (ref GLib.Menu section)
+    /* called from inside the pathbar, by ShortPathbar and LargePathbar*Item* (so cannot make "protected") */
+    internal static void populate_pathbar_menu (bool is_folder, ref GLib.Menu menu)
     {
+        add_copy_path_section (ref menu);
+        if (is_folder)
+            add_open_config_section (ref menu);
+    }
+
+    private static void add_copy_path_section (ref GLib.Menu menu)
+    {
+        GLib.Menu section = new GLib.Menu ();
         /* Translators: menu entry of the pathbar menu */
         section.append (_("Copy current path"), "base.copy-alt");
         // or "app.copy(\"" + get_action_target_value ().get_string () + "\")"
+        section.freeze ();
+        menu.append_section (null, section);
+    }
+
+    private static void add_open_config_section (ref GLib.Menu menu)
+    {
+        // method "disabled" for now
+        return;
+
+        GLib.Menu section = new GLib.Menu ();
+        /* Translators: menu entry of the pathbar menu (not displayed for now) */
+        section.append (_("Show properties"), "browser.open-config-local");
+        section.freeze ();
+        menu.append_section (null, section);
     }
 }
diff --git a/editor/browser-window.vala b/editor/browser-window.vala
index 1e6453c..46265a6 100644
--- a/editor/browser-window.vala
+++ b/editor/browser-window.vala
@@ -84,6 +84,7 @@ private abstract class BrowserWindow : BaseWindow
         { "open-folder",        open_folder, "s" },
         { "open-object",        open_object, "(sq)" },
         { "open-config",        open_config, "s" },
+        { "open-config-local",  open_config_local },
         { "open-search",        open_search, "s" },
         { "next-search",        next_search, "s" },
         { "open-parent",        open_parent, "s" },
@@ -133,6 +134,13 @@ private abstract class BrowserWindow : BaseWindow
         request_config (full_name);
     }
 
+    private void open_config_local (/* SimpleAction action, Variant? path_variant */)
+    {
+        headerbar.close_popovers ();
+
+        request_config (current_path);
+    }
+
     private void open_search (SimpleAction action, Variant? search_variant)
         requires (search_variant != null)
     {
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index e83077b..185173a 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -963,7 +963,11 @@ private class DConfWindow : BrowserWindow
         GLib.ListStore key_model = new GLib.ListStore (typeof (SimpleSettingObject));
 
         string name = ModelUtils.get_name (base_path);
-        SimpleSettingObject sso = new SimpleSettingObject.from_full_name (ModelUtils.folder_context_id, 
name, base_path, false, true);
+        SimpleSettingObject sso = new SimpleSettingObject.from_full_name (/* context id */ 
ModelUtils.folder_context_id,
+                                                                          /* name       */ name,
+                                                                          /* base path  */ base_path,
+                                                                          /* is search  */ false,
+                                                                          /* is special */ true);
         key_model.append (sso);
 
         if (children != null)
diff --git a/editor/large-pathbar.vala b/editor/large-pathbar.vala
index 1e7d21d..311d883 100644
--- a/editor/large-pathbar.vala
+++ b/editor/large-pathbar.vala
@@ -278,13 +278,13 @@ private class LargePathbar : Box, Pathbar
     {
         Variant variant = new Variant.string (complete_path);
         string _variant = variant.print (false);
-        path_bar_item = new LargePathbarItem (label, "browser.open-folder(" + _variant + ")", 
"ui.notify-folder-emptied(" + _variant + ")");
+        path_bar_item = new LargePathbarItem (label, "browser.open-folder(" + _variant + ")", 
"ui.notify-folder-emptied(" + _variant + ")", true);
     }
     private static inline void init_object_path_bar_item (string label, string complete_path, out 
LargePathbarItem path_bar_item)
     {
         Variant variant = new Variant ("(sq)", complete_path, ModelUtils.undefined_context_id);
         string _variant = variant.print (true);
-        path_bar_item = new LargePathbarItem (label, "browser.open-object(" + _variant + ")", 
"ui.notify-object-deleted(" + _variant + ")");
+        path_bar_item = new LargePathbarItem (label, "browser.open-object(" + _variant + ")", 
"ui.notify-object-deleted(" + _variant + ")", false);
     }
 
     private void activate_item (LargePathbarItem item, bool state)   // never called when current_view is 
search
@@ -336,7 +336,8 @@ private class LargePathbarItem : Button
     [CCode (notify = false)] public string alternative_action { internal get; internal construct; }
     [CCode (notify = false)] public string default_action     { internal get; internal construct; }
     [CCode (notify = false)] public string text_string        { internal get; internal construct; }
- 
+    [CCode (notify = false)] public bool   has_config_menu    { private get;  internal construct; }
+
     [GtkChild] private Label text_label;
     private Popover? popover = null;
 
@@ -397,9 +398,9 @@ private class LargePathbarItem : Button
         ((!) popover).popup ();
     }
 
-    internal LargePathbarItem (string label, string _default_action, string _alternative_action)
+    internal LargePathbarItem (string label, string _default_action, string _alternative_action, bool 
_has_config_menu)
     {
-        Object (text_string: label, default_action: _default_action, alternative_action: 
_alternative_action);
+        Object (text_string: label, default_action: _default_action, alternative_action: 
_alternative_action, has_config_menu: _has_config_menu);
         text_label.set_text (label);
         set_detailed_action_name (_default_action);
     }
@@ -429,7 +430,7 @@ private class LargePathbarItem : Button
     private void generate_popover ()
     {
         GLib.Menu menu = new GLib.Menu ();
-        Pathbar.add_copy_path_entry (ref menu);
+        Pathbar.populate_pathbar_menu (/* is folder */ has_config_menu, ref menu);
         menu.freeze ();
 
         popover = new Popover.from_model (this, (MenuModel) menu);
diff --git a/editor/short-pathbar.vala b/editor/short-pathbar.vala
index e7c316c..a11e57f 100644
--- a/editor/short-pathbar.vala
+++ b/editor/short-pathbar.vala
@@ -142,12 +142,7 @@ private class ShortPathbar : Grid, Pathbar
         section.freeze ();
         menu.append_section (null, section);
 
-        section = new GLib.Menu ();
-
-        Pathbar.add_copy_path_entry (ref section);
-
-        section.freeze ();
-        menu.append_section (null, section);
+        Pathbar.populate_pathbar_menu (/* is folder */ last == "", ref menu);
 
         menu.freeze ();
     }


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