[empathy: 53/80] Add a clear icon to the search entry



commit 0fecd9297170528afedbb3e8c3da92debbc41136
Author: Emilio Pozuelo Monfort <emilio pozuelo collabora co uk>
Date:   Wed Apr 27 13:02:31 2011 +0100

    Add a clear icon to the search entry

 libempathy-gtk/empathy-log-window.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index c564276..95c8cea 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -102,6 +102,10 @@ static void log_window_search_entry_changed_cb   (GtkWidget        *entry,
                                                   EmpathyLogWindow *window);
 static void log_window_search_entry_activate_cb  (GtkWidget        *widget,
                                                   EmpathyLogWindow *window);
+static void log_window_search_entry_icon_pressed_cb (GtkEntry      *entry,
+                                                  GtkEntryIconPosition icon_pos,
+                                                  GdkEvent *event,
+                                                  gpointer user_data);
 static void log_window_who_populate              (EmpathyLogWindow *window);
 static void log_window_who_setup                 (EmpathyLogWindow *window);
 static void log_window_when_setup                (EmpathyLogWindow *window);
@@ -503,6 +507,8 @@ empathy_log_window_show (TpAccount  *account,
   window->search_entry = gtk_entry_new ();
   gtk_entry_set_icon_from_stock (GTK_ENTRY (window->search_entry),
       GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
+  gtk_entry_set_icon_from_stock (GTK_ENTRY (window->search_entry),
+      GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
 
   label = gtk_label_new (_("Search"));
 
@@ -525,6 +531,10 @@ empathy_log_window_show (TpAccount  *account,
       G_CALLBACK (log_window_search_entry_activate_cb),
       window);
 
+  g_signal_connect (window->search_entry, "icon-press",
+      G_CALLBACK (log_window_search_entry_icon_pressed_cb),
+      window);
+
   /* Contacts */
   log_window_events_setup (window);
   log_window_who_setup (window);
@@ -1461,6 +1471,19 @@ log_window_search_entry_activate_cb (GtkWidget *entry,
   start_find_search (self);
 }
 
+static void
+log_window_search_entry_icon_pressed_cb (GtkEntry *entry,
+    GtkEntryIconPosition icon_pos,
+    GdkEvent *event,
+    gpointer user_data)
+{
+  if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
+    return;
+
+  gtk_entry_buffer_set_text (gtk_entry_get_buffer (entry),
+    "", -1);
+}
+
 /*
  * Chats Code
  */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]