[dconf-editor] Add keyboard shortcuts for browsing pathbar.



commit 3a43b1845350919af66a2e1b8259f897270c13ef
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Aug 5 01:59:36 2016 +0200

    Add keyboard shortcuts for browsing pathbar.

 editor/dconf-window.vala |   18 ++++++++++++++++++
 editor/help-overlay.ui   |   40 +++++++++++++++++++++++++++++++++++++---
 editor/pathbar.vala      |   25 +++++++++++++++++++++++--
 3 files changed, 78 insertions(+), 5 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 42f6d77..ccf8832 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -331,6 +331,24 @@ class DConfWindow : ApplicationWindow
             }
         }
 
+        if (((event.state & Gdk.ModifierType.MOD1_MASK) != 0))
+        {
+            if (name == "Up")
+            {
+                if (current_path == "/")
+                    return true;
+                if ((event.state & Gdk.ModifierType.SHIFT_MASK) != 0)
+                    request_path ("/");
+                else if (current_path.has_suffix ("/"))
+                    request_path (current_path.slice (0, current_path.slice (0, current_path.length - 
1).last_index_of_char ('/') + 1));
+                else
+                    request_path (current_path.slice (0, current_path.last_index_of_char ('/') + 1));
+                return true;
+            }
+            else if (name == "Down")
+                return pathbar.open_child ((event.state & Gdk.ModifierType.SHIFT_MASK) != 0 ? null : 
current_path);
+        }
+
         /* don't use "else if", or some widgets will not be hidden on <ctrl>F10 or such things */
         if (name == "F10")
         {
diff --git a/editor/help-overlay.ui b/editor/help-overlay.ui
index 027c649..93c1e10 100644
--- a/editor/help-overlay.ui
+++ b/editor/help-overlay.ui
@@ -4,7 +4,7 @@
     <child>
       <object class="GtkShortcutsSection">
         <property name="visible">True</property>
-        <property name="max-height">8</property>
+        <property name="max-height">12</property>
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
@@ -44,13 +44,13 @@
                 <property name="accelerator">F10</property>
               </object>
             </child>
-            <child>
+            <!-- child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
                 <property name="title" translatable="yes" context="shortcut window">Current row 
menu</property>
                 <property name="accelerator">Menu</property>
               </object>
-            </child>
+            </child -->
           </object>
         </child>
         <child>
@@ -76,6 +76,40 @@
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
+            <property name="title" translatable="yes" context="shortcut window">Path bar 
navigation</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Open root 
folder</property>
+                <property name="accelerator">&lt;Alt&gt;&lt;Shift&gt;Up</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Open parent 
folder</property>
+                <property name="accelerator">&lt;Alt&gt;Up</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Open active direct 
child</property>
+                <property name="accelerator">&lt;Alt&gt;Down</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Open active last 
child</property>
+                <property name="accelerator">&lt;Alt&gt;&lt;Shift&gt;Down</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
             <property name="title" translatable="yes" context="shortcut window">Generic</property>
             <child>
               <object class="GtkShortcutsShortcut">
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index 8c31e29..9018051 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -22,18 +22,24 @@ public class PathBar : Box, PathElement
 {
     [GtkChild] private Button root_button;
 
+    private string complete_path = "";
+
     construct
     {
         add_slash_label ();
         root_button.clicked.connect (() => request_path ("/"));
     }
 
+    /*\
+    * * public calls
+    \*/
+
     public void set_path (string path)
         requires (path [0] == '/')
     {
         root_button.set_sensitive (path != "/");
 
-        string complete_path = "";
+        complete_path = "";
         string [] split = path.split ("/", /* max tokens disabled */ 0);
         string last = split [split.length - 1];
         bool is_key_path = last != "";
@@ -52,6 +58,7 @@ public class PathBar : Box, PathElement
 
                 if (maintain_all)
                 {
+                    complete_path += ((PathBarItem) child).text_string;
                     child.set_sensitive (true);
                     return;
                 }
@@ -101,8 +108,22 @@ public class PathBar : Box, PathElement
         show_all ();
     }
 
+    public bool open_child (string? current_path)
+    {
+        if (current_path == null)
+        {
+            request_path (complete_path);
+            return true;
+        }
+        if (current_path == complete_path)
+            return false;
+        int index_of_last_slash = complete_path.index_of ("/", ((!) current_path).length);
+        request_path (index_of_last_slash == -1 ? complete_path : complete_path.slice (0, 
index_of_last_slash + 1));
+        return true;
+    }
+
     /*\
-    * * widgets
+    * * widgets creation
     \*/
 
     private void add_slash_label ()


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