diff options
Diffstat (limited to 'libempathy-gtk/empathy-search-bar.c')
-rw-r--r-- | libempathy-gtk/empathy-search-bar.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-search-bar.c b/libempathy-gtk/empathy-search-bar.c index 2526510b2..cc2b97753 100644 --- a/libempathy-gtk/empathy-search-bar.c +++ b/libempathy-gtk/empathy-search-bar.c @@ -20,6 +20,7 @@ #include <glib.h> #include <glib-object.h> #include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> #include <libempathy/empathy-utils.h> @@ -155,15 +156,13 @@ empathy_search_bar_show (EmpathySearchBar *self) gtk_widget_show (GTK_WIDGET (self)); } - -static void -empathy_search_bar_close_cb (GtkButton *button, - gpointer user_data) +void +empathy_search_bar_hide (EmpathySearchBar *self) { - EmpathySearchBarPriv *priv = GET_PRIV (user_data); + EmpathySearchBarPriv *priv = GET_PRIV (self); empathy_chat_view_highlight (priv->chat_view, "", FALSE); - gtk_widget_hide (GTK_WIDGET (user_data)); + gtk_widget_hide (GTK_WIDGET (self)); /* give the focus back to the focus-chain with the chat view */ gtk_widget_grab_focus (GTK_WIDGET (priv->chat_view)); @@ -213,12 +212,32 @@ empathy_search_bar_search (EmpathySearchBar *self, } static void +empathy_search_bar_close_cb (GtkButton *button, + gpointer user_data) +{ + empathy_search_bar_hide (EMPATHY_SEARCH_BAR (user_data)); +} + +static void empathy_search_bar_entry_changed (GtkEditable *entry, gpointer user_data) { empathy_search_bar_search (EMPATHY_SEARCH_BAR (user_data), FALSE, TRUE); } +static gboolean +empathy_search_bar_key_pressed (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data) +{ + if (event->keyval == GDK_Escape) + { + empathy_search_bar_hide (EMPATHY_SEARCH_BAR (widget)); + return TRUE; + } + return FALSE; +} + static void empathy_search_bar_next_cb (GtkButton *button, gpointer user_data) @@ -274,6 +293,9 @@ empathy_search_bar_init (EmpathySearchBar * self) "search_match_case", "toggled", empathy_search_bar_match_case_toggled, NULL); + g_signal_connect (G_OBJECT (self), "key-press-event", + G_CALLBACK (empathy_search_bar_key_pressed), NULL); + gtk_container_add (GTK_CONTAINER (self), internal); gtk_widget_show_all (internal); gtk_widget_hide (priv->search_not_found); |