[dconf-editor] Rename and fix up_pressed and down_pressed.



commit 11f835645f0dddc3a5cf6be573d6c87ffe02c4c5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Nov 28 12:46:39 2018 +0100

    Rename and fix up_pressed and down_pressed.

 editor/bookmarks.vala              |  8 ++++----
 editor/browser-headerbar.vala      |  8 ++++----
 editor/browser-stack.vala          |  8 ++++----
 editor/browser-view.vala           | 26 ++++++++++++++++++++------
 editor/dconf-window.vala           | 28 ++++++++++++++++------------
 editor/modifications-revealer.vala | 14 ++++++++++++++
 editor/overlayed-list.vala         | 17 +++++++++--------
 editor/registry-list.vala          | 18 +++++++++++++-----
 8 files changed, 84 insertions(+), 43 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index c6465ce..39e86bb 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -195,16 +195,16 @@ private class Bookmarks : MenuButton
 
     // keyboard call
 
-    internal void down_pressed ()
+    internal void next_match ()
         requires (active)
     {
-        bookmarks_list.down_pressed ();
+        bookmarks_list.next_match ();
     }
 
-    internal void up_pressed ()
+    internal void previous_match ()
         requires (active)
     {
-        bookmarks_list.up_pressed ();
+        bookmarks_list.previous_match ();
     }
 
     internal void bookmark_current_path ()
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index 4795392..74f5df9 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -115,20 +115,20 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
         return path_widget.handle_event (event);
     }
 
-    internal void down_pressed ()
+    internal void next_match ()
     {
         if (info_button.active)
             return;
         if (bookmarks_button.active)
-            bookmarks_button.down_pressed ();
+            bookmarks_button.next_match ();
     }
 
-    internal void up_pressed ()
+    internal void previous_match ()
     {
         if (info_button.active)
             return;
         if (bookmarks_button.active)
-            bookmarks_button.up_pressed ();
+            bookmarks_button.previous_match ();
     }
 
     internal void close_popovers ()
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index 6483223..a022cab 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -216,17 +216,17 @@ private class BrowserStack : Grid, AdaptativeWidget
         return search_view.return_pressed ();
     }
 
-    internal bool up_pressed ()
+    internal bool next_match ()
     {
         if (ViewType.displays_objects_list (current_view))
-            return ((RegistryList) stack.get_visible_child ()).up_or_down_pressed (false);
+            return ((RegistryList) stack.get_visible_child ()).next_match ();
         return false;
     }
 
-    internal bool down_pressed ()
+    internal bool previous_match ()
     {
         if (ViewType.displays_objects_list (current_view))
-            return ((RegistryList) stack.get_visible_child ()).up_or_down_pressed (true);
+            return ((RegistryList) stack.get_visible_child ()).previous_match ();
         return false;
     }
 }
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 74bc2dc..faa7e54 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -488,25 +488,39 @@ private class BrowserView : Stack, AdaptativeWidget
 
     // keyboard
     internal bool return_pressed ()   { return current_child.return_pressed ();   }
-    internal bool up_pressed ()
+    internal bool next_match ()
     {
         if (in_window_bookmarks)
         {
-            bookmarks_list.up_pressed ();
+            bookmarks_list.next_match ();
             return true;
         }
+        else if (in_window_modifications)
+        {
+            modifications_list.next_match ();
+            return true;
+        }
+        else if (in_window_about)
+            return true;
         else
-            return current_child.up_pressed ();
+            return current_child.next_match ();
     }
-    internal bool down_pressed ()
+    internal bool previous_match ()
     {
         if (in_window_bookmarks)
         {
-            bookmarks_list.down_pressed ();
+            bookmarks_list.previous_match ();
             return true;
         }
+        else if (in_window_modifications)
+        {
+            modifications_list.previous_match ();
+            return true;
+        }
+        else if (in_window_about)
+            return true;
         else
-            return current_child.down_pressed ();
+            return current_child.previous_match ();
     }
 
     internal bool toggle_row_popover ()     // Menu
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index b1bc1f5..d5b5654 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -1126,17 +1126,21 @@ 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.down_pressed ();
-        else if (!revealer.get_modifications_list_state () && !browser_view.in_window_modifications)
-            browser_view.down_pressed ();               // FIXME returns bool
+            headerbar.next_match ();
+        else if (revealer.get_modifications_list_state ())
+            revealer.next_match ();
+        else
+            browser_view.next_match ();             // FIXME returns bool
     }
 
     private void previous_match                         (/* SimpleAction action, Variant? variant */)   // 
See also "Up"
     {
         if (headerbar.has_popover ()) // for bookmarks popover, let headerbar handle that
-            headerbar.up_pressed ();
-        else if (!revealer.get_modifications_list_state () && !browser_view.in_window_modifications)
-            browser_view.up_pressed ();                 // FIXME returns bool
+            headerbar.previous_match ();
+        else if (revealer.get_modifications_list_state ())
+            revealer.previous_match ();
+        else
+            browser_view.previous_match ();         // FIXME returns bool
     }
 
     private void _request_config                        (/* SimpleAction action, Variant? variant */)  // 
