[gnome-builder/wip/search] search: activate first result upon GtkEntry::activated
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/search] search: activate first result upon GtkEntry::activated
- Date: Sun, 18 Jan 2015 08:03:34 +0000 (UTC)
commit 5010caa3cabbb0752de79a6d2cca730bc7ea199b
Author: Christian Hergert <christian hergert me>
Date: Sun Jan 18 00:03:28 2015 -0800
search: activate first result upon GtkEntry::activated
src/search/gb-search-display-group.c | 14 ++++++++++++++
src/search/gb-search-display-group.h | 1 +
src/search/gb-search-display.c | 21 +++++++++++++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/src/search/gb-search-display-group.c b/src/search/gb-search-display-group.c
index bd38da7..35c6ac8 100644
--- a/src/search/gb-search-display-group.c
+++ b/src/search/gb-search-display-group.c
@@ -60,6 +60,20 @@ static GQuark gQuarkRow;
static GParamSpec *gParamSpecs [LAST_PROP];
static guint gSignals [LAST_SIGNAL];
+GbSearchResult *
+gb_search_display_group_get_first (GbSearchDisplayGroup *group)
+{
+ GtkListBoxRow *row;
+
+ g_return_val_if_fail (GB_IS_SEARCH_DISPLAY_GROUP (group), NULL);
+
+ row = gtk_list_box_get_row_at_y (group->priv->rows, 1);
+ if (row)
+ return g_object_get_qdata (G_OBJECT (row), gQuarkResult);
+
+ return NULL;
+}
+
GbSearchProvider *
gb_search_display_group_get_provider (GbSearchDisplayGroup *group)
{
diff --git a/src/search/gb-search-display-group.h b/src/search/gb-search-display-group.h
index ec17842..aae69b4 100644
--- a/src/search/gb-search-display-group.h
+++ b/src/search/gb-search-display-group.h
@@ -56,6 +56,7 @@ void gb_search_display_group_set_count (GbSearchDisplayGroup *g
void gb_search_display_group_unselect (GbSearchDisplayGroup *group);
void gb_search_display_group_focus_first (GbSearchDisplayGroup *group);
void gb_search_display_group_focus_last (GbSearchDisplayGroup *group);
+GbSearchResult *gb_search_display_group_get_first (GbSearchDisplayGroup *group);
G_END_DECLS
diff --git a/src/search/gb-search-display.c b/src/search/gb-search-display.c
index 5524fa3..da092c9 100644
--- a/src/search/gb-search-display.c
+++ b/src/search/gb-search-display.c
@@ -168,9 +168,26 @@ gb_search_display_keynav_failed (GbSearchDisplay *display,
}
void
-gb_search_display_activate (GbSearchDisplay *display)
+gb_search_display_activate (GbSearchDisplay *self)
{
- g_warning ("TODO: implement display_activate()");
+ GbSearchDisplayPrivate *priv;
+ GbSearchResult *result = NULL;
+ guint i;
+
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY (self));
+
+ priv = self->priv;
+
+ for (i = 0; !result && i < priv->providers->len; i++)
+ {
+ ProviderEntry *ptr;
+
+ ptr = &g_array_index (self->priv->providers, ProviderEntry, i);
+ result = gb_search_display_group_get_first (ptr->group);
+ }
+
+ if (result)
+ g_signal_emit (self, gSignals [RESULT_ACTIVATED], 0, result);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]