diff options
author | Thomas Meire <blackskad@gmail.com> | 2010-01-21 08:20:08 +0800 |
---|---|---|
committer | Thomas Meire <blackskad@gmail.com> | 2010-01-21 08:20:09 +0800 |
commit | 7c0d4aca42f309b89684636ad84fd4969eac6943 (patch) | |
tree | ea3e33fdb6745bee526383c0a789445b57f38f5f /libempathy-gtk/empathy-search-bar.c | |
parent | cc0b2a8f267d1396ecae90452f4623d5b4c5ebb1 (diff) | |
download | gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.tar gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.tar.gz gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.tar.bz2 gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.tar.lz gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.tar.xz gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.tar.zst gsoc2013-empathy-7c0d4aca42f309b89684636ad84fd4969eac6943.zip |
Capture the escape key on the chat view and search bar, to make it hide the search bar
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); |