[dconf-editor] Keyboard stuff.



commit 46c67fa100547f2024b28049e28d0d07dd110449
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jan 23 15:07:30 2017 +0100

    Keyboard stuff.

 editor/dconf-window.vala     |    8 ++++++
 editor/help-overlay.ui       |   55 +++++++++++++++++++++++++---------------
 editor/key-list-box-row.vala |    8 ++++++
 editor/registry-view.vala    |   56 ++++++++++++++++++++++++++++++------------
 4 files changed, 90 insertions(+), 37 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index d0c3329..9ec399e 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -348,6 +348,14 @@ class DConfWindow : ApplicationWindow
                         return false;   // help overlay
                     ((ConfigurationEditor) get_application ()).about_cb ();
                     return true;
+                case "Return":
+                case "KP_Enter":
+                    if (info_button.active || bookmarks_button.active)
+                        return false;
+                    registry_view.set_search_mode (false);
+                    registry_view.discard_row_popover ();
+                    registry_view.toggle_boolean_key ();
+                    return true;
                 default:
                     break;  // TODO make <ctrl>v work; https://bugzilla.gnome.org/show_bug.cgi?id=762257 is 
WONTFIX
             }
diff --git a/editor/help-overlay.ui b/editor/help-overlay.ui
index 93c1e10..5b17974 100644
--- a/editor/help-overlay.ui
+++ b/editor/help-overlay.ui
@@ -44,31 +44,38 @@
                 <property name="accelerator">F10</property>
               </object>
             </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 -->
           </object>
         </child>
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
-            <property name="title" translatable="yes" context="shortcut window">Clipboard</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">Copy 
descriptor</property>
-                <property name="accelerator">&lt;Primary&gt;c</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">Copy path</property>
-                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;c</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>
@@ -76,33 +83,39 @@
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
-            <property name="title" translatable="yes" context="shortcut window">Path bar 
navigation</property>
+            <property name="title" translatable="yes" context="shortcut window">Keys list actions</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>
+                <property name="title" translatable="yes" context="shortcut window">Contextual 
menu</property>
+                <property name="accelerator">Menu</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>
+                <property name="title" translatable="yes" context="shortcut window">Toggle boolean 
value</property>
+                <property name="accelerator">&lt;Primary&gt;Return</property>
               </object>
             </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes" context="shortcut window">Clipboard</property>
             <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>
+                <property name="title" translatable="yes" context="shortcut window">Copy 
descriptor</property>
+                <property name="accelerator">&lt;Primary&gt;c</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>
+                <property name="title" translatable="yes" context="shortcut window">Copy path</property>
+                <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;c</property>
               </object>
             </child>
           </object>
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 70b58f0..b0fc4a9 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -141,6 +141,7 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
         if (abstract_key.type_string == "b")
         {
             boolean_switch = new Switch ();
+            ((!) boolean_switch).can_focus = false;
             ((!) boolean_switch).valign = Align.CENTER;
             ((!) boolean_switch).show ();
             key_value_label.hide ();
@@ -158,6 +159,13 @@ private abstract class KeyListBoxRow : ClickableListBoxRow
     }
     private abstract Key abstract_key { get; }
     protected abstract void update ();
+
+    public void toggle_boolean_key ()
+    {
+        if (boolean_switch == null)
+            return;
+        ((!) boolean_switch).set_active (!((!) boolean_switch).get_active ());
+    }
 }
 
 private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index e8571d7..2382e69 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -197,7 +197,6 @@ class RegistryView : Grid, PathElement
 
         properties_view.populate_properties_list_box ((!) key);
         show_properties_view (full_name);
-        return;
     }
     private bool select_folder (string full_name)
     {
@@ -428,7 +427,7 @@ class RegistryView : Grid, PathElement
     }
 
     /*\
-    * * Search box
+    * * Keyboard calls
     \*/
 
     public void set_search_mode (bool? mode)    // mode is never 'true'...
@@ -441,7 +440,7 @@ class RegistryView : Grid, PathElement
 
     public bool handle_search_event (Gdk.EventKey event)
     {
-        if (stack.get_visible_child_name () != "browse-view")
+        if (is_not_browsing_view ())
             return false;
 
         return search_bar.handle_event (event);
@@ -449,10 +448,7 @@ class RegistryView : Grid, PathElement
 
     public bool show_row_popover ()
     {
-        if (stack.get_visible_child_name () != "browse-view")
-            return false;
-
-        ListBoxRow? selected_row = (ListBoxRow) key_list_box.get_selected_row ();
+        ListBoxRow? selected_row = get_key_row ();
         if (selected_row == null)
             return false;
 
@@ -464,26 +460,54 @@ class RegistryView : Grid, PathElement
 
     public string? get_copy_text ()
     {
-        if (stack.get_visible_child_name () != "browse-view")
+        if (is_not_browsing_view ())
             return properties_view.get_copy_text ();
+
+        ListBoxRow? selected_row = key_list_box.get_selected_row ();
+        if (selected_row == null)
+            return null;
         else
-        {
-            ListBoxRow? selected_row = key_list_box.get_selected_row ();
-            if (selected_row == null)
-                return null;
-            else
-                return ((ClickableListBoxRow) ((!) selected_row).get_child ()).get_text ();
-        }
+            return ((ClickableListBoxRow) ((!) selected_row).get_child ()).get_text ();
+    }
+
+    public void toggle_boolean_key ()
+    {
+        ListBoxRow? selected_row = get_key_row ();
+        if (selected_row == null)
+            return;
+
+        if (!(((!) selected_row).get_child () is KeyListBoxRow))
+            return;
+
+        ((KeyListBoxRow) ((!) selected_row).get_child ()).toggle_boolean_key ();
     }
 
     public void discard_row_popover ()
     {
-        ListBoxRow? selected_row = (ListBoxRow) key_list_box.get_selected_row ();
+        ListBoxRow? selected_row = get_key_row ();
         if (selected_row == null)
             return;
+
         ((ClickableListBoxRow) ((!) selected_row).get_child ()).hide_right_click_popover ();
     }
 
+    private bool is_not_browsing_view ()
+    {
+        string? visible_child_name = stack.get_visible_child_name ();
+        return (visible_child_name == null || ((!) visible_child_name) != "browse-view");
+    }
+
+    private ListBoxRow? get_key_row ()
+    {
+        if (is_not_browsing_view ())
+            return null;
+        return (ListBoxRow?) key_list_box.get_selected_row ();
+    }
+
+    /*\
+    * * Search box
+    \*/
+
     [GtkCallback]
     private void find_next_cb ()
     {


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