TODO unduplicate method name
@@ -1611,18 +1615,18 @@ private class DConfWindow : AdaptativeWindow, AdaptativeWidget
         }
 
         /* for changing row during search; cannot use set_accels_for_action() else popovers are not handled 
anymore */
-        if (name == "Up"
+        if (name == "Down"
          && (event.state & Gdk.ModifierType.MOD1_MASK) == 0
-         // see also <ctrl>G
+         // see also <ctrl>g
          && !headerbar.has_popover ()
          && !revealer.get_modifications_list_state ())
-            return browser_view.up_pressed ();
-        if (name == "Down"
+            return browser_view.next_match ();
+        if (name == "Up"
          && (event.state & Gdk.ModifierType.MOD1_MASK) == 0
-         // see also <ctrl>g
+         // see also <ctrl>G
          && !headerbar.has_popover ()
          && !revealer.get_modifications_list_state ())
-            return browser_view.down_pressed ();
+            return browser_view.previous_match ();
 
         if (name == "Return" || name == "KP_Enter")
         {
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 609164c..1ebabc2 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -135,6 +135,20 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
             label.set_text (_("Nothing to reset."));
     }
 
+    /*\
+    * * keyboard calls
+    \*/
+
+    internal void next_match ()
+    {
+        modifications_list.next_match ();
+    }
+
+    internal void previous_match ()
+    {
+        modifications_list.previous_match ();
+    }
+
     /*\
     * * Modifications list public functions
     \*/
diff --git a/editor/overlayed-list.vala b/editor/overlayed-list.vala
index c002772..7ac712c 100644
--- a/editor/overlayed-list.vala
+++ b/editor/overlayed-list.vala
@@ -114,13 +114,13 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     * * keyboard
     \*/
 
-    internal void down_pressed ()
+    internal void next_match ()
     {
-        _down_pressed (ref main_list_box);
+        _next_match (ref main_list_box);
     }
-    private static inline void _down_pressed (ref ListBox main_list_box)
+    private static inline void _next_match (ref ListBox main_list_box)
     {
-        ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows
+        ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows and focus-only lists
         if (row == null)
             row = main_list_box.get_row_at_index (0);
         else
@@ -132,16 +132,17 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
         ((!) row).grab_focus ();
     }
 
-    internal void up_pressed ()
+    internal void previous_match ()
     {
-        _up_pressed (n_items, ref main_list_box);
+        _previous_match (ref main_list_box);
     }
-    private static inline void _up_pressed (uint n_items, ref ListBox main_list_box)
+    private static inline void _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;
 
-        ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows
+        ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows and focus-only lists
         if (row == null)
             row = main_list_box.get_row_at_index ((int) n_items - 1);
         else
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index f0d1e3e..18df310 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -352,7 +352,15 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
         ((!) selected_row).grab_focus ();
     }
 
-    internal bool up_or_down_pressed (bool is_down)
+    internal bool next_match ()
+    {
+        return next_or_previous_match (true);
+    }
+    internal bool previous_match ()
+    {
+        return next_or_previous_match (false);
+    }
+    private bool next_or_previous_match (bool is_next)
     {
         ListBoxRow? selected_row = (ListBoxRow?) key_list_box.get_selected_row ();
         uint n_items = list_model.get_n_items ();
@@ -365,14 +373,14 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
 
             int position = ((!) selected_row).get_index ();
             ListBoxRow? row = null;
-            if (!is_down && (position >= 1))
+            if (!is_next && (position >= 1))
                 row = key_list_box.get_row_at_index (position - 1);
-            if (is_down && (position < n_items - 1))
+            if (is_next && (position < n_items - 1))
                 row = key_list_box.get_row_at_index (position + 1);
 
             if (row != null)
             {
-                scroll_to_row ((!) row, is_down ? ScrollToRowBehaviour.SCROLL_DOWN : 
ScrollToRowBehaviour.SCROLL_UP);
+                scroll_to_row ((!) row, is_next ? ScrollToRowBehaviour.SCROLL_DOWN : 
ScrollToRowBehaviour.SCROLL_UP);
                 if (search_mode)
                 {
                     Container list_box = (Container) ((!) selected_row).get_parent ();
@@ -385,7 +393,7 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
         }
         else if (n_items >= 1)
         {
-            selected_row = key_list_box.get_row_at_index (is_down ? 0 : (int) n_items - 1);
+            selected_row = key_list_box.get_row_at_index (is_next ? 0 : (int) n_items - 1);
             if (selected_row == null)
                 return false;
             select_row_and_if_true_grab_focus ((!) selected_row, true);


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