[gnome-software] Improve keynav in category view



commit 8d92b02dafac8e4c52294025f6ab5bff18c9b758
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 18 23:15:59 2013 -0400

    Improve keynav in category view
    
    Arrange things so that Tab moves focus from the subcategory list
    to the application grid, and make Page Up/Down page the application
    grid, regardless where the focus is.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708308

 src/gs-shell-category.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index cb3e834..9ddb5bb 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -324,6 +324,36 @@ scrollbar_mapped_cb (GtkWidget *sb, GtkScrolledWindow *swin)
        }
 }
 
+static gboolean
+key_event (GtkWidget *listbox, GdkEvent *event, GsShellCategory *shell)
+{
+       guint keyval;
+       GtkWidget *sw;
+       GtkWidget *grid;
+       gboolean handled;
+
+       if (!gdk_event_get_keyval (event, &keyval))
+               return FALSE;
+
+       sw = GTK_WIDGET (gtk_builder_get_object (shell->priv->builder, "scrolledwindow_category"));
+       grid = GTK_WIDGET (gtk_builder_get_object (shell->priv->builder, "category_detail_grid"));
+       if (keyval == GDK_KEY_Page_Up ||
+           keyval == GDK_KEY_KP_Page_Up)
+               g_signal_emit_by_name (sw, "scroll-child",
+                                      GTK_SCROLL_PAGE_UP, FALSE, &handled);
+       else if (keyval == GDK_KEY_Page_Down ||
+                keyval == GDK_KEY_KP_Page_Down)
+               g_signal_emit_by_name (sw, "scroll-child",
+                                      GTK_SCROLL_PAGE_DOWN, FALSE, &handled);
+       else if (keyval == GDK_KEY_Tab ||
+                keyval == GDK_KEY_KP_Tab)
+               gtk_widget_child_focus (grid, GTK_DIR_TAB_FORWARD);
+       else
+               return FALSE;
+
+       return TRUE;
+}
+
 void
 gs_shell_category_setup (GsShellCategory *shell_category,
                         GsShell *shell,
@@ -354,6 +384,10 @@ gs_shell_category_setup (GsShellCategory *shell_category,
        adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "category_detail_grid"));
        gtk_container_set_focus_vadjustment (GTK_CONTAINER (widget), adj);
+
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "listbox_filter"));
+       g_signal_connect (widget, "key-press-event",
+                         G_CALLBACK (key_event), shell_category);
 }
 
 GsShellCategory *



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