[gnome-control-center] search: Search group fixups



commit e14847b73f1ea9d9654d8c55aa0e661ad9f1ebaf
Author: Christopher Davis <christopherdavis gnome org>
Date:   Tue Feb 8 19:43:03 2022 -0800

    search: Search group fixups
    
    * Set the right accessibility relations, as
    AdwPreferencesGroup does not manage it
    for custom listboxes
    
    * Handle `keynav-failed` for proper behavior with arrow keys
    
    * Set `selection-mode` to none

 panels/search/cc-search-panel.c  | 16 ++++++++++++++++
 panels/search/cc-search-panel.ui |  3 +++
 2 files changed, 19 insertions(+)
---
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index 661a74272..80c8c94b9 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -46,6 +46,21 @@ CC_PANEL_REGISTER (CcSearchPanel, cc_search_panel)
 
 #define SHELL_PROVIDER_GROUP "Shell Search Provider"
 
+static gboolean
+keynav_failed_cb (CcSearchPanel *self, GtkDirectionType direction, GtkWidget *list)
+{
+  GtkWidget *toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (self)));
+
+  if (!toplevel)
+    return FALSE;
+
+  if (direction != GTK_DIR_UP && direction != GTK_DIR_DOWN)
+    return FALSE;
+
+  return gtk_widget_child_focus (toplevel, direction == GTK_DIR_UP ?
+                                 GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD);
+}
+
 static gint
 list_sort_func (gconstpointer a,
                 gconstpointer b,
@@ -664,4 +679,5 @@ cc_search_panel_class_init (CcSearchPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcSearchPanel, settings_row);
 
   gtk_widget_class_bind_template_callback (widget_class, settings_row_activated);
+  gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
 }
diff --git a/panels/search/cc-search-panel.ui b/panels/search/cc-search-panel.ui
index 1380b7e6f..21f297db7 100644
--- a/panels/search/cc-search-panel.ui
+++ b/panels/search/cc-search-panel.ui
@@ -38,6 +38,9 @@
             <property name="description" translatable="yes">Results are displayed according to the list 
order.</property>
             <child>
               <object class="GtkListBox" id="list_box">
+                <property name="selection-mode">none</property>
+                <signal name="keynav-failed" handler="keynav_failed_cb" object="CcSearchPanel" 
swapped="yes"/>
+                <accessibility name="labelled-by">search_group</accessibility>
                 <style>
                   <class name="boxed-list"/>
                 </style>


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