aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Meire <blackskad@gmail.com>2010-01-21 08:20:08 +0800
committerThomas Meire <blackskad@gmail.com>2010-01-21 08:20:09 +0800
commit7c0d4aca42f309b89684636ad84fd4969eac6943 (patch)
treeea3e33fdb6745bee526383c0a789445b57f38f5f
parentcc0b2a8f267d1396ecae90452f4623d5b4c5ebb1 (diff)
downloadgsoc2013-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
-rw-r--r--libempathy-gtk/empathy-chat.c3
-rw-r--r--libempathy-gtk/empathy-search-bar.c34
-rw-r--r--libempathy-gtk/empathy-search-bar.h1
3 files changed, 32 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 65676b559..222258082 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1371,6 +1371,9 @@ chat_input_key_press_event_cb (GtkWidget *widget,
gtk_adjustment_set_value (adj, val);
return TRUE;
}
+ if (event->keyval == GDK_Escape) {
+ empathy_search_bar_hide (EMPATHY_SEARCH_BAR (priv->search_bar));
+ }
if (!(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) &&
event->keyval == GDK_Tab) {
GtkTextBuffer *buffer;
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);
diff --git a/libempathy-gtk/empathy-search-bar.h b/libempathy-gtk/empathy-search-bar.h
index d4cd042fe..c17778b7f 100644
--- a/libempathy-gtk/empathy-search-bar.h
+++ b/libempathy-gtk/empathy-search-bar.h
@@ -58,6 +58,7 @@ struct _EmpathySearchBarClass
GType empathy_search_bar_get_type (void) G_GNUC_CONST;
GtkWidget * empathy_search_bar_new (EmpathyChatView *view);
void empathy_search_bar_show (EmpathySearchBar *searchbar);
+void empathy_search_bar_hide (EmpathySearchBar *searchbar);
G_END_DECLS