[gnome-control-center] notifications: Handle `keynav-failed` on app list



commit 17d3a297ae5aa9a35c939cd88e309e7841847846
Author: Christopher Davis <christopherdavis gnome org>
Date:   Tue Feb 8 21:46:09 2022 -0800

    notifications: Handle `keynav-failed` on app list
    
    Fixes keyboard navigation with arrow keys

 panels/notifications/cc-notifications-panel.c  | 17 +++++++++++++++++
 panels/notifications/cc-notifications-panel.ui |  1 +
 2 files changed, 18 insertions(+)
---
diff --git a/panels/notifications/cc-notifications-panel.c b/panels/notifications/cc-notifications-panel.c
index c3fd06673..f3408586c 100644
--- a/panels/notifications/cc-notifications-panel.c
+++ b/panels/notifications/cc-notifications-panel.c
@@ -72,6 +72,22 @@ static int  sort_apps       (gconstpointer one, gconstpointer two, gpointer user
 
 CC_PANEL_REGISTER (CcNotificationsPanel, cc_notifications_panel);
 
+static gboolean
+keynav_failed_cb (CcNotificationsPanel *self,
+                  GtkDirectionType      direction)
+{
+  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 void
 cc_notifications_panel_dispose (GObject *object)
 {
@@ -179,6 +195,7 @@ cc_notifications_panel_class_init (CcNotificationsPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcNotificationsPanel, sizegroup1);
 
   gtk_widget_class_bind_template_callback (widget_class, select_app);
+  gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
 }
 
 static inline GQuark
diff --git a/panels/notifications/cc-notifications-panel.ui b/panels/notifications/cc-notifications-panel.ui
index 38a8e325d..fa6654083 100644
--- a/panels/notifications/cc-notifications-panel.ui
+++ b/panels/notifications/cc-notifications-panel.ui
@@ -28,6 +28,7 @@
               <object class="GtkListBox" id="app_listbox">
                 <property name="selection_mode">none</property>
                 <signal name="row-activated" handler="select_app" object="CcNotificationsPanel" 
swapped="yes" />
+                <signal name="keynav-failed" handler="keynav_failed_cb" object="CcNotificationsPanel" 
swapped="yes"/>
                 <style>
                   <class name="boxed-list"/>
                 </style>


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