[dconf-editor] Fix Up and Down keyboard inputs.



commit 9113179d2953a768208bcf13244d8654b91bef67
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Nov 29 08:01:06 2018 +0100

    Fix Up and Down keyboard inputs.

 editor/bookmarks.vala              |  8 +++----
 editor/browser-headerbar.vala      | 16 ++++++++-----
 editor/browser-view.vala           | 32 ++++++++-----------------
 editor/dconf-window.vala           | 48 +++++++++++++++++++-------------------
 editor/modifications-revealer.vala |  8 +++----
 editor/overlayed-list.vala         | 20 +++++++++-------
 6 files changed, 63 insertions(+), 69 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 39e86bb..1b1bd6d 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -195,16 +195,16 @@ private class Bookmarks : MenuButton
 
     // keyboard call
 
-    internal void next_match ()
+    internal bool next_match ()
         requires (active)
     {
-        bookmarks_list.next_match ();
+        return bookmarks_list.next_match ();
     }
 
-    internal void previous_match ()
+    internal bool previous_match ()
         requires (active)
     {
-        bookmarks_list.previous_match ();
+        return bookmarks_list.previous_match ();
     }
 
     internal void bookmark_current_path ()
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index 17ca582..8139274 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -121,20 +121,24 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
         return path_widget.handle_event (event);
     }
 
-    internal void next_match ()
+    internal bool next_match ()
     {
         if (info_button.active)
-            return;
+            return false;
         if (bookmarks_button.active)
-            bookmarks_button.next_match ();
+            return bookmarks_button.next_match ();
+        else
+            return false;
     }
 
-    internal void previous_match ()
+    internal bool previous_match ()
     {
         if (info_button.active)
-            return;
+            return false;
         if (bookmarks_button.active)
-            bookmarks_button.previous_match ();
+            return bookmarks_button.previous_match ();
+        else
+            return false;
     }
 
     internal void close_popovers ()
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 1655dd8..fc3b046 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -523,34 +523,22 @@ private class BrowserView : Stack, AdaptativeWidget
     internal bool next_match ()
     {
         if (in_window_bookmarks)
-        {
-            bookmarks_list.next_match ();
-            return true;
-        }
-        else if (in_window_modifications)
-        {
-            modifications_list.next_match ();
-            return true;
-        }
-        else if (in_window_about)
-            return true;
+            return bookmarks_list.next_match ();
+        if (in_window_modifications)
+            return modifications_list.next_match ();
+        if (in_window_about)
+            return false;       // TODO scroll down at last line
         else
             return current_child.next_match ();
     }
     internal bool previous_match ()
     {
         if (in_window_bookmarks)
-        {
-            bookmarks_list.previous_match ();
-            return true;
-        }
-        else if (in_window_modifications)
-        {
-            modifications_list.previous_match ();
-            return true;
-        }
-        else if (in_window_about)
-            return true;
+            return bookmarks_list.previous_match ();
+        if (in_window_modifications)
+            return modifications_list.previous_match ();
+        if (in_window_about)
+            return false;
         else
             return current_child.previous_match ();
     }
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index ee18ed3..9836aee 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -1135,22 +1135,30 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
 
     private void next_match                             (/* SimpleAction action, Variant? variant */)   // 
See also "Down"
     {
-        if (headerbar.has_popover ()) // for bookmarks popover, let headerbar handle that
-            headerbar.next_match ();
-        else if (revealer.get_modifications_list_state ())
-            revealer.next_match ();
+        _next_match ();         // NOTE returns bool
+    }
+    private bool _next_match ()
+    {
+        if (headerbar.has_popover ())                   // for bookmarks popover
+            return headerbar.next_match ();
+        if (revealer.get_modifications_list_state ())   // for modifications popover
+            return revealer.next_match ();
         else
-            browser_view.next_match ();             // FIXME returns bool
+            return browser_view.next_match ();          // for in-window things and main list
     }
 
     private void previous_match                         (/* SimpleAction action, Variant? variant */)   // 
