[gnome-builder] GbSearchBox: activate first search result upon entry activate signal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbSearchBox: activate first search result upon entry activate signal
- Date: Thu, 18 Dec 2014 08:47:04 +0000 (UTC)
commit 8d46a4c4c5b9919b84d7c1eb8175a68f34502e1a
Author: Christian Hergert <christian hergert me>
Date: Thu Dec 18 00:46:56 2014 -0800
GbSearchBox: activate first search result upon entry activate signal
src/search/gb-search-box.c | 17 +++++++++++++++++
src/search/gb-search-display.c | 22 ++++++++++++++++++++++
src/search/gb-search-display.h | 1 +
3 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/search/gb-search-box.c b/src/search/gb-search-box.c
index 86611a5..760306f 100644
--- a/src/search/gb-search-box.c
+++ b/src/search/gb-search-box.c
@@ -143,6 +143,18 @@ gb_search_box_entry_focus_in (GbSearchBox *box,
}
static void
+gb_search_box_entry_activate (GbSearchBox *box,
+ GtkSearchEntry *entry)
+{
+ g_return_if_fail (GB_IS_SEARCH_BOX (box));
+ g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry));
+
+ g_print ("activate!\n");
+
+ gb_search_display_activate (box->priv->display);
+}
+
+static void
gb_search_box_entry_changed (GbSearchBox *box,
GtkSearchEntry *entry)
{
@@ -320,6 +332,11 @@ gb_search_box_constructed (GObject *object)
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->entry,
+ "activate",
+ G_CALLBACK (gb_search_box_entry_activate),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (priv->entry,
"changed",
G_CALLBACK (gb_search_box_entry_changed),
self,
diff --git a/src/search/gb-search-display.c b/src/search/gb-search-display.c
index 2cf5120..5541951 100644
--- a/src/search/gb-search-display.c
+++ b/src/search/gb-search-display.c
@@ -202,6 +202,28 @@ gb_search_display_row_activated (GbSearchDisplay *display,
gb_search_display_emit_result_activated (display, GB_SEARCH_RESULT (child));
}
+void
+gb_search_display_activate (GbSearchDisplay *display)
+{
+ GtkListBoxRow *row;
+
+ g_return_if_fail (GB_IS_SEARCH_DISPLAY (display));
+
+ row = gtk_list_box_get_selected_row (display->priv->list_box);
+
+ /*
+ * WORKAROUND:
+ *
+ * Workaround since get_index() does not take into account sorts and
+ * a y of 0 doesn't currently work.
+ */
+ if (!row)
+ row = gtk_list_box_get_row_at_y (display->priv->list_box, 5);
+
+ if (row)
+ gb_search_display_row_activated (display, row, display->priv->list_box);
+}
+
static gint
gb_search_display_sort_cb (GtkListBoxRow *row1,
GtkListBoxRow *row2,
diff --git a/src/search/gb-search-display.h b/src/search/gb-search-display.h
index baa42e1..bd4e39d 100644
--- a/src/search/gb-search-display.h
+++ b/src/search/gb-search-display.h
@@ -60,6 +60,7 @@ GtkWidget *gb_search_display_new (void);
GbSearchContext *gb_search_display_get_context (GbSearchDisplay *display);
void gb_search_display_set_context (GbSearchDisplay *display,
GbSearchContext *context);
+void gb_search_display_activate (GbSearchDisplay *display);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]