[gnome-builder] search: don't display search results until the entry has text
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] search: don't display search results until the entry has text
- Date: Mon, 19 Jan 2015 04:05:07 +0000 (UTC)
commit 66a5d9f2c97979ea76ba6f0ec8789aac44a6ffc2
Author: Christian Hergert <christian hergert me>
Date: Sun Jan 18 20:04:59 2015 -0800
search: don't display search results until the entry has text
src/search/gb-search-box.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/search/gb-search-box.c b/src/search/gb-search-box.c
index dbba308..88ca9e8 100644
--- a/src/search/gb-search-box.c
+++ b/src/search/gb-search-box.c
@@ -27,6 +27,7 @@
#include "gb-search-display.h"
#include "gb-search-manager.h"
#include "gb-search-result.h"
+#include "gb-string.h"
#include "gb-widget.h"
#include "gb-workbench.h"
@@ -138,11 +139,16 @@ gb_search_box_entry_focus_in (GbSearchBox *box,
GdkEventFocus *focus,
GtkWidget *entry)
{
+ const gchar *text;
+
g_return_val_if_fail (GB_IS_SEARCH_BOX (box), FALSE);
g_return_val_if_fail (focus, FALSE);
g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (entry), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->priv->button), TRUE);
+ text = gtk_entry_get_text (GTK_ENTRY (box->priv->entry));
+
+ if (!gb_str_empty0 (text))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->priv->button), TRUE);
return GDK_EVENT_PROPAGATE;
}
@@ -161,11 +167,21 @@ static void
gb_search_box_entry_changed (GbSearchBox *box,
GtkSearchEntry *entry)
{
+ GtkToggleButton *button;
+ const gchar *text;
+ gboolean active;
guint delay_msec = SHORT_DELAY_TIMEOUT_MSEC;
g_return_if_fail (GB_IS_SEARCH_BOX (box));
g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry));
+ button = GTK_TOGGLE_BUTTON (box->priv->button);
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ active = !gb_str_empty0 (text);
+
+ if (gtk_toggle_button_get_active (button) != active)
+ gtk_toggle_button_set_active (button, active);
+
if (!box->priv->delay_timeout)
{
const gchar *search_text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]