See also "Up"
     {
-        if (headerbar.has_popover ()) // for bookmarks popover, let headerbar handle that
-            headerbar.previous_match ();
-        else if (revealer.get_modifications_list_state ())
-            revealer.previous_match ();
+        _previous_match ();     // NOTE returns bool
+    }
+    private bool _previous_match ()
+    {
+        if (headerbar.has_popover ())                   // for bookmarks popover
+            return headerbar.previous_match ();
+        if (revealer.get_modifications_list_state ())   // for modifications popover
+            return revealer.previous_match ();
         else
-            browser_view.previous_match ();         // FIXME returns bool
+            return browser_view.previous_match ();      // for in-window things and main list
     }
 
     private void _request_config                        (/* SimpleAction action, Variant? variant */)  // 
TODO unduplicate method name
@@ -1608,6 +1616,12 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
             }
         }
 
+        /* for changing row during search; cannot use set_accels_for_action() else popovers are not handled 
anymore */
+        if (name == "Down" && (event.state & Gdk.ModifierType.MOD1_MASK) == 0)  // see also <ctrl>g
+            return _next_match ();
+        if (name == "Up"   && (event.state & Gdk.ModifierType.MOD1_MASK) == 0)  // see also <ctrl>G
+            return _previous_match ();
+
         if (browser_view.in_window_bookmarks)
             return false;
         if (browser_view.in_window_modifications)
@@ -1625,20 +1639,6 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
             return true;
         }
 
-        /* for changing row during search; cannot use set_accels_for_action() else popovers are not handled 
anymore */
-        if (name == "Down"
-         && (event.state & Gdk.ModifierType.MOD1_MASK) == 0
-         // see also <ctrl>g
-         && !headerbar.has_popover ()
-         && !revealer.get_modifications_list_state ())
-            return browser_view.next_match ();
-        if (name == "Up"
-         && (event.state & Gdk.ModifierType.MOD1_MASK) == 0
-         // see also <ctrl>G
-         && !headerbar.has_popover ()
-         && !revealer.get_modifications_list_state ())
-            return browser_view.previous_match ();
-
         if (name == "Return" || name == "KP_Enter")
         {
             if (browser_view.current_view == ViewType.SEARCH
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 1ebabc2..93a6b4b 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -139,14 +139,14 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
     * * keyboard calls
     \*/
 
-    internal void next_match ()
+    internal bool next_match ()
     {
-        modifications_list.next_match ();
+        return modifications_list.next_match ();
     }
 
-    internal void previous_match ()
+    internal bool previous_match ()
     {
-        modifications_list.previous_match ();
+        return modifications_list.previous_match ();
     }
 
     /*\
diff --git a/editor/overlayed-list.vala b/editor/overlayed-list.vala
index c26b514..8e877f3 100644
--- a/editor/overlayed-list.vala
+++ b/editor/overlayed-list.vala
@@ -114,11 +114,11 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     * * keyboard
     \*/
 
-    internal void next_match ()
+    internal bool next_match ()
     {
-        _next_match (ref main_list_box);
+        return _next_match (ref main_list_box);
     }
-    private static inline void _next_match (ref ListBox main_list_box)
+    private static inline bool _next_match (ref ListBox main_list_box)
     {
         ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows and focus-only lists
         if (row == null)
@@ -129,21 +129,22 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
         if (row == null)
         {
             _scroll_bottom (ref main_list_box);
-            return;
+            return false;
         }
         main_list_box.select_row ((!) row);
         ((!) row).grab_focus ();
+        return true;
     }
 
-    internal void previous_match ()
+    internal bool previous_match ()
     {
-        _previous_match (ref main_list_box);
+        return _previous_match (ref main_list_box);
     }
-    private static inline void _previous_match (ref ListBox main_list_box)
+    private static inline bool _previous_match (ref ListBox main_list_box)
     {
         uint n_items = main_list_box.get_children ().length ();  // FIXME OverlayedList.n_items is unreliable
         if (n_items == 0)
-            return;
+            return false;
 
         ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows and focus-only lists
         if (row == null)
@@ -152,7 +153,7 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
         {
             int index = ((!) row).get_index ();
             if (index <= 0)
-                return;
+                return false;
             row = main_list_box.get_row_at_index (index - 1);
         }
 
@@ -161,6 +162,7 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
 
         main_list_box.select_row ((!) row);
         ((!) row).grab_focus ();
+        return true;
     }
 
     internal void select_all ()


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