[gnome-builder/wip/plugins] search: fixup keyboard navigation from search box
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/plugins] search: fixup keyboard navigation from search box
- Date: Sat, 13 Jun 2015 05:40:31 +0000 (UTC)
commit 6a3f0d829431cc04eb1a1ae778b392c8dc63609a
Author: Christian Hergert <christian hergert me>
Date: Fri Jun 12 22:40:24 2015 -0700
search: fixup keyboard navigation from search box
src/search/gb-search-display-group.c | 26 +++++++++++++--------
src/search/gb-search-display.c | 41 +++++++++++++++++++++++----------
2 files changed, 44 insertions(+), 23 deletions(-)
---
diff --git a/src/search/gb-search-display-group.c b/src/search/gb-search-display-group.c
index 02af027..974445f 100644
--- a/src/search/gb-search-display-group.c
+++ b/src/search/gb-search-display-group.c
@@ -57,23 +57,29 @@ static GQuark gQuarkRow;
static GParamSpec *gParamSpecs [LAST_PROP];
static guint gSignals [LAST_SIGNAL];
+static void
+gb_search_display_group_foreach_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ GtkWidget **row = user_data;
+
+ if (*row == NULL)
+ *row = widget;
+}
+
IdeSearchResult *
gb_search_display_group_get_first (GbSearchDisplayGroup *self)
{
- GtkListBoxRow *row;
+ GtkListBoxRow *row = NULL;
g_return_val_if_fail (GB_IS_SEARCH_DISPLAY_GROUP (self), NULL);
- row = gtk_list_box_get_row_at_y (self->rows, 1);
+ gtk_container_foreach (GTK_CONTAINER (self->rows),
+ gb_search_display_group_foreach_cb,
+ &row);
- if (row)
- {
- GtkWidget *child;
-
- child = gtk_bin_get_child (GTK_BIN (row));
- if (GB_IS_SEARCH_DISPLAY_ROW (child))
- return gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (child));
- }
+ if (GB_IS_SEARCH_DISPLAY_ROW (row))
+ return gb_search_display_row_get_result (GB_SEARCH_DISPLAY_ROW (row));
return NULL;
}
diff --git a/src/search/gb-search-display.c b/src/search/gb-search-display.c
index a732602..1b59b36 100644
--- a/src/search/gb-search-display.c
+++ b/src/search/gb-search-display.c
@@ -142,9 +142,10 @@ gb_search_display_keynav_failed (GbSearchDisplay *self,
GtkDirectionType dir,
GbSearchDisplayGroup *group)
{
- GList *list;
+ GList *list = NULL;
GList *iter;
gint position = -1;
+ gboolean ret = FALSE;
g_return_val_if_fail (GB_IS_SEARCH_DISPLAY (self), FALSE);
g_return_val_if_fail (GB_IS_SEARCH_DISPLAY_GROUP (group), FALSE);
@@ -157,26 +158,34 @@ gb_search_display_keynav_failed (GbSearchDisplay *self,
{
list = gtk_container_get_children (GTK_CONTAINER (self));
iter = g_list_nth (list, position + 1);
- if (iter && (iter->data != self->last_group))
+ for (; iter; iter = iter->next)
{
- gb_search_display_group_unselect (group);
- gb_search_display_group_focus_first (iter->data);
- return TRUE;
+ if (gb_search_display_group_get_first (iter->data))
+ {
+ gb_search_display_group_unselect (group);
+ gb_search_display_group_focus_first (iter->data);
+ ret = TRUE;
+ }
}
}
else if (dir == GTK_DIR_UP && position > 0)
{
list = gtk_container_get_children (GTK_CONTAINER (self));
iter = g_list_nth (list, position - 1);
- if (iter)
+ for (; iter; iter = iter->prev)
{
- gb_search_display_group_unselect (group);
- gb_search_display_group_focus_last (iter->data);
- return TRUE;
+ if (gb_search_display_group_get_first (iter->data))
+ {
+ gb_search_display_group_unselect (group);
+ gb_search_display_group_focus_last (iter->data);
+ ret = TRUE;
+ }
}
}
- return FALSE;
+ g_list_free (list);
+
+ return ret;
}
void
@@ -483,15 +492,21 @@ static void
gb_search_display_grab_focus (GtkWidget *widget)
{
GbSearchDisplay *self = (GbSearchDisplay *)widget;
+ gsize i;
g_return_if_fail (GB_IS_SEARCH_DISPLAY (self));
- if (self->providers->len)
+ for (i = 0; i < self->providers->len; i++)
{
ProviderEntry *ptr;
- ptr = g_ptr_array_index (self->providers, 0);
- gtk_widget_child_focus (GTK_WIDGET (ptr->group), GTK_DIR_DOWN);
+ ptr = g_ptr_array_index (self->providers, i);
+
+ if (gb_search_display_group_get_first (ptr->group))
+ {
+ gtk_widget_child_focus (GTK_WIDGET (ptr->group), GTK_DIR_DOWN);
+ break;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]