[gnome-logs/wip/batching] Ignore tab focus direction inside category list
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs/wip/batching] Ignore tab focus direction inside category list
- Date: Thu, 27 Feb 2014 12:47:51 +0000 (UTC)
commit 9d091f31fd58f274f5d9933122ff5486f86048c9
Author: David King <davidk gnome org>
Date: Thu Feb 27 12:38:45 2014 +0000
Ignore tab focus direction inside category list
Make a tab forward or back to another child within the category list
instead jump out of the list and focus the next child of the window.
This improves keyboard navigation, by making the listbox behave more
like a treeview.
https://bugzilla.gnome.org/show_bug.cgi?id=724980
src/gl-categorylist.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/gl-categorylist.c b/src/gl-categorylist.c
index f15f6bc..9c80591 100644
--- a/src/gl-categorylist.c
+++ b/src/gl-categorylist.c
@@ -39,6 +39,36 @@ typedef struct
G_DEFINE_TYPE_WITH_PRIVATE (GlCategoryList, gl_category_list, GTK_TYPE_LIST_BOX)
+static gboolean
+gl_category_list_focus (GtkWidget *listbox, GtkDirectionType direction)
+{
+ switch (direction)
+ {
+ case GTK_DIR_TAB_BACKWARD:
+ case GTK_DIR_TAB_FORWARD:
+ if (gtk_container_get_focus_child (GTK_CONTAINER (listbox)))
+ {
+ /* Force tab events which jump to another child to jump out of
+ * the category list. */
+ return FALSE;
+ }
+ else
+ {
+ /* Allow tab events to focus into the widget. */
+ GTK_WIDGET_CLASS (gl_category_list_parent_class)->focus (listbox,
+ direction);
+ return TRUE;
+ }
+ break;
+ /* Allow the widget to handle all other focus events. */
+ default:
+ GTK_WIDGET_CLASS (gl_category_list_parent_class)->focus (listbox,
+ direction);
+ return TRUE;
+ break;
+ }
+}
+
static void
on_gl_category_list_row_selected (GlCategoryList *listbox,
GtkListBoxRow *row,
@@ -121,6 +151,7 @@ gl_category_list_class_init (GlCategoryListClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->focus = gl_category_list_focus;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Logs/gl-categorylist.ui");
gtk_widget_class_bind_template_child_private (widget_class, GlCategoryList,